/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Christian Meyer co-programmer: ... */ #include "key_names.h" #include "stdincl.h" #include using namespace std; int buttonnameToSDLB(const char* name) { if( !strcmp (name, "BUTTON_LEFT")) return SDL_BUTTON_LEFT; if( !strcmp (name, "BUTTON_MIDDLE")) return SDL_BUTTON_MIDDLE; if( !strcmp (name, "BUTTON_RIGHT")) return SDL_BUTTON_RIGHT; if( !strcmp (name, "BUTTON_WHEELUP")) return SDL_BUTTON_WHEELUP; if( !strcmp (name, "BUTTON_WHEELDOWN")) return SDL_BUTTON_WHEELDOWN; return -1; } char* SDLBToButtonname( int button) { if( button == SDL_BUTTON_LEFT) return "BUTTON_LEFT"; if( button == SDL_BUTTON_MIDDLE) return "BUTTON_MIDDLE"; if( button == SDL_BUTTON_RIGHT) return "BUTTON_RIGHT"; if( button == SDL_BUTTON_WHEELUP) return "BUTTON_WHEELUP"; if( button == SDL_BUTTON_WHEELDOWN) return "BUTTON_WHEELDOWN"; return "UNKNOWN"; } int keynameToSDLK(const char* name) { if( !strcmp (name, "BACKSPACE")) return SDLK_BACKSPACE; if( !strcmp (name, "TAB")) return SDLK_TAB; if( !strcmp (name, "CLEAR")) return SDLK_CLEAR; if( !strcmp (name, "RETURN")) return SDLK_RETURN; if( !strcmp (name, "ESCAPE")) return SDLK_ESCAPE; if( !strcmp (name, "SPACE")) return SDLK_SPACE; if( !strcmp (name, "EXCLAIM")) return SDLK_EXCLAIM; if( !strcmp (name, "QUOTEDBL")) return SDLK_QUOTEDBL; if( !strcmp (name, "HASH")) return SDLK_HASH; if( !strcmp (name, "PAUSE")) return SDLK_PAUSE; if( !strcmp (name, "DOLLAR")) return SDLK_DOLLAR; if( !strcmp (name, "AMPERSAND")) return SDLK_AMPERSAND; if( !strcmp (name, "QUOTE")) return SDLK_QUOTE; if( !strcmp (name, "LEFTPAREN")) return SDLK_LEFTPAREN; if( !strcmp (name, "RIGHTPAREN")) return SDLK_RIGHTPAREN; if( !strcmp (name, "ASTERISK")) return SDLK_ASTERISK; if( !strcmp (name, "PLUS")) return SDLK_PLUS; if( !strcmp (name, "COMMA")) return SDLK_COMMA; if( !strcmp (name, "MINUS")) return SDLK_MINUS; if( !strcmp (name, "PERIOD")) return SDLK_PERIOD; if( !strcmp (name, "SLASH")) return SDLK_SLASH; if( !strcmp (name, "0")) return SDLK_0; if( !strcmp (name, "1")) return SDLK_1; if( !strcmp (name, "2")) return SDLK_2; if( !strcmp (name, "3")) return SDLK_3; if( !strcmp (name, "4")) return SDLK_4; if( !strcmp (name, "5")) return SDLK_5; if( !strcmp (name, "6")) return SDLK_6; if( !strcmp (name, "7")) return SDLK_7; if( !strcmp (name, "8")) return SDLK_8; if( !strcmp (name, "9")) return SDLK_9; if( !strcmp (name, "COLON")) return SDLK_COLON; if( !strcmp (name, "SEMICOLON")) return SDLK_SEMICOLON; if( !strcmp (name, "LESS")) return SDLK_LESS; if( !strcmp (name, "EQUALS")) return SDLK_EQUALS; if( !strcmp (name, "GREATER")) return SDLK_GREATER; if( !strcmp (name, "QUESTION")) return SDLK_QUESTION; if( !strcmp (name, "AT")) return SDLK_AT; if( !strcmp (name, "LEFTBRACKET")) return SDLK_LEFTBRACKET; if( !strcmp (name, "BACKSLASH")) return SDLK_BACKSLASH; if( !strcmp (name, "RIGHTBRACKET")) return SDLK_RIGHTBRACKET; if( !strcmp (name, "CARET")) return SDLK_CARET; if( !strcmp (name, "UNDERSCORE")) return SDLK_UNDERSCORE; if( !strcmp (name, "BACKQUOTE")) return SDLK_BACKQUOTE; if( !strcmp (name, "a")) return SDLK_a; if( !strcmp (name, "b")) return SDLK_b; if( !strcmp (name, "c")) return SDLK_c; if( !strcmp (name, "d")) return SDLK_d; if( !strcmp (name, "e")) return SDLK_e; if( !strcmp (name, "f")) return SDLK_f; if( !strcmp (name, "g")) return SDLK_g; if( !strcmp (name, "h")) return SDLK_h; if( !strcmp (name, "i")) return SDLK_i; if( !strcmp (name, "j")) return SDLK_j; if( !strcmp (name, "k")) return SDLK_k; if( !strcmp (name, "l")) return SDLK_l; if( !strcmp (name, "m")) return SDLK_m; if( !strcmp (name, "n")) return SDLK_n; if( !strcmp (name, "o")) return SDLK_o; if( !strcmp (name, "p")) return SDLK_p; if( !strcmp (name, "q")) return SDLK_q; if( !strcmp (name, "r")) return SDLK_r; if( !strcmp (name, "s")) return SDLK_s; if( !strcmp (name, "t")) return SDLK_t; if( !strcmp (name, "u")) return SDLK_u; if( !strcmp (name, "v")) return SDLK_v; if( !strcmp (name, "w")) return SDLK_w; if( !strcmp (name, "x")) return SDLK_x; if( !strcmp (name, "y")) return SDLK_y; if( !strcmp (name, "z")) return SDLK_z; if( !strcmp (name, "DELETE")) return SDLK_DELETE; if( !strcmp (name, "KP0")) return SDLK_KP0; if( !strcmp (name, "KP1")) return SDLK_KP1; if( !strcmp (name, "KP2")) return SDLK_KP2; if( !strcmp (name, "KP3")) return SDLK_KP3; if( !strcmp (name, "KP4")) return SDLK_KP4; if( !strcmp (name, "KP5")) return SDLK_KP5; if( !strcmp (name, "KP6")) return SDLK_KP6; if( !strcmp (name, "KP7")) return SDLK_KP7; if( !strcmp (name, "KP8")) return SDLK_KP8; if( !strcmp (name, "KP9")) return SDLK_KP9; if( !strcmp (name, "KP_PERIOD")) return SDLK_KP_PERIOD; if( !strcmp (name, "KP_DIVIDE")) return SDLK_KP_DIVIDE; if( !strcmp (name, "KP_MULTIPLY")) return SDLK_KP_MULTIPLY; if( !strcmp (name, "KP_MINUS")) return SDLK_KP_MINUS; if( !strcmp (name, "KP_PLUS")) return SDLK_KP_PLUS; if( !strcmp (name, "KP_ENTER")) return SDLK_KP_ENTER; if( !strcmp (name, "KP_EQUALS")) return SDLK_KP_EQUALS; if( !strcmp (name, "UP")) return SDLK_UP; if( !strcmp (name, "DOWN")) return SDLK_DOWN; if( !strcmp (name, "RIGHT")) return SDLK_RIGHT; if( !strcmp (name, "LEFT")) return SDLK_LEFT; if( !strcmp (name, "INSERT")) return SDLK_INSERT; if( !strcmp (name, "HOME")) return SDLK_HOME; if( !strcmp (name, "END")) return SDLK_END; if( !strcmp (name, "PAGEUP")) return SDLK_PAGEUP; if( !strcmp (name, "PAGEDOWN")) return SDLK_PAGEDOWN; if( !strcmp (name, "F1")) return SDLK_F1; if( !strcmp (name, "F2")) return SDLK_F2; if( !strcmp (name, "F3")) return SDLK_F3; if( !strcmp (name, "F4")) return SDLK_F4; if( !strcmp (name, "F5")) return SDLK_F5; if( !strcmp (name, "F6")) return SDLK_F6; if( !strcmp (name, "F7")) return SDLK_F7; if( !strcmp (name, "F8")) return SDLK_F8; if( !strcmp (name, "F9")) return SDLK_F9; if( !strcmp (name, "F10")) return SDLK_F10; if( !strcmp (name, "F11")) return SDLK_F11; if( !strcmp (name, "F12")) return SDLK_F12; if( !strcmp (name, "F13")) return SDLK_F13; if( !strcmp (name, "F14")) return SDLK_F14; if( !strcmp (name, "F15")) return SDLK_F15; if( !strcmp (name, "NUMLOCK")) return SDLK_NUMLOCK; if( !strcmp (name, "CAPSLOCK")) return SDLK_CAPSLOCK; if( !strcmp (name, "SCROLLOCK")) return SDLK_SCROLLOCK; if( !strcmp (name, "RSHIFT")) return SDLK_RSHIFT; if( !strcmp (name, "LSHIFT")) return SDLK_LSHIFT; if( !strcmp (name, "RCTRL")) return SDLK_RCTRL; if( !strcmp (name, "LCTRL")) return SDLK_LCTRL; if( !strcmp (name, "RALT")) return SDLK_RALT; if( !strcmp (name, "LALT")) return SDLK_LALT; if( !strcmp (name, "RMETA")) return SDLK_RMETA; if( !strcmp (name, "LMETA")) return SDLK_LMETA; if( !strcmp (name, "LSUPER")) return SDLK_LSUPER; if( !strcmp (name, "RSUPER")) return SDLK_RSUPER; if( !strcmp (name, "MODE")) return SDLK_MODE; if( !strcmp (name, "HELP")) return SDLK_HELP; if( !strcmp (name, "PRINT")) return SDLK_PRINT; if( !strcmp (name, "SYSREQ")) return SDLK_SYSREQ; if( !strcmp (name, "BREAK")) return SDLK_BREAK; if( !strcmp (name, "MENU")) return SDLK_MENU; if( !strcmp (name, "POWER")) return SDLK_POWER; if( !strcmp (name, "EURO")) return SDLK_EURO; return -1; } char* SDLKToKeyname( int key) { if( key == SDLK_BACKSPACE) return "BACKSPACE"; if( key == SDLK_TAB) return "TAB"; if( key == SDLK_CLEAR) return "CLEAR"; if( key == SDLK_RETURN) return "RETURN"; if( key == SDLK_SPACE) return "SPACE"; if( key == SDLK_ESCAPE) return "ESCAPE"; if( key == SDLK_EXCLAIM) return "EXCLAIM"; if( key == SDLK_QUOTEDBL) return "QUOTEDBL"; if( key == SDLK_HASH) return "HASH"; if( key == SDLK_PAUSE) return "PAUSE"; if( key == SDLK_DOLLAR) return "DOLLAR"; if( key == SDLK_AMPERSAND) return "AMPERSAND"; if( key == SDLK_QUOTE) return "QUOTE"; if( key == SDLK_LEFTPAREN) return "LEFTPAREN"; if( key == SDLK_RIGHTPAREN) return "RIGHTPAREN"; if( key == SDLK_ASTERISK) return "ASTERISK"; if( key == SDLK_PLUS) return "PLUS"; if( key == SDLK_COMMA) return "COMMA"; if( key == SDLK_MINUS) return "MINUS"; if( key == SDLK_PERIOD) return "PERIOD"; if( key == SDLK_SLASH) return "SLASH"; if( key == SDLK_0) return "0"; if( key == SDLK_1) return "1"; if( key == SDLK_2) return "2"; if( key == SDLK_3) return "3"; if( key == SDLK_4) return "4"; if( key == SDLK_5) return "5"; if( key == SDLK_6) return "6"; if( key == SDLK_7) return "7"; if( key == SDLK_8) return "8"; if( key == SDLK_9) return "9"; if( key == SDLK_COLON) return "COLON"; if( key == SDLK_SEMICOLON) return "SEMICOLON"; if( key == SDLK_LESS) return "LESS"; if( key == SDLK_EQUALS) return "EQUALS"; if( key == SDLK_GREATER) return "GREATER"; if( key == SDLK_QUESTION) return "QUESTION"; if( key == SDLK_AT) return "AT"; if( key == SDLK_LEFTBRACKET) return "LEFTBRACKET"; if( key == SDLK_BACKSLASH) return "BACKSLASH"; if( key == SDLK_RIGHTBRACKET) return "RIGHTBRACKET"; if( key == SDLK_CARET) return "CARET"; if( key == SDLK_UNDERSCORE) return "UNDERSCORE"; if( key == SDLK_BACKQUOTE) return "BACKQUOTE"; if( key == SDLK_a) return "a"; if( key == SDLK_b) return "b"; if( key == SDLK_c) return "c"; if( key == SDLK_d) return "d"; if( key == SDLK_e) return "e"; if( key == SDLK_f) return "f"; if( key == SDLK_g) return "g"; if( key == SDLK_h) return "h"; if( key == SDLK_i) return "i"; if( key == SDLK_j) return "j"; if( key == SDLK_k) return "k"; if( key == SDLK_l) return "l"; if( key == SDLK_m) return "m"; if( key == SDLK_n) return "n"; if( key == SDLK_o) return "o"; if( key == SDLK_p) return "p"; if( key == SDLK_q) return "q"; if( key == SDLK_r) return "r"; if( key == SDLK_s) return "s"; if( key == SDLK_t) return "t"; if( key == SDLK_u) return "u"; if( key == SDLK_v) return "v"; if( key == SDLK_w) return "w"; if( key == SDLK_x) return "x"; if( key == SDLK_y) return "y"; if( key == SDLK_z) return "z"; if( key == SDLK_DELETE) return "DELETE"; if( key == SDLK_KP0) return "KP0"; if( key == SDLK_KP1) return "KP1"; if( key == SDLK_KP2) return "KP2"; if( key == SDLK_KP3) return "KP3"; if( key == SDLK_KP4) return "KP4"; if( key == SDLK_KP5) return "KP5"; if( key == SDLK_KP6) return "KP6"; if( key == SDLK_KP7) return "KP7"; if( key == SDLK_KP8) return "KP8"; if( key == SDLK_KP9) return "KP9"; if( key == SDLK_KP_PERIOD) return "KP_PERIOD"; if( key == SDLK_KP_DIVIDE) return "KP_DIVIDE"; if( key == SDLK_KP_MULTIPLY) return "KP_MULTIPLY"; if( key == SDLK_KP_MINUS) return "KP_MINUS"; if( key == SDLK_KP_PLUS) return "KP_PLUS"; if( key == SDLK_KP_ENTER) return "KP_ENTER"; if( key == SDLK_KP_EQUALS) return "KP_EQUALS"; if( key == SDLK_UP) return "UP"; if( key == SDLK_DOWN) return "DOWN"; if( key == SDLK_RIGHT) return "RIGHT"; if( key == SDLK_LEFT) return "LEFT"; if( key == SDLK_INSERT) return "INSERT"; if( key == SDLK_HOME) return "HOME"; if( key == SDLK_END) return "END"; if( key == SDLK_PAGEUP) return "PAGEUP"; if( key == SDLK_PAGEDOWN) return "PAGEDOWN"; if( key == SDLK_F1) return "F1"; if( key == SDLK_F2) return "F2"; if( key == SDLK_F3) return "F3"; if( key == SDLK_F4) return "F4"; if( key == SDLK_F5) return "F5"; if( key == SDLK_F6) return "F6"; if( key == SDLK_F7) return "F7"; if( key == SDLK_F8) return "F8"; if( key == SDLK_F9) return "F9"; if( key == SDLK_F10) return "F10"; if( key == SDLK_F11) return "F11"; if( key == SDLK_F12) return "F12"; if( key == SDLK_F13) return "F13"; if( key == SDLK_F14) return "F14"; if( key == SDLK_F15) return "F15"; if( key == SDLK_NUMLOCK) return "NUMLOCK"; if( key == SDLK_CAPSLOCK) return "CAPSLOCK"; if( key == SDLK_SCROLLOCK) return "SCROLLOCK"; if( key == SDLK_RSHIFT) return "RSHIFT"; if( key == SDLK_LSHIFT) return "LSHIFT"; if( key == SDLK_RCTRL) return "RCTRL"; if( key == SDLK_LCTRL) return "LCTRL"; if( key == SDLK_RALT) return "RALT"; if( key == SDLK_LALT) return "LALT"; if( key == SDLK_RMETA) return "RMETA"; if( key == SDLK_LMETA) return "LMETA"; if( key == SDLK_LSUPER) return "LSUPER"; if( key == SDLK_RSUPER) return "RSUPER"; if( key == SDLK_MODE) return "MODE"; if( key == SDLK_HELP) return "HELP"; if( key == SDLK_PRINT) return "PRINT"; if( key == SDLK_SYSREQ) return "SYSREQ"; if( key == SDLK_BREAK) return "BREAK"; if( key == SDLK_MENU) return "MENU"; if( key == SDLK_POWER) return "POWER"; if( key == SDLK_EURO) return "EURO"; return "UNKNOWN"; }