From 9c9eeb8c3a59c6bf1432e93eed836760c6b71573 Mon Sep 17 00:00:00 2001 From: Jaafar Biyadi Date: Sat, 29 Feb 2020 18:33:17 +0100 Subject: [PATCH 1/3] Handle events on NumPad when NumLock is disabled --- app/src/event_converter.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/event_converter.c b/app/src/event_converter.c index 80ead6153d..8e903d2fe7 100644 --- a/app/src/event_converter.c +++ b/app/src/event_converter.c @@ -102,6 +102,23 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod, if (mod & (KMOD_LALT | KMOD_RALT | KMOD_LGUI | KMOD_RGUI)) { return false; } + + if (!(mod & (KMOD_NUM | KMOD_SHIFT))) { + // handling Numpad events when Num Lock is disabled + switch(from){ + MAP(SDLK_KP_6, AKEYCODE_DPAD_RIGHT); + MAP(SDLK_KP_4, AKEYCODE_DPAD_LEFT); + MAP(SDLK_KP_2, AKEYCODE_DPAD_DOWN); + MAP(SDLK_KP_8, AKEYCODE_DPAD_UP); + MAP(SDLK_KP_7, AKEYCODE_MOVE_HOME); + MAP(SDLK_KP_1, AKEYCODE_MOVE_END); + MAP(SDLK_KP_3, AKEYCODE_PAGE_DOWN); + MAP(SDLK_KP_9, AKEYCODE_PAGE_UP); + MAP(SDLK_KP_0, AKEYCODE_INSERT); + MAP(SDLK_KP_PERIOD, AKEYCODE_FORWARD_DEL); + } + } + // if ALT and META are not pressed, also handle letters and space switch (from) { MAP(SDLK_a, AKEYCODE_A); From 197904384c600b53115c5bb4ddaa01d925f8823a Mon Sep 17 00:00:00 2001 From: Jaafar Biyadi Date: Sun, 1 Mar 2020 11:53:16 +0100 Subject: [PATCH 2/3] Solve coding style issues --- app/src/event_converter.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/event_converter.c b/app/src/event_converter.c index 8e903d2fe7..76bd8a39bd 100644 --- a/app/src/event_converter.c +++ b/app/src/event_converter.c @@ -104,20 +104,20 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod, } if (!(mod & (KMOD_NUM | KMOD_SHIFT))) { - // handling Numpad events when Num Lock is disabled + // handling Numpad events when Num Lock is disabled switch(from){ - MAP(SDLK_KP_6, AKEYCODE_DPAD_RIGHT); - MAP(SDLK_KP_4, AKEYCODE_DPAD_LEFT); - MAP(SDLK_KP_2, AKEYCODE_DPAD_DOWN); - MAP(SDLK_KP_8, AKEYCODE_DPAD_UP); - MAP(SDLK_KP_7, AKEYCODE_MOVE_HOME); - MAP(SDLK_KP_1, AKEYCODE_MOVE_END); - MAP(SDLK_KP_3, AKEYCODE_PAGE_DOWN); - MAP(SDLK_KP_9, AKEYCODE_PAGE_UP); - MAP(SDLK_KP_0, AKEYCODE_INSERT); - MAP(SDLK_KP_PERIOD, AKEYCODE_FORWARD_DEL); + MAP(SDLK_KP_6, AKEYCODE_DPAD_RIGHT); + MAP(SDLK_KP_4, AKEYCODE_DPAD_LEFT); + MAP(SDLK_KP_2, AKEYCODE_DPAD_DOWN); + MAP(SDLK_KP_8, AKEYCODE_DPAD_UP); + MAP(SDLK_KP_7, AKEYCODE_MOVE_HOME); + MAP(SDLK_KP_1, AKEYCODE_MOVE_END); + MAP(SDLK_KP_3, AKEYCODE_PAGE_DOWN); + MAP(SDLK_KP_9, AKEYCODE_PAGE_UP); + MAP(SDLK_KP_0, AKEYCODE_INSERT); + MAP(SDLK_KP_PERIOD, AKEYCODE_FORWARD_DEL); } - } + } // if ALT and META are not pressed, also handle letters and space switch (from) { From e63ca4e084a7fa4e9cdb0b3506e48938c14e59cb Mon Sep 17 00:00:00 2001 From: Jaafar Biyadi Date: Mon, 2 Mar 2020 22:22:03 +0100 Subject: [PATCH 3/3] Fix additional coding style issue --- app/src/event_converter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/event_converter.c b/app/src/event_converter.c index 76bd8a39bd..0fc8660ec5 100644 --- a/app/src/event_converter.c +++ b/app/src/event_converter.c @@ -105,7 +105,7 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod, if (!(mod & (KMOD_NUM | KMOD_SHIFT))) { // handling Numpad events when Num Lock is disabled - switch(from){ + switch(from) { MAP(SDLK_KP_6, AKEYCODE_DPAD_RIGHT); MAP(SDLK_KP_4, AKEYCODE_DPAD_LEFT); MAP(SDLK_KP_2, AKEYCODE_DPAD_DOWN);