Linux: Fix numpad arrow keys not working when num lock is off

Fixes #857
This commit is contained in:
Kovid Goyal
2018-09-05 07:31:55 +05:30
parent b1a5e98630
commit 547959c1ef
2 changed files with 13 additions and 5 deletions

View File

@@ -10,6 +10,8 @@ Changelog
font fallback for all subsequent characters that cannot be rendered in the
main font to fail (:iss:`799`)
- Linux: Fix numpad arrow keys not working when num lock is off (:iss:`857`)
- Allow mapping shortcuts using the raw key code from the OS (:iss:`848`)
- Allow mapping of individual keypresses without modifiers as shortcuts

16
glfw/xkb_glfw.c vendored
View File

@@ -33,7 +33,7 @@
#define debug(...) if (_glfw.hints.init.debugKeyboard) printf(__VA_ARGS__);
#define map_key(key) { \
#define map_key(key) \
switch(key) { \
S(space, SPACE); \
S(apostrophe, APOSTROPHE); \
@@ -93,10 +93,6 @@
D(A, Z, A, Z); \
R(F1, F25, F1, F25); \
R(KP_0, KP_9, KP_0, KP_9); \
default: \
break; \
} \
}
static int
glfw_key_for_sym(xkb_keysym_t key) {
@@ -105,6 +101,13 @@ glfw_key_for_sym(xkb_keysym_t key) {
#define R(s, e, gs, ...) case XKB_KEY_##s ... XKB_KEY_##e: return GLFW_KEY_##gs + key - XKB_KEY_##s
#define D(s, e, gs, ...) R(s, e, gs)
map_key(key)
S(KP_Up, UP);
S(KP_Down, DOWN);
S(KP_Left, LEFT);
S(KP_Right, RIGHT);
default:
break;
}
return GLFW_KEY_UNKNOWN;
#undef F
#undef D
@@ -119,6 +122,9 @@ glfw_xkb_sym_for_key(int key) {
#define R(s, e, gs, ge) case GLFW_KEY_##gs ... GLFW_KEY_##ge: return XKB_KEY_##s + key - GLFW_KEY_##gs
#define D(...)
map_key(key)
default:
break;
}
return GLFW_KEY_UNKNOWN;
#undef F
#undef D