comparison src/video/directfb/SDL_DirectFB_mouse.c @ 2860:6ce28e5287e9

Date: Sun, 07 Dec 2008 13:35:23 +0100 From: Couriersud Subject: SDL: Mouse last_x, last_y into SDL_Mouse the attached diff moves the static vars last_x and last_y into SDL_Mouse. These, as far as I understand it, should be tied to the individual mouse. The patch also makes the code check for out of window conditions of mouse->x,y when relative movements are passed to MouseSendMotion. Also attached is the latest DirectFB code (dfb20081208) supporting multiple mice and keyboards. This works quite well with sdlmame now. It however needs more testing with different directfb configurations.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 08 Dec 2008 00:52:12 +0000
parents 99210400e8b9
children b93965a16fe0
comparison
equal deleted inserted replaced
2859:99210400e8b9 2860:6ce28e5287e9
33 static void DirectFB_FreeCursor(SDL_Cursor * cursor); 33 static void DirectFB_FreeCursor(SDL_Cursor * cursor);
34 static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, 34 static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID,
35 int x, int y); 35 int x, int y);
36 static void DirectFB_FreeMouse(SDL_Mouse * mouse); 36 static void DirectFB_FreeMouse(SDL_Mouse * mouse);
37 37
38 static int id_mask;
39
40 static DFBEnumerationResult
41 EnumMice(DFBInputDeviceID device_id,
42 DFBInputDeviceDescription desc, void *callbackdata)
43 {
44 DFB_DeviceData *devdata = callbackdata;
45
46 if ((desc.type & DIDTF_MOUSE) && (device_id & id_mask)) {
47 SDL_Mouse mouse;
48
49 SDL_zero(mouse);
50 mouse.CreateCursor = DirectFB_CreateCursor;
51 mouse.ShowCursor = DirectFB_ShowCursor;
52 mouse.MoveCursor = DirectFB_MoveCursor;
53 mouse.FreeCursor = DirectFB_FreeCursor;
54 mouse.WarpMouse = DirectFB_WarpMouse;
55 mouse.FreeMouse = DirectFB_FreeMouse;
56 mouse.cursor_shown = 1;
57
58 SDL_SetMouseIndexId(device_id, devdata->num_mice);
59 SDL_AddMouse(&mouse, devdata->num_mice, desc.name, 0, 0, 1);
60 devdata->mouse_id[devdata->num_mice] = device_id;
61 devdata->num_mice++;
62 }
63 return DFENUM_OK;
64 }
65
38 void 66 void
39 DirectFB_InitMouse(_THIS) 67 DirectFB_InitMouse(_THIS)
40 { 68 {
41 SDL_DFB_DEVICEDATA(_this); 69 SDL_DFB_DEVICEDATA(_this);
42 SDL_Mouse mouse; 70
43 71 devdata->num_mice = 0;
44 SDL_zero(mouse); 72 if (LINUX_INPUT_SUPPORT) {
45 mouse.CreateCursor = DirectFB_CreateCursor; 73 /* try non-core devices first */
46 mouse.ShowCursor = DirectFB_ShowCursor; 74 id_mask = 0xF0;
47 mouse.MoveCursor = DirectFB_MoveCursor; 75 devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata);
48 mouse.FreeCursor = DirectFB_FreeCursor; 76 if (devdata->num_mice == 0) {
49 mouse.WarpMouse = DirectFB_WarpMouse; 77 /* try core devices */
50 mouse.FreeMouse = DirectFB_FreeMouse; 78 id_mask = 0x0F;
51 mouse.cursor_shown = 1; 79 devdata->dfb->EnumInputDevices(devdata->dfb, EnumMice, devdata);
52 SDL_SetMouseIndexId(0, 0); /* ID == Index ! */ 80 }
53 devdata->mouse = SDL_AddMouse(&mouse, 0, "Mouse", 0, 0, 1); 81 }
82 if (devdata->num_mice == 0) {
83 SDL_Mouse mouse;
84
85 SDL_zero(mouse);
86 mouse.CreateCursor = DirectFB_CreateCursor;
87 mouse.ShowCursor = DirectFB_ShowCursor;
88 mouse.MoveCursor = DirectFB_MoveCursor;
89 mouse.FreeCursor = DirectFB_FreeCursor;
90 mouse.WarpMouse = DirectFB_WarpMouse;
91 mouse.FreeMouse = DirectFB_FreeMouse;
92 mouse.cursor_shown = 1;
93
94 SDL_SetMouseIndexId(0, 0); /* ID == Index ! */
95 devdata->mouse_id[0] = 0;
96 SDL_AddMouse(&mouse, 0, "Mouse", 0, 0, 1);
97 devdata->num_mice = 1;
98 }
54 } 99 }
55 100
56 void 101 void
57 DirectFB_QuitMouse(_THIS) 102 DirectFB_QuitMouse(_THIS)
58 { 103 {
59 SDL_DFB_DEVICEDATA(_this); 104 SDL_DFB_DEVICEDATA(_this);
60 105
61 SDL_DelMouse(devdata->mouse); 106 if (LINUX_INPUT_SUPPORT) {
107 SDL_MouseQuit();
108 } else {
109 SDL_DelMouse(0);
110 }
62 } 111 }
63 112
64 /* Create a cursor from a surface */ 113 /* Create a cursor from a surface */
65 static SDL_Cursor * 114 static SDL_Cursor *
66 DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) 115 DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)