Mercurial > sdl-ios-xcode
comparison src/events/SDL_keyboard.c @ 5083:25d4feb7c127
Renamed SDL_keysym to SDL_KeySym
Renamed SDL_scancode to SDL_ScanCode
Added #defines to SDL_compat.h
author | krogoway |
---|---|
date | Mon, 24 Jan 2011 13:47:35 -0600 |
parents | 443771460df9 |
children | dc0dfdd58f27 |
comparison
equal
deleted
inserted
replaced
5082:de59e0218aa2 | 5083:25d4feb7c127 |
---|---|
560 | 560 |
561 void | 561 void |
562 SDL_ResetKeyboard(void) | 562 SDL_ResetKeyboard(void) |
563 { | 563 { |
564 SDL_Keyboard *keyboard = &SDL_keyboard; | 564 SDL_Keyboard *keyboard = &SDL_keyboard; |
565 SDL_scancode scancode; | 565 SDL_ScanCode scancode; |
566 | 566 |
567 for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { | 567 for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { |
568 if (keyboard->keystate[scancode] == SDL_PRESSED) { | 568 if (keyboard->keystate[scancode] == SDL_PRESSED) { |
569 SDL_SendKeyboardKey(SDL_RELEASED, scancode); | 569 SDL_SendKeyboardKey(SDL_RELEASED, scancode); |
570 } | 570 } |
588 | 588 |
589 SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length); | 589 SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length); |
590 } | 590 } |
591 | 591 |
592 void | 592 void |
593 SDL_SetScancodeName(SDL_scancode scancode, const char *name) | 593 SDL_SetScancodeName(SDL_ScanCode scancode, const char *name) |
594 { | 594 { |
595 SDL_scancode_names[scancode] = name; | 595 SDL_scancode_names[scancode] = name; |
596 } | 596 } |
597 | 597 |
598 SDL_Window * | 598 SDL_Window * |
636 } | 636 } |
637 } | 637 } |
638 } | 638 } |
639 | 639 |
640 int | 640 int |
641 SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode) | 641 SDL_SendKeyboardKey(Uint8 state, SDL_ScanCode scancode) |
642 { | 642 { |
643 SDL_Keyboard *keyboard = &SDL_keyboard; | 643 SDL_Keyboard *keyboard = &SDL_keyboard; |
644 int posted; | 644 int posted; |
645 Uint16 modstate; | 645 Uint16 modstate; |
646 Uint32 type; | 646 Uint32 type; |
847 | 847 |
848 keyboard->modstate = modstate; | 848 keyboard->modstate = modstate; |
849 } | 849 } |
850 | 850 |
851 SDLKey | 851 SDLKey |
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(SDLKey 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; |
866 ++scancode) { | 866 ++scancode) { |
867 if (keyboard->keymap[scancode] == key) { | 867 if (keyboard->keymap[scancode] == key) { |
868 return scancode; | 868 return scancode; |
870 } | 870 } |
871 return SDL_SCANCODE_UNKNOWN; | 871 return SDL_SCANCODE_UNKNOWN; |
872 } | 872 } |
873 | 873 |
874 const char * | 874 const char * |
875 SDL_GetScancodeName(SDL_scancode scancode) | 875 SDL_GetScancodeName(SDL_ScanCode scancode) |
876 { | 876 { |
877 const char *name = SDL_scancode_names[scancode]; | 877 const char *name = SDL_scancode_names[scancode]; |
878 | 878 |
879 if (name) | 879 if (name) |
880 return name; | 880 return name; |
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) { |
892 return | 892 return |
893 SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK)); | 893 SDL_GetScancodeName((SDL_ScanCode) (key & ~SDLK_SCANCODE_MASK)); |
894 } | 894 } |
895 | 895 |
896 switch (key) { | 896 switch (key) { |
897 case SDLK_RETURN: | 897 case SDLK_RETURN: |
898 return SDL_GetScancodeName(SDL_SCANCODE_RETURN); | 898 return SDL_GetScancodeName(SDL_SCANCODE_RETURN); |