comparison src/video/directfb/SDL_DirectFB_events.c @ 2721:e82a0e3e9b0e

Date: Sun, 20 Jul 2008 22:34:37 +0200 From: Couriersud Subject: Updated DirectFB driver for SDL1.3 please find attached a patch for an updated directfb driver for SDL1.3. It does now - properly supported the new input api. - send unicode text events - support directfb windows - support multiple screens - support hardware YUV scaling for the first YUV texture created. - support hardware scaling for textures. - properly interpret streaming access - support software opengl if one manages to install the mesa directfb driver (broken/not broken in mesa svn) Within bugzilla (http://bugzilla.libsdl.org/show_bug.cgi?id=603) there is another patch which fixes a crash due to GL context creation. Kind regards, couriersud
author Sam Lantinga <slouken@libsdl.org>
date Tue, 26 Aug 2008 02:32:45 +0000
parents 1e690901ecd7
children 204be4fc2726
comparison
equal deleted inserted replaced
2720:4eb759edddf5 2721:e82a0e3e9b0e
23 23
24 /* Handle the event stream, converting DirectFB input events into SDL events */ 24 /* Handle the event stream, converting DirectFB input events into SDL events */
25 25
26 #include <directfb.h> 26 #include <directfb.h>
27 27
28 #include "SDL.h"
29 #include "../SDL_sysvideo.h" 28 #include "../SDL_sysvideo.h"
30 #include "../../events/SDL_sysevents.h" 29 #include "../../events/SDL_sysevents.h"
31 #include "../../events/SDL_events_c.h" 30 #include "../../events/SDL_events_c.h"
31 #include "../../events/SDL_keyboard_c.h"
32 #include "../../events/scancodes_linux.h"
32 #include "SDL_DirectFB_events.h" 33 #include "SDL_DirectFB_events.h"
33 34
34 /* The translation tables from a DirectFB keycode to a SDL keysym */ 35 /* The translation tables from a DirectFB keycode to a SDL keysym */
35 static SDLKey keymap[256]; 36 static SDLKey keymap[256];
36 37
37 static SDL_keysym *DirectFB_TranslateKey(DFBInputDeviceKeyIdentifier key_id, 38 static SDL_keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
38 DFBInputDeviceKeySymbol key_symbol,
39 DFBInputDeviceModifierMask key_mod,
40 SDL_keysym * keysym); 39 SDL_keysym * keysym);
41 40
41 static void DirectFB_InitOSKeymap(_THIS);
42 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); 42 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
43
44 static void
45 DirectFB_SetContext(_THIS, SDL_WindowID id)
46 {
47 #if (DIRECTFB_MAJOR_VERSION >= 1)
48 /* FIXME: does not work on 1.0/1.2 with radeon driver
49 * the approach did work with the matrox driver
50 * Perhaps make this depending on env var, e.g. SDLDIRECTFB_SWITCHCONTEXT_SUPPORTED
51 */
52
53 if (getenv("SDLDIRECTFB_SWITCHCONTEXT_SUPPORTED") != NULL) {
54 SDL_DFB_DEVICEDATA(_this);
55 SDL_Window *window = SDL_GetWindowFromID(id);
56 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
57 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
58 if (dispdata->vidID >= 0 && dispdata->vidIDinuse) {
59 IDirectFBDisplayLayer *lay = NULL;
60 devdata->dfb->GetDisplayLayer(devdata->dfb, dispdata->vidID,
61 &lay);
62 if (lay)
63 lay->SwitchContext(lay, DFB_TRUE);
64 }
65 }
66 #endif
67
68 }
43 69
44 void 70 void
45 DirectFB_PumpEventsWindow(_THIS) 71 DirectFB_PumpEventsWindow(_THIS)
46 { 72 {
47 SDL_DFB_DEVICEDATA(_this); 73 SDL_DFB_DEVICEDATA(_this);
48 DFB_WindowData *p; 74 DFB_WindowData *p;
49 DFBWindowEvent evt; 75 DFBWindowEvent evt;
76 char text[5];
50 77
51 for (p = devdata->firstwin; p != NULL; p = p->next) { 78 for (p = devdata->firstwin; p != NULL; p = p->next) {
52 while (p->eventbuffer->GetEvent(p->eventbuffer, 79 while (p->eventbuffer->GetEvent(p->eventbuffer,
53 DFB_EVENT(&evt)) == DFB_OK) { 80 DFB_EVENT(&evt)) == DFB_OK) {
54 SDL_keysym keysym; 81 SDL_keysym keysym;
65 break; 92 break;
66 case DWET_MOTION: 93 case DWET_MOTION:
67 SDL_SendMouseMotion(devdata->mouse, 0, evt.cx, evt.cy); 94 SDL_SendMouseMotion(devdata->mouse, 0, evt.cx, evt.cy);
68 break; 95 break;
69 case DWET_KEYDOWN: 96 case DWET_KEYDOWN:
70 DirectFB_TranslateKey(evt.key_id, evt.key_symbol, 97 DirectFB_TranslateKey(_this, &evt, &keysym);
71 evt.modifiers, &keysym);
72 SDL_SendKeyboardKey(devdata->keyboard, SDL_PRESSED, 98 SDL_SendKeyboardKey(devdata->keyboard, SDL_PRESSED,
73 keysym.scancode, keysym.sym); 99 keysym.scancode);
100 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
101 SDL_memcpy(text, &keysym.unicode, 4);
102 text[4] = 0;
103 if (*text) {
104 SDL_SendKeyboardText(devdata->keyboard, text);
105 }
106 }
74 break; 107 break;
75 case DWET_KEYUP: 108 case DWET_KEYUP:
76 DirectFB_TranslateKey(evt.key_id, evt.key_symbol, 109 DirectFB_TranslateKey(_this, &evt, &keysym);
77 evt.modifiers, &keysym);
78 SDL_SendKeyboardKey(devdata->keyboard, SDL_RELEASED, 110 SDL_SendKeyboardKey(devdata->keyboard, SDL_RELEASED,
79 keysym.scancode, keysym.sym); 111 keysym.scancode);
80 break; 112 break;
81 case DWET_POSITION_SIZE: 113 case DWET_POSITION_SIZE:
82 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_MOVED, evt.x, 114 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_MOVED, evt.x,
83 evt.y); 115 evt.y);
84 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_RESIZED, evt.w, 116 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_RESIZED, evt.w,
94 break; 126 break;
95 case DWET_CLOSE: 127 case DWET_CLOSE:
96 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_CLOSE, 0, 0); 128 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_CLOSE, 0, 0);
97 break; 129 break;
98 case DWET_GOTFOCUS: 130 case DWET_GOTFOCUS:
99 //TODO: Implement for yuv-overlay DirectFB_SwitchOverlayContext(this, evt.window_id); 131 DirectFB_SetContext(_this, p->id);
100 SDL_SetKeyboardFocus(devdata->keyboard, p->id); 132 SDL_SetKeyboardFocus(devdata->keyboard, p->id);
133 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_FOCUS_GAINED,
134 0, 0);
101 break; 135 break;
102 case DWET_LOSTFOCUS: 136 case DWET_LOSTFOCUS:
137 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_FOCUS_LOST, 0,
138 0);
103 SDL_SetKeyboardFocus(devdata->keyboard, 0); 139 SDL_SetKeyboardFocus(devdata->keyboard, 0);
104 break; 140 break;
105 case DWET_ENTER: 141 case DWET_ENTER:
106 //SDL_DirectFB_ReshowCursor(_this, 0); 142 //SDL_DirectFB_ReshowCursor(_this, 0);
107 SDL_SetMouseFocus(devdata->mouse, p->id); 143 SDL_SetMouseFocus(devdata->mouse, p->id);
144 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_ENTER, 0, 0);
108 break; 145 break;
109 case DWET_LEAVE: 146 case DWET_LEAVE:
147 SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_LEAVE, 0, 0);
110 SDL_SetMouseFocus(devdata->mouse, 0); 148 SDL_SetMouseFocus(devdata->mouse, 0);
111 //SDL_DirectFB_ReshowCursor(_this, 1); 149 //SDL_DirectFB_ReshowCursor(_this, 1);
112 break; 150 break;
113 default: 151 default:
114 ; 152 ;
123 { 161 {
124 int i; 162 int i;
125 163
126 /* Initialize the DirectFB key translation table */ 164 /* Initialize the DirectFB key translation table */
127 for (i = 0; i < SDL_arraysize(keymap); ++i) 165 for (i = 0; i < SDL_arraysize(keymap); ++i)
128 keymap[i] = SDLK_UNKNOWN; 166 keymap[i] = SDL_SCANCODE_UNKNOWN;
129 167
130 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a; 168 keymap[DIKI_A - DIKI_UNKNOWN] = SDL_SCANCODE_A;
131 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b; 169 keymap[DIKI_B - DIKI_UNKNOWN] = SDL_SCANCODE_B;
132 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c; 170 keymap[DIKI_C - DIKI_UNKNOWN] = SDL_SCANCODE_C;
133 keymap[DIKI_D - DIKI_UNKNOWN] = SDLK_d; 171 keymap[DIKI_D - DIKI_UNKNOWN] = SDL_SCANCODE_D;
134 keymap[DIKI_E - DIKI_UNKNOWN] = SDLK_e; 172 keymap[DIKI_E - DIKI_UNKNOWN] = SDL_SCANCODE_E;
135 keymap[DIKI_F - DIKI_UNKNOWN] = SDLK_f; 173 keymap[DIKI_F - DIKI_UNKNOWN] = SDL_SCANCODE_F;
136 keymap[DIKI_G - DIKI_UNKNOWN] = SDLK_g; 174 keymap[DIKI_G - DIKI_UNKNOWN] = SDL_SCANCODE_G;
137 keymap[DIKI_H - DIKI_UNKNOWN] = SDLK_h; 175 keymap[DIKI_H - DIKI_UNKNOWN] = SDL_SCANCODE_H;
138 keymap[DIKI_I - DIKI_UNKNOWN] = SDLK_i; 176 keymap[DIKI_I - DIKI_UNKNOWN] = SDL_SCANCODE_I;
139 keymap[DIKI_J - DIKI_UNKNOWN] = SDLK_j; 177 keymap[DIKI_J - DIKI_UNKNOWN] = SDL_SCANCODE_J;
140 keymap[DIKI_K - DIKI_UNKNOWN] = SDLK_k; 178 keymap[DIKI_K - DIKI_UNKNOWN] = SDL_SCANCODE_K;
141 keymap[DIKI_L - DIKI_UNKNOWN] = SDLK_l; 179 keymap[DIKI_L - DIKI_UNKNOWN] = SDL_SCANCODE_L;
142 keymap[DIKI_M - DIKI_UNKNOWN] = SDLK_m; 180 keymap[DIKI_M - DIKI_UNKNOWN] = SDL_SCANCODE_M;
143 keymap[DIKI_N - DIKI_UNKNOWN] = SDLK_n; 181 keymap[DIKI_N - DIKI_UNKNOWN] = SDL_SCANCODE_N;
144 keymap[DIKI_O - DIKI_UNKNOWN] = SDLK_o; 182 keymap[DIKI_O - DIKI_UNKNOWN] = SDL_SCANCODE_O;
145 keymap[DIKI_P - DIKI_UNKNOWN] = SDLK_p; 183 keymap[DIKI_P - DIKI_UNKNOWN] = SDL_SCANCODE_P;
146 keymap[DIKI_Q - DIKI_UNKNOWN] = SDLK_q; 184 keymap[DIKI_Q - DIKI_UNKNOWN] = SDL_SCANCODE_Q;
147 keymap[DIKI_R - DIKI_UNKNOWN] = SDLK_r; 185 keymap[DIKI_R - DIKI_UNKNOWN] = SDL_SCANCODE_R;
148 keymap[DIKI_S - DIKI_UNKNOWN] = SDLK_s; 186 keymap[DIKI_S - DIKI_UNKNOWN] = SDL_SCANCODE_S;
149 keymap[DIKI_T - DIKI_UNKNOWN] = SDLK_t; 187 keymap[DIKI_T - DIKI_UNKNOWN] = SDL_SCANCODE_T;
150 keymap[DIKI_U - DIKI_UNKNOWN] = SDLK_u; 188 keymap[DIKI_U - DIKI_UNKNOWN] = SDL_SCANCODE_U;
151 keymap[DIKI_V - DIKI_UNKNOWN] = SDLK_v; 189 keymap[DIKI_V - DIKI_UNKNOWN] = SDL_SCANCODE_V;
152 keymap[DIKI_W - DIKI_UNKNOWN] = SDLK_w; 190 keymap[DIKI_W - DIKI_UNKNOWN] = SDL_SCANCODE_W;
153 keymap[DIKI_X - DIKI_UNKNOWN] = SDLK_x; 191 keymap[DIKI_X - DIKI_UNKNOWN] = SDL_SCANCODE_X;
154 keymap[DIKI_Y - DIKI_UNKNOWN] = SDLK_y; 192 keymap[DIKI_Y - DIKI_UNKNOWN] = SDL_SCANCODE_Y;
155 keymap[DIKI_Z - DIKI_UNKNOWN] = SDLK_z; 193 keymap[DIKI_Z - DIKI_UNKNOWN] = SDL_SCANCODE_Z;
156 194
157 keymap[DIKI_0 - DIKI_UNKNOWN] = SDLK_0; 195 keymap[DIKI_0 - DIKI_UNKNOWN] = SDL_SCANCODE_0;
158 keymap[DIKI_1 - DIKI_UNKNOWN] = SDLK_1; 196 keymap[DIKI_1 - DIKI_UNKNOWN] = SDL_SCANCODE_1;
159 keymap[DIKI_2 - DIKI_UNKNOWN] = SDLK_2; 197 keymap[DIKI_2 - DIKI_UNKNOWN] = SDL_SCANCODE_2;
160 keymap[DIKI_3 - DIKI_UNKNOWN] = SDLK_3; 198 keymap[DIKI_3 - DIKI_UNKNOWN] = SDL_SCANCODE_3;
161 keymap[DIKI_4 - DIKI_UNKNOWN] = SDLK_4; 199 keymap[DIKI_4 - DIKI_UNKNOWN] = SDL_SCANCODE_4;
162 keymap[DIKI_5 - DIKI_UNKNOWN] = SDLK_5; 200 keymap[DIKI_5 - DIKI_UNKNOWN] = SDL_SCANCODE_5;
163 keymap[DIKI_6 - DIKI_UNKNOWN] = SDLK_6; 201 keymap[DIKI_6 - DIKI_UNKNOWN] = SDL_SCANCODE_6;
164 keymap[DIKI_7 - DIKI_UNKNOWN] = SDLK_7; 202 keymap[DIKI_7 - DIKI_UNKNOWN] = SDL_SCANCODE_7;
165 keymap[DIKI_8 - DIKI_UNKNOWN] = SDLK_8; 203 keymap[DIKI_8 - DIKI_UNKNOWN] = SDL_SCANCODE_8;
166 keymap[DIKI_9 - DIKI_UNKNOWN] = SDLK_9; 204 keymap[DIKI_9 - DIKI_UNKNOWN] = SDL_SCANCODE_9;
167 205
168 keymap[DIKI_F1 - DIKI_UNKNOWN] = SDLK_F1; 206 keymap[DIKI_F1 - DIKI_UNKNOWN] = SDL_SCANCODE_F1;
169 keymap[DIKI_F2 - DIKI_UNKNOWN] = SDLK_F2; 207 keymap[DIKI_F2 - DIKI_UNKNOWN] = SDL_SCANCODE_F2;
170 keymap[DIKI_F3 - DIKI_UNKNOWN] = SDLK_F3; 208 keymap[DIKI_F3 - DIKI_UNKNOWN] = SDL_SCANCODE_F3;
171 keymap[DIKI_F4 - DIKI_UNKNOWN] = SDLK_F4; 209 keymap[DIKI_F4 - DIKI_UNKNOWN] = SDL_SCANCODE_F4;
172 keymap[DIKI_F5 - DIKI_UNKNOWN] = SDLK_F5; 210 keymap[DIKI_F5 - DIKI_UNKNOWN] = SDL_SCANCODE_F5;
173 keymap[DIKI_F6 - DIKI_UNKNOWN] = SDLK_F6; 211 keymap[DIKI_F6 - DIKI_UNKNOWN] = SDL_SCANCODE_F6;
174 keymap[DIKI_F7 - DIKI_UNKNOWN] = SDLK_F7; 212 keymap[DIKI_F7 - DIKI_UNKNOWN] = SDL_SCANCODE_F7;
175 keymap[DIKI_F8 - DIKI_UNKNOWN] = SDLK_F8; 213 keymap[DIKI_F8 - DIKI_UNKNOWN] = SDL_SCANCODE_F8;
176 keymap[DIKI_F9 - DIKI_UNKNOWN] = SDLK_F9; 214 keymap[DIKI_F9 - DIKI_UNKNOWN] = SDL_SCANCODE_F9;
177 keymap[DIKI_F10 - DIKI_UNKNOWN] = SDLK_F10; 215 keymap[DIKI_F10 - DIKI_UNKNOWN] = SDL_SCANCODE_F10;
178 keymap[DIKI_F11 - DIKI_UNKNOWN] = SDLK_F11; 216 keymap[DIKI_F11 - DIKI_UNKNOWN] = SDL_SCANCODE_F11;
179 keymap[DIKI_F12 - DIKI_UNKNOWN] = SDLK_F12; 217 keymap[DIKI_F12 - DIKI_UNKNOWN] = SDL_SCANCODE_F12;
180 218
181 keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDLK_ESCAPE; 219 keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDL_SCANCODE_ESCAPE;
182 keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDLK_LEFT; 220 keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_LEFT;
183 keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDLK_RIGHT; 221 keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_RIGHT;
184 keymap[DIKI_UP - DIKI_UNKNOWN] = SDLK_UP; 222 keymap[DIKI_UP - DIKI_UNKNOWN] = SDL_SCANCODE_UP;
185 keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDLK_DOWN; 223 keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDL_SCANCODE_DOWN;
186 keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDLK_LCTRL; 224 keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDL_SCANCODE_LCTRL;
187 keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDLK_RCTRL; 225 keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDL_SCANCODE_RCTRL;
188 keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDLK_LSHIFT; 226 keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDL_SCANCODE_LSHIFT;
189 keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDLK_RSHIFT; 227 keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDL_SCANCODE_RSHIFT;
190 keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDLK_LALT; 228 keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDL_SCANCODE_LALT;
191 keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDLK_RALT; 229 keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDL_SCANCODE_RALT;
192 keymap[DIKI_TAB - DIKI_UNKNOWN] = SDLK_TAB; 230 keymap[DIKI_META_L - DIKI_UNKNOWN] = SDL_SCANCODE_LGUI;
193 keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDLK_RETURN; 231 keymap[DIKI_META_R - DIKI_UNKNOWN] = SDL_SCANCODE_RGUI;
194 keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDLK_SPACE; 232 keymap[DIKI_SUPER_L - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
195 keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDLK_BACKSPACE; 233 keymap[DIKI_SUPER_R - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
196 keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDLK_INSERT; 234 //FIXME:Do we read hyper keys ?
197 keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDLK_DELETE; 235 //keymap[DIKI_HYPER_L - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
198 keymap[DIKI_HOME - DIKI_UNKNOWN] = SDLK_HOME; 236 //keymap[DIKI_HYPER_R - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
199 keymap[DIKI_END - DIKI_UNKNOWN] = SDLK_END; 237 keymap[DIKI_TAB - DIKI_UNKNOWN] = SDL_SCANCODE_TAB;
200 keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDLK_PAGEUP; 238 keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDL_SCANCODE_RETURN;
201 keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDLK_PAGEDOWN; 239 keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDL_SCANCODE_SPACE;
202 keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDLK_CAPSLOCK; 240 keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDL_SCANCODE_BACKSPACE;
203 keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDLK_NUMLOCK; 241 keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDL_SCANCODE_INSERT;
204 keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDLK_SCROLLOCK; 242 keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDL_SCANCODE_DELETE;
205 keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDLK_PRINT; 243 keymap[DIKI_HOME - DIKI_UNKNOWN] = SDL_SCANCODE_HOME;
206 keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDLK_PAUSE; 244 keymap[DIKI_END - DIKI_UNKNOWN] = SDL_SCANCODE_END;
207 245 keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDL_SCANCODE_PAGEUP;
208 keymap[DIKI_KP_EQUAL - DIKI_UNKNOWN] = SDLK_KP_EQUALS; 246 keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDL_SCANCODE_PAGEDOWN;
209 keymap[DIKI_KP_DECIMAL - DIKI_UNKNOWN] = SDLK_KP_PERIOD; 247 keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_CAPSLOCK;
210 keymap[DIKI_KP_0 - DIKI_UNKNOWN] = SDLK_KP0; 248 keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_NUMLOCKCLEAR;
211 keymap[DIKI_KP_1 - DIKI_UNKNOWN] = SDLK_KP1; 249 keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_SCROLLLOCK;
212 keymap[DIKI_KP_2 - DIKI_UNKNOWN] = SDLK_KP2; 250 keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDL_SCANCODE_PRINTSCREEN;
213 keymap[DIKI_KP_3 - DIKI_UNKNOWN] = SDLK_KP3; 251 keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDL_SCANCODE_PAUSE;
214 keymap[DIKI_KP_4 - DIKI_UNKNOWN] = SDLK_KP4; 252
215 keymap[DIKI_KP_5 - DIKI_UNKNOWN] = SDLK_KP5; 253 keymap[DIKI_KP_EQUAL - DIKI_UNKNOWN] = SDL_SCANCODE_KP_EQUALS;
216 keymap[DIKI_KP_6 - DIKI_UNKNOWN] = SDLK_KP6; 254 keymap[DIKI_KP_DECIMAL - DIKI_UNKNOWN] = SDL_SCANCODE_KP_PERIOD;
217 keymap[DIKI_KP_7 - DIKI_UNKNOWN] = SDLK_KP7; 255 keymap[DIKI_KP_0 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_0;
218 keymap[DIKI_KP_8 - DIKI_UNKNOWN] = SDLK_KP8; 256 keymap[DIKI_KP_1 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_1;
219 keymap[DIKI_KP_9 - DIKI_UNKNOWN] = SDLK_KP9; 257 keymap[DIKI_KP_2 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_2;
220 keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDLK_KP_DIVIDE; 258 keymap[DIKI_KP_3 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_3;
221 keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDLK_KP_MULTIPLY; 259 keymap[DIKI_KP_4 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_4;
222 keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDLK_KP_MINUS; 260 keymap[DIKI_KP_5 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_5;
223 keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDLK_KP_PLUS; 261 keymap[DIKI_KP_6 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_6;
224 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER; 262 keymap[DIKI_KP_7 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_7;
225 263 keymap[DIKI_KP_8 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_8;
226 keymap[DIKI_QUOTE_LEFT - DIKI_UNKNOWN] = SDLK_BACKQUOTE; /* TLDE */ 264 keymap[DIKI_KP_9 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_9;
227 keymap[DIKI_MINUS_SIGN - DIKI_UNKNOWN] = SDLK_MINUS; /* AE11 */ 265 keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDL_SCANCODE_KP_DIVIDE;
228 keymap[DIKI_EQUALS_SIGN - DIKI_UNKNOWN] = SDLK_EQUALS; /* AE12 */ 266 keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDL_SCANCODE_KP_MULTIPLY;
229 keymap[DIKI_BRACKET_LEFT - DIKI_UNKNOWN] = SDLK_RIGHTBRACKET; /* AD11 */ 267 keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDL_SCANCODE_KP_MINUS;
230 keymap[DIKI_BRACKET_RIGHT - DIKI_UNKNOWN] = SDLK_LEFTBRACKET; /* AD12 */ 268 keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDL_SCANCODE_KP_PLUS;
231 keymap[DIKI_BACKSLASH - DIKI_UNKNOWN] = SDLK_BACKSLASH; /* BKSL */ 269 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDL_SCANCODE_KP_ENTER;
232 keymap[DIKI_SEMICOLON - DIKI_UNKNOWN] = SDLK_SEMICOLON; /* AC10 */ 270
233 keymap[DIKI_QUOTE_RIGHT - DIKI_UNKNOWN] = SDLK_QUOTE; /* AC11 */ 271 keymap[DIKI_QUOTE_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_GRAVE; /* TLDE */
234 keymap[DIKI_COMMA - DIKI_UNKNOWN] = SDLK_COMMA; /* AB08 */ 272 keymap[DIKI_MINUS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_MINUS; /* AE11 */
235 keymap[DIKI_PERIOD - DIKI_UNKNOWN] = SDLK_PERIOD; /* AB09 */ 273 keymap[DIKI_EQUALS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_EQUALS; /* AE12 */
236 keymap[DIKI_SLASH - DIKI_UNKNOWN] = SDLK_SLASH; /* AB10 */ 274 keymap[DIKI_BRACKET_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_RIGHTBRACKET; /* AD11 */
237 keymap[DIKI_LESS_SIGN - DIKI_UNKNOWN] = SDLK_LESS; /* 103rd */ 275 keymap[DIKI_BRACKET_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_LEFTBRACKET; /* AD12 */
276 keymap[DIKI_BACKSLASH - DIKI_UNKNOWN] = SDL_SCANCODE_BACKSLASH; /* BKSL */
277 keymap[DIKI_SEMICOLON - DIKI_UNKNOWN] = SDL_SCANCODE_SEMICOLON; /* AC10 */
278 keymap[DIKI_QUOTE_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_APOSTROPHE; /* AC11 */
279 keymap[DIKI_COMMA - DIKI_UNKNOWN] = SDL_SCANCODE_COMMA; /* AB08 */
280 keymap[DIKI_PERIOD - DIKI_UNKNOWN] = SDL_SCANCODE_PERIOD; /* AB09 */
281 keymap[DIKI_SLASH - DIKI_UNKNOWN] = SDL_SCANCODE_SLASH; /* AB10 */
282 keymap[DIKI_LESS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_NONUSBACKSLASH; /* 103rd */
283
238 } 284 }
239 285
240 static SDL_keysym * 286 static SDL_keysym *
241 DirectFB_TranslateKey(DFBInputDeviceKeyIdentifier key_id, 287 DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_keysym * keysym)
242 DFBInputDeviceKeySymbol key_symbol, 288 {
243 DFBInputDeviceModifierMask key_mod, SDL_keysym * keysym) 289 SDL_DFB_DEVICEDATA(_this);
244 { 290
245 SDLMod mod = KMOD_NONE; 291 if (evt->key_code >= 0
246 292 && evt->key_code < SDL_arraysize(linux_scancode_table))
247 /* 293 keysym->scancode = linux_scancode_table[evt->key_code]; // key_id;
248 * Set modifier information 294 else
249 */ 295 keysym->scancode = SDL_SCANCODE_UNKNOWN;
250 296
251 if (key_mod & DIMM_SHIFT) 297 if (keysym->scancode == SDL_SCANCODE_UNKNOWN || devdata->kbdgeneric) {
252 mod = mod | KMOD_LSHIFT; 298 if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(keymap))
253 if (key_mod & DIMM_CONTROL) 299 keysym->scancode = keymap[evt->key_id - DIKI_UNKNOWN];
254 mod = mod | KMOD_LCTRL; 300 else
255 if (key_mod & DIMM_ALT) 301 keysym->scancode = SDL_SCANCODE_UNKNOWN;
256 mod = mod | KMOD_LALT; 302 }
257 if (key_mod & DIMM_ALTGR) 303
258 mod = mod | KMOD_RALT;
259 if (key_mod & DIMM_META)
260 mod = mod | KMOD_LMETA;
261
262 /* Set the keysym information */
263 keysym->scancode = key_id;
264
265 keysym->mod = mod;
266 keysym->unicode = 304 keysym->unicode =
267 (DFB_KEY_TYPE(key_symbol) == DIKT_UNICODE) ? key_symbol : 0; 305 (DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
268 306 if (keysym->unicode == 0
269 if (key_symbol > 0 && key_symbol < 255) 307 && (evt->key_symbol > 0 && evt->key_symbol < 255))
270 keysym->sym = key_symbol; 308 keysym->unicode = evt->key_symbol;
271 else
272 keysym->sym = keymap[key_id - DIKI_UNKNOWN];
273 309
274 return keysym; 310 return keysym;
275 } 311 }
276 312
277 static int 313 static int
287 default: 323 default:
288 return 0; 324 return 0;
289 } 325 }
290 } 326 }
291 327
328 static DFBEnumerationResult
329 input_device_cb(DFBInputDeviceID device_id, DFBInputDeviceDescription desc,
330 void *callbackdata)
331 {
332 DFB_DeviceData *devdata = callbackdata;
333 SDL_Keyboard keyboard;
334 SDL_scancode scancode;
335 SDLKey keymap[SDL_NUM_SCANCODES];
336
337 if ((desc.caps & DIDTF_KEYBOARD) && device_id == DIDID_KEYBOARD) {
338 SDL_zero(keyboard);
339 devdata->keyboard = SDL_AddKeyboard(&keyboard, -1);
340 if (!strncmp("X11", desc.name, 3))
341 devdata->kbdgeneric = 1;
342
343 SDL_GetDefaultKeymap(keymap);
344 SDL_SetKeymap(devdata->keyboard, 0, keymap, SDL_NUM_SCANCODES);
345 }
346 return DFB_OK;
347 }
348
349 void
350 DirectFB_InitKeyboard(_THIS)
351 {
352 SDL_DFB_DEVICEDATA(_this);
353 int ret;
354
355 DirectFB_InitOSKeymap(_this);
356
357 devdata->kbdgeneric = 0;
358
359 SDL_DFB_CHECK(devdata->dfb->
360 EnumInputDevices(devdata->dfb, input_device_cb, devdata));
361 }
362
292 #if 0 363 #if 0
364 /* FIXME: Remove once determined this is not needed in fullscreen mode */
293 void 365 void
294 DirectFB_PumpEvents(_THIS) 366 DirectFB_PumpEvents(_THIS)
295 { 367 {
296 SDL_DFB_DEVICEDATA(_this); 368 SDL_DFB_DEVICEDATA(_this);
297 DFBInputEvent evt; 369 DFBInputEvent evt;