Date: Sun, 04 Jan 2009 20:53:30 +0100
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Jan 2009 23:43:33 +0000
changeset 2998d364ee9b9c15
parent 2997 e4f025078c1c
child 2999 b2025ca5d7a5
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.
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
     1.1 --- a/README.DirectFB	Sun Jan 04 23:41:09 2009 +0000
     1.2 +++ b/README.DirectFB	Sun Jan 04 23:43:33 2009 +0000
     1.3 @@ -20,12 +20,20 @@
     1.4  your joystick work and avoid crashes:
     1.5  ------------------------
     1.6  disable-module=joystick
     1.7 -disable-module=linux_input
     1.8  disable-module=cle266
     1.9  disable-module=cyber5k
    1.10 -disable-module=x11input
    1.11 +no-linux-input-grab
    1.12  ------------------------
    1.13  
    1.14 +To disable to use x11 backend when DISPLAY variable is found use
    1.15 +
    1.16 +export SDL_DIRECTFB_X11_CHECK=0
    1.17 +
    1.18 +To disable the use of linux input devices, i.e. multimice/multikeyboard support,
    1.19 +use
    1.20 +
    1.21 +export SDL_DIRECTFB_LINUX_INPUT=0
    1.22 +
    1.23  To use hardware accelerated YUV-overlays for YUV-textures, use:
    1.24  
    1.25  export SDL_DIRECTFB_YUV_DIRECT=1
     2.1 --- a/configure.in	Sun Jan 04 23:41:09 2009 +0000
     2.2 +++ b/configure.in	Sun Jan 04 23:43:33 2009 +0000
     2.3 @@ -1311,7 +1311,7 @@
     2.4      if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
     2.5          video_directfb=no
     2.6  
     2.7 -        DIRECTFB_REQUIRED_VERSION=0.9.15
     2.8 +        DIRECTFB_REQUIRED_VERSION=1.0.0
     2.9  
    2.10          AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
    2.11          if test x$DIRECTFBCONFIG = xno; then
    2.12 @@ -1321,6 +1321,7 @@
    2.13                  if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
    2.14                      DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
    2.15                      DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
    2.16 +                    DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
    2.17                      video_directfb=yes
    2.18                  fi
    2.19              fi
    2.20 @@ -1334,16 +1335,39 @@
    2.21              if test $HAVE_VERSION -ge $NEED_VERSION; then
    2.22                  DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
    2.23                  DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
    2.24 +                DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
    2.25                  video_directfb=yes
    2.26              fi
    2.27              AC_MSG_RESULT($video_directfb)
    2.28          fi
    2.29  
    2.30          if test x$video_directfb = xyes; then
    2.31 +            AC_ARG_ENABLE(directfb-shared,
    2.32 +AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
    2.33 +                              , enable_directfb_shared=yes)
    2.34 +
    2.35              AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
    2.36              SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
    2.37              EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
    2.38 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
    2.39 +
    2.40 +	        AC_MSG_CHECKING(for directfb dynamic loading support)
    2.41 +			directfb_shared=no
    2.42 +            directfb_lib_spec="$DIRECTFB_PREFIX/lib/libdirectfb.so*"
    2.43 +            directfb_lib=`ls -- $directfb_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
    2.44 +            dnl echo "-- $directfb_lib_spec -> $directfb_lib"
    2.45 +
    2.46 +            if test x$have_loadso != xyes && \
    2.47 +               test x$enable_directfb_shared = xyes; then
    2.48 +                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
    2.49 +            fi
    2.50 +            if test x$have_loadso = xyes && \
    2.51 +               test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
    2.52 +				directfb_shared=yes
    2.53 +                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib")
    2.54 +            else
    2.55 +	            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
    2.56 +            fi
    2.57 +	        AC_MSG_RESULT($directfb_shared)
    2.58              have_video=yes
    2.59          fi
    2.60      fi
     3.1 --- a/include/SDL_config.h.in	Sun Jan 04 23:41:09 2009 +0000
     3.2 +++ b/include/SDL_config.h.in	Sun Jan 04 23:43:33 2009 +0000
     3.3 @@ -263,6 +263,7 @@
     3.4  #undef SDL_VIDEO_DRIVER_COCOA
     3.5  #undef SDL_VIDEO_DRIVER_DC
     3.6  #undef SDL_VIDEO_DRIVER_DIRECTFB
     3.7 +#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
     3.8  #undef SDL_VIDEO_DRIVER_DUMMY
     3.9  #undef SDL_VIDEO_DRIVER_FBCON
    3.10  #undef SDL_VIDEO_DRIVER_GAPI
     4.1 --- a/src/video/directfb/SDL_DirectFB_events.c	Sun Jan 04 23:41:09 2009 +0000
     4.2 +++ b/src/video/directfb/SDL_DirectFB_events.c	Sun Jan 04 23:43:33 2009 +0000
     4.3 @@ -144,7 +144,7 @@
     4.4              if (evt.clazz == DFEC_WINDOW) {
     4.5                  switch (evt.type) {
     4.6                  case DWET_BUTTONDOWN:
     4.7 -                    if (!LINUX_INPUT_SUPPORT) {
     4.8 +                    if (!devdata->use_linux_input) {
     4.9                          SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
    4.10                                              evt.cy, 0);
    4.11                          SDL_SendMouseButton(devdata->mouse_id[0], SDL_PRESSED,
    4.12 @@ -155,7 +155,7 @@
    4.13                      }
    4.14                      break;
    4.15                  case DWET_BUTTONUP:
    4.16 -                    if (!LINUX_INPUT_SUPPORT) {
    4.17 +                    if (!devdata->use_linux_input) {
    4.18                          SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
    4.19                                              evt.cy, 0);
    4.20                          SDL_SendMouseButton(devdata->mouse_id[0],
    4.21 @@ -167,7 +167,7 @@
    4.22                      }
    4.23                      break;
    4.24                  case DWET_MOTION:
    4.25 -                    if (!LINUX_INPUT_SUPPORT) {
    4.26 +                    if (!devdata->use_linux_input) {
    4.27                          if (!(w->flags & SDL_WINDOW_INPUT_GRABBED))
    4.28                              SDL_SendMouseMotion(devdata->mouse_id[0], 0,
    4.29                                                  evt.cx, evt.cy, 0);
    4.30 @@ -183,7 +183,7 @@
    4.31                      }
    4.32                      break;
    4.33                  case DWET_KEYDOWN:
    4.34 -                    if (!LINUX_INPUT_SUPPORT) {
    4.35 +                    if (!devdata->use_linux_input) {
    4.36                          DirectFB_TranslateKey(_this, &evt, &keysym);
    4.37                          SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode);
    4.38                          if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
    4.39 @@ -196,7 +196,7 @@
    4.40                      }
    4.41                      break;
    4.42                  case DWET_KEYUP:
    4.43 -                    if (!LINUX_INPUT_SUPPORT) {
    4.44 +                    if (!devdata->use_linux_input) {
    4.45                          DirectFB_TranslateKey(_this, &evt, &keysym);
    4.46                          SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode);
    4.47                      }
    4.48 @@ -260,7 +260,7 @@
    4.49  
    4.50          switch (ievt.type) {
    4.51          case DIET_AXISMOTION:
    4.52 -            if (!LINUX_INPUT_SUPPORT) {
    4.53 +            if (!devdata->use_linux_input) {
    4.54                  if ((grabbed_window >= 0) && (ievt.flags & DIEF_AXISREL)) {
    4.55                      printf("rel devid %d\n", ievt.device_id);
    4.56                      if (ievt.axis == DIAI_X)
    4.57 @@ -273,7 +273,7 @@
    4.58              }
    4.59              break;
    4.60          }
    4.61 -        if (LINUX_INPUT_SUPPORT) {
    4.62 +        if (devdata->use_linux_input) {
    4.63              IDirectFBInputDevice *idev;
    4.64              static int last_x, last_y;
    4.65  
    4.66 @@ -600,7 +600,7 @@
    4.67      DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap));
    4.68  
    4.69      devdata->num_keyboard = 0;
    4.70 -    if (LINUX_INPUT_SUPPORT) {
    4.71 +    if (devdata->use_linux_input) {
    4.72          sys_ids = 0;
    4.73          SDL_DFB_CHECK(devdata->dfb->
    4.74                        EnumInputDevices(devdata->dfb, EnumKeyboards, devdata));
     5.1 --- a/src/video/directfb/SDL_DirectFB_mouse.c	Sun Jan 04 23:41:09 2009 +0000
     5.2 +++ b/src/video/directfb/SDL_DirectFB_mouse.c	Sun Jan 04 23:43:33 2009 +0000
     5.3 @@ -68,7 +68,7 @@
     5.4      SDL_DFB_DEVICEDATA(_this);
     5.5  
     5.6      devdata->num_mice = 0;
     5.7 -    if (LINUX_INPUT_SUPPORT) {
     5.8 +    if (devdata->use_linux_input) {
     5.9          /* try non-core devices first */
    5.10          id_mask = 0xF0;
    5.11          devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata);
    5.12 @@ -100,7 +100,7 @@
    5.13  {
    5.14      SDL_DFB_DEVICEDATA(_this);
    5.15  
    5.16 -    if (LINUX_INPUT_SUPPORT) {
    5.17 +    if (devdata->use_linux_input) {
    5.18          SDL_MouseQuit();
    5.19      } else {
    5.20          SDL_DelMouse(0);
     6.1 --- a/src/video/directfb/SDL_DirectFB_opengl.c	Sun Jan 04 23:41:09 2009 +0000
     6.2 +++ b/src/video/directfb/SDL_DirectFB_opengl.c	Sun Jan 04 23:43:33 2009 +0000
     6.3 @@ -175,6 +175,10 @@
     6.4  
     6.5      SDL_DFB_CHECKERR(windata->surface->
     6.6                       GetGL(windata->surface, &context->context));
     6.7 +
     6.8 +    if (!context->context)
     6.9 +        return NULL;
    6.10 +
    6.11      SDL_DFB_CHECKERR(context->context->Unlock(context->context));
    6.12  
    6.13      context->next = _this->gl_data->firstgl;
     7.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Sun Jan 04 23:41:09 2009 +0000
     7.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Sun Jan 04 23:43:33 2009 +0000
     7.3 @@ -46,6 +46,8 @@
     7.4  #include "SDL_DirectFB_render.h"
     7.5  #include "SDL_DirectFB_mouse.h"
     7.6  
     7.7 +#include "SDL_DirectFB_dyn.h"
     7.8 +
     7.9  /* Initialization/Query functions */
    7.10  static int DirectFB_VideoInit(_THIS);
    7.11  static void DirectFB_VideoQuit(_THIS);
    7.12 @@ -66,14 +68,18 @@
    7.13  static int
    7.14  DirectFB_Available(void)
    7.15  {
    7.16 +    if (!SDL_DirectFB_LoadLibrary())
    7.17 +        return 0;
    7.18 +    SDL_DirectFB_UnLoadLibrary();
    7.19      return 1;
    7.20  }
    7.21  
    7.22  static void
    7.23  DirectFB_DeleteDevice(SDL_VideoDevice * device)
    7.24  {
    7.25 -    SDL_free(device->driverdata);
    7.26 -    SDL_free(device);
    7.27 +    SDL_DirectFB_UnLoadLibrary();
    7.28 +    SDL_DFB_FREE(device->driverdata);
    7.29 +    SDL_DFB_FREE(device);
    7.30  }
    7.31  
    7.32  static SDL_VideoDevice *
    7.33 @@ -81,6 +87,9 @@
    7.34  {
    7.35      SDL_VideoDevice *device;
    7.36  
    7.37 +    if (!SDL_DirectFB_LoadLibrary())
    7.38 +        return NULL;
    7.39 +
    7.40      /* Initialize all variables that we clean on shutdown */
    7.41      SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice));
    7.42  
    7.43 @@ -140,22 +149,47 @@
    7.44  DirectFB_VideoInit(_THIS)
    7.45  {
    7.46      IDirectFB *dfb = NULL;
    7.47 -    DFB_DeviceData *devdata;
    7.48 +    DFB_DeviceData *devdata = NULL;
    7.49      char *stemp;
    7.50      DFBResult ret;
    7.51  
    7.52 +    SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
    7.53 +
    7.54      SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
    7.55 +
    7.56 +    /* avoid switching to the framebuffer when we
    7.57 +     * are running X11 */
    7.58 +    stemp = getenv(DFBENV_USE_X11_CHECK);
    7.59 +    if (stemp)
    7.60 +        ret = atoi(stemp);
    7.61 +    else
    7.62 +        ret = 1;
    7.63 +
    7.64 +    if (ret) {
    7.65 +        if (getenv("DISPLAY"))
    7.66 +            DirectFBSetOption("system", "x11");
    7.67 +        else
    7.68 +            DirectFBSetOption("disable-module", "x11input");
    7.69 +    }
    7.70 +
    7.71 +    devdata->use_linux_input = 1;       /* default: on */
    7.72 +    stemp = getenv(DFBENV_USE_LINUX_INPUT);
    7.73 +    if (stemp)
    7.74 +        devdata->use_linux_input = atoi(stemp);
    7.75 +
    7.76 +    if (!devdata->use_linux_input)
    7.77 +        DirectFBSetOption("disable-module", "linux_input");
    7.78 +
    7.79      SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
    7.80  
    7.81 -    SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
    7.82 -
    7.83      devdata->use_yuv_underlays = 0;     /* default: off */
    7.84      stemp = getenv(DFBENV_USE_YUV_UNDERLAY);
    7.85      if (stemp)
    7.86          devdata->use_yuv_underlays = atoi(stemp);
    7.87  
    7.88 +
    7.89      /* Create global Eventbuffer for axis events */
    7.90 -    if (LINUX_INPUT_SUPPORT) {
    7.91 +    if (devdata->use_linux_input) {
    7.92          SDL_DFB_CHECKERR(dfb->
    7.93                           CreateInputEventBuffer(dfb, DICAPS_ALL,
    7.94                                                  DFB_TRUE, &devdata->events));
    7.95 @@ -187,6 +221,7 @@
    7.96  
    7.97  
    7.98    error:
    7.99 +    SDL_DFB_FREE(devdata);
   7.100      SDL_DFB_RELEASE(dfb);
   7.101      return -1;
   7.102  }
   7.103 @@ -202,7 +237,6 @@
   7.104  
   7.105      SDL_DFB_RELEASE(devdata->events);
   7.106      SDL_DFB_RELEASE(devdata->dfb);
   7.107 -    SDL_DFB_FREE(_this->driverdata);
   7.108  
   7.109  #if SDL_DIRECTFB_OPENGL
   7.110      DirectFB_GL_Shutdown(_this);
     8.1 --- a/src/video/directfb/SDL_DirectFB_video.h	Sun Jan 04 23:41:09 2009 +0000
     8.2 +++ b/src/video/directfb/SDL_DirectFB_video.h	Sun Jan 04 23:43:33 2009 +0000
     8.3 @@ -31,8 +31,6 @@
     8.4  
     8.5  #include "SDL_mouse.h"
     8.6  
     8.7 -#define LINUX_INPUT_SUPPORT	1
     8.8 -
     8.9  #define DEBUG 0
    8.10  #define LOG_CHANNEL 	stdout
    8.11  
    8.12 @@ -59,8 +57,10 @@
    8.13  #include "SDL_DirectFB_opengl.h"
    8.14  #include "SDL_DirectFB_window.h"
    8.15  
    8.16 -#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY"
    8.17 -#define DFBENV_USE_YUV_DIRECT   "SDL_DIRECTFB_YUV_DIRECT"
    8.18 +#define DFBENV_USE_YUV_UNDERLAY 	"SDL_DIRECTFB_YUV_UNDERLAY"     /* Default: off */
    8.19 +#define DFBENV_USE_YUV_DIRECT   	"SDL_DIRECTFB_YUV_DIRECT"       /* Default: off */
    8.20 +#define DFBENV_USE_X11_CHECK		"SDL_DIRECTFB_X11_CHECK"        /* Default: on  */
    8.21 +#define DFBENV_USE_LINUX_INPUT		"SDL_DIRECTFB_LINUX_INPUT"      /* Default: on  */
    8.22  
    8.23  #define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
    8.24  #define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
    8.25 @@ -137,6 +137,7 @@
    8.26      DFB_WindowData *firstwin;
    8.27  
    8.28      int use_yuv_underlays;
    8.29 +    int use_linux_input;
    8.30  
    8.31      /* OpenGL */
    8.32      void (*glFinish) (void);