Mercurial > sdl-ios-xcode
diff src/video/directfb/SDL_DirectFB_mouse.c @ 2737:140a7edcf2bd
Date: Sun, 31 Aug 2008 17:53:59 +0200
From: Couriersud
Subject: Re: Updated DirectFB driver for SDL1.3
attached is a patch which brings the directfb driver in line with
current svn. In addition:
* driver now is in line with the structure of the X11 driver.
This adds a couple of files.
* driver now supports relative mouse movements
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 31 Aug 2008 16:04:32 +0000 |
parents | 204be4fc2726 |
children | 483f85e35a1a |
line wrap: on
line diff
--- a/src/video/directfb/SDL_DirectFB_mouse.c Sun Aug 31 16:03:55 2008 +0000 +++ b/src/video/directfb/SDL_DirectFB_mouse.c Sun Aug 31 16:04:32 2008 +0000 @@ -22,7 +22,6 @@ #include "SDL_config.h" #include "SDL_DirectFB_video.h" -#include "SDL_DirectFB_mouse.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" @@ -49,7 +48,8 @@ mouse.FreeCursor = DirectFB_FreeCursor; mouse.WarpMouse = DirectFB_WarpMouse; mouse.FreeMouse = DirectFB_FreeMouse; - devdata->mouse = SDL_AddMouse(&mouse, -1); + mouse.cursor_shown = 1; + devdata->mouse = SDL_AddMouse(&mouse, -1, "Mouse", 0, 0, 1); } void @@ -85,23 +85,21 @@ dsc.height = surface->h; dsc.pixelformat = DSPF_ARGB; - SDL_DFB_CHECKERR(devdata-> - dfb->CreateSurface(devdata->dfb, &dsc, &curdata->surf)); + SDL_DFB_CHECKERR(devdata->dfb-> + CreateSurface(devdata->dfb, &dsc, &curdata->surf)); curdata->hotx = hot_x; curdata->hoty = hot_y; cursor->driverdata = curdata; - SDL_DFB_CHECKERR(curdata-> - surf->Lock(curdata->surf, DSLF_WRITE, (void *) &dest, - &pitch)); + SDL_DFB_CHECKERR(curdata->surf-> + Lock(curdata->surf, DSLF_WRITE, (void *) &dest, &pitch)); - //FIXME: Implies a lot of things, e.g. rgba format for SDL_SURFACE .... + /* Relies on the fact that this is only called with ARGB surface. */ p = surface->pixels; - for (i = 0; i < surface->w * surface->h; i++) - if (p[i] == 0x00000000) - dest[i] = 0x00000000; - else - dest[i] = p[i]; + for (i = 0; i < surface->h; i++) + memcpy((char *) dest + i * pitch, (char *) p + i * surface->pitch, + 4 * surface->w); + curdata->surf->Unlock(curdata->surf); return cursor; error: @@ -113,37 +111,38 @@ DirectFB_ShowCursor(SDL_Cursor * cursor) { SDL_DFB_CURSORDATA(cursor); - SDL_VideoDevice *dev = SDL_GetVideoDevice(); - SDL_DFB_DEVICEDATA(dev); -#if 0 - DFB_DisplayData *dispdata = - (DFB_DisplayData *) dev->displays[dev->current_display].driverdata; -#endif DFBResult ret; SDL_WindowID wid; wid = SDL_GetFocusWindow(); - if (!wid) + if (wid < 0) return -1; else { SDL_Window *window = SDL_GetWindowFromID(wid); SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); - DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; - DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; + + if (display) { + DFB_DisplayData *dispdata = + (DFB_DisplayData *) display->driverdata; + DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; + + if (cursor) + SDL_DFB_CHECKERR(windata->window-> + SetCursorShape(windata->window, + curdata->surf, curdata->hotx, + curdata->hoty)); - if (cursor) - SDL_DFB_CHECKERR(windata->window->SetCursorShape(windata->window, - curdata->surf, - curdata->hotx, - curdata->hoty)); - //TODO: Check administrative - SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, - DLSCL_ADMINISTRATIVE)); - SDL_DFB_CHECKERR(dispdata->layer->SetCursorOpacity(dispdata->layer, - cursor ? 0xC0 : - 0x00)); - SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, - DLSCL_SHARED)); + /* fprintf(stdout, "Cursor is %s\n", cursor ? "on" : "off"); */ + SDL_DFB_CHECKERR(dispdata->layer-> + SetCooperativeLevel(dispdata->layer, + DLSCL_ADMINISTRATIVE)); + SDL_DFB_CHECKERR(dispdata->layer-> + SetCursorOpacity(dispdata->layer, + cursor ? 0xC0 : 0x00)); + SDL_DFB_CHECKERR(dispdata->layer-> + SetCooperativeLevel(dispdata->layer, + DLSCL_SHARED)); + } } return 0; @@ -155,8 +154,7 @@ static void DirectFB_MoveCursor(SDL_Cursor * cursor) { - SDL_DFB_CURSORDATA(cursor); - /* Do we need to do something here ? */ + } /* Free a window manager cursor */ @@ -182,8 +180,8 @@ int cx, cy; SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy)); - SDL_DFB_CHECKERR(dispdata-> - layer->WarpCursor(dispdata->layer, cx + x, cy + y)); + SDL_DFB_CHECKERR(dispdata->layer-> + WarpCursor(dispdata->layer, cx + x, cy + y)); error: return; @@ -193,8 +191,7 @@ static void DirectFB_FreeMouse(SDL_Mouse * mouse) { - // nothing yet - + /* nothing yet */ } /* vi: set ts=4 sw=4 expandtab: */