svgalib support
[btb/d2x.git] / input / sdl_key.c
1 // SDL keyboard input support
2
3 #include <conf.h>
4
5 #ifdef SDL_INPUT
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 #include <SDL/SDL.h>
11
12 #include "event.h"
13 #include "error.h"
14 #include "key.h"
15 #include "timer.h"
16
17 //added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such
18 #include "d_delay.h"
19 //end this section addition - Matt Mueller
20
21 #define KEY_BUFFER_SIZE 16
22
23 static unsigned char Installed = 0;
24
25 //-------- Variable accessed by outside functions ---------
26 unsigned char           keyd_buffer_type;               // 0=No buffer, 1=buffer ASCII, 2=buffer scans
27 unsigned char           keyd_repeat;
28 unsigned char           keyd_editor_mode;
29 volatile unsigned char  keyd_last_pressed;
30 volatile unsigned char  keyd_last_released;
31 volatile unsigned char  keyd_pressed[256];
32 volatile int            keyd_time_when_last_pressed;
33
34 typedef struct Key_info {
35         ubyte           state;                  // state of key 1 == down, 0 == up
36         ubyte           last_state;             // previous state of key
37         int             counter;                // incremented each time key is down in handler
38         fix             timewentdown;   // simple counter incremented each time in interrupt and key is down
39         fix             timehelddown;   // counter to tell how long key is down -- gets reset to 0 by key routines
40         ubyte           downcount;              // number of key counts key was down
41         ubyte           upcount;                // number of times key was released
42 } Key_info;
43
44 typedef struct keyboard {
45         unsigned short          keybuffer[KEY_BUFFER_SIZE];
46         Key_info                keys[256];
47         fix                     time_pressed[KEY_BUFFER_SIZE];
48         unsigned int            keyhead, keytail;
49 } keyboard;
50
51 static keyboard key_data;
52
53 typedef struct key_props {
54         char *key_text;
55         unsigned char ascii_value;
56         unsigned char shifted_ascii_value;
57         SDLKey sym;
58 } key_props;
59
60 key_props key_properties[256] = {
61 { "",       255,    255,    -1                 },
62 { "ESC",    255,    255,    SDLK_ESCAPE        },
63 { "1",      '1',    '!',    SDLK_1             },
64 { "2",      '2',    '@',    SDLK_2             },
65 { "3",      '3',    '#',    SDLK_3             },
66 { "4",      '4',    '$',    SDLK_4             },
67 { "5",      '5',    '%',    SDLK_5             },
68 { "6",      '6',    '^',    SDLK_6             },
69 { "7",      '7',    '&',    SDLK_7             },
70 { "8",      '8',    '*',    SDLK_8             },
71 { "9",      '9',    '(',    SDLK_9             },
72 { "0",      '0',    ')',    SDLK_0             },
73 { "-",      '-',    '_',    SDLK_MINUS         },
74 { "=",      '=',    '+',    SDLK_EQUALS        },
75 { "BSPC",   255,    255,    SDLK_BACKSPACE     },
76 { "TAB",    255,    255,    SDLK_TAB           },
77 { "Q",      'q',    'Q',    SDLK_q             },
78 { "W",      'w',    'W',    SDLK_w             },
79 { "E",      'e',    'E',    SDLK_e             },
80 { "R",      'r',    'R',    SDLK_r             },
81 { "T",      't',    'T',    SDLK_t             },
82 { "Y",      'y',    'Y',    SDLK_y             },
83 { "U",      'u',    'U',    SDLK_u             },
84 { "I",      'i',    'I',    SDLK_i             },
85 { "O",      'o',    'O',    SDLK_o             },
86 { "P",      'p',    'P',    SDLK_p             },
87 { "[",      '[',    '{',    SDLK_LEFTBRACKET   },
88 { "]",      ']',    '}',    SDLK_RIGHTBRACKET  },
89 //edited 06/08/99 Matt Mueller - set to correct key_text
90 { "\83",      255,    255,    SDLK_RETURN        },
91 //end edit -MM
92 { "LCTRL",  255,    255,    SDLK_LCTRL         },
93 { "A",      'a',    'A',    SDLK_a             },
94 { "S",      's',    'S',    SDLK_s             },
95 { "D",      'd',    'D',    SDLK_d             },
96 { "F",      'f',    'F',    SDLK_f             },
97 { "G",      'g',    'G',    SDLK_g             },
98 { "H",      'h',    'H',    SDLK_h             },
99 { "J",      'j',    'J',    SDLK_j             },
100 { "K",      'k',    'K',    SDLK_k             },
101 { "L",      'l',    'L',    SDLK_l             },
102 //edited 06/08/99 Matt Mueller - set to correct sym
103 { ";",      ';',    ':',    SDLK_SEMICOLON         },
104 //end edit -MM
105 { "'",      '\'',   '"',    SDLK_QUOTE         },
106 //edited 06/08/99 Matt Mueller - set to correct sym
107 { "`",      '`',    '~',    SDLK_BACKQUOTE     },
108 //end edit -MM
109 { "LSHFT",  255,    255,    SDLK_LSHIFT        },
110 { "\\",     '\\',   '|',    SDLK_BACKSLASH     },
111 { "Z",      'z',    'Z',    SDLK_z             },
112 { "X",      'x',    'X',    SDLK_x             },
113 { "C",      'c',    'C',    SDLK_c             },
114 { "V",      'v',    'V',    SDLK_v             },
115 { "B",      'b',    'B',    SDLK_b             },
116 { "N",      'n',    'N',    SDLK_n             },
117 { "M",      'm',    'M',    SDLK_m             },
118 //edited 06/08/99 Matt Mueller - set to correct syms
119 { ",",      ',',    '<',    SDLK_COMMA  },
120 { ".",      '.',    '>',    SDLK_PERIOD },
121 { "/",      '/',    '?',    SDLK_SLASH  },
122 //end edit -MM
123 { "RSHFT",  255,    255,    SDLK_RSHIFT },
124 { "PAD*",   '*',    255,    SDLK_KP_MULTIPLY   },
125 { "LALT",   255,    255,    SDLK_LALT          },
126 { "SPC",    ' ',    ' ',    SDLK_SPACE         },
127 { "CPSLK",  255,    255,    SDLK_CAPSLOCK      },
128 { "F1",     255,    255,    SDLK_F1            },
129 { "F2",     255,    255,    SDLK_F2            },
130 { "F3",     255,    255,    SDLK_F3            },
131 { "F4",     255,    255,    SDLK_F4            },
132 { "F5",     255,    255,    SDLK_F5            },
133 { "F6",     255,    255,    SDLK_F6            },
134 { "F7",     255,    255,    SDLK_F7            },
135 { "F8",     255,    255,    SDLK_F8            },
136 { "F9",     255,    255,    SDLK_F9            },
137 { "F10",    255,    255,    SDLK_F10           },
138 { "NMLCK",  255,    255,    SDLK_NUMLOCK       },
139 { "SCLK",   255,    255,    SDLK_SCROLLOCK     },
140 { "PAD7",   255,    255,    SDLK_KP7           },
141 { "PAD8",   255,    255,    SDLK_KP8           },
142 { "PAD9",   255,    255,    SDLK_KP9           },
143 { "PAD-",   255,    255,    SDLK_KP_MINUS      },
144 { "PAD4",   255,    255,    SDLK_KP4           },
145 { "PAD5",   255,    255,    SDLK_KP5           },
146 { "PAD6",   255,    255,    SDLK_KP6           },
147 { "PAD+",   255,    255,    SDLK_KP_PLUS       },
148 { "PAD1",   255,    255,    SDLK_KP1           },
149 { "PAD2",   255,    255,    SDLK_KP2           },
150 { "PAD3",   255,    255,    SDLK_KP3           },
151 { "PAD0",   255,    255,    SDLK_KP0           },
152 { "PAD.",   255,    255,    SDLK_KP_PERIOD     },
153 { "",       255,    255,    -1                 },
154 { "",       255,    255,    -1                 },
155 { "",       255,    255,    -1                 },
156 { "F11",    255,    255,    SDLK_F11           },
157 { "F12",    255,    255,    SDLK_F12           },
158 { "",       255,    255,    -1                 },       
159 { "",       255,    255,    -1                 },
160 { "",       255,    255,    -1                 },
161 { "",       255,    255,    -1                 },
162 { "",       255,    255,    -1                 },
163 { "",       255,    255,    -1                 },
164 { "",       255,    255,    -1                 },
165 { "",       255,    255,    -1                 },
166 //edited 06/08/99 Matt Mueller - add pause ability
167 { "PAUSE",       255,    255,    SDLK_PAUSE                 },
168 //end edit -MM
169 { "",       255,    255,    -1                 },
170 { "",       255,    255,    -1                 },
171 { "",       255,    255,    -1                 },
172 { "",       255,    255,    -1                 },
173 { "",       255,    255,    -1                 },
174 { "",       255,    255,    -1                 },
175 { "",       255,    255,    -1                 },
176 { "",       255,    255,    -1                 },
177 { "",       255,    255,    -1                 },
178 { "",       255,    255,    -1                 },
179 { "",       255,    255,    -1                 },
180 { "",       255,    255,    -1                 },
181 { "",       255,    255,    -1                 },
182 { "",       255,    255,    -1                 },
183 { "",       255,    255,    -1                 },
184 { "",       255,    255,    -1                 },
185 { "",       255,    255,    -1                 },
186 { "",       255,    255,    -1                 },
187 { "",       255,    255,    -1                 },
188 { "",       255,    255,    -1                 },
189 { "",       255,    255,    -1                 },
190 { "",       255,    255,    -1                 },
191 { "",       255,    255,    -1                 },
192 { "",       255,    255,    -1                 },
193 { "",       255,    255,    -1                 },
194 { "",       255,    255,    -1                 },
195 { "",       255,    255,    -1                 },
196 { "",       255,    255,    -1                 },
197 { "",       255,    255,    -1                 },
198 { "",       255,    255,    -1                 },
199 { "",       255,    255,    -1                 },
200 { "",       255,    255,    -1                 },
201 { "",       255,    255,    -1                 },
202 { "",       255,    255,    -1                 },
203 { "",       255,    255,    -1                 },
204 { "",       255,    255,    -1                 },
205 { "",       255,    255,    -1                 },
206 { "",       255,    255,    -1                 },
207 { "",       255,    255,    -1                 },
208 { "",       255,    255,    -1                 },
209 { "",       255,    255,    -1                 },
210 { "",       255,    255,    -1                 },
211 { "",       255,    255,    -1                 },
212 { "",       255,    255,    -1                 },
213 { "",       255,    255,    -1                 },
214 { "",       255,    255,    -1                 },
215 { "",       255,    255,    -1                 },
216 { "",       255,    255,    -1                 },
217 { "",       255,    255,    -1                 },
218 { "",       255,    255,    -1                 },
219 { "",       255,    255,    -1                 },
220 { "",       255,    255,    -1                 },
221 { "",       255,    255,    -1                 },
222 { "",       255,    255,    -1                 },
223 { "",       255,    255,    -1                 },
224 { "",       255,    255,    -1                 },
225 { "",       255,    255,    -1                 },
226 { "",       255,    255,    -1                 },
227 //edited 06/08/99 Matt Mueller - set to correct key_text
228 { "PAD\83",   255,    255,    SDLK_KP_ENTER      },
229 //end edit -MM
230 //edited 06/08/99 Matt Mueller - set to correct sym
231 { "RCTRL",  255,    255,    SDLK_RCTRL            },
232 //end edit -MM
233 { "",       255,    255,    -1                 },
234 { "",       255,    255,    -1                 },
235 { "",       255,    255,    -1                 },
236 { "",       255,    255,    -1                 },
237 { "",       255,    255,    -1                 },
238 { "",       255,    255,    -1                 },
239 { "",       255,    255,    -1                 },
240 { "",       255,    255,    -1                 },
241 { "",       255,    255,    -1                 },
242 { "",       255,    255,    -1                 },
243 { "",       255,    255,    -1                 },
244 { "",       255,    255,    -1                 },
245 { "",       255,    255,    -1                 },
246 { "",       255,    255,    -1                 },
247 { "",       255,    255,    -1                 },
248 { "",       255,    255,    -1                 },
249 { "",       255,    255,    -1                 },
250 { "",       255,    255,    -1                 },
251 { "",       255,    255,    -1                 },
252 { "",       255,    255,    -1                 },
253 { "",       255,    255,    -1                 },
254 { "",       255,    255,    -1                 },
255 { "",       255,    255,    -1                 },
256 { "PAD/",   255,    255,    SDLK_KP_DIVIDE     },
257 { "",       255,    255,    -1                 },
258 //edited 06/08/99 Matt Mueller - add printscreen ability
259 { "PRSCR",       255,    255,    SDLK_PRINT                 },
260 //end edit -MM
261 { "RALT",   255,    255,    SDLK_RALT          },
262 { "",       255,    255,    -1                 },
263 { "",       255,    255,    -1                 },
264 { "",       255,    255,    -1                 },
265 { "",       255,    255,    -1                 },
266 { "",       255,    255,    -1                 },
267 { "",       255,    255,    -1                 },
268 { "",       255,    255,    -1                 },
269 { "",       255,    255,    -1                 },
270 { "",       255,    255,    -1                 },
271 { "",       255,    255,    -1                 },
272 { "",       255,    255,    -1                 },
273 { "",       255,    255,    -1                 },
274 { "",       255,    255,    -1                 },
275 { "",       255,    255,    -1                 },
276 { "HOME",   255,    255,    SDLK_HOME          },
277 //edited 06/08/99 Matt Mueller - set to correct key_text
278 { "UP",         255,    255,    SDLK_UP            },
279 //end edit -MM
280 { "PGUP",   255,    255,    SDLK_PAGEUP        },
281 { "",       255,    255,    -1                 },
282 //edited 06/08/99 Matt Mueller - set to correct key_text
283 { "LEFT",       255,    255,    SDLK_LEFT          },
284 //end edit -MM
285 { "",       255,    255,    -1                 },
286 //edited 06/08/99 Matt Mueller - set to correct key_text
287 { "RIGHT",      255,    255,    SDLK_RIGHT         },
288 //end edit -MM
289 { "",       255,    255,    -1                 },
290 //edited 06/08/99 Matt Mueller - set to correct key_text
291 { "END",    255,    255,    SDLK_END           },
292 //end edit -MM
293 { "DOWN",       255,    255,    SDLK_DOWN          },
294 { "PGDN",       255,    255,    SDLK_PAGEDOWN      },
295 { "INS",        255,    255,    SDLK_INSERT        },
296 { "DEL",        255,    255,    SDLK_DELETE        },
297 { "",       255,    255,    -1                 },
298 { "",       255,    255,    -1                 },
299 { "",       255,    255,    -1                 },
300 { "",       255,    255,    -1                 },
301 { "",       255,    255,    -1                 },
302 { "",       255,    255,    -1                 },
303 { "",       255,    255,    -1                 },
304 { "",       255,    255,    -1                 },
305 { "",       255,    255,    -1                 },
306 { "",       255,    255,    -1                 },
307 { "",       255,    255,    -1                 },
308 { "",       255,    255,    -1                 },
309 { "",       255,    255,    -1                 },
310 { "",       255,    255,    -1                 },
311 { "",       255,    255,    -1                 },
312 { "",       255,    255,    -1                 },
313 { "",       255,    255,    -1                 },
314 { "",       255,    255,    -1                 },
315 { "",       255,    255,    -1                 },
316 { "",       255,    255,    -1                 },
317 { "",       255,    255,    -1                 },
318 { "",       255,    255,    -1                 },
319 { "",       255,    255,    -1                 },
320 { "",       255,    255,    -1                 },
321 { "",       255,    255,    -1                 },
322 { "",       255,    255,    -1                 },
323 { "",       255,    255,    -1                 },
324 { "",       255,    255,    -1                 },
325 { "",       255,    255,    -1                 },
326 { "",       255,    255,    -1                 },
327 { "",       255,    255,    -1                 },
328 { "",       255,    255,    -1                 },
329 { "",       255,    255,    -1                 },
330 { "",       255,    255,    -1                 },
331 { "",       255,    255,    -1                 },
332 { "",       255,    255,    -1                 },
333 { "",       255,    255,    -1                 },
334 { "",       255,    255,    -1                 },
335 { "",       255,    255,    -1                 },
336 { "",       255,    255,    -1                 },
337 { "",       255,    255,    -1                 },
338 { "",       255,    255,    -1                 },
339 { "",       255,    255,    -1                 },
340 { "",       255,    255,    -1                 },
341 };
342
343 char *key_text[256];
344
345 void key_buid_key_text(void)
346 {
347 }
348
349 unsigned char key_to_ascii(int keycode )
350 {
351         int shifted;
352
353         shifted = keycode & KEY_SHIFTED;
354         keycode &= 0xFF;
355
356         if (shifted)
357                 return key_properties[keycode].shifted_ascii_value;
358         else
359                 return key_properties[keycode].ascii_value;
360 }
361
362 void key_handler(SDL_KeyboardEvent *event)
363 {
364         ubyte state;
365         int i, keycode, event_key, key_state;
366         Key_info *key;
367         unsigned char temp;
368
369         event_key = event->keysym.sym;
370
371         key_state = (event->state == SDL_PRESSED); //  !(wInfo & KF_UP);
372         //=====================================================
373         //Here a translation from win keycodes to mac keycodes!
374         //=====================================================
375
376         for (i = 255; i >= 0; i--) {
377
378                 keycode = i;
379                 key = &(key_data.keys[keycode]);
380                 if (key_properties[i].sym == event_key)
381                         state = key_state;
382                 else
383                         state = key->last_state;
384                         
385                 if ( key->last_state == state ) {
386                         if (state) {
387                                 key->counter++;
388                                 keyd_last_pressed = keycode;
389                                 keyd_time_when_last_pressed = timer_get_fixed_seconds();
390                         }
391                 } else {
392                         if (state)      {
393                                 keyd_last_pressed = keycode;
394                                 keyd_pressed[keycode] = 1;
395                                 key->downcount += state;
396                                 key->state = 1;
397                                 key->timewentdown = keyd_time_when_last_pressed = timer_get_fixed_seconds();
398                                 key->counter++;
399                         } else {        
400                                 keyd_pressed[keycode] = 0;
401                                 keyd_last_released = keycode;
402                                 key->upcount += key->state;
403                                 key->state = 0;
404                                 key->counter = 0;
405                                 key->timehelddown += timer_get_fixed_seconds() - key->timewentdown;
406                         }
407                 }
408                 if ( (state && !key->last_state) || (state && key->last_state && (key->counter > 30) && (key->counter & 0x01)) ) {
409                         if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT])
410                                 keycode |= KEY_SHIFTED;
411                         if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT])
412                                 keycode |= KEY_ALTED;
413                         if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL])
414                                 keycode |= KEY_CTRLED;
415                         if ( keyd_pressed[KEY_DELETE] )
416                                 keycode |= KEY_DEBUGGED;
417                         temp = key_data.keytail+1;
418                         if ( temp >= KEY_BUFFER_SIZE ) temp=0;
419                         if (temp!=key_data.keyhead)     {
420                                 key_data.keybuffer[key_data.keytail] = keycode;
421                                 key_data.time_pressed[key_data.keytail] = keyd_time_when_last_pressed;
422                                 key_data.keytail = temp;
423                         }
424                 }
425                 key->last_state = state;
426         }
427 }
428
429 void key_close()
430 {
431  Installed = 0;
432 }
433
434 void key_init()
435 {
436   int i;
437   
438   if (Installed) return;
439
440   Installed=1;
441
442   keyd_time_when_last_pressed = timer_get_fixed_seconds();
443   keyd_buffer_type = 1;
444   keyd_repeat = 1;
445   
446   for(i=0; i<256; i++)
447      key_text[i] = key_properties[i].key_text;
448      
449   // Clear the keyboard array
450   key_flush();
451   atexit(key_close);
452 }
453
454 void key_flush()
455 {
456         int i;
457         fix curtime;
458
459         if (!Installed)
460                 key_init();
461
462         key_data.keyhead = key_data.keytail = 0;
463
464         //Clear the keyboard buffer
465         for (i=0; i<KEY_BUFFER_SIZE; i++ )      {
466                 key_data.keybuffer[i] = 0;
467                 key_data.time_pressed[i] = 0;
468         }
469
470 //use gettimeofday here:
471         curtime = timer_get_fixed_seconds();
472
473         for (i=0; i<256; i++ )  {
474                 keyd_pressed[i] = 0;
475                 key_data.keys[i].state = 1;
476                 key_data.keys[i].last_state = 0;
477                 key_data.keys[i].timewentdown = curtime;
478                 key_data.keys[i].downcount=0;
479                 key_data.keys[i].upcount=0;
480                 key_data.keys[i].timehelddown = 0;
481                 key_data.keys[i].counter = 0;
482         }
483 }
484
485 int add_one(int n)
486 {
487  n++;
488  if ( n >= KEY_BUFFER_SIZE ) n=0;
489  return n;
490 }
491
492 int key_checkch()
493 {
494         int is_one_waiting = 0;
495         event_poll();
496         if (key_data.keytail!=key_data.keyhead)
497                 is_one_waiting = 1;
498         return is_one_waiting;
499 }
500
501 int key_inkey()
502 {
503         int key = 0;
504         if (!Installed)
505                 key_init();
506         event_poll();
507         if (key_data.keytail!=key_data.keyhead) {
508                 key = key_data.keybuffer[key_data.keyhead];
509                 key_data.keyhead = add_one(key_data.keyhead);
510         }
511 //added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such
512         else d_delay(1);
513 //end addition - Matt Mueller
514              
515         return key;
516 }
517
518 int key_inkey_time(fix * time)
519 {
520         int key = 0;
521
522         if (!Installed)
523                 key_init();
524         event_poll();
525         if (key_data.keytail!=key_data.keyhead) {
526                 key = key_data.keybuffer[key_data.keyhead];
527                 *time = key_data.time_pressed[key_data.keyhead];
528                 key_data.keyhead = add_one(key_data.keyhead);
529         }
530         return key;
531 }
532
533 int key_peekkey()
534 {
535         int key = 0;
536         event_poll();
537         if (key_data.keytail!=key_data.keyhead)
538                 key = key_data.keybuffer[key_data.keyhead];
539
540         return key;
541 }
542
543 int key_getch()
544 {
545         int dummy=0;
546
547         if (!Installed)
548                 return 0;
549 //              return getch();
550
551         while (!key_checkch())
552                 dummy++;
553         return key_inkey();
554 }
555
556 unsigned int key_get_shift_status()
557 {
558         unsigned int shift_status = 0;
559
560         if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT] )
561                 shift_status |= KEY_SHIFTED;
562
563         if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT] )
564                 shift_status |= KEY_ALTED;
565
566         if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL] )
567                 shift_status |= KEY_CTRLED;
568
569 #ifndef NDEBUG
570         if (keyd_pressed[KEY_DELETE])
571                 shift_status |=KEY_DEBUGGED;
572 #endif
573
574         return shift_status;
575 }
576
577 // Returns the number of seconds this key has been down since last call.
578 fix key_down_time(int scancode)
579 {
580         fix time_down, time;
581
582         event_poll();
583         if ((scancode<0)|| (scancode>255)) return 0;
584
585         if (!keyd_pressed[scancode]) {
586                 time_down = key_data.keys[scancode].timehelddown;
587                 key_data.keys[scancode].timehelddown = 0;
588         } else {
589                 time = timer_get_fixed_seconds();
590                 time_down = time - key_data.keys[scancode].timewentdown;
591                 key_data.keys[scancode].timewentdown = time;
592         }
593
594         return time_down;
595 }
596
597 unsigned int key_down_count(int scancode)
598 {
599         int n;
600         event_poll();
601         if ((scancode<0)|| (scancode>255)) return 0;
602
603         n = key_data.keys[scancode].downcount;
604         key_data.keys[scancode].downcount = 0;
605
606         return n;
607 }
608
609 unsigned int key_up_count(int scancode)
610 {
611         int n;
612         event_poll();
613         if ((scancode<0)|| (scancode>255)) return 0;
614
615         n = key_data.keys[scancode].upcount;
616         key_data.keys[scancode].upcount = 0;
617
618         return n;
619 }
620
621 #endif //SDL_INPUT