/* client/keyboard.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #include "client/keyboard.h" #include namespace client { void setkeyboardmode(bool input) { if(input) SDL_EnableKeyRepeat(250, SDL_DEFAULT_REPEAT_INTERVAL); else SDL_EnableKeyRepeat(10, SDL_DEFAULT_REPEAT_INTERVAL); } char keysym_to_char(const SDL_keysym &keysym) { char c = (char) keysym.sym; bool shiftstate = false; if (keysym.mod & KMOD_CAPS) shiftstate = true; if ((keysym.mod & KMOD_LSHIFT) || (keysym.mod & KMOD_RSHIFT)) { shiftstate = !shiftstate; } if (!shiftstate) return c; if ((c >= 'a' && c <= 'z')) { c = c + 'A' - 'a'; } else { switch (c) { case '`': c = '~'; break; case '1': c = '!'; break; case '2': c = '@'; break; case '3': c = '#'; break; case '4': c = '$'; break; case '5': c = '%'; break; case '6': c = '^'; break; case '7': c = '&'; break; case '8': c = '*'; break; case '9': c = '('; break; case '0': c = ')'; break; case '-': c = '_'; break; case '=': c = '+'; break; // second row case '[': c = '{'; break; case ']': c = '}'; break; case '|': c = '\\'; break; // third row case ';': c = ':'; break; case '\'': c = '"'; break; // fourth row case ',': c = '<'; break; case '.': c = '>'; break; case '/': c = '?'; break; } } return c; } } // namespace client