Fixed numpad usage

This commit is contained in:
George Sokianos 2022-05-02 17:50:42 +01:00
parent 1e90105944
commit 89e2defb5b
1 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,8 @@ static const char *numpad[] = { "end", "down", "pagedown", "left", "", "right",
static const char *get_key_name(const SDL_Event *e, char *buf) { static const char *get_key_name(const SDL_Event *e, char *buf) {
SDL_Scancode scancode = e->key.keysym.scancode; SDL_Scancode scancode = e->key.keysym.scancode;
#if !defined(__amigaos4__) && !defined(__MORPHOS__)
/* Is the scancode from the keypad and the number-lock off? /* Is the scancode from the keypad and the number-lock off?
** We assume that SDL_SCANCODE_KP_1 up to SDL_SCANCODE_KP_9 and SDL_SCANCODE_KP_0 ** We assume that SDL_SCANCODE_KP_1 up to SDL_SCANCODE_KP_9 and SDL_SCANCODE_KP_0
** and SDL_SCANCODE_KP_PERIOD are declared in SDL2 in that order. */ ** and SDL_SCANCODE_KP_PERIOD are declared in SDL2 in that order. */
@ -108,6 +110,8 @@ static const char *get_key_name(const SDL_Event *e, char *buf) {
!(e->key.keysym.mod & KMOD_NUM)) { !(e->key.keysym.mod & KMOD_NUM)) {
return numpad[scancode - SDL_SCANCODE_KP_1]; return numpad[scancode - SDL_SCANCODE_KP_1];
} else { } else {
#endif
/* We need to correctly handle non-standard layouts such as dvorak. /* We need to correctly handle non-standard layouts such as dvorak.
Therefore, if a Latin letter(code<128) is pressed in the current layout, Therefore, if a Latin letter(code<128) is pressed in the current layout,
then we transmit it as it is. But we also need to support shortcuts in then we transmit it as it is. But we also need to support shortcuts in
@ -119,7 +123,10 @@ static const char *get_key_name(const SDL_Event *e, char *buf) {
strcpy(buf, SDL_GetScancodeName(scancode)); strcpy(buf, SDL_GetScancodeName(scancode));
str_tolower(buf); str_tolower(buf);
return buf; return buf;
#if !defined(__amigaos4__) && !defined(__MORPHOS__)
} }
#endif
} }
static int f_poll_event(lua_State *L) { static int f_poll_event(lua_State *L) {