Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Date: Sun, 04 Jan 2009 20:53:30 +0100
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Jan 4, 2009
1 parent 337a50e commit 8c237a4
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 25 deletions.
12 changes: 10 additions & 2 deletions README.DirectFB
Expand Up @@ -20,12 +20,20 @@ This file should contain the following lines to make
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
Expand Down
28 changes: 26 additions & 2 deletions configure.in
Expand Up @@ -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
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
Expand All @@ -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
DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
video_directfb=yes
fi
fi
Expand All @@ -1334,16 +1335,39 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
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
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.in
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/video/directfb/SDL_DirectFB_events.c
Expand Up @@ -144,7 +144,7 @@ DirectFB_PumpEventsWindow(_THIS)
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,
Expand All @@ -155,7 +155,7 @@ DirectFB_PumpEventsWindow(_THIS)
}
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],
Expand All @@ -167,7 +167,7 @@ DirectFB_PumpEventsWindow(_THIS)
}
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);
Expand All @@ -183,7 +183,7 @@ DirectFB_PumpEventsWindow(_THIS)
}
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)) {
Expand All @@ -196,7 +196,7 @@ DirectFB_PumpEventsWindow(_THIS)
}
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);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ DirectFB_PumpEventsWindow(_THIS)

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)
Expand All @@ -273,7 +273,7 @@ DirectFB_PumpEventsWindow(_THIS)
}
break;
}
if (LINUX_INPUT_SUPPORT) {
if (devdata->use_linux_input) {
IDirectFBInputDevice *idev;
static int last_x, last_y;

Expand Down Expand Up @@ -600,7 +600,7 @@ DirectFB_InitKeyboard(_THIS)
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));
Expand Down
4 changes: 2 additions & 2 deletions src/video/directfb/SDL_DirectFB_mouse.c
Expand Up @@ -68,7 +68,7 @@ DirectFB_InitMouse(_THIS)
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);
Expand Down Expand Up @@ -100,7 +100,7 @@ DirectFB_QuitMouse(_THIS)
{
SDL_DFB_DEVICEDATA(_this);

if (LINUX_INPUT_SUPPORT) {
if (devdata->use_linux_input) {
SDL_MouseQuit();
} else {
SDL_DelMouse(0);
Expand Down
4 changes: 4 additions & 0 deletions src/video/directfb/SDL_DirectFB_opengl.c
Expand Up @@ -175,6 +175,10 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)

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;
Expand Down
48 changes: 41 additions & 7 deletions src/video/directfb/SDL_DirectFB_video.c
Expand Up @@ -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);
Expand All @@ -66,21 +68,28 @@ VideoBootStrap DirectFB_bootstrap = {
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 *
DirectFB_CreateDevice(int devindex)
{
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));

Expand Down Expand Up @@ -140,22 +149,47 @@ static int
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));
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 */
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));
Expand Down Expand Up @@ -187,6 +221,7 @@ DirectFB_VideoInit(_THIS)


error:
SDL_DFB_FREE(devdata);
SDL_DFB_RELEASE(dfb);
return -1;
}
Expand All @@ -202,7 +237,6 @@ DirectFB_VideoQuit(_THIS)

SDL_DFB_RELEASE(devdata->events);
SDL_DFB_RELEASE(devdata->dfb);
SDL_DFB_FREE(_this->driverdata);

#if SDL_DIRECTFB_OPENGL
DirectFB_GL_Shutdown(_this);
Expand Down
9 changes: 5 additions & 4 deletions src/video/directfb/SDL_DirectFB_video.h
Expand Up @@ -31,8 +31,6 @@

#include "SDL_mouse.h"

#define LINUX_INPUT_SUPPORT 1

#define DEBUG 0
#define LOG_CHANNEL stdout

Expand All @@ -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)
Expand Down Expand Up @@ -137,6 +137,7 @@ struct _DFB_DeviceData
DFB_WindowData *firstwin;

int use_yuv_underlays;
int use_linux_input;

/* OpenGL */
void (*glFinish) (void);
Expand Down

0 comments on commit 8c237a4

Please sign in to comment.