Skip to content

Commit

Permalink
Handle NumPad events when NumLock is disabled
Browse files Browse the repository at this point in the history
PR #1188 <#1188>
Fixes #1048 <#1048>

Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
jaafarbi authored and rom1v committed Mar 14, 2020
1 parent ae2d094 commit a5b4324
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/src/event_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod,
MAP(SDLK_UP, AKEYCODE_DPAD_UP);
}

if (!(mod & (KMOD_NUM | KMOD_SHIFT))) {
// handle Numpad events when Num Lock is disabled
switch(from) {
MAP(SDLK_KP_0, AKEYCODE_INSERT);
MAP(SDLK_KP_1, AKEYCODE_MOVE_END);
MAP(SDLK_KP_2, AKEYCODE_DPAD_DOWN);
MAP(SDLK_KP_3, AKEYCODE_PAGE_DOWN);
MAP(SDLK_KP_4, AKEYCODE_DPAD_LEFT);
MAP(SDLK_KP_6, AKEYCODE_DPAD_RIGHT);
MAP(SDLK_KP_7, AKEYCODE_MOVE_HOME);
MAP(SDLK_KP_8, AKEYCODE_DPAD_UP);
MAP(SDLK_KP_9, AKEYCODE_PAGE_UP);
MAP(SDLK_KP_PERIOD, AKEYCODE_FORWARD_DEL);
}
}

if (prefer_text) {
// do not forward alpha and space key events
return false;
Expand All @@ -102,6 +118,7 @@ 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 ALT and META are not pressed, also handle letters and space
switch (from) {
MAP(SDLK_a, AKEYCODE_A);
Expand Down

0 comments on commit a5b4324

Please sign in to comment.