#include #include #include namespace orange::Input { static constexpr Array s_scancodeToKey = []() { Array scanToKey; for (int i = SDL_SCANCODE_A; i <= SDL_SCANCODE_Z; i++) scanToKey[i] = ButtonCode(ButtonCodes::Key_A + (i - SDL_SCANCODE_A)); for (int i = SDL_SCANCODE_1; i <= SDL_SCANCODE_9; i++) scanToKey[i] = ButtonCode(ButtonCodes::Key_1 + (i - SDL_SCANCODE_1)); for (int i = SDL_SCANCODE_F1; i <= SDL_SCANCODE_F12; i++) scanToKey[i] = ButtonCode(ButtonCodes::Key_F1 + (i - SDL_SCANCODE_F1)); for (int i = SDL_SCANCODE_KP_1; i <= SDL_SCANCODE_KP_9; i++) scanToKey[i] = ButtonCode(ButtonCodes::Key_Numpad_1 + (i - SDL_SCANCODE_KP_1)); scanToKey[SDL_SCANCODE_0] = ButtonCodes::Key_0; scanToKey[SDL_SCANCODE_KP_0] = ButtonCodes::Key_Numpad_0; scanToKey[SDL_SCANCODE_RETURN] = ButtonCodes::Key_Enter; scanToKey[SDL_SCANCODE_ESCAPE] = ButtonCodes::Key_Escape; scanToKey[SDL_SCANCODE_BACKSPACE] = ButtonCodes::Key_Backspace; scanToKey[SDL_SCANCODE_TAB] = ButtonCodes::Key_Tab; scanToKey[SDL_SCANCODE_SPACE] = ButtonCodes::Key_Space; scanToKey[SDL_SCANCODE_MINUS] = ButtonCodes::Key_Minus; scanToKey[SDL_SCANCODE_EQUALS] = ButtonCodes::Key_Equal; scanToKey[SDL_SCANCODE_LEFTBRACKET] = ButtonCodes::Key_LBracket; scanToKey[SDL_SCANCODE_RIGHTBRACKET] = ButtonCodes::Key_RBracket; scanToKey[SDL_SCANCODE_BACKSLASH] = ButtonCodes::Key_Backslash; scanToKey[SDL_SCANCODE_SEMICOLON] = ButtonCodes::Key_Semicolon; scanToKey[SDL_SCANCODE_APOSTROPHE] = ButtonCodes::Key_Apostrophe; scanToKey[SDL_SCANCODE_GRAVE] = ButtonCodes::Key_Backquote; scanToKey[SDL_SCANCODE_COMMA] = ButtonCodes::Key_Comma; scanToKey[SDL_SCANCODE_PERIOD] = ButtonCodes::Key_Period; scanToKey[SDL_SCANCODE_SLASH] = ButtonCodes::Key_Slash; scanToKey[SDL_SCANCODE_CAPSLOCK] = ButtonCodes::Key_CapsLock; scanToKey[SDL_SCANCODE_SCROLLLOCK] = ButtonCodes::Key_ScrollLock; scanToKey[SDL_SCANCODE_INSERT] = ButtonCodes::Key_Insert; scanToKey[SDL_SCANCODE_HOME] = ButtonCodes::Key_Home; scanToKey[SDL_SCANCODE_PAGEUP] = ButtonCodes::Key_PageUp; scanToKey[SDL_SCANCODE_DELETE] = ButtonCodes::Key_Delete; scanToKey[SDL_SCANCODE_END] = ButtonCodes::Key_End; scanToKey[SDL_SCANCODE_PAGEDOWN] = ButtonCodes::Key_PageDown; scanToKey[SDL_SCANCODE_RIGHT] = ButtonCodes::Key_Right; scanToKey[SDL_SCANCODE_LEFT] = ButtonCodes::Key_Left; scanToKey[SDL_SCANCODE_DOWN] = ButtonCodes::Key_Down; scanToKey[SDL_SCANCODE_UP] = ButtonCodes::Key_Up; scanToKey[SDL_SCANCODE_NUMLOCKCLEAR] = ButtonCodes::Key_NumLock; scanToKey[SDL_SCANCODE_KP_DIVIDE] = ButtonCodes::Key_Numpad_Divide; scanToKey[SDL_SCANCODE_KP_MULTIPLY] = ButtonCodes::Key_Numpad_Multiply; scanToKey[SDL_SCANCODE_KP_MINUS] = ButtonCodes::Key_Numpad_Minus; scanToKey[SDL_SCANCODE_KP_PLUS] = ButtonCodes::Key_Numpad_Plus; scanToKey[SDL_SCANCODE_KP_ENTER] = ButtonCodes::Key_Numpad_Enter; scanToKey[SDL_SCANCODE_KP_PERIOD] = ButtonCodes::Key_Numpad_Decimal; scanToKey[SDL_SCANCODE_APPLICATION] = ButtonCodes::Key_App; scanToKey[SDL_SCANCODE_LCTRL] = ButtonCodes::Key_LControl; scanToKey[SDL_SCANCODE_LSHIFT] = ButtonCodes::Key_LShift; scanToKey[SDL_SCANCODE_LALT] = ButtonCodes::Key_LAlt; scanToKey[SDL_SCANCODE_LGUI] = ButtonCodes::Key_LSuper; scanToKey[SDL_SCANCODE_RCTRL] = ButtonCodes::Key_RControl; scanToKey[SDL_SCANCODE_RSHIFT] = ButtonCodes::Key_RShift; scanToKey[SDL_SCANCODE_RALT] = ButtonCodes::Key_RAlt; scanToKey[SDL_SCANCODE_RGUI] = ButtonCodes::Key_RSuper; return scanToKey; }(); ButtonCode SDLScancodeToButton(int scancode) { return s_scancodeToKey[scancode]; } }