Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_riscosevents.c @ 733:9557ac1857a3
Date: Mon, 13 Oct 2003 13:37:18 +0100
From: "alan buckley"
Subject: Modification for RISC OS SDL port (SDL_riscosevents.c)
This modification improves the key press to Unicode character translation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 05 Nov 2003 23:11:05 +0000 |
parents | e71b7108d2d7 |
children | b8d311d90021 |
comparison
equal
deleted
inserted
replaced
732:d18e2b224d0e | 733:9557ac1857a3 |
---|---|
68 #define ROKEYBD_ARRAYSIZE 125 | 68 #define ROKEYBD_ARRAYSIZE 125 |
69 | 69 |
70 static char RO_pressed[ROKEYBD_ARRAYSIZE]; | 70 static char RO_pressed[ROKEYBD_ARRAYSIZE]; |
71 | 71 |
72 static SDL_keysym *TranslateKey(int intkey, SDL_keysym *keysym, int pressed); | 72 static SDL_keysym *TranslateKey(int intkey, SDL_keysym *keysym, int pressed); |
73 | |
74 | 73 |
75 void RISCOS_PollMouse(_THIS); | 74 void RISCOS_PollMouse(_THIS); |
76 void RISCOS_PollKeyboard(); | 75 void RISCOS_PollKeyboard(); |
77 | 76 |
78 void RISCOS_PollMouseHelper(_THIS, int fullscreen); | 77 void RISCOS_PollMouseHelper(_THIS, int fullscreen); |
142 RO_keymap[51] = SDLK_r; | 141 RO_keymap[51] = SDLK_r; |
143 RO_keymap[52] = SDLK_6; | 142 RO_keymap[52] = SDLK_6; |
144 RO_keymap[53] = SDLK_u; | 143 RO_keymap[53] = SDLK_u; |
145 RO_keymap[54] = SDLK_o; | 144 RO_keymap[54] = SDLK_o; |
146 RO_keymap[55] = SDLK_p; | 145 RO_keymap[55] = SDLK_p; |
147 RO_keymap[56] = SDLK_LEFTPAREN; | 146 RO_keymap[56] = SDLK_LEFTBRACKET; |
148 RO_keymap[57] = SDLK_UP; | 147 RO_keymap[57] = SDLK_UP; |
149 RO_keymap[58] = SDLK_KP_PLUS; | 148 RO_keymap[58] = SDLK_KP_PLUS; |
150 RO_keymap[59] = SDLK_KP_MINUS; | 149 RO_keymap[59] = SDLK_KP_MINUS; |
151 RO_keymap[60] = SDLK_KP_ENTER; | 150 RO_keymap[60] = SDLK_KP_ENTER; |
152 RO_keymap[61] = SDLK_INSERT; | 151 RO_keymap[61] = SDLK_INSERT; |
171 RO_keymap[83] = SDLK_g; | 170 RO_keymap[83] = SDLK_g; |
172 RO_keymap[84] = SDLK_h; | 171 RO_keymap[84] = SDLK_h; |
173 RO_keymap[85] = SDLK_n; | 172 RO_keymap[85] = SDLK_n; |
174 RO_keymap[86] = SDLK_l; | 173 RO_keymap[86] = SDLK_l; |
175 RO_keymap[87] = SDLK_SEMICOLON; | 174 RO_keymap[87] = SDLK_SEMICOLON; |
176 RO_keymap[88] = SDLK_RIGHTPAREN; | 175 RO_keymap[88] = SDLK_RIGHTBRACKET; |
177 RO_keymap[89] = SDLK_DELETE; | 176 RO_keymap[89] = SDLK_DELETE; |
178 RO_keymap[90] = SDLK_KP_MINUS; | 177 RO_keymap[90] = SDLK_KP_MINUS; |
179 RO_keymap[91] = SDLK_KP_MULTIPLY; | 178 RO_keymap[91] = SDLK_KP_MULTIPLY; |
180 RO_keymap[93] = SDLK_EQUALS; | 179 RO_keymap[93] = SDLK_EQUALS; |
181 RO_keymap[94] = SDLK_BACKSLASH; | 180 RO_keymap[94] = SDLK_BACKSLASH; |
354 /* Scan the keyboard to see what is pressed */ | 353 /* Scan the keyboard to see what is pressed */ |
355 while (which_key <= ROKEY_LAST_KEY) | 354 while (which_key <= ROKEY_LAST_KEY) |
356 { | 355 { |
357 which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF); | 356 which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF); |
358 if (which_key != ROKEY_NONE) | 357 if (which_key != ROKEY_NONE) |
359 { | 358 { |
360 switch(which_key) | 359 switch(which_key) |
361 { | 360 { |
362 /* Skip over mouse keys */ | 361 /* Skip over mouse keys */ |
363 case ROKEY_LEFT_MOUSE: | 362 case ROKEY_LEFT_MOUSE: |
364 case ROKEY_CENTRE_MOUSE: | 363 case ROKEY_CENTRE_MOUSE: |
367 break; | 366 break; |
368 | 367 |
369 /* Ignore keys that cause 2 internal number to be generated */ | 368 /* Ignore keys that cause 2 internal number to be generated */ |
370 case 71: case 24: case 87: case 40: | 369 case 71: case 24: case 87: case 40: |
371 break; | 370 break; |
371 | |
372 /* Ignore break as it can be latched on */ | |
373 case 44: | |
374 break; | |
372 | 375 |
373 default: | 376 default: |
374 RO_pressed[which_key] += 2; | 377 RO_pressed[which_key] += 2; |
375 break; | 378 break; |
376 } | 379 } |
424 int state; | 427 int state; |
425 int ch; | 428 int ch; |
426 | 429 |
427 state = (_kernel_osbyte(202, 0, 255) & 0xFF); | 430 state = (_kernel_osbyte(202, 0, 255) & 0xFF); |
428 | 431 |
429 /*TODO: better key to char mapping */ | 432 /*TODO: Take into account other keyboard layouts */ |
430 | 433 |
431 ch = keysym->sym; /* This should handle most keys */ | 434 ch = keysym->sym; /* This should handle most unshifted keys */ |
432 | 435 |
433 if (intkey < 9) | 436 if (intkey < 9 || ch == SDLK_UNKNOWN) |
434 { | 437 { |
435 ch = 0; | 438 ch = 0; |
436 | 439 |
437 } else if (state & 64) /* Control on */ | 440 } else if (state & 64) /* Control on */ |
438 { | 441 { |
439 ch = ch & 31; | 442 ch = ch & 31; |
440 | 443 |
441 } else if ((state & 16) == 0) /* Caps lock is on */ | 444 } else |
442 { | 445 { |
443 if ((state & 128) == 0) /* Shift Enable off */ | 446 int topOfKey = 0; |
444 { | 447 if (state & 8) /* Shift on */ |
445 ch = toupper(ch); | 448 { |
449 topOfKey = 1; | |
446 } | 450 } |
447 } else if (state & 8) /* Shift on */ | 451 |
448 { | 452 if ((state & 16) == 0) /* Caps lock is on */ |
449 ch = toupper(ch); | 453 { |
454 if (ch >= SDLK_a && ch <= SDLK_z) | |
455 { | |
456 if ((state & 128) == 0) /* Shift Enable off */ | |
457 { | |
458 /* All letter become upper case */ | |
459 topOfKey = 1; | |
460 } else | |
461 { | |
462 /* Shift+Letters gives lower case */ | |
463 topOfKey = 1 - topOfKey; | |
464 } | |
465 } | |
466 } | |
467 | |
468 if (topOfKey) | |
469 { | |
470 /* Key produced with shift held down */ | |
471 | |
472 /* Letters just give upper case version */ | |
473 if (ch >= SDLK_a && ch <= SDLK_z) ch = toupper(ch); | |
474 else | |
475 { | |
476 switch(ch) | |
477 { | |
478 case SDLK_HASH: ch = '~'; break; | |
479 case SDLK_QUOTE: ch = '@'; break; | |
480 case SDLK_COMMA: ch = '<'; break; | |
481 case SDLK_MINUS: ch = '_'; break; | |
482 case SDLK_PERIOD: ch = '>'; break; | |
483 case SDLK_SLASH: ch = '?'; break; | |
484 | |
485 case SDLK_0: ch = ')'; break; | |
486 case SDLK_1: ch = '!'; break; | |
487 case SDLK_2: ch = '"'; break; | |
488 case SDLK_3: ch = '£'; break; | |
489 case SDLK_4: ch = '$'; break; | |
490 case SDLK_5: ch = '%'; break; | |
491 case SDLK_6: ch = '^'; break; | |
492 case SDLK_7: ch = '&'; break; | |
493 case SDLK_8: ch = '*'; break; | |
494 case SDLK_9: ch = '('; break; | |
495 | |
496 case SDLK_SEMICOLON: ch = ':'; break; | |
497 case SDLK_EQUALS: ch = '+'; break; | |
498 case SDLK_LEFTBRACKET: ch = '{'; break; | |
499 case SDLK_BACKSLASH: ch = '|'; break; | |
500 case SDLK_RIGHTBRACKET: ch = '}'; break; | |
501 case SDLK_BACKQUOTE: ch = '¬'; break; | |
502 | |
503 default: | |
504 ch = 0; /* Map to zero character if we don't understand it */ | |
505 break; | |
506 } | |
507 } | |
508 | |
509 } else if (ch > 126) | |
510 { | |
511 /* SDL key code < 126 map directly onto their Unicode equivalents */ | |
512 /* Keypad 0 to 9 maps to numeric equivalent */ | |
513 if (ch >= SDLK_KP0 && ch <= SDLK_KP9) ch = ch - SDLK_KP0 + '0'; | |
514 else | |
515 { | |
516 /* Following switch maps other keys that produce an Ascii value */ | |
517 switch(ch) | |
518 { | |
519 case SDLK_KP_PERIOD: ch = '.'; break; | |
520 case SDLK_KP_DIVIDE: ch = '/'; break; | |
521 case SDLK_KP_MULTIPLY: ch = '*'; break; | |
522 case SDLK_KP_MINUS: ch = '-'; break; | |
523 case SDLK_KP_PLUS: ch = '+'; break; | |
524 case SDLK_KP_EQUALS: ch = '='; break; | |
525 | |
526 default: | |
527 /* If we don't know what it is set the Unicode to 0 */ | |
528 ch = 0; | |
529 break; | |
530 } | |
531 } | |
532 } | |
450 } | 533 } |
451 | 534 |
452 keysym->unicode = ch; | 535 keysym->unicode = ch; |
453 } | 536 } |
454 return(keysym); | 537 return(keysym); |
455 } | 538 } |
456 | 539 |
457 /* end of SDL_riscosevents.c ... */ | 540 /* end of SDL_riscosevents.c ... */ |
458 |