comparison src/video/svga/SDL_svgaevents.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
49 static keymap_t *vga_keymap = NULL; 49 static keymap_t *vga_keymap = NULL;
50 #else 50 #else
51 #error You must choose your operating system here 51 #error You must choose your operating system here
52 #endif 52 #endif
53 static SDLKey keymap[128]; 53 static SDLKey keymap[128];
54 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym); 54 static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym);
55 55
56 /* Ugh, we have to duplicate the kernel's keysym mapping code... 56 /* Ugh, we have to duplicate the kernel's keysym mapping code...
57 Oh, it's not so bad. :-) 57 Oh, it's not so bad. :-)
58 58
59 FIXME: Add keyboard LED handling code 59 FIXME: Add keyboard LED handling code
60 */ 60 */
61 #if defined(linux) 61 #if defined(linux)
62 int SVGA_initkeymaps(int fd) 62 int
63 { 63 SVGA_initkeymaps (int fd)
64 struct kbentry entry; 64 {
65 int map, i; 65 struct kbentry entry;
66 66 int map, i;
67 /* Load all the keysym mappings */ 67
68 for ( map=0; map<NUM_VGAKEYMAPS; ++map ) { 68 /* Load all the keysym mappings */
69 SDL_memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16)); 69 for (map = 0; map < NUM_VGAKEYMAPS; ++map) {
70 for ( i=0; i<NR_KEYS; ++i ) { 70 SDL_memset (vga_keymap[map], 0, NR_KEYS * sizeof (Uint16));
71 entry.kb_table = map; 71 for (i = 0; i < NR_KEYS; ++i) {
72 entry.kb_index = i; 72 entry.kb_table = map;
73 if ( ioctl(fd, KDGKBENT, &entry) == 0 ) { 73 entry.kb_index = i;
74 /* The "Enter" key is a special case */ 74 if (ioctl (fd, KDGKBENT, &entry) == 0) {
75 if ( entry.kb_value == K_ENTER ) { 75 /* The "Enter" key is a special case */
76 entry.kb_value = K(KT_ASCII,13); 76 if (entry.kb_value == K_ENTER) {
77 } 77 entry.kb_value = K (KT_ASCII, 13);
78 /* Handle numpad specially as well */ 78 }
79 if ( KTYP(entry.kb_value) == KT_PAD ) { 79 /* Handle numpad specially as well */
80 switch ( entry.kb_value ) { 80 if (KTYP (entry.kb_value) == KT_PAD) {
81 case K_P0: 81 switch (entry.kb_value) {
82 case K_P1: 82 case K_P0:
83 case K_P2: 83 case K_P1:
84 case K_P3: 84 case K_P2:
85 case K_P4: 85 case K_P3:
86 case K_P5: 86 case K_P4:
87 case K_P6: 87 case K_P5:
88 case K_P7: 88 case K_P6:
89 case K_P8: 89 case K_P7:
90 case K_P9: 90 case K_P8:
91 vga_keymap[map][i]=entry.kb_value; 91 case K_P9:
92 vga_keymap[map][i]+= '0'; 92 vga_keymap[map][i] = entry.kb_value;
93 break; 93 vga_keymap[map][i] += '0';
94 case K_PPLUS: 94 break;
95 vga_keymap[map][i]=K(KT_ASCII,'+'); 95 case K_PPLUS:
96 break; 96 vga_keymap[map][i] = K (KT_ASCII, '+');
97 case K_PMINUS: 97 break;
98 vga_keymap[map][i]=K(KT_ASCII,'-'); 98 case K_PMINUS:
99 break; 99 vga_keymap[map][i] = K (KT_ASCII, '-');
100 case K_PSTAR: 100 break;
101 vga_keymap[map][i]=K(KT_ASCII,'*'); 101 case K_PSTAR:
102 break; 102 vga_keymap[map][i] = K (KT_ASCII, '*');
103 case K_PSLASH: 103 break;
104 vga_keymap[map][i]=K(KT_ASCII,'/'); 104 case K_PSLASH:
105 break; 105 vga_keymap[map][i] = K (KT_ASCII, '/');
106 case K_PENTER: 106 break;
107 vga_keymap[map][i]=K(KT_ASCII,'\r'); 107 case K_PENTER:
108 break; 108 vga_keymap[map][i] = K (KT_ASCII, '\r');
109 case K_PCOMMA: 109 break;
110 vga_keymap[map][i]=K(KT_ASCII,','); 110 case K_PCOMMA:
111 break; 111 vga_keymap[map][i] = K (KT_ASCII, ',');
112 case K_PDOT: 112 break;
113 vga_keymap[map][i]=K(KT_ASCII,'.'); 113 case K_PDOT:
114 break; 114 vga_keymap[map][i] = K (KT_ASCII, '.');
115 default: 115 break;
116 break; 116 default:
117 } 117 break;
118 } 118 }
119 /* Do the normal key translation */ 119 }
120 if ( (KTYP(entry.kb_value) == KT_LATIN) || 120 /* Do the normal key translation */
121 (KTYP(entry.kb_value) == KT_ASCII) || 121 if ((KTYP (entry.kb_value) == KT_LATIN) ||
122 (KTYP(entry.kb_value) == KT_LETTER) ) { 122 (KTYP (entry.kb_value) == KT_ASCII) ||
123 vga_keymap[map][i] = entry.kb_value; 123 (KTYP (entry.kb_value) == KT_LETTER)) {
124 } 124 vga_keymap[map][i] = entry.kb_value;
125 } 125 }
126 } 126 }
127 } 127 }
128 return(0); 128 }
129 return (0);
129 } 130 }
130 #elif defined(__FREEBSD__) 131 #elif defined(__FREEBSD__)
131 int SVGA_initkeymaps(int fd) 132 int
132 { 133 SVGA_initkeymaps (int fd)
133 vga_keymap = SDL_malloc(sizeof(keymap_t)); 134 {
134 if ( ! vga_keymap ) { 135 vga_keymap = SDL_malloc (sizeof (keymap_t));
135 SDL_OutOfMemory(); 136 if (!vga_keymap) {
136 return(-1); 137 SDL_OutOfMemory ();
137 } 138 return (-1);
138 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { 139 }
139 SDL_free(vga_keymap); 140 if (ioctl (fd, GIO_KEYMAP, vga_keymap) == -1) {
140 vga_keymap = NULL; 141 SDL_free (vga_keymap);
141 SDL_SetError("Unable to get keyboard map"); 142 vga_keymap = NULL;
142 return(-1); 143 SDL_SetError ("Unable to get keyboard map");
143 } 144 return (-1);
144 return(0); 145 }
146 return (0);
145 } 147 }
146 #else 148 #else
147 #error You must choose your operating system here 149 #error You must choose your operating system here
148 #endif 150 #endif
149 151
150 int posted = 0; 152 int posted = 0;
151 153
152 void SVGA_mousecallback(int button, int dx, int dy, 154 void
153 int u1,int u2,int u3, int u4) 155 SVGA_mousecallback (int button, int dx, int dy,
154 { 156 int u1, int u2, int u3, int u4)
155 if ( dx || dy ) { 157 {
156 posted += SDL_PrivateMouseMotion(0, 1, dx, dy); 158 if (dx || dy) {
157 } 159 posted += SDL_PrivateMouseMotion (0, 1, dx, dy);
158 if ( button & MOUSE_LEFTBUTTON ) { 160 }
159 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { 161 if (button & MOUSE_LEFTBUTTON) {
160 posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); 162 if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (1))) {
161 } 163 posted += SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0);
162 } else { 164 }
163 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { 165 } else {
164 posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); 166 if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (1))) {
165 } 167 posted += SDL_PrivateMouseButton (SDL_RELEASED, 1, 0, 0);
166 } 168 }
167 if ( button & MOUSE_MIDDLEBUTTON ) { 169 }
168 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { 170 if (button & MOUSE_MIDDLEBUTTON) {
169 posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); 171 if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (2))) {
170 } 172 posted += SDL_PrivateMouseButton (SDL_PRESSED, 2, 0, 0);
171 } else { 173 }
172 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { 174 } else {
173 posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); 175 if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (2))) {
174 } 176 posted += SDL_PrivateMouseButton (SDL_RELEASED, 2, 0, 0);
175 } 177 }
176 if ( button & MOUSE_RIGHTBUTTON ) { 178 }
177 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { 179 if (button & MOUSE_RIGHTBUTTON) {
178 posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); 180 if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (3))) {
179 } 181 posted += SDL_PrivateMouseButton (SDL_PRESSED, 3, 0, 0);
180 } else { 182 }
181 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { 183 } else {
182 posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); 184 if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (3))) {
183 } 185 posted += SDL_PrivateMouseButton (SDL_RELEASED, 3, 0, 0);
184 } 186 }
185 } 187 }
186 188 }
187 void SVGA_keyboardcallback(int scancode, int pressed) 189
188 { 190 void
189 SDL_keysym keysym; 191 SVGA_keyboardcallback (int scancode, int pressed)
190 192 {
191 if ( pressed ) { 193 SDL_keysym keysym;
192 posted += SDL_PrivateKeyboard(SDL_PRESSED, 194
193 TranslateKey(scancode, &keysym)); 195 if (pressed) {
194 } else { 196 posted += SDL_PrivateKeyboard (SDL_PRESSED,
195 posted += SDL_PrivateKeyboard(SDL_RELEASED, 197 TranslateKey (scancode, &keysym));
196 TranslateKey(scancode, &keysym)); 198 } else {
197 } 199 posted += SDL_PrivateKeyboard (SDL_RELEASED,
198 } 200 TranslateKey (scancode, &keysym));
199 201 }
200 void SVGA_PumpEvents(_THIS) 202 }
201 { 203
202 do { 204 void
203 posted = 0; 205 SVGA_PumpEvents (_THIS)
204 mouse_update(); 206 {
205 keyboard_update(); 207 do {
206 } while ( posted ); 208 posted = 0;
207 } 209 mouse_update ();
208 210 keyboard_update ();
209 void SVGA_InitOSKeymap(_THIS) 211 }
210 { 212 while (posted);
211 int i; 213 }
212 214
213 /* Initialize the BeOS key translation table */ 215 void
214 for ( i=0; i<SDL_arraysize(keymap); ++i ) 216 SVGA_InitOSKeymap (_THIS)
215 keymap[i] = SDLK_UNKNOWN; 217 {
216 218 int i;
217 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; 219
218 keymap[SCANCODE_1] = SDLK_1; 220 /* Initialize the BeOS key translation table */
219 keymap[SCANCODE_2] = SDLK_2; 221 for (i = 0; i < SDL_arraysize (keymap); ++i)
220 keymap[SCANCODE_3] = SDLK_3; 222 keymap[i] = SDLK_UNKNOWN;
221 keymap[SCANCODE_4] = SDLK_4; 223
222 keymap[SCANCODE_5] = SDLK_5; 224 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
223 keymap[SCANCODE_6] = SDLK_6; 225 keymap[SCANCODE_1] = SDLK_1;
224 keymap[SCANCODE_7] = SDLK_7; 226 keymap[SCANCODE_2] = SDLK_2;
225 keymap[SCANCODE_8] = SDLK_8; 227 keymap[SCANCODE_3] = SDLK_3;
226 keymap[SCANCODE_9] = SDLK_9; 228 keymap[SCANCODE_4] = SDLK_4;
227 keymap[SCANCODE_0] = SDLK_0; 229 keymap[SCANCODE_5] = SDLK_5;
228 keymap[SCANCODE_MINUS] = SDLK_MINUS; 230 keymap[SCANCODE_6] = SDLK_6;
229 keymap[SCANCODE_EQUAL] = SDLK_EQUALS; 231 keymap[SCANCODE_7] = SDLK_7;
230 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; 232 keymap[SCANCODE_8] = SDLK_8;
231 keymap[SCANCODE_TAB] = SDLK_TAB; 233 keymap[SCANCODE_9] = SDLK_9;
232 keymap[SCANCODE_Q] = SDLK_q; 234 keymap[SCANCODE_0] = SDLK_0;
233 keymap[SCANCODE_W] = SDLK_w; 235 keymap[SCANCODE_MINUS] = SDLK_MINUS;
234 keymap[SCANCODE_E] = SDLK_e; 236 keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
235 keymap[SCANCODE_R] = SDLK_r; 237 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
236 keymap[SCANCODE_T] = SDLK_t; 238 keymap[SCANCODE_TAB] = SDLK_TAB;
237 keymap[SCANCODE_Y] = SDLK_y; 239 keymap[SCANCODE_Q] = SDLK_q;
238 keymap[SCANCODE_U] = SDLK_u; 240 keymap[SCANCODE_W] = SDLK_w;
239 keymap[SCANCODE_I] = SDLK_i; 241 keymap[SCANCODE_E] = SDLK_e;
240 keymap[SCANCODE_O] = SDLK_o; 242 keymap[SCANCODE_R] = SDLK_r;
241 keymap[SCANCODE_P] = SDLK_p; 243 keymap[SCANCODE_T] = SDLK_t;
242 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; 244 keymap[SCANCODE_Y] = SDLK_y;
243 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; 245 keymap[SCANCODE_U] = SDLK_u;
244 keymap[SCANCODE_ENTER] = SDLK_RETURN; 246 keymap[SCANCODE_I] = SDLK_i;
245 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; 247 keymap[SCANCODE_O] = SDLK_o;
246 keymap[SCANCODE_A] = SDLK_a; 248 keymap[SCANCODE_P] = SDLK_p;
247 keymap[SCANCODE_S] = SDLK_s; 249 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
248 keymap[SCANCODE_D] = SDLK_d; 250 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
249 keymap[SCANCODE_F] = SDLK_f; 251 keymap[SCANCODE_ENTER] = SDLK_RETURN;
250 keymap[SCANCODE_G] = SDLK_g; 252 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
251 keymap[SCANCODE_H] = SDLK_h; 253 keymap[SCANCODE_A] = SDLK_a;
252 keymap[SCANCODE_J] = SDLK_j; 254 keymap[SCANCODE_S] = SDLK_s;
253 keymap[SCANCODE_K] = SDLK_k; 255 keymap[SCANCODE_D] = SDLK_d;
254 keymap[SCANCODE_L] = SDLK_l; 256 keymap[SCANCODE_F] = SDLK_f;
255 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; 257 keymap[SCANCODE_G] = SDLK_g;
256 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; 258 keymap[SCANCODE_H] = SDLK_h;
257 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE; 259 keymap[SCANCODE_J] = SDLK_j;
258 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; 260 keymap[SCANCODE_K] = SDLK_k;
259 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; 261 keymap[SCANCODE_L] = SDLK_l;
260 keymap[SCANCODE_Z] = SDLK_z; 262 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
261 keymap[SCANCODE_X] = SDLK_x; 263 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
262 keymap[SCANCODE_C] = SDLK_c; 264 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
263 keymap[SCANCODE_V] = SDLK_v; 265 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
264 keymap[SCANCODE_B] = SDLK_b; 266 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
265 keymap[SCANCODE_N] = SDLK_n; 267 keymap[SCANCODE_Z] = SDLK_z;
266 keymap[SCANCODE_M] = SDLK_m; 268 keymap[SCANCODE_X] = SDLK_x;
267 keymap[SCANCODE_COMMA] = SDLK_COMMA; 269 keymap[SCANCODE_C] = SDLK_c;
268 keymap[SCANCODE_PERIOD] = SDLK_PERIOD; 270 keymap[SCANCODE_V] = SDLK_v;
269 keymap[SCANCODE_SLASH] = SDLK_SLASH; 271 keymap[SCANCODE_B] = SDLK_b;
270 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; 272 keymap[SCANCODE_N] = SDLK_n;
271 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY; 273 keymap[SCANCODE_M] = SDLK_m;
272 keymap[SCANCODE_LEFTALT] = SDLK_LALT; 274 keymap[SCANCODE_COMMA] = SDLK_COMMA;
273 keymap[SCANCODE_SPACE] = SDLK_SPACE; 275 keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
274 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; 276 keymap[SCANCODE_SLASH] = SDLK_SLASH;
275 keymap[SCANCODE_F1] = SDLK_F1; 277 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
276 keymap[SCANCODE_F2] = SDLK_F2; 278 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
277 keymap[SCANCODE_F3] = SDLK_F3; 279 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
278 keymap[SCANCODE_F4] = SDLK_F4; 280 keymap[SCANCODE_SPACE] = SDLK_SPACE;
279 keymap[SCANCODE_F5] = SDLK_F5; 281 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
280 keymap[SCANCODE_F6] = SDLK_F6; 282 keymap[SCANCODE_F1] = SDLK_F1;
281 keymap[SCANCODE_F7] = SDLK_F7; 283 keymap[SCANCODE_F2] = SDLK_F2;
282 keymap[SCANCODE_F8] = SDLK_F8; 284 keymap[SCANCODE_F3] = SDLK_F3;
283 keymap[SCANCODE_F9] = SDLK_F9; 285 keymap[SCANCODE_F4] = SDLK_F4;
284 keymap[SCANCODE_F10] = SDLK_F10; 286 keymap[SCANCODE_F5] = SDLK_F5;
285 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK; 287 keymap[SCANCODE_F6] = SDLK_F6;
286 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK; 288 keymap[SCANCODE_F7] = SDLK_F7;
287 keymap[SCANCODE_KEYPAD7] = SDLK_KP7; 289 keymap[SCANCODE_F8] = SDLK_F8;
288 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7; 290 keymap[SCANCODE_F9] = SDLK_F9;
289 keymap[SCANCODE_KEYPAD8] = SDLK_KP8; 291 keymap[SCANCODE_F10] = SDLK_F10;
290 keymap[SCANCODE_CURSORUP] = SDLK_KP8; 292 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
291 keymap[SCANCODE_KEYPAD9] = SDLK_KP9; 293 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
292 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9; 294 keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
293 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS; 295 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
294 keymap[SCANCODE_KEYPAD4] = SDLK_KP4; 296 keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
295 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4; 297 keymap[SCANCODE_CURSORUP] = SDLK_KP8;
296 keymap[SCANCODE_KEYPAD5] = SDLK_KP5; 298 keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
297 keymap[SCANCODE_KEYPAD6] = SDLK_KP6; 299 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
298 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6; 300 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
299 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS; 301 keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
300 keymap[SCANCODE_KEYPAD1] = SDLK_KP1; 302 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
301 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1; 303 keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
302 keymap[SCANCODE_KEYPAD2] = SDLK_KP2; 304 keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
303 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2; 305 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
304 keymap[SCANCODE_KEYPAD3] = SDLK_KP3; 306 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
305 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3; 307 keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
306 keymap[SCANCODE_KEYPAD0] = SDLK_KP0; 308 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
307 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD; 309 keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
308 keymap[SCANCODE_LESS] = SDLK_LESS; 310 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
309 keymap[SCANCODE_F11] = SDLK_F11; 311 keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
310 keymap[SCANCODE_F12] = SDLK_F12; 312 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
311 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER; 313 keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
312 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL; 314 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
313 keymap[SCANCODE_CONTROL] = SDLK_RCTRL; 315 keymap[SCANCODE_LESS] = SDLK_LESS;
314 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE; 316 keymap[SCANCODE_F11] = SDLK_F11;
315 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT; 317 keymap[SCANCODE_F12] = SDLK_F12;
316 keymap[SCANCODE_RIGHTALT] = SDLK_RALT; 318 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
317 keymap[SCANCODE_BREAK] = SDLK_BREAK; 319 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
318 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN; 320 keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
319 keymap[SCANCODE_HOME] = SDLK_HOME; 321 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
320 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; 322 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
321 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; 323 keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
322 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; 324 keymap[SCANCODE_BREAK] = SDLK_BREAK;
323 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; 325 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
324 keymap[SCANCODE_END] = SDLK_END; 326 keymap[SCANCODE_HOME] = SDLK_HOME;
325 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; 327 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
326 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; 328 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
327 keymap[SCANCODE_INSERT] = SDLK_INSERT; 329 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
328 keymap[SCANCODE_REMOVE] = SDLK_DELETE; 330 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
329 keymap[119] = SDLK_PAUSE; 331 keymap[SCANCODE_END] = SDLK_END;
330 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER; 332 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
331 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER; 333 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
332 keymap[127] = SDLK_MENU; 334 keymap[SCANCODE_INSERT] = SDLK_INSERT;
335 keymap[SCANCODE_REMOVE] = SDLK_DELETE;
336 keymap[119] = SDLK_PAUSE;
337 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
338 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
339 keymap[127] = SDLK_MENU;
333 } 340 }
334 341
335 #if defined(linux) 342 #if defined(linux)
336 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) 343 static SDL_keysym *
337 { 344 TranslateKey (int scancode, SDL_keysym * keysym)
338 /* Set the keysym information */ 345 {
339 keysym->scancode = scancode; 346 /* Set the keysym information */
340 keysym->sym = keymap[scancode]; 347 keysym->scancode = scancode;
341 keysym->mod = KMOD_NONE; 348 keysym->sym = keymap[scancode];
342 349 keysym->mod = KMOD_NONE;
343 /* If UNICODE is on, get the UNICODE value for the key */ 350
344 keysym->unicode = 0; 351 /* If UNICODE is on, get the UNICODE value for the key */
345 if ( SDL_TranslateUNICODE ) { 352 keysym->unicode = 0;
346 int map; 353 if (SDL_TranslateUNICODE) {
347 SDLMod modstate; 354 int map;
348 355 SDLMod modstate;
349 modstate = SDL_GetModState(); 356
350 map = 0; 357 modstate = SDL_GetModState ();
351 if ( modstate & KMOD_SHIFT ) { 358 map = 0;
352 map |= (1<<KG_SHIFT); 359 if (modstate & KMOD_SHIFT) {
353 } 360 map |= (1 << KG_SHIFT);
354 if ( modstate & KMOD_CTRL ) { 361 }
355 map |= (1<<KG_CTRL); 362 if (modstate & KMOD_CTRL) {
356 } 363 map |= (1 << KG_CTRL);
357 if ( modstate & KMOD_ALT ) { 364 }
358 map |= (1<<KG_ALT); 365 if (modstate & KMOD_ALT) {
359 } 366 map |= (1 << KG_ALT);
360 if ( modstate & KMOD_MODE ) { 367 }
361 map |= (1<<KG_ALTGR); 368 if (modstate & KMOD_MODE) {
362 } 369 map |= (1 << KG_ALTGR);
363 if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) { 370 }
364 if ( modstate & KMOD_CAPS ) { 371 if (KTYP (vga_keymap[map][scancode]) == KT_LETTER) {
365 map ^= (1<<KG_SHIFT); 372 if (modstate & KMOD_CAPS) {
366 } 373 map ^= (1 << KG_SHIFT);
367 } 374 }
368 if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) { 375 }
369 if ( modstate & KMOD_NUM ) { 376 if (KTYP (vga_keymap[map][scancode]) == KT_PAD) {
370 keysym->unicode=KVAL(vga_keymap[map][scancode]); 377 if (modstate & KMOD_NUM) {
371 } 378 keysym->unicode = KVAL (vga_keymap[map][scancode]);
372 } else { 379 }
373 keysym->unicode = KVAL(vga_keymap[map][scancode]); 380 } else {
374 } 381 keysym->unicode = KVAL (vga_keymap[map][scancode]);
375 } 382 }
376 return(keysym); 383 }
384 return (keysym);
377 } 385 }
378 #elif defined(__FREEBSD__) 386 #elif defined(__FREEBSD__)
379 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) 387 static SDL_keysym *
380 { 388 TranslateKey (int scancode, SDL_keysym * keysym)
381 /* Set the keysym information */ 389 {
382 keysym->scancode = scancode; 390 /* Set the keysym information */
383 keysym->sym = keymap[scancode]; 391 keysym->scancode = scancode;
384 keysym->mod = KMOD_NONE; 392 keysym->sym = keymap[scancode];
385 393 keysym->mod = KMOD_NONE;
386 /* If UNICODE is on, get the UNICODE value for the key */ 394
387 keysym->unicode = 0; 395 /* If UNICODE is on, get the UNICODE value for the key */
388 if ( SDL_TranslateUNICODE && vga_keymap ) { 396 keysym->unicode = 0;
389 int map; 397 if (SDL_TranslateUNICODE && vga_keymap) {
390 SDLMod modstate; 398 int map;
391 399 SDLMod modstate;
392 modstate = SDL_GetModState(); 400
393 map = 0; 401 modstate = SDL_GetModState ();
394 if ( modstate & KMOD_SHIFT ) { 402 map = 0;
395 map += 1; 403 if (modstate & KMOD_SHIFT) {
396 } 404 map += 1;
397 if ( modstate & KMOD_CTRL ) { 405 }
398 map += 2; 406 if (modstate & KMOD_CTRL) {
399 } 407 map += 2;
400 if ( modstate & KMOD_ALT ) { 408 }
401 map += 4; 409 if (modstate & KMOD_ALT) {
402 } 410 map += 4;
403 if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) { 411 }
404 keysym->unicode = vga_keymap->key[scancode].map[map]; 412 if (!(vga_keymap->key[scancode].spcl & (0x80 >> map))) {
405 } 413 keysym->unicode = vga_keymap->key[scancode].map[map];
406 414 }
407 } 415
408 return(keysym); 416 }
417 return (keysym);
409 } 418 }
410 #else 419 #else
411 #error You must choose your operating system here 420 #error You must choose your operating system here
412 #endif 421 #endif
422 /* vi: set ts=4 sw=4 expandtab: */