Mercurial > sdl-ios-xcode
changeset 4568:25b9cd8bdc30
Couriersud to Sam
I have done some quick changes and at least the code compiles again. It
also works with a number of the test executables with the DFB X11
backend. I hope to find time to get SDLMAME to work with latest SDL1.3
(i.e. rip out multi-keyboard, multi-mice & cursor support) next week to
test it further.
Regards,
André
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 23 Jul 2010 21:33:00 -0700 |
parents | 1d7ea8724f4a |
children | e1664f94f026 |
files | src/video/directfb/SDL_DirectFB_WM.c src/video/directfb/SDL_DirectFB_events.c src/video/directfb/SDL_DirectFB_modes.h src/video/directfb/SDL_DirectFB_mouse.c src/video/directfb/SDL_DirectFB_render.c src/video/directfb/SDL_DirectFB_video.c src/video/directfb/SDL_DirectFB_video.h src/video/directfb/SDL_DirectFB_window.c src/video/directfb/SDL_DirectFB_window.h |
diffstat | 9 files changed, 121 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/directfb/SDL_DirectFB_WM.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_WM.c Fri Jul 23 21:33:00 2010 -0700 @@ -210,7 +210,7 @@ windata->window->MoveTo(windata->window, 0, 0); windata->window->Resize(windata->window, display->current_mode.w, display->current_mode.h); - SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } void @@ -226,7 +226,7 @@ windata->restore.y); windata->window->Resize(windata->window, windata->restore.w, windata->restore.h); - SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_RESTORED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } enum @@ -304,7 +304,7 @@ case WM_POS_NONE: return 0; case WM_POS_CLOSE: - SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0, 0); return 1; case WM_POS_MAX:
--- a/src/video/directfb/SDL_DirectFB_events.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_events.c Fri Jul 23 21:33:00 2010 -0700 @@ -32,6 +32,19 @@ #include "../../events/scancodes_linux.h" #include "SDL_DirectFB_events.h" +#if USE_MULTI_API +#define SDL_SendMouseMotion_ex(id, relative, x, y, p) SDL_SendMouseMotion(id, relative, x, y, p) +#define SDL_SendMouseButton_ex(id, state, button) SDL_SendMouseButton(id, state, button) +#define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(id, state, scancode) +#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text) +#else +#define SDL_SendMouseMotion_ex(id, relative, x, y, p) SDL_SendMouseMotion(relative, x, y) +#define SDL_SendMouseButton_ex(id, state, button) SDL_SendMouseButton(state, button) +#define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(state, scancode) +#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text) +#endif + + /* The translation tables from a DirectFB keycode to a SDL keysym */ static SDLKey oskeymap[256]; static int sys_ids; @@ -54,7 +67,6 @@ * This has simply no effect. */ - SDL_Window *window = SDL_GetWindowFromID(id); SDL_VideoDisplay *display = window->display; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; int ret; @@ -72,27 +84,36 @@ static void FocusAllMice(_THIS, SDL_Window *window) { +#if USE_MULTI_API SDL_DFB_DEVICEDATA(_this); int index; for (index = 0; index < devdata->num_mice; index++) SDL_SetMouseFocus(devdata->mouse_id[index], id); +#else + SDL_SetMouseFocus(window); +#endif } static void FocusAllKeyboards(_THIS, SDL_Window *window) { +#if USE_MULTI_API SDL_DFB_DEVICEDATA(_this); int index; for (index = 0; index < devdata->num_keyboard; index++) SDL_SetKeyboardFocus(index, id); +#else + SDL_SetKeyboardFocus(window); +#endif } static void MotionAllMice(_THIS, int x, int y) { +#if USE_MULTI_API SDL_DFB_DEVICEDATA(_this); int index; @@ -102,6 +123,7 @@ mouse->y = mouse->last_y = y; //SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); } +#endif } static int @@ -150,9 +172,9 @@ case DWET_BUTTONDOWN: if (ClientXY(p, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt->x, + SDL_SendMouseMotion_ex(devdata->mouse_id[0], 0, evt->x, evt->y, 0); - SDL_SendMouseButton(devdata->mouse_id[0], + SDL_SendMouseButton_ex(devdata->mouse_id[0], SDL_PRESSED, DirectFB_TranslateButton (evt->button)); @@ -164,9 +186,9 @@ case DWET_BUTTONUP: if (ClientXY(p, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt->x, + SDL_SendMouseMotion_ex(devdata->mouse_id[0], 0, evt->x, evt->y, 0); - SDL_SendMouseButton(devdata->mouse_id[0], + SDL_SendMouseButton_ex(devdata->mouse_id[0], SDL_RELEASED, DirectFB_TranslateButton (evt->button)); @@ -177,10 +199,10 @@ break; case DWET_MOTION: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_Window *window = p->window; + SDL_Window *window = p->sdl_window; if (!devdata->use_linux_input) { if (!(flags & SDL_WINDOW_INPUT_GRABBED)) - SDL_SendMouseMotion(devdata->mouse_id[0], 0, + SDL_SendMouseMotion_ex(devdata->mouse_id[0], 0, evt->x, evt->y, 0); } else { /* relative movements are not exact! @@ -200,12 +222,12 @@ case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym); - SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode); + SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_memcpy(text, &keysym.unicode, 4); text[4] = 0; if (*text) { - SDL_SendKeyboardText(0, text); + SDL_SendKeyboardText_ex(0, text); } } } @@ -213,18 +235,18 @@ case DWET_KEYUP: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym); - SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode); + SDL_SendKeyboardKey_ex(0, SDL_RELEASED, keysym.scancode); } break; case DWET_POSITION: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } break; case DWET_POSITION_SIZE: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } /* fall throught */ @@ -234,32 +256,32 @@ evt->h -= (p->theme.top_size + p->theme.bottom_size + p->theme.caption_size); - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_RESIZED, + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_RESIZED, evt->w, evt->h); break; case DWET_CLOSE: - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_CLOSE, 0, 0); + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_CLOSE, 0, 0); break; case DWET_GOTFOCUS: - DirectFB_SetContext(_this, p->window); - FocusAllKeyboards(_this, p->window); - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_GAINED, + DirectFB_SetContext(_this, p->sdl_window); + FocusAllKeyboards(_this, p->sdl_window); + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); break; case DWET_LOSTFOCUS: - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); FocusAllKeyboards(_this, 0); break; case DWET_ENTER: /* SDL_DirectFB_ReshowCursor(_this, 0); */ - FocusAllMice(_this, p->window); + FocusAllMice(_this, p->sdl_window); // FIXME: when do we really enter ? if (ClientXY(p, &evt->x, &evt->y)) MotionAllMice(_this, evt->x, evt->y); - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, 0); + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0, 0); break; case DWET_LEAVE: - SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_LEAVE, 0, 0); + SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_LEAVE, 0, 0); FocusAllMice(_this, 0); /* SDL_DirectFB_ReshowCursor(_this, 1); */ break; @@ -271,7 +293,7 @@ } static void -ProcessInputEvent(_THIS, Sint32 grabbed_window, DFBInputEvent * ievt) +ProcessInputEvent(_THIS, SDL_Window *grabbed_window, DFBInputEvent * ievt) { SDL_DFB_DEVICEDATA(_this); SDL_keysym keysym; @@ -280,16 +302,17 @@ if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { - if ((grabbed_window >= 0) && (ievt->flags & DIEF_AXISREL)) { + if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { if (ievt->axis == DIAI_X) - SDL_SendMouseMotion(ievt->device_id, 1, + SDL_SendMouseMotion_ex(ievt->device_id, 1, ievt->axisrel, 0, 0); else if (ievt->axis == DIAI_Y) - SDL_SendMouseMotion(ievt->device_id, 1, 0, + SDL_SendMouseMotion_ex(ievt->device_id, 1, 0, ievt->axisrel, 0); } } } else { +#if USE_MULTI_API static int last_x, last_y; switch (ievt->type) { @@ -308,34 +331,34 @@ int x, y; windata->window->GetPosition(windata->window, &x, &y); - SDL_SendMouseMotion(ievt->device_id, 0, + SDL_SendMouseMotion_ex(ievt->device_id, 0, last_x - (x + windata->client.x), last_y - (y + windata->client.y), 0); } else { - SDL_SendMouseMotion(ievt->device_id, 0, last_x, + SDL_SendMouseMotion_ex(ievt->device_id, 0, last_x, last_y, 0); } } } else if (ievt->flags & DIEF_AXISREL) { if (ievt->axis == DIAI_X) - SDL_SendMouseMotion(ievt->device_id, 1, + SDL_SendMouseMotion_ex(ievt->device_id, 1, ievt->axisrel, 0, 0); else if (ievt->axis == DIAI_Y) - SDL_SendMouseMotion(ievt->device_id, 1, 0, + SDL_SendMouseMotion_ex(ievt->device_id, 1, 0, ievt->axisrel, 0); } break; case DIET_KEYPRESS: kbd_idx = KbdIndex(_this, ievt->device_id); DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym); - SDL_SendKeyboardKey(kbd_idx, SDL_PRESSED, keysym.scancode); + SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_memcpy(text, &keysym.unicode, 4); text[4] = 0; if (*text) { - SDL_SendKeyboardText(kbd_idx, text); + SDL_SendKeyboardText_ex(kbd_idx, text); } } break; @@ -363,6 +386,7 @@ default: break; /* please gcc */ } +#endif } } @@ -378,7 +402,7 @@ for (p = devdata->firstwin; p != NULL; p = p->next) { DFBWindowEvent evt; - SDL_Window *w = SDL_GetWindowFromID(p->window); + SDL_Window *w = p->sdl_window; if (w->flags & SDL_WINDOW_INPUT_GRABBED) { grabbed_window = w; @@ -603,19 +627,27 @@ DFBInputDeviceDescription desc, void *callbackdata) { DFB_DeviceData *devdata = callbackdata; +#if USE_MULTI_API SDL_Keyboard keyboard; +#endif SDLKey keymap[SDL_NUM_SCANCODES]; if ((desc.caps & DIDTF_KEYBOARD) && device_id == DIDID_KEYBOARD) { +#if USE_MULTI_API SDL_zero(keyboard); SDL_AddKeyboard(&keyboard, 0); +#endif devdata->keyboard[0].id = device_id; devdata->keyboard[0].is_generic = 0; if (!strncmp("X11", desc.name, 3)) devdata->keyboard[0].is_generic = 1; SDL_GetDefaultKeymap(keymap); +#if USE_MULTI_API SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); +#else + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); +#endif devdata->num_keyboard++; return DFENUM_CANCEL; @@ -623,6 +655,7 @@ return DFENUM_OK; } +#if USE_MULTI_API static DFBEnumerationResult EnumKeyboards(DFBInputDeviceID device_id, DFBInputDeviceDescription desc, void *callbackdata) @@ -652,6 +685,7 @@ } return DFENUM_OK; } +#endif void DirectFB_InitKeyboard(_THIS) @@ -662,6 +696,7 @@ DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap)); devdata->num_keyboard = 0; +#if USE_MULTI_API if (devdata->use_linux_input) { sys_ids = 0; SDL_DFB_CHECK(devdata->dfb-> @@ -672,11 +707,14 @@ EnumKeyboards, devdata)); } - } else { + } else +#else + { SDL_DFB_CHECK(devdata->dfb->EnumInputDevices(devdata->dfb, input_device_cb, devdata)); } +#endif } void @@ -759,3 +797,4 @@ } } #endif +
--- a/src/video/directfb/SDL_DirectFB_modes.h Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_modes.h Fri Jul 23 21:33:00 2010 -0700 @@ -26,7 +26,7 @@ #include "SDL_DirectFB_video.h" -#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL) +#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (win)->display->driverdata : NULL) typedef struct _DFB_DisplayData DFB_DisplayData; struct _DFB_DisplayData
--- a/src/video/directfb/SDL_DirectFB_mouse.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_mouse.c Fri Jul 23 21:33:00 2010 -0700 @@ -26,6 +26,7 @@ #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" +#if USE_MULTI_API static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); static int DirectFB_ShowCursor(SDL_Cursor * cursor); @@ -239,4 +240,23 @@ /* nothing yet */ } +#else /* USE_MULTI_API */ + +void +DirectFB_InitMouse(_THIS) +{ + SDL_DFB_DEVICEDATA(_this); + + devdata->num_mice = 1; +} + +void +DirectFB_QuitMouse(_THIS) +{ + SDL_DFB_DEVICEDATA(_this); +} + + +#endif + /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/directfb/SDL_DirectFB_render.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_render.c Fri Jul 23 21:33:00 2010 -0700 @@ -423,7 +423,7 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) { SDL_DFB_RENDERERDATA(renderer); - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); if (renddata->size_changed || windata->wm_needs_redraw) { @@ -445,7 +445,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_DFB_RENDERERDATA(renderer); - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_VideoDisplay *display = window->display; SDL_DFB_DEVICEDATA(display->device); DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; @@ -501,7 +501,7 @@ static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_VideoDisplay *display = window->display; SDL_DFB_DEVICEDATA(display->device); DirectFB_TextureData *data; @@ -950,7 +950,7 @@ if (texturedata->display) { int px, py; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); SDL_VideoDisplay *display = texturedata->display; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; @@ -1048,7 +1048,7 @@ DirectFB_RenderPresent(SDL_Renderer * renderer) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); DFBRectangle sr;
--- a/src/video/directfb/SDL_DirectFB_video.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_video.c Fri Jul 23 21:33:00 2010 -0700 @@ -129,7 +129,7 @@ #endif device->free = DirectFB_DeleteDevice; - + fprintf(LOG_CHANNEL, "Device setup %p!!\n", device->ShowWindow); return device; error: if (device) @@ -163,19 +163,20 @@ fprintf(LOG_CHANNEL, "\nBlitting flags:\n"); for (n = 0; blitting_flags[n].flag; n++) { if (desc.blitting_flags & blitting_flags[n].flag) - printf(" %s\n", blitting_flags[n].name); + fprintf(LOG_CHANNEL, " %s\n", blitting_flags[n].name); } fprintf(LOG_CHANNEL, "\nDrawing flags:\n"); for (n = 0; drawing_flags[n].flag; n++) { if (desc.drawing_flags & drawing_flags[n].flag) - printf(" %s\n", drawing_flags[n].name); + fprintf(LOG_CHANNEL, " %s\n", drawing_flags[n].name); } + fprintf(LOG_CHANNEL, "\nAcceleration flags:\n"); for (n = 0; acceleration_mask[n].mask; n++) { if (desc.acceleration_mask & acceleration_mask[n].mask) - printf(" %s\n", acceleration_mask[n].name); + fprintf(LOG_CHANNEL, " %s\n", acceleration_mask[n].name); } @@ -208,10 +209,14 @@ DirectFBSetOption("disable-module", "x11input"); } - devdata->use_linux_input = 1; /* default: on */ +#if USE_MULTI_API + devdata->use_linux_input = 1; /* default: on */ stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT); if (stemp) devdata->use_linux_input = atoi(stemp); +#else + devdata->use_linux_input = 0; /* no way to support this ... */ +#endif if (!devdata->use_linux_input) DirectFBSetOption("disable-module", "linux_input");
--- a/src/video/directfb/SDL_DirectFB_video.h Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_video.h Fri Jul 23 21:33:00 2010 -0700 @@ -31,7 +31,14 @@ #include "SDL_mouse.h" -#define DEBUG 0 + +/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in + * in case we see this again ... + */ + +#define USE_MULTI_API (0) + +#define DEBUG 1 #define LOG_CHANNEL stdout #define DFB_VERSIONNUM(X, Y, Z) \
--- a/src/video/directfb/SDL_DirectFB_window.c Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_window.c Fri Jul 23 21:33:00 2010 -0700 @@ -140,7 +140,7 @@ windata->window->RaiseToTop(windata->window); /* remember parent */ - windata->window = window; + windata->sdl_window = window; /* Add to list ... */
--- a/src/video/directfb/SDL_DirectFB_window.h Thu Jul 22 22:09:04 2010 -0700 +++ b/src/video/directfb/SDL_DirectFB_window.h Fri Jul 23 21:33:00 2010 -0700 @@ -36,7 +36,7 @@ IDirectFBWindow *window; DirectFB_GLContext *gl_context; IDirectFBEventBuffer *eventbuffer; - SDL_Window *window; + SDL_Window *sdl_window; DFB_WindowData *next; Uint8 opacity; DFBRectangle client;