diff options
Diffstat (limited to 'textscreen/txt_main.c')
-rw-r--r-- | textscreen/txt_main.c | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/textscreen/txt_main.c b/textscreen/txt_main.c index 256775a8..5682c023 100644 --- a/textscreen/txt_main.c +++ b/textscreen/txt_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: txt_main.c 291 2006-01-13 23:56:00Z fraggle $ +// $Id: txt_main.c 490 2006-05-20 16:34:34Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -49,6 +49,8 @@ #include <stdlib.h> #include <string.h> +#include "doomkeys.h" + #include "txt_main.h" #include "txt_font.h" @@ -183,6 +185,87 @@ void TXT_UpdateScreen(void) TXT_UpdateScreenArea(0, 0, TXT_SCREEN_W, TXT_SCREEN_H); } +// +// Translates the SDL key +// + +static int TranslateKey(SDL_keysym *sym) +{ + switch(sym->sym) + { + case SDLK_LEFT: return KEY_LEFTARROW; + case SDLK_RIGHT: return KEY_RIGHTARROW; + case SDLK_DOWN: return KEY_DOWNARROW; + case SDLK_UP: return KEY_UPARROW; + case SDLK_ESCAPE: return KEY_ESCAPE; + case SDLK_RETURN: return KEY_ENTER; + case SDLK_TAB: return KEY_TAB; + case SDLK_F1: return KEY_F1; + case SDLK_F2: return KEY_F2; + case SDLK_F3: return KEY_F3; + case SDLK_F4: return KEY_F4; + case SDLK_F5: return KEY_F5; + case SDLK_F6: return KEY_F6; + case SDLK_F7: return KEY_F7; + case SDLK_F8: return KEY_F8; + case SDLK_F9: return KEY_F9; + case SDLK_F10: return KEY_F10; + case SDLK_F11: return KEY_F11; + case SDLK_F12: return KEY_F12; + + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_DELETE: return KEY_DEL; + + case SDLK_PAUSE: return KEY_PAUSE; + + case SDLK_EQUALS: + case SDLK_KP_EQUALS: return KEY_EQUALS; + + case SDLK_MINUS: return KEY_MINUS; + + case SDLK_LSHIFT: + case SDLK_RSHIFT: + return KEY_RSHIFT; + + case SDLK_LCTRL: + case SDLK_RCTRL: + return KEY_RCTRL; + + case SDLK_LALT: + case SDLK_LMETA: + case SDLK_RALT: + case SDLK_RMETA: + return KEY_RALT; + + case SDLK_CAPSLOCK: return KEY_CAPSLOCK; + case SDLK_SCROLLOCK: return KEY_SCRLCK; + + case SDLK_KP0: return KEYP_0; + case SDLK_KP1: return KEYP_1; + case SDLK_KP2: return KEYP_2; + case SDLK_KP3: return KEYP_3; + case SDLK_KP4: return KEYP_4; + case SDLK_KP5: return KEYP_5; + case SDLK_KP6: return KEYP_6; + case SDLK_KP7: return KEYP_7; + case SDLK_KP8: return KEYP_8; + case SDLK_KP9: return KEYP_9; + + case SDLK_HOME: return KEY_HOME; + case SDLK_INSERT: return KEY_INS; + case SDLK_END: return KEY_END; + case SDLK_PAGEUP: return KEY_PGUP; + case SDLK_PAGEDOWN: return KEY_PGDN; + case SDLK_KP_MULTIPLY: return KEYP_MULTIPLY; + case SDLK_KP_PLUS: return KEYP_PLUS; + case SDLK_KP_MINUS: return KEYP_MINUS; + case SDLK_KP_DIVIDE: return KEYP_DIVIDE; + + default: return tolower(sym->sym); + } +} + + signed int TXT_GetChar(void) { SDL_Event ev; @@ -201,7 +284,7 @@ signed int TXT_GetChar(void) break; case SDL_KEYDOWN: - return ev.key.keysym.unicode; + return TranslateKey(&ev.key.keysym); case SDL_QUIT: // Quit = escape |