Browse Source

Use SDL api rather than my scancode translation

Macoy Madson 11 months ago
  1. 250


@ -213,252 +213,10 @@
(not (at key last-frame-key-states)))))
(defun sdl-scancode-to-user-string (code (unsigned int) &return (* (const char)))
;; TODO: Would be faster in switch, possibly
;; Note: MSVC actually breaks if this is a cond with "blocks nested too deep"
(when (= code SDL_SCANCODE_UNKNOWN) (return "Unknown"))
(when (= code SDL_SCANCODE_A) (return "A"))
(when (= code SDL_SCANCODE_B) (return "B"))
(when (= code SDL_SCANCODE_C) (return "C"))
(when (= code SDL_SCANCODE_D) (return "D"))
(when (= code SDL_SCANCODE_E) (return "E"))
(when (= code SDL_SCANCODE_F) (return "F"))
(when (= code SDL_SCANCODE_G) (return "G"))
(when (= code SDL_SCANCODE_H) (return "H"))
(when (= code SDL_SCANCODE_I) (return "I"))
(when (= code SDL_SCANCODE_J) (return "J"))
(when (= code SDL_SCANCODE_K) (return "K"))
(when (= code SDL_SCANCODE_L) (return "L"))
(when (= code SDL_SCANCODE_M) (return "M"))
(when (= code SDL_SCANCODE_N) (return "N"))
(when (= code SDL_SCANCODE_O) (return "O"))
(when (= code SDL_SCANCODE_P) (return "P"))
(when (= code SDL_SCANCODE_Q) (return "Q"))
(when (= code SDL_SCANCODE_R) (return "R"))
(when (= code SDL_SCANCODE_S) (return "S"))
(when (= code SDL_SCANCODE_T) (return "T"))
(when (= code SDL_SCANCODE_U) (return "U"))
(when (= code SDL_SCANCODE_V) (return "V"))
(when (= code SDL_SCANCODE_W) (return "W"))
(when (= code SDL_SCANCODE_X) (return "X"))
(when (= code SDL_SCANCODE_Y) (return "Y"))
(when (= code SDL_SCANCODE_Z) (return "Z"))
(when (= code SDL_SCANCODE_1) (return "1"))
(when (= code SDL_SCANCODE_2) (return "2"))
(when (= code SDL_SCANCODE_3) (return "3"))
(when (= code SDL_SCANCODE_4) (return "4"))
(when (= code SDL_SCANCODE_5) (return "5"))
(when (= code SDL_SCANCODE_6) (return "6"))
(when (= code SDL_SCANCODE_7) (return "7"))
(when (= code SDL_SCANCODE_8) (return "8"))
(when (= code SDL_SCANCODE_9) (return "9"))
(when (= code SDL_SCANCODE_0) (return "0"))
(when (= code SDL_SCANCODE_RETURN) (return "Return"))
(when (= code SDL_SCANCODE_ESCAPE) (return "Escape"))
(when (= code SDL_SCANCODE_BACKSPACE) (return "Backspace"))
(when (= code SDL_SCANCODE_TAB) (return "Tab"))
(when (= code SDL_SCANCODE_SPACE) (return "Space"))
(when (= code SDL_SCANCODE_MINUS) (return "Minus"))
(when (= code SDL_SCANCODE_EQUALS) (return "Equals"))
(when (= code SDL_SCANCODE_LEFTBRACKET) (return "["))
(when (= code SDL_SCANCODE_RIGHTBRACKET) (return "]"))
(when (= code SDL_SCANCODE_BACKSLASH) (return "Backslash"))
(when (= code SDL_SCANCODE_NONUSHASH) (return "NONUSHASH"))
(when (= code SDL_SCANCODE_SEMICOLON) (return ";"))
(when (= code SDL_SCANCODE_APOSTROPHE) (return "'"))
(when (= code SDL_SCANCODE_GRAVE) (return "`"))
(when (= code SDL_SCANCODE_COMMA) (return ","))
(when (= code SDL_SCANCODE_PERIOD) (return "."))
(when (= code SDL_SCANCODE_SLASH) (return "/"))
(when (= code SDL_SCANCODE_CAPSLOCK) (return "Capslock"))
(when (= code SDL_SCANCODE_F1) (return "F1"))
(when (= code SDL_SCANCODE_F2) (return "F2"))
(when (= code SDL_SCANCODE_F3) (return "F3"))
(when (= code SDL_SCANCODE_F4) (return "F4"))
(when (= code SDL_SCANCODE_F5) (return "F5"))
(when (= code SDL_SCANCODE_F6) (return "F6"))
(when (= code SDL_SCANCODE_F7) (return "F7"))
(when (= code SDL_SCANCODE_F8) (return "F8"))
(when (= code SDL_SCANCODE_F9) (return "F9"))
(when (= code SDL_SCANCODE_F10) (return "F10"))
(when (= code SDL_SCANCODE_F11) (return "F11"))
(when (= code SDL_SCANCODE_F12) (return "F12"))
(when (= code SDL_SCANCODE_PRINTSCREEN) (return "Print screen"))
(when (= code SDL_SCANCODE_SCROLLLOCK) (return "Scroll lock"))
(when (= code SDL_SCANCODE_PAUSE) (return "Pause"))
(when (= code SDL_SCANCODE_INSERT) (return "Insert"))
(when (= code SDL_SCANCODE_HOME) (return "Home"))
(when (= code SDL_SCANCODE_PAGEUP) (return "Page Up"))
(when (= code SDL_SCANCODE_DELETE) (return "Delete"))
(when (= code SDL_SCANCODE_END) (return "End"))
(when (= code SDL_SCANCODE_PAGEDOWN) (return "Page Down"))
(when (= code SDL_SCANCODE_RIGHT) (return "Right"))
(when (= code SDL_SCANCODE_LEFT) (return "Left"))
(when (= code SDL_SCANCODE_DOWN) (return "Down"))
(when (= code SDL_SCANCODE_UP) (return "Up"))
(when (= code SDL_SCANCODE_NUMLOCKCLEAR) (return "Num lock clear"))
(when (= code SDL_SCANCODE_KP_DIVIDE) (return "Keypad /"))
(when (= code SDL_SCANCODE_KP_MULTIPLY) (return "Keypad *"))
(when (= code SDL_SCANCODE_KP_MINUS) (return "Keypad -"))
(when (= code SDL_SCANCODE_KP_PLUS) (return "Keypad +"))
(when (= code SDL_SCANCODE_KP_ENTER) (return "Keypad Enter"))
(when (= code SDL_SCANCODE_KP_1) (return "Keypad 1"))
(when (= code SDL_SCANCODE_KP_2) (return "Keypad 2"))
(when (= code SDL_SCANCODE_KP_3) (return "Keypad 3"))
(when (= code SDL_SCANCODE_KP_4) (return "Keypad 4"))
(when (= code SDL_SCANCODE_KP_5) (return "Keypad 5"))
(when (= code SDL_SCANCODE_KP_6) (return "Keypad 6"))
(when (= code SDL_SCANCODE_KP_7) (return "Keypad 7"))
(when (= code SDL_SCANCODE_KP_8) (return "Keypad 8"))
(when (= code SDL_SCANCODE_KP_9) (return "Keypad 9"))
(when (= code SDL_SCANCODE_KP_0) (return "Keypad 0"))
(when (= code SDL_SCANCODE_KP_PERIOD) (return "Keypad ."))
(when (= code SDL_SCANCODE_APPLICATION) (return "Application"))
(when (= code SDL_SCANCODE_POWER) (return "Power"))
(when (= code SDL_SCANCODE_KP_EQUALS) (return "Keypad ="))
(when (= code SDL_SCANCODE_F13) (return "F13"))
(when (= code SDL_SCANCODE_F14) (return "F14"))
(when (= code SDL_SCANCODE_F15) (return "F15"))
(when (= code SDL_SCANCODE_F16) (return "F16"))
(when (= code SDL_SCANCODE_F17) (return "F17"))
(when (= code SDL_SCANCODE_F18) (return "F18"))
(when (= code SDL_SCANCODE_F19) (return "F19"))
(when (= code SDL_SCANCODE_F20) (return "F20"))
(when (= code SDL_SCANCODE_F21) (return "F21"))
(when (= code SDL_SCANCODE_F22) (return "F22"))
(when (= code SDL_SCANCODE_F23) (return "F23"))
(when (= code SDL_SCANCODE_F24) (return "F24"))
(when (= code SDL_SCANCODE_EXECUTE) (return "Execute"))
(when (= code SDL_SCANCODE_HELP) (return "Help"))
(when (= code SDL_SCANCODE_MENU) (return "Menu"))
(when (= code SDL_SCANCODE_SELECT) (return "Select"))
(when (= code SDL_SCANCODE_STOP) (return "Stop"))
(when (= code SDL_SCANCODE_AGAIN) (return "Again"))
(when (= code SDL_SCANCODE_UNDO) (return "Undo"))
(when (= code SDL_SCANCODE_CUT) (return "Cut"))
(when (= code SDL_SCANCODE_COPY) (return "Copy"))
(when (= code SDL_SCANCODE_PASTE) (return "Paste"))
(when (= code SDL_SCANCODE_FIND) (return "Find"))
(when (= code SDL_SCANCODE_MUTE) (return "Mute"))
(when (= code SDL_SCANCODE_VOLUMEUP) (return "Volume Up"))
(when (= code SDL_SCANCODE_VOLUMEDOWN) (return "Volume Down"))
(when (= code SDL_SCANCODE_KP_COMMA) (return "Keypad ,"))
(when (= code SDL_SCANCODE_KP_EQUALSAS400) (return "Keypad EQUALSAS400"))
(when (= code SDL_SCANCODE_INTERNATIONAL1) (return "International1"))
(when (= code SDL_SCANCODE_INTERNATIONAL2) (return "International2"))
(when (= code SDL_SCANCODE_INTERNATIONAL3) (return "International3"))
(when (= code SDL_SCANCODE_INTERNATIONAL4) (return "International4"))
(when (= code SDL_SCANCODE_INTERNATIONAL5) (return "International5"))
(when (= code SDL_SCANCODE_INTERNATIONAL6) (return "International6"))
(when (= code SDL_SCANCODE_INTERNATIONAL7) (return "International7"))
(when (= code SDL_SCANCODE_INTERNATIONAL8) (return "International8"))
(when (= code SDL_SCANCODE_INTERNATIONAL9) (return "International9"))
(when (= code SDL_SCANCODE_LANG1) (return "Lang1"))
(when (= code SDL_SCANCODE_LANG2) (return "Lang2"))
(when (= code SDL_SCANCODE_LANG3) (return "Lang3"))
(when (= code SDL_SCANCODE_LANG4) (return "Lang4"))
(when (= code SDL_SCANCODE_LANG5) (return "Lang5"))
(when (= code SDL_SCANCODE_LANG6) (return "Lang6"))
(when (= code SDL_SCANCODE_LANG7) (return "Lang7"))
(when (= code SDL_SCANCODE_LANG8) (return "Lang8"))
(when (= code SDL_SCANCODE_LANG9) (return "Lang9"))
(when (= code SDL_SCANCODE_ALTERASE) (return "Alt erase"))
(when (= code SDL_SCANCODE_SYSREQ) (return "Sysreq"))
(when (= code SDL_SCANCODE_CANCEL) (return "Cancel"))
(when (= code SDL_SCANCODE_CLEAR) (return "Clear"))
(when (= code SDL_SCANCODE_PRIOR) (return "Prior"))
(when (= code SDL_SCANCODE_RETURN2) (return "Return2"))
(when (= code SDL_SCANCODE_SEPARATOR) (return "Separator"))
(when (= code SDL_SCANCODE_OUT) (return "Out"))
(when (= code SDL_SCANCODE_OPER) (return "Oper"))
(when (= code SDL_SCANCODE_CLEARAGAIN) (return "Clearagain"))
(when (= code SDL_SCANCODE_CRSEL) (return "Crsel"))
(when (= code SDL_SCANCODE_EXSEL) (return "Exsel"))
(when (= code SDL_SCANCODE_KP_00) (return "Keypad 00"))
(when (= code SDL_SCANCODE_KP_000) (return "Keypad 000"))
(when (= code SDL_SCANCODE_THOUSANDSSEPARATOR) (return "Thousands separator"))
(when (= code SDL_SCANCODE_DECIMALSEPARATOR) (return "Decimal separator"))
(when (= code SDL_SCANCODE_CURRENCYUNIT) (return "Currency unit"))
(when (= code SDL_SCANCODE_CURRENCYSUBUNIT) (return "Currency sub-unit"))
(when (= code SDL_SCANCODE_KP_LEFTPAREN) (return "Keypad ("))
(when (= code SDL_SCANCODE_KP_RIGHTPAREN) (return "Keypad )"))
(when (= code SDL_SCANCODE_KP_LEFTBRACE) (return "Keypad ["))
(when (= code SDL_SCANCODE_KP_RIGHTBRACE) (return "Keypad ]"))
(when (= code SDL_SCANCODE_KP_TAB) (return "Keypad Tab"))
(when (= code SDL_SCANCODE_KP_BACKSPACE) (return "Keypad Backspace"))
(when (= code SDL_SCANCODE_KP_A) (return "Keypad A"))
(when (= code SDL_SCANCODE_KP_B) (return "Keypad B"))
(when (= code SDL_SCANCODE_KP_C) (return "Keypad C"))
(when (= code SDL_SCANCODE_KP_D) (return "Keypad D"))
(when (= code SDL_SCANCODE_KP_E) (return "Keypad E"))
(when (= code SDL_SCANCODE_KP_F) (return "Keypad F"))
(when (= code SDL_SCANCODE_KP_XOR) (return "Keypad XOR"))
(when (= code SDL_SCANCODE_KP_POWER) (return "Keypad Power"))
(when (= code SDL_SCANCODE_KP_PERCENT) (return "Keypad %"))
(when (= code SDL_SCANCODE_KP_LESS) (return "Keypad <"))
(when (= code SDL_SCANCODE_KP_GREATER) (return "Keypad >"))
(when (= code SDL_SCANCODE_KP_AMPERSAND) (return "Keypad &"))
(when (= code SDL_SCANCODE_KP_DBLAMPERSAND) (return "Keypad &&"))
(when (= code SDL_SCANCODE_KP_VERTICALBAR) (return "Keypad |"))
(when (= code SDL_SCANCODE_KP_DBLVERTICALBAR) (return "Keypad ||"))
(when (= code SDL_SCANCODE_KP_COLON) (return "Keypad :"))
(when (= code SDL_SCANCODE_KP_HASH) (return "Keypad #"))
(when (= code SDL_SCANCODE_KP_SPACE) (return "Keypad Space"))
(when (= code SDL_SCANCODE_KP_AT) (return "Keypad At"))
(when (= code SDL_SCANCODE_KP_EXCLAM) (return "Keypad !"))
(when (= code SDL_SCANCODE_KP_MEMSTORE) (return "Keypad Mem store"))
(when (= code SDL_SCANCODE_KP_MEMRECALL) (return "Keypad Mem recall"))
(when (= code SDL_SCANCODE_KP_MEMCLEAR) (return "Keypad Mem clear"))
(when (= code SDL_SCANCODE_KP_MEMADD) (return "Keypad Mem add"))
(when (= code SDL_SCANCODE_KP_MEMSUBTRACT) (return "Keypad Mem subtract"))
(when (= code SDL_SCANCODE_KP_MEMMULTIPLY) (return "Keypad Mem multiply"))
(when (= code SDL_SCANCODE_KP_MEMDIVIDE) (return "Keypad Mem divide"))
(when (= code SDL_SCANCODE_KP_PLUSMINUS) (return "Keypad Plus/minus"))
(when (= code SDL_SCANCODE_KP_CLEAR) (return "Keypad Clear"))
(when (= code SDL_SCANCODE_KP_CLEARENTRY) (return "Keypad Clearentry"))
(when (= code SDL_SCANCODE_KP_BINARY) (return "Keypad Binary"))
(when (= code SDL_SCANCODE_KP_OCTAL) (return "Keypad Octal"))
(when (= code SDL_SCANCODE_KP_DECIMAL) (return "Keypad Decimal"))
(when (= code SDL_SCANCODE_KP_HEXADECIMAL) (return "Keypad Hexadecimal"))
(when (= code SDL_SCANCODE_LCTRL) (return "Left Ctrl"))
(when (= code SDL_SCANCODE_LSHIFT) (return "Left Shift"))
(when (= code SDL_SCANCODE_LALT) (return "Left Alt"))
(when (= code SDL_SCANCODE_LGUI) (return "Left GUI"))
(when (= code SDL_SCANCODE_RCTRL) (return "Right Ctrl"))
(when (= code SDL_SCANCODE_RSHIFT) (return "Right Shift"))
(when (= code SDL_SCANCODE_RALT) (return "Right Alt"))
(when (= code SDL_SCANCODE_RGUI) (return "Right GUI"))
(when (= code SDL_SCANCODE_MODE) (return "Mode"))
(when (= code SDL_SCANCODE_AUDIONEXT) (return "Audio next"))
(when (= code SDL_SCANCODE_AUDIOPREV) (return "Audio prev"))
(when (= code SDL_SCANCODE_AUDIOSTOP) (return "Audio stop"))
(when (= code SDL_SCANCODE_AUDIOPLAY) (return "Audio play"))
(when (= code SDL_SCANCODE_AUDIOMUTE) (return "Audio mute"))
(when (= code SDL_SCANCODE_MEDIASELECT) (return "Media select"))
(when (= code SDL_SCANCODE_WWW) (return "www"))
(when (= code SDL_SCANCODE_MAIL) (return "Mail"))
(when (= code SDL_SCANCODE_CALCULATOR) (return "Calculator"))
(when (= code SDL_SCANCODE_COMPUTER) (return "Computer"))
(when (= code SDL_SCANCODE_AC_SEARCH) (return "AC Search"))
(when (= code SDL_SCANCODE_AC_HOME) (return "AC Home"))
(when (= code SDL_SCANCODE_AC_BACK) (return "AC Back"))
(when (= code SDL_SCANCODE_AC_FORWARD) (return "AC Forward"))
(when (= code SDL_SCANCODE_AC_STOP) (return "AC Stop"))
(when (= code SDL_SCANCODE_AC_REFRESH) (return "AC Refresh"))
(when (= code SDL_SCANCODE_AC_BOOKMARKS) (return "AC Bookmarks"))
(when (= code SDL_SCANCODE_BRIGHTNESSDOWN) (return "Brightness down"))
(when (= code SDL_SCANCODE_BRIGHTNESSUP) (return "Brightness up"))
(when (= code SDL_SCANCODE_DISPLAYSWITCH) (return "Display switch"))
(when (= code SDL_SCANCODE_KBDILLUMTOGGLE) (return "Kbd illum toggle"))
(when (= code SDL_SCANCODE_KBDILLUMDOWN) (return "Kbd illum down"))
(when (= code SDL_SCANCODE_KBDILLUMUP) (return "Kbd illum up"))
(when (= code SDL_SCANCODE_EJECT) (return "Eject"))
(when (= code SDL_SCANCODE_SLEEP) (return "Sleep"))
(when (= code SDL_SCANCODE_APP1) (return "App1"))
(when (= code SDL_SCANCODE_APP2) (return "App2"))
(when (= code SDL_SCANCODE_AUDIOREWIND) (return "Audio rewind"))
(when (= code SDL_SCANCODE_AUDIOFASTFORWARD) (return "Audio fast-forward"))
(return "Unknown"))
(var name (* (const char)) (SDL_GetScancodeName (type-cast code SDL_Scancode)))
(unless name
(return "Unknown"))
(return name))
;; TODO Cakelisp CHelpers support flags
(var-global keybind-modifier-flags-none (unsigned char) 0)