Mercurial > sdl-ios-xcode
changeset 2998:d364ee9b9c15
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2009 23:43:33 +0000 |
parents | e4f025078c1c |
children | b2025ca5d7a5 |
files | README.DirectFB configure.in include/SDL_config.h.in src/video/directfb/SDL_DirectFB_events.c src/video/directfb/SDL_DirectFB_mouse.c src/video/directfb/SDL_DirectFB_opengl.c src/video/directfb/SDL_DirectFB_video.c src/video/directfb/SDL_DirectFB_video.h |
diffstat | 8 files changed, 97 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/README.DirectFB Sun Jan 04 23:41:09 2009 +0000 +++ b/README.DirectFB Sun Jan 04 23:43:33 2009 +0000 @@ -20,12 +20,20 @@ your joystick work and avoid crashes: ------------------------ disable-module=joystick -disable-module=linux_input disable-module=cle266 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: export SDL_DIRECTFB_YUV_DIRECT=1
--- a/configure.in Sun Jan 04 23:41:09 2009 +0000 +++ b/configure.in Sun Jan 04 23:43:33 2009 +0000 @@ -1311,7 +1311,7 @@ if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then video_directfb=no - DIRECTFB_REQUIRED_VERSION=0.9.15 + DIRECTFB_REQUIRED_VERSION=1.0.0 AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no) if test x$DIRECTFBCONFIG = xno; then @@ -1321,6 +1321,7 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb` DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb` + DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb` video_directfb=yes fi fi @@ -1334,16 +1335,39 @@ if test $HAVE_VERSION -ge $NEED_VERSION; then DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags` DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs` + DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix` video_directfb=yes fi AC_MSG_RESULT($video_directfb) fi 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) SOURCES="$SOURCES $srcdir/src/video/directfb/*.c" 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 fi fi
--- a/include/SDL_config.h.in Sun Jan 04 23:41:09 2009 +0000 +++ b/include/SDL_config.h.in Sun Jan 04 23:43:33 2009 +0000 @@ -263,6 +263,7 @@ #undef SDL_VIDEO_DRIVER_COCOA #undef SDL_VIDEO_DRIVER_DC #undef SDL_VIDEO_DRIVER_DIRECTFB +#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC #undef SDL_VIDEO_DRIVER_DUMMY #undef SDL_VIDEO_DRIVER_FBCON #undef SDL_VIDEO_DRIVER_GAPI
--- a/src/video/directfb/SDL_DirectFB_events.c Sun Jan 04 23:41:09 2009 +0000 +++ b/src/video/directfb/SDL_DirectFB_events.c Sun Jan 04 23:43:33 2009 +0000 @@ -144,7 +144,7 @@ if (evt.clazz == DFEC_WINDOW) { switch (evt.type) { case DWET_BUTTONDOWN: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx, evt.cy, 0); SDL_SendMouseButton(devdata->mouse_id[0], SDL_PRESSED, @@ -155,7 +155,7 @@ } break; case DWET_BUTTONUP: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx, evt.cy, 0); SDL_SendMouseButton(devdata->mouse_id[0], @@ -167,7 +167,7 @@ } break; case DWET_MOTION: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { if (!(w->flags & SDL_WINDOW_INPUT_GRABBED)) SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx, evt.cy, 0); @@ -183,7 +183,7 @@ } break; case DWET_KEYDOWN: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, &evt, &keysym); SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { @@ -196,7 +196,7 @@ } break; case DWET_KEYUP: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, &evt, &keysym); SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode); } @@ -260,7 +260,7 @@ switch (ievt.type) { case DIET_AXISMOTION: - if (!LINUX_INPUT_SUPPORT) { + if (!devdata->use_linux_input) { if ((grabbed_window >= 0) && (ievt.flags & DIEF_AXISREL)) { printf("rel devid %d\n", ievt.device_id); if (ievt.axis == DIAI_X) @@ -273,7 +273,7 @@ } break; } - if (LINUX_INPUT_SUPPORT) { + if (devdata->use_linux_input) { IDirectFBInputDevice *idev; static int last_x, last_y; @@ -600,7 +600,7 @@ DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap)); devdata->num_keyboard = 0; - if (LINUX_INPUT_SUPPORT) { + if (devdata->use_linux_input) { sys_ids = 0; SDL_DFB_CHECK(devdata->dfb-> EnumInputDevices(devdata->dfb, EnumKeyboards, devdata));
--- a/src/video/directfb/SDL_DirectFB_mouse.c Sun Jan 04 23:41:09 2009 +0000 +++ b/src/video/directfb/SDL_DirectFB_mouse.c Sun Jan 04 23:43:33 2009 +0000 @@ -68,7 +68,7 @@ SDL_DFB_DEVICEDATA(_this); devdata->num_mice = 0; - if (LINUX_INPUT_SUPPORT) { + if (devdata->use_linux_input) { /* try non-core devices first */ id_mask = 0xF0; devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata); @@ -100,7 +100,7 @@ { SDL_DFB_DEVICEDATA(_this); - if (LINUX_INPUT_SUPPORT) { + if (devdata->use_linux_input) { SDL_MouseQuit(); } else { SDL_DelMouse(0);
--- a/src/video/directfb/SDL_DirectFB_opengl.c Sun Jan 04 23:41:09 2009 +0000 +++ b/src/video/directfb/SDL_DirectFB_opengl.c Sun Jan 04 23:43:33 2009 +0000 @@ -175,6 +175,10 @@ SDL_DFB_CHECKERR(windata->surface-> GetGL(windata->surface, &context->context)); + + if (!context->context) + return NULL; + SDL_DFB_CHECKERR(context->context->Unlock(context->context)); context->next = _this->gl_data->firstgl;
--- a/src/video/directfb/SDL_DirectFB_video.c Sun Jan 04 23:41:09 2009 +0000 +++ b/src/video/directfb/SDL_DirectFB_video.c Sun Jan 04 23:43:33 2009 +0000 @@ -46,6 +46,8 @@ #include "SDL_DirectFB_render.h" #include "SDL_DirectFB_mouse.h" +#include "SDL_DirectFB_dyn.h" + /* Initialization/Query functions */ static int DirectFB_VideoInit(_THIS); static void DirectFB_VideoQuit(_THIS); @@ -66,14 +68,18 @@ static int DirectFB_Available(void) { + if (!SDL_DirectFB_LoadLibrary()) + return 0; + SDL_DirectFB_UnLoadLibrary(); return 1; } static void DirectFB_DeleteDevice(SDL_VideoDevice * device) { - SDL_free(device->driverdata); - SDL_free(device); + SDL_DirectFB_UnLoadLibrary(); + SDL_DFB_FREE(device->driverdata); + SDL_DFB_FREE(device); } static SDL_VideoDevice * @@ -81,6 +87,9 @@ { SDL_VideoDevice *device; + if (!SDL_DirectFB_LoadLibrary()) + return NULL; + /* Initialize all variables that we clean on shutdown */ SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice)); @@ -140,22 +149,47 @@ DirectFB_VideoInit(_THIS) { IDirectFB *dfb = NULL; - DFB_DeviceData *devdata; + DFB_DeviceData *devdata = NULL; char *stemp; DFBResult ret; + SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); + SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); + + /* 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)); - SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); - devdata->use_yuv_underlays = 0; /* default: off */ stemp = getenv(DFBENV_USE_YUV_UNDERLAY); if (stemp) devdata->use_yuv_underlays = atoi(stemp); + /* Create global Eventbuffer for axis events */ - if (LINUX_INPUT_SUPPORT) { + if (devdata->use_linux_input) { SDL_DFB_CHECKERR(dfb-> CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_TRUE, &devdata->events)); @@ -187,6 +221,7 @@ error: + SDL_DFB_FREE(devdata); SDL_DFB_RELEASE(dfb); return -1; } @@ -202,7 +237,6 @@ SDL_DFB_RELEASE(devdata->events); SDL_DFB_RELEASE(devdata->dfb); - SDL_DFB_FREE(_this->driverdata); #if SDL_DIRECTFB_OPENGL DirectFB_GL_Shutdown(_this);
--- a/src/video/directfb/SDL_DirectFB_video.h Sun Jan 04 23:41:09 2009 +0000 +++ b/src/video/directfb/SDL_DirectFB_video.h Sun Jan 04 23:43:33 2009 +0000 @@ -31,8 +31,6 @@ #include "SDL_mouse.h" -#define LINUX_INPUT_SUPPORT 1 - #define DEBUG 0 #define LOG_CHANNEL stdout @@ -59,8 +57,10 @@ #include "SDL_DirectFB_opengl.h" #include "SDL_DirectFB_window.h" -#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" -#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" +#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */ +#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_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0) @@ -137,6 +137,7 @@ DFB_WindowData *firstwin; int use_yuv_underlays; + int use_linux_input; /* OpenGL */ void (*glFinish) (void);