comparison src/video/vgl/SDL_vglevents.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents d910939febfa
children e27bdcc80744
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
39 39
40 /* The translation tables from a console scancode to a SDL keysym */ 40 /* The translation tables from a console scancode to a SDL keysym */
41 /* FIXME: Free the keymap when we shut down the video mode */ 41 /* FIXME: Free the keymap when we shut down the video mode */
42 static keymap_t *vga_keymap = NULL; 42 static keymap_t *vga_keymap = NULL;
43 static SDLKey keymap[128]; 43 static SDLKey keymap[128];
44 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym); 44 static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym);
45 45
46 static int posted = 0; 46 static int posted = 0;
47 static int oldx = -1; 47 static int oldx = -1;
48 static int oldy = -1; 48 static int oldy = -1;
49 static struct mouse_info mouseinfo; 49 static struct mouse_info mouseinfo;
51 /* Ugh, we have to duplicate the kernel's keysym mapping code... 51 /* Ugh, we have to duplicate the kernel's keysym mapping code...
52 Oh, it's not so bad. :-) 52 Oh, it's not so bad. :-)
53 53
54 FIXME: Add keyboard LED handling code 54 FIXME: Add keyboard LED handling code
55 */ 55 */
56 int VGL_initkeymaps(int fd) 56 int
57 { 57 VGL_initkeymaps(int fd)
58 vga_keymap = SDL_malloc(sizeof(keymap_t)); 58 {
59 if ( ! vga_keymap ) { 59 vga_keymap = SDL_malloc(sizeof(keymap_t));
60 SDL_OutOfMemory(); 60 if (!vga_keymap) {
61 return(-1); 61 SDL_OutOfMemory();
62 } 62 return (-1);
63 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { 63 }
64 SDL_free(vga_keymap); 64 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) {
65 vga_keymap = NULL; 65 SDL_free(vga_keymap);
66 SDL_SetError("Unable to get keyboard map"); 66 vga_keymap = NULL;
67 return(-1); 67 SDL_SetError("Unable to get keyboard map");
68 } 68 return (-1);
69 return(0); 69 }
70 } 70 return (0);
71 71 }
72 static void handle_keyboard(_THIS) 72
73 { 73 static void
74 SDL_keysym keysym; 74 handle_keyboard(_THIS)
75 int c, pressed, scancode; 75 {
76 76 SDL_keysym keysym;
77 while ((c = VGLKeyboardGetCh()) != 0) { 77 int c, pressed, scancode;
78 scancode = c & 0x7F; 78
79 if (c & 0x80) { 79 while ((c = VGLKeyboardGetCh()) != 0) {
80 pressed = SDL_RELEASED; 80 scancode = c & 0x7F;
81 } else { 81 if (c & 0x80) {
82 pressed = SDL_PRESSED; 82 pressed = SDL_RELEASED;
83 } 83 } else {
84 84 pressed = SDL_PRESSED;
85 posted += SDL_PrivateKeyboard(pressed, 85 }
86 TranslateKey(scancode, &keysym)); 86
87 } 87 posted += SDL_PrivateKeyboard(pressed,
88 } 88 TranslateKey(scancode, &keysym));
89 89 }
90 int VGL_initmouse(int fd) 90 }
91 { 91
92 mouseinfo.operation = MOUSE_GETINFO; 92 int
93 if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0) 93 VGL_initmouse(int fd)
94 return -1; 94 {
95 95 mouseinfo.operation = MOUSE_GETINFO;
96 return 0; 96 if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0)
97 } 97 return -1;
98 98
99 static void handle_mouse(_THIS) 99 return 0;
100 { 100 }
101 char buttons; 101
102 int x, y; 102 static void
103 int button_state, state_changed, state; 103 handle_mouse(_THIS)
104 int i; 104 {
105 105 char buttons;
106 ioctl(0, CONS_MOUSECTL, &mouseinfo); 106 int x, y;
107 x = mouseinfo.u.data.x; 107 int button_state, state_changed, state;
108 y = mouseinfo.u.data.y; 108 int i;
109 buttons = mouseinfo.u.data.buttons; 109
110 110 ioctl(0, CONS_MOUSECTL, &mouseinfo);
111 if ((x != oldx) || (y != oldy)) { 111 x = mouseinfo.u.data.x;
112 posted += SDL_PrivateMouseMotion(0, 0, x, y); 112 y = mouseinfo.u.data.y;
113 oldx = x; 113 buttons = mouseinfo.u.data.buttons;
114 oldy = y; 114
115 } 115 if ((x != oldx) || (y != oldy)) {
116 116 posted += SDL_PrivateMouseMotion(0, 0, x, y);
117 /* See what's changed */ 117 oldx = x;
118 button_state = SDL_GetMouseState(NULL, NULL); 118 oldy = y;
119 state_changed = button_state ^ buttons; 119 }
120 for (i = 0; i < 8; i++) { 120
121 if (state_changed & (1<<i)) { 121 /* See what's changed */
122 if (buttons & (1<<i)) { 122 button_state = SDL_GetMouseState(NULL, NULL);
123 state = SDL_PRESSED; 123 state_changed = button_state ^ buttons;
124 } else { 124 for (i = 0; i < 8; i++) {
125 state = SDL_RELEASED; 125 if (state_changed & (1 << i)) {
126 } 126 if (buttons & (1 << i)) {
127 posted += SDL_PrivateMouseButton(state, i + 1, 0, 0); 127 state = SDL_PRESSED;
128 } 128 } else {
129 } 129 state = SDL_RELEASED;
130 } 130 }
131 131 posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
132 132 }
133 void VGL_PumpEvents(_THIS) 133 }
134 { 134 }
135 do { 135
136 posted = 0; 136
137 handle_keyboard(this); 137 void
138 handle_mouse(this); 138 VGL_PumpEvents(_THIS)
139 } while (posted != 0); 139 {
140 } 140 do {
141 141 posted = 0;
142 void VGL_InitOSKeymap(_THIS) 142 handle_keyboard(this);
143 { 143 handle_mouse(this);
144 int i; 144 }
145 145 while (posted != 0);
146 /* Initialize the BeOS key translation table */ 146 }
147 for ( i=0; i<SDL_arraysize(keymap); ++i ) 147
148 keymap[i] = SDLK_UNKNOWN; 148 void
149 149 VGL_InitOSKeymap(_THIS)
150 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; 150 {
151 keymap[SCANCODE_1] = SDLK_1; 151 int i;
152 keymap[SCANCODE_2] = SDLK_2; 152
153 keymap[SCANCODE_3] = SDLK_3; 153 /* Initialize the BeOS key translation table */
154 keymap[SCANCODE_4] = SDLK_4; 154 for (i = 0; i < SDL_arraysize(keymap); ++i)
155 keymap[SCANCODE_5] = SDLK_5; 155 keymap[i] = SDLK_UNKNOWN;
156 keymap[SCANCODE_6] = SDLK_6; 156
157 keymap[SCANCODE_7] = SDLK_7; 157 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
158 keymap[SCANCODE_8] = SDLK_8; 158 keymap[SCANCODE_1] = SDLK_1;
159 keymap[SCANCODE_9] = SDLK_9; 159 keymap[SCANCODE_2] = SDLK_2;
160 keymap[SCANCODE_0] = SDLK_0; 160 keymap[SCANCODE_3] = SDLK_3;
161 keymap[SCANCODE_MINUS] = SDLK_MINUS; 161 keymap[SCANCODE_4] = SDLK_4;
162 keymap[SCANCODE_EQUAL] = SDLK_EQUALS; 162 keymap[SCANCODE_5] = SDLK_5;
163 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; 163 keymap[SCANCODE_6] = SDLK_6;
164 keymap[SCANCODE_TAB] = SDLK_TAB; 164 keymap[SCANCODE_7] = SDLK_7;
165 keymap[SCANCODE_Q] = SDLK_q; 165 keymap[SCANCODE_8] = SDLK_8;
166 keymap[SCANCODE_W] = SDLK_w; 166 keymap[SCANCODE_9] = SDLK_9;
167 keymap[SCANCODE_E] = SDLK_e; 167 keymap[SCANCODE_0] = SDLK_0;
168 keymap[SCANCODE_R] = SDLK_r; 168 keymap[SCANCODE_MINUS] = SDLK_MINUS;
169 keymap[SCANCODE_T] = SDLK_t; 169 keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
170 keymap[SCANCODE_Y] = SDLK_y; 170 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
171 keymap[SCANCODE_U] = SDLK_u; 171 keymap[SCANCODE_TAB] = SDLK_TAB;
172 keymap[SCANCODE_I] = SDLK_i; 172 keymap[SCANCODE_Q] = SDLK_q;
173 keymap[SCANCODE_O] = SDLK_o; 173 keymap[SCANCODE_W] = SDLK_w;
174 keymap[SCANCODE_P] = SDLK_p; 174 keymap[SCANCODE_E] = SDLK_e;
175 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; 175 keymap[SCANCODE_R] = SDLK_r;
176 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; 176 keymap[SCANCODE_T] = SDLK_t;
177 keymap[SCANCODE_ENTER] = SDLK_RETURN; 177 keymap[SCANCODE_Y] = SDLK_y;
178 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; 178 keymap[SCANCODE_U] = SDLK_u;
179 keymap[SCANCODE_A] = SDLK_a; 179 keymap[SCANCODE_I] = SDLK_i;
180 keymap[SCANCODE_S] = SDLK_s; 180 keymap[SCANCODE_O] = SDLK_o;
181 keymap[SCANCODE_D] = SDLK_d; 181 keymap[SCANCODE_P] = SDLK_p;
182 keymap[SCANCODE_F] = SDLK_f; 182 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
183 keymap[SCANCODE_G] = SDLK_g; 183 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
184 keymap[SCANCODE_H] = SDLK_h; 184 keymap[SCANCODE_ENTER] = SDLK_RETURN;
185 keymap[SCANCODE_J] = SDLK_j; 185 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
186 keymap[SCANCODE_K] = SDLK_k; 186 keymap[SCANCODE_A] = SDLK_a;
187 keymap[SCANCODE_L] = SDLK_l; 187 keymap[SCANCODE_S] = SDLK_s;
188 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; 188 keymap[SCANCODE_D] = SDLK_d;
189 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; 189 keymap[SCANCODE_F] = SDLK_f;
190 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE; 190 keymap[SCANCODE_G] = SDLK_g;
191 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; 191 keymap[SCANCODE_H] = SDLK_h;
192 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; 192 keymap[SCANCODE_J] = SDLK_j;
193 keymap[SCANCODE_Z] = SDLK_z; 193 keymap[SCANCODE_K] = SDLK_k;
194 keymap[SCANCODE_X] = SDLK_x; 194 keymap[SCANCODE_L] = SDLK_l;
195 keymap[SCANCODE_C] = SDLK_c; 195 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
196 keymap[SCANCODE_V] = SDLK_v; 196 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
197 keymap[SCANCODE_B] = SDLK_b; 197 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
198 keymap[SCANCODE_N] = SDLK_n; 198 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
199 keymap[SCANCODE_M] = SDLK_m; 199 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
200 keymap[SCANCODE_COMMA] = SDLK_COMMA; 200 keymap[SCANCODE_Z] = SDLK_z;
201 keymap[SCANCODE_PERIOD] = SDLK_PERIOD; 201 keymap[SCANCODE_X] = SDLK_x;
202 keymap[SCANCODE_SLASH] = SDLK_SLASH; 202 keymap[SCANCODE_C] = SDLK_c;
203 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; 203 keymap[SCANCODE_V] = SDLK_v;
204 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY; 204 keymap[SCANCODE_B] = SDLK_b;
205 keymap[SCANCODE_LEFTALT] = SDLK_LALT; 205 keymap[SCANCODE_N] = SDLK_n;
206 keymap[SCANCODE_SPACE] = SDLK_SPACE; 206 keymap[SCANCODE_M] = SDLK_m;
207 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; 207 keymap[SCANCODE_COMMA] = SDLK_COMMA;
208 keymap[SCANCODE_F1] = SDLK_F1; 208 keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
209 keymap[SCANCODE_F2] = SDLK_F2; 209 keymap[SCANCODE_SLASH] = SDLK_SLASH;
210 keymap[SCANCODE_F3] = SDLK_F3; 210 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
211 keymap[SCANCODE_F4] = SDLK_F4; 211 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
212 keymap[SCANCODE_F5] = SDLK_F5; 212 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
213 keymap[SCANCODE_F6] = SDLK_F6; 213 keymap[SCANCODE_SPACE] = SDLK_SPACE;
214 keymap[SCANCODE_F7] = SDLK_F7; 214 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
215 keymap[SCANCODE_F8] = SDLK_F8; 215 keymap[SCANCODE_F1] = SDLK_F1;
216 keymap[SCANCODE_F9] = SDLK_F9; 216 keymap[SCANCODE_F2] = SDLK_F2;
217 keymap[SCANCODE_F10] = SDLK_F10; 217 keymap[SCANCODE_F3] = SDLK_F3;
218 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK; 218 keymap[SCANCODE_F4] = SDLK_F4;
219 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK; 219 keymap[SCANCODE_F5] = SDLK_F5;
220 keymap[SCANCODE_KEYPAD7] = SDLK_KP7; 220 keymap[SCANCODE_F6] = SDLK_F6;
221 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7; 221 keymap[SCANCODE_F7] = SDLK_F7;
222 keymap[SCANCODE_KEYPAD8] = SDLK_KP8; 222 keymap[SCANCODE_F8] = SDLK_F8;
223 keymap[SCANCODE_CURSORUP] = SDLK_KP8; 223 keymap[SCANCODE_F9] = SDLK_F9;
224 keymap[SCANCODE_KEYPAD9] = SDLK_KP9; 224 keymap[SCANCODE_F10] = SDLK_F10;
225 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9; 225 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
226 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS; 226 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
227 keymap[SCANCODE_KEYPAD4] = SDLK_KP4; 227 keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
228 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4; 228 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
229 keymap[SCANCODE_KEYPAD5] = SDLK_KP5; 229 keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
230 keymap[SCANCODE_KEYPAD6] = SDLK_KP6; 230 keymap[SCANCODE_CURSORUP] = SDLK_KP8;
231 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6; 231 keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
232 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS; 232 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
233 keymap[SCANCODE_KEYPAD1] = SDLK_KP1; 233 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
234 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1; 234 keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
235 keymap[SCANCODE_KEYPAD2] = SDLK_KP2; 235 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
236 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2; 236 keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
237 keymap[SCANCODE_KEYPAD3] = SDLK_KP3; 237 keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
238 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3; 238 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
239 keymap[SCANCODE_KEYPAD0] = SDLK_KP0; 239 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
240 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD; 240 keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
241 keymap[SCANCODE_LESS] = SDLK_LESS; 241 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
242 keymap[SCANCODE_F11] = SDLK_F11; 242 keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
243 keymap[SCANCODE_F12] = SDLK_F12; 243 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
244 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER; 244 keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
245 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL; 245 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
246 keymap[SCANCODE_CONTROL] = SDLK_RCTRL; 246 keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
247 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE; 247 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
248 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT; 248 keymap[SCANCODE_LESS] = SDLK_LESS;
249 keymap[SCANCODE_RIGHTALT] = SDLK_RALT; 249 keymap[SCANCODE_F11] = SDLK_F11;
250 keymap[SCANCODE_BREAK] = SDLK_BREAK; 250 keymap[SCANCODE_F12] = SDLK_F12;
251 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN; 251 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
252 keymap[SCANCODE_HOME] = SDLK_HOME; 252 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
253 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; 253 keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
254 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; 254 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
255 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; 255 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
256 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; 256 keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
257 keymap[SCANCODE_END] = SDLK_END; 257 keymap[SCANCODE_BREAK] = SDLK_BREAK;
258 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; 258 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
259 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; 259 keymap[SCANCODE_HOME] = SDLK_HOME;
260 keymap[SCANCODE_INSERT] = SDLK_INSERT; 260 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
261 keymap[SCANCODE_REMOVE] = SDLK_DELETE; 261 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
262 keymap[119] = SDLK_PAUSE; 262 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
263 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER; 263 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
264 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER; 264 keymap[SCANCODE_END] = SDLK_END;
265 keymap[127] = SDLK_MENU; 265 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
266 } 266 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
267 267 keymap[SCANCODE_INSERT] = SDLK_INSERT;
268 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) 268 keymap[SCANCODE_REMOVE] = SDLK_DELETE;
269 { 269 keymap[119] = SDLK_PAUSE;
270 /* Set the keysym information */ 270 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
271 keysym->scancode = scancode; 271 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
272 keysym->sym = keymap[scancode]; 272 keymap[127] = SDLK_MENU;
273 keysym->mod = KMOD_NONE; 273 }
274 274
275 /* If UNICODE is on, get the UNICODE value for the key */ 275 static SDL_keysym *
276 keysym->unicode = 0; 276 TranslateKey(int scancode, SDL_keysym * keysym)
277 if ( SDL_TranslateUNICODE && vga_keymap ) { 277 {
278 int map; 278 /* Set the keysym information */
279 SDLMod modstate; 279 keysym->scancode = scancode;
280 280 keysym->sym = keymap[scancode];
281 modstate = SDL_GetModState(); 281 keysym->mod = KMOD_NONE;
282 map = 0; 282
283 if ( modstate & KMOD_SHIFT ) { 283 /* If UNICODE is on, get the UNICODE value for the key */
284 map += 1; 284 keysym->unicode = 0;
285 } 285 if (SDL_TranslateUNICODE && vga_keymap) {
286 if ( modstate & KMOD_CTRL ) { 286 int map;
287 map += 2; 287 SDLMod modstate;
288 } 288
289 if ( modstate & KMOD_ALT ) { 289 modstate = SDL_GetModState();
290 map += 4; 290 map = 0;
291 } 291 if (modstate & KMOD_SHIFT) {
292 if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) { 292 map += 1;
293 keysym->unicode = vga_keymap->key[scancode].map[map]; 293 }
294 } 294 if (modstate & KMOD_CTRL) {
295 295 map += 2;
296 } 296 }
297 return(keysym); 297 if (modstate & KMOD_ALT) {
298 } 298 map += 4;
299 299 }
300 if (!(vga_keymap->key[scancode].spcl & (0x80 >> map))) {
301 keysym->unicode = vga_keymap->key[scancode].map[map];
302 }
303
304 }
305 return (keysym);
306 }
307
308 /* vi: set ts=4 sw=4 expandtab: */