summaryrefslogtreecommitdiff
path: root/textscreen/txt_sdl.c
diff options
context:
space:
mode:
authorSimon Howard2011-10-23 19:53:06 +0000
committerSimon Howard2011-10-23 19:53:06 +0000
commitcc87c97e4bae07238e9e1af8668944fd7805c133 (patch)
tree365d56c28649da21734fcc529c0ef0d33164ef28 /textscreen/txt_sdl.c
parent8ee96dadb97afad79ce77eef6da94a67db6be62b (diff)
downloadchocolate-doom-cc87c97e4bae07238e9e1af8668944fd7805c133.tar.gz
chocolate-doom-cc87c97e4bae07238e9e1af8668944fd7805c133.tar.bz2
chocolate-doom-cc87c97e4bae07238e9e1af8668944fd7805c133.zip
Fix numeric keypad when entering values in text boxes (thanks Twelve).
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2463
Diffstat (limited to 'textscreen/txt_sdl.c')
-rw-r--r--textscreen/txt_sdl.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index 767c9b3e..a2781ac1 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -405,25 +405,6 @@ static int TranslateKey(SDL_keysym *sym)
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_KP_PERIOD: return KEYP_PERIOD;
- 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;
- case SDLK_KP_EQUALS: return KEYP_EQUALS;
- case SDLK_KP_ENTER: return KEYP_ENTER;
-
case SDLK_HOME: return KEY_HOME;
case SDLK_INSERT: return KEY_INS;
case SDLK_END: return KEY_END;
@@ -454,7 +435,34 @@ static int TranslateKey(SDL_keysym *sym)
}
else
{
- return tolower(sym->sym);
+ // Keypad mapping is only done when we want a raw value:
+ // most of the time, the keypad should behave as it normally
+ // does.
+
+ switch (sym->sym)
+ {
+ 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_KP_PERIOD: return KEYP_PERIOD;
+ 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;
+ case SDLK_KP_EQUALS: return KEYP_EQUALS;
+ case SDLK_KP_ENTER: return KEYP_ENTER;
+
+ default:
+ return tolower(sym->sym);
+ }
}
}