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
This commit is contained in:
Sam Lantinga 2009-01-04 23:43:33 +00:00
parent ba8f64f259
commit 7c0f19e5aa
8 changed files with 98 additions and 26 deletions

View file

@ -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,
@ -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],
@ -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);
@ -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)) {
@ -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);
}
@ -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)
@ -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;
@ -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));

View file

@ -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);
@ -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);

View file

@ -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;

View file

@ -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 @@ 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 *
@ -81,6 +87,9 @@ 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));
@ -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_CHECKERR(DirectFBInit(NULL, NULL));
SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
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));
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 @@ DirectFB_VideoInit(_THIS)
error:
SDL_DFB_FREE(devdata);
SDL_DFB_RELEASE(dfb);
return -1;
}
@ -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);

View file

@ -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 @@ struct _DFB_DeviceData
DFB_WindowData *firstwin;
int use_yuv_underlays;
int use_linux_input;
/* OpenGL */
void (*glFinish) (void);