Commit 7c0f19e5 authored by Sam Lantinga's avatar Sam Lantinga

Date: Sun, 04 Jan 2009 20:53:30 +0100

From: Couriersud
Subject: SDL1.3 DirectFB patches

The attached contains the following directfb changes:

- Dynamic loading of libdirectfb.so. This may to turned off as well in configure
- Use linux-input by default. May be switched off by environment variable.
- Added some code which will use directfb's x11 backend when DISPLAY is set.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403460
parent ba8f64f2
...@@ -20,12 +20,20 @@ This file should contain the following lines to make ...@@ -20,12 +20,20 @@ This file should contain the following lines to make
your joystick work and avoid crashes: your joystick work and avoid crashes:
------------------------ ------------------------
disable-module=joystick disable-module=joystick
disable-module=linux_input
disable-module=cle266 disable-module=cle266
disable-module=cyber5k disable-module=cyber5k
disable-module=x11input no-linux-input-grab
------------------------ ------------------------
To disable to use x11 backend when DISPLAY variable is found use
export SDL_DIRECTFB_X11_CHECK=0
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
use
export SDL_DIRECTFB_LINUX_INPUT=0
To use hardware accelerated YUV-overlays for YUV-textures, use: To use hardware accelerated YUV-overlays for YUV-textures, use:
export SDL_DIRECTFB_YUV_DIRECT=1 export SDL_DIRECTFB_YUV_DIRECT=1
......
...@@ -1311,7 +1311,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n ...@@ -1311,7 +1311,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
video_directfb=no video_directfb=no
DIRECTFB_REQUIRED_VERSION=0.9.15 DIRECTFB_REQUIRED_VERSION=1.0.0
AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no) AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
if test x$DIRECTFBCONFIG = xno; then if test x$DIRECTFBCONFIG = xno; then
...@@ -1321,6 +1321,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n ...@@ -1321,6 +1321,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb` DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb` DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
video_directfb=yes video_directfb=yes
fi fi
fi fi
...@@ -1334,16 +1335,39 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n ...@@ -1334,16 +1335,39 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
if test $HAVE_VERSION -ge $NEED_VERSION; then if test $HAVE_VERSION -ge $NEED_VERSION; then
DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags` DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs` DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
video_directfb=yes video_directfb=yes
fi fi
AC_MSG_RESULT($video_directfb) AC_MSG_RESULT($video_directfb)
fi fi
if test x$video_directfb = xyes; then if test x$video_directfb = xyes; then
AC_ARG_ENABLE(directfb-shared,
AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
, enable_directfb_shared=yes)
AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB) AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
SOURCES="$SOURCES $srcdir/src/video/directfb/*.c" SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
AC_MSG_CHECKING(for directfb dynamic loading support)
directfb_shared=no
directfb_lib_spec="$DIRECTFB_PREFIX/lib/libdirectfb.so*"
directfb_lib=`ls -- $directfb_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
dnl echo "-- $directfb_lib_spec -> $directfb_lib"
if test x$have_loadso != xyes && \
test x$enable_directfb_shared = xyes; then
AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
fi
if test x$have_loadso = xyes && \
test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
directfb_shared=yes
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib")
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
fi
AC_MSG_RESULT($directfb_shared)
have_video=yes have_video=yes
fi fi
fi fi
......
...@@ -263,6 +263,7 @@ ...@@ -263,6 +263,7 @@
#undef SDL_VIDEO_DRIVER_COCOA #undef SDL_VIDEO_DRIVER_COCOA
#undef SDL_VIDEO_DRIVER_DC #undef SDL_VIDEO_DRIVER_DC
#undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DIRECTFB
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
#undef SDL_VIDEO_DRIVER_DUMMY #undef SDL_VIDEO_DRIVER_DUMMY
#undef SDL_VIDEO_DRIVER_FBCON #undef SDL_VIDEO_DRIVER_FBCON
#undef SDL_VIDEO_DRIVER_GAPI #undef SDL_VIDEO_DRIVER_GAPI
......
...@@ -144,7 +144,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -144,7 +144,7 @@ DirectFB_PumpEventsWindow(_THIS)
if (evt.clazz == DFEC_WINDOW) { if (evt.clazz == DFEC_WINDOW) {
switch (evt.type) { switch (evt.type) {
case DWET_BUTTONDOWN: case DWET_BUTTONDOWN:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx, SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
evt.cy, 0); evt.cy, 0);
SDL_SendMouseButton(devdata->mouse_id[0], SDL_PRESSED, SDL_SendMouseButton(devdata->mouse_id[0], SDL_PRESSED,
...@@ -155,7 +155,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -155,7 +155,7 @@ DirectFB_PumpEventsWindow(_THIS)
} }
break; break;
case DWET_BUTTONUP: case DWET_BUTTONUP:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx, SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
evt.cy, 0); evt.cy, 0);
SDL_SendMouseButton(devdata->mouse_id[0], SDL_SendMouseButton(devdata->mouse_id[0],
...@@ -167,7 +167,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -167,7 +167,7 @@ DirectFB_PumpEventsWindow(_THIS)
} }
break; break;
case DWET_MOTION: case DWET_MOTION:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
if (!(w->flags & SDL_WINDOW_INPUT_GRABBED)) if (!(w->flags & SDL_WINDOW_INPUT_GRABBED))
SDL_SendMouseMotion(devdata->mouse_id[0], 0, SDL_SendMouseMotion(devdata->mouse_id[0], 0,
evt.cx, evt.cy, 0); evt.cx, evt.cy, 0);
...@@ -183,7 +183,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -183,7 +183,7 @@ DirectFB_PumpEventsWindow(_THIS)
} }
break; break;
case DWET_KEYDOWN: case DWET_KEYDOWN:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
DirectFB_TranslateKey(_this, &evt, &keysym); DirectFB_TranslateKey(_this, &evt, &keysym);
SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode); SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode);
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
...@@ -196,7 +196,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -196,7 +196,7 @@ DirectFB_PumpEventsWindow(_THIS)
} }
break; break;
case DWET_KEYUP: case DWET_KEYUP:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
DirectFB_TranslateKey(_this, &evt, &keysym); DirectFB_TranslateKey(_this, &evt, &keysym);
SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode); SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode);
} }
...@@ -260,7 +260,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -260,7 +260,7 @@ DirectFB_PumpEventsWindow(_THIS)
switch (ievt.type) { switch (ievt.type) {
case DIET_AXISMOTION: case DIET_AXISMOTION:
if (!LINUX_INPUT_SUPPORT) { if (!devdata->use_linux_input) {
if ((grabbed_window >= 0) && (ievt.flags & DIEF_AXISREL)) { if ((grabbed_window >= 0) && (ievt.flags & DIEF_AXISREL)) {
printf("rel devid %d\n", ievt.device_id); printf("rel devid %d\n", ievt.device_id);
if (ievt.axis == DIAI_X) if (ievt.axis == DIAI_X)
...@@ -273,7 +273,7 @@ DirectFB_PumpEventsWindow(_THIS) ...@@ -273,7 +273,7 @@ DirectFB_PumpEventsWindow(_THIS)
} }
break; break;
} }
if (LINUX_INPUT_SUPPORT) { if (devdata->use_linux_input) {
IDirectFBInputDevice *idev; IDirectFBInputDevice *idev;
static int last_x, last_y; static int last_x, last_y;
...@@ -600,7 +600,7 @@ DirectFB_InitKeyboard(_THIS) ...@@ -600,7 +600,7 @@ DirectFB_InitKeyboard(_THIS)
DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap)); DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap));
devdata->num_keyboard = 0; devdata->num_keyboard = 0;
if (LINUX_INPUT_SUPPORT) { if (devdata->use_linux_input) {
sys_ids = 0; sys_ids = 0;
SDL_DFB_CHECK(devdata->dfb-> SDL_DFB_CHECK(devdata->dfb->
EnumInputDevices(devdata->dfb, EnumKeyboards, devdata)); EnumInputDevices(devdata->dfb, EnumKeyboards, devdata));
......
...@@ -68,7 +68,7 @@ DirectFB_InitMouse(_THIS) ...@@ -68,7 +68,7 @@ DirectFB_InitMouse(_THIS)
SDL_DFB_DEVICEDATA(_this); SDL_DFB_DEVICEDATA(_this);
devdata->num_mice = 0; devdata->num_mice = 0;
if (LINUX_INPUT_SUPPORT) { if (devdata->use_linux_input) {
/* try non-core devices first */ /* try non-core devices first */
id_mask = 0xF0; id_mask = 0xF0;
devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata); devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata);
...@@ -100,7 +100,7 @@ DirectFB_QuitMouse(_THIS) ...@@ -100,7 +100,7 @@ DirectFB_QuitMouse(_THIS)
{ {
SDL_DFB_DEVICEDATA(_this); SDL_DFB_DEVICEDATA(_this);
if (LINUX_INPUT_SUPPORT) { if (devdata->use_linux_input) {
SDL_MouseQuit(); SDL_MouseQuit();
} else { } else {
SDL_DelMouse(0); SDL_DelMouse(0);
......
...@@ -175,6 +175,10 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window) ...@@ -175,6 +175,10 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
SDL_DFB_CHECKERR(windata->surface-> SDL_DFB_CHECKERR(windata->surface->
GetGL(windata->surface, &context->context)); GetGL(windata->surface, &context->context));
if (!context->context)
return NULL;
SDL_DFB_CHECKERR(context->context->Unlock(context->context)); SDL_DFB_CHECKERR(context->context->Unlock(context->context));
context->next = _this->gl_data->firstgl; context->next = _this->gl_data->firstgl;
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "SDL_DirectFB_render.h" #include "SDL_DirectFB_render.h"
#include "SDL_DirectFB_mouse.h" #include "SDL_DirectFB_mouse.h"
#include "SDL_DirectFB_dyn.h"
/* Initialization/Query functions */ /* Initialization/Query functions */
static int DirectFB_VideoInit(_THIS); static int DirectFB_VideoInit(_THIS);
static void DirectFB_VideoQuit(_THIS); static void DirectFB_VideoQuit(_THIS);
...@@ -66,14 +68,18 @@ VideoBootStrap DirectFB_bootstrap = { ...@@ -66,14 +68,18 @@ VideoBootStrap DirectFB_bootstrap = {
static int static int
DirectFB_Available(void) DirectFB_Available(void)
{ {
if (!SDL_DirectFB_LoadLibrary())
return 0;
SDL_DirectFB_UnLoadLibrary();
return 1; return 1;
} }
static void static void
DirectFB_DeleteDevice(SDL_VideoDevice * device) DirectFB_DeleteDevice(SDL_VideoDevice * device)
{ {
SDL_free(device->driverdata); SDL_DirectFB_UnLoadLibrary();
SDL_free(device); SDL_DFB_FREE(device->driverdata);
SDL_DFB_FREE(device);
} }
static SDL_VideoDevice * static SDL_VideoDevice *
...@@ -81,6 +87,9 @@ DirectFB_CreateDevice(int devindex) ...@@ -81,6 +87,9 @@ DirectFB_CreateDevice(int devindex)
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device;
if (!SDL_DirectFB_LoadLibrary())
return NULL;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice)); SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice));
...@@ -140,22 +149,47 @@ static int ...@@ -140,22 +149,47 @@ static int
DirectFB_VideoInit(_THIS) DirectFB_VideoInit(_THIS)
{ {
IDirectFB *dfb = NULL; IDirectFB *dfb = NULL;
DFB_DeviceData *devdata; DFB_DeviceData *devdata = NULL;
char *stemp; char *stemp;
DFBResult ret; DFBResult ret;
SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); /* avoid switching to the framebuffer when we
* are running X11 */
stemp = getenv(DFBENV_USE_X11_CHECK);
if (stemp)
ret = atoi(stemp);
else
ret = 1;
if (ret) {
if (getenv("DISPLAY"))
DirectFBSetOption("system", "x11");
else
DirectFBSetOption("disable-module", "x11input");
}
devdata->use_linux_input = 1; /* default: on */
stemp = getenv(DFBENV_USE_LINUX_INPUT);
if (stemp)
devdata->use_linux_input = atoi(stemp);
if (!devdata->use_linux_input)
DirectFBSetOption("disable-module", "linux_input");
SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
devdata->use_yuv_underlays = 0; /* default: off */ devdata->use_yuv_underlays = 0; /* default: off */
stemp = getenv(DFBENV_USE_YUV_UNDERLAY); stemp = getenv(DFBENV_USE_YUV_UNDERLAY);
if (stemp) if (stemp)
devdata->use_yuv_underlays = atoi(stemp); devdata->use_yuv_underlays = atoi(stemp);
/* Create global Eventbuffer for axis events */ /* Create global Eventbuffer for axis events */
if (LINUX_INPUT_SUPPORT) { if (devdata->use_linux_input) {
SDL_DFB_CHECKERR(dfb-> SDL_DFB_CHECKERR(dfb->
CreateInputEventBuffer(dfb, DICAPS_ALL, CreateInputEventBuffer(dfb, DICAPS_ALL,
DFB_TRUE, &devdata->events)); DFB_TRUE, &devdata->events));
...@@ -187,6 +221,7 @@ DirectFB_VideoInit(_THIS) ...@@ -187,6 +221,7 @@ DirectFB_VideoInit(_THIS)
error: error:
SDL_DFB_FREE(devdata);
SDL_DFB_RELEASE(dfb); SDL_DFB_RELEASE(dfb);
return -1; return -1;
} }
...@@ -202,7 +237,6 @@ DirectFB_VideoQuit(_THIS) ...@@ -202,7 +237,6 @@ DirectFB_VideoQuit(_THIS)
SDL_DFB_RELEASE(devdata->events); SDL_DFB_RELEASE(devdata->events);
SDL_DFB_RELEASE(devdata->dfb); SDL_DFB_RELEASE(devdata->dfb);
SDL_DFB_FREE(_this->driverdata);
#if SDL_DIRECTFB_OPENGL #if SDL_DIRECTFB_OPENGL
DirectFB_GL_Shutdown(_this); DirectFB_GL_Shutdown(_this);
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include "SDL_mouse.h" #include "SDL_mouse.h"
#define LINUX_INPUT_SUPPORT 1
#define DEBUG 0 #define DEBUG 0
#define LOG_CHANNEL stdout #define LOG_CHANNEL stdout
...@@ -59,8 +57,10 @@ ...@@ -59,8 +57,10 @@
#include "SDL_DirectFB_opengl.h" #include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h" #include "SDL_DirectFB_window.h"
#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" #define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */
#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" #define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */
#define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */
#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0) #define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0) #define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
...@@ -137,6 +137,7 @@ struct _DFB_DeviceData ...@@ -137,6 +137,7 @@ struct _DFB_DeviceData
DFB_WindowData *firstwin; DFB_WindowData *firstwin;
int use_yuv_underlays; int use_yuv_underlays;
int use_linux_input;
/* OpenGL */ /* OpenGL */
void (*glFinish) (void); void (*glFinish) (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment