Mercurial > sdl-ios-xcode
comparison src/events/SDL_keyboard.c @ 5225:1fbe1c202501
Renamed SDL_Key to SDL_Keycode to clarify terminology.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 07 Feb 2011 10:40:21 -0800 |
parents | c1a92e61907d |
children | b530ef003506 |
comparison
equal
deleted
inserted
replaced
5224:c1a92e61907d | 5225:1fbe1c202501 |
---|---|
37 { | 37 { |
38 /* Data common to all keyboards */ | 38 /* Data common to all keyboards */ |
39 SDL_Window *focus; | 39 SDL_Window *focus; |
40 Uint16 modstate; | 40 Uint16 modstate; |
41 Uint8 keystate[SDL_NUM_SCANCODES]; | 41 Uint8 keystate[SDL_NUM_SCANCODES]; |
42 SDL_Key keymap[SDL_NUM_SCANCODES]; | 42 SDL_Keycode keymap[SDL_NUM_SCANCODES]; |
43 }; | 43 }; |
44 | 44 |
45 static SDL_Keyboard SDL_keyboard; | 45 static SDL_Keyboard SDL_keyboard; |
46 | 46 |
47 static const SDL_Key SDL_default_keymap[SDL_NUM_SCANCODES] = { | 47 static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = { |
48 0, 0, 0, 0, | 48 0, 0, 0, 0, |
49 'a', | 49 'a', |
50 'b', | 50 'b', |
51 'c', | 51 'c', |
52 'd', | 52 'd', |
570 } | 570 } |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 void | 574 void |
575 SDL_GetDefaultKeymap(SDL_Key * keymap) | 575 SDL_GetDefaultKeymap(SDL_Keycode * keymap) |
576 { | 576 { |
577 SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); | 577 SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); |
578 } | 578 } |
579 | 579 |
580 void | 580 void |
581 SDL_SetKeymap(int start, SDL_Key * keys, int length) | 581 SDL_SetKeymap(int start, SDL_Keycode * keys, int length) |
582 { | 582 { |
583 SDL_Keyboard *keyboard = &SDL_keyboard; | 583 SDL_Keyboard *keyboard = &SDL_keyboard; |
584 | 584 |
585 if (start < 0 || start + length > SDL_NUM_SCANCODES) { | 585 if (start < 0 || start + length > SDL_NUM_SCANCODES) { |
586 return; | 586 return; |
830 *numkeys = SDL_NUM_SCANCODES; | 830 *numkeys = SDL_NUM_SCANCODES; |
831 } | 831 } |
832 return keyboard->keystate; | 832 return keyboard->keystate; |
833 } | 833 } |
834 | 834 |
835 SDL_Mod | 835 SDL_Keymod |
836 SDL_GetModState(void) | 836 SDL_GetModState(void) |
837 { | 837 { |
838 SDL_Keyboard *keyboard = &SDL_keyboard; | 838 SDL_Keyboard *keyboard = &SDL_keyboard; |
839 | 839 |
840 return keyboard->modstate; | 840 return keyboard->modstate; |
841 } | 841 } |
842 | 842 |
843 void | 843 void |
844 SDL_SetModState(SDL_Mod modstate) | 844 SDL_SetModState(SDL_Keymod modstate) |
845 { | 845 { |
846 SDL_Keyboard *keyboard = &SDL_keyboard; | 846 SDL_Keyboard *keyboard = &SDL_keyboard; |
847 | 847 |
848 keyboard->modstate = modstate; | 848 keyboard->modstate = modstate; |
849 } | 849 } |
850 | 850 |
851 SDL_Key | 851 SDL_Keycode |
852 SDL_GetKeyFromScancode(SDL_Scancode scancode) | 852 SDL_GetKeyFromScancode(SDL_Scancode scancode) |
853 { | 853 { |
854 SDL_Keyboard *keyboard = &SDL_keyboard; | 854 SDL_Keyboard *keyboard = &SDL_keyboard; |
855 | 855 |
856 return keyboard->keymap[scancode]; | 856 return keyboard->keymap[scancode]; |
857 } | 857 } |
858 | 858 |
859 SDL_Scancode | 859 SDL_Scancode |
860 SDL_GetScancodeFromKey(SDL_Key key) | 860 SDL_GetScancodeFromKey(SDL_Keycode key) |
861 { | 861 { |
862 SDL_Keyboard *keyboard = &SDL_keyboard; | 862 SDL_Keyboard *keyboard = &SDL_keyboard; |
863 SDL_Scancode scancode; | 863 SDL_Scancode scancode; |
864 | 864 |
865 for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; | 865 for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; |
881 else | 881 else |
882 return ""; | 882 return ""; |
883 } | 883 } |
884 | 884 |
885 const char * | 885 const char * |
886 SDL_GetKeyName(SDL_Key key) | 886 SDL_GetKeyName(SDL_Keycode key) |
887 { | 887 { |
888 static char name[8]; | 888 static char name[8]; |
889 char *end; | 889 char *end; |
890 | 890 |
891 if (key & SDLK_SCANCODE_MASK) { | 891 if (key & SDLK_SCANCODE_MASK) { |