MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ProcessKeyPress

Function ProcessKeyPress

src/openrct2-ui/TextComposition.cpp:62–106  ·  view source on GitHub ↗

* Remaps keypad enter keypress to normal enter and the numpad keys that can be used for navigation when num lock is off. * @return A pair with the remapped keycode and scancode. */

Source from the content-addressed store, hash-verified

60 * @return A pair with the remapped keycode and scancode.
61 */
62static std::pair<SDL_Keycode, SDL_Scancode> ProcessKeyPress(SDL_Keycode key, SDL_Scancode scancode)
63{
64 if (key == SDLK_KP_ENTER)
65 {
66 key = SDLK_RETURN;
67 scancode = SDL_SCANCODE_RETURN;
68 }
69 else if (!(SDL_GetModState() & KMOD_NUM))
70 {
71 switch (key)
72 {
73 case SDLK_KP_1:
74 {
75 key = SDLK_END;
76 scancode = SDL_SCANCODE_END;
77 break;
78 }
79 case SDLK_KP_4:
80 {
81 key = SDLK_LEFT;
82 scancode = SDL_SCANCODE_LEFT;
83 break;
84 }
85 case SDLK_KP_6:
86 {
87 key = SDLK_RIGHT;
88 scancode = SDL_SCANCODE_RIGHT;
89 break;
90 }
91 case SDLK_KP_7:
92 {
93 key = SDLK_HOME;
94 scancode = SDL_SCANCODE_HOME;
95 break;
96 }
97 case SDLK_KP_PERIOD:
98 {
99 key = SDLK_DELETE;
100 scancode = SDL_SCANCODE_DELETE;
101 break;
102 }
103 }
104 }
105 return { key, scancode };
106}
107
108void TextComposition::HandleMessage(const SDL_Event* e)
109{

Callers 1

HandleMessageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected