comparison src/events/SDL_keyboard.c @ 5224:c1a92e61907d

Renamed SDLKey and SDLMod for consistency
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Feb 2011 09:42:08 -0800
parents 572a73d71b5f
children 1fbe1c202501
comparison
equal deleted inserted replaced
5223:572a73d71b5f 5224:c1a92e61907d
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 SDLKey keymap[SDL_NUM_SCANCODES]; 42 SDL_Key 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 SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = { 47 static const SDL_Key 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(SDLKey * keymap) 575 SDL_GetDefaultKeymap(SDL_Key * 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, SDLKey * keys, int length) 581 SDL_SetKeymap(int start, SDL_Key * 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 SDLMod 835 SDL_Mod
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(SDLMod modstate) 844 SDL_SetModState(SDL_Mod 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 SDLKey 851 SDL_Key
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(SDLKey key) 860 SDL_GetScancodeFromKey(SDL_Key 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(SDLKey key) 886 SDL_GetKeyName(SDL_Key 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) {