From 773a85cd2d6d95d27c3404961630babfd1ba29f2 Mon Sep 17 00:00:00 2001 From: Jipok Date: Wed, 22 Dec 2021 01:30:55 +0500 Subject: [PATCH] Support for remaped special keys(Fix #757) --- src/api/system.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/api/system.c b/src/api/system.c index cbddd5f9..ecd68270 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -109,9 +109,14 @@ static const char *get_key_name(const SDL_Event *e, char *buf) { /* We need to correctly handle non-standard layouts such as dvorak. 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 - other languages, so for non-Latin characters we pass the scancode that - matches the letter in the QWERTY layout. */ - if (e->key.keysym.sym < 128) + other languages, so for non-Latin characters(code>128) we pass the + scancode based name that matches the letter in the QWERTY layout. + + In SDL, the codes of all special buttons such as control, shift, arrows + and others, are shifted using bit mask 1<<30(SDLK_SCANCODE_MASK) outside + the unicode range(>0x10FFFF). User can remap these buttons, so we need + to give correct name, not scancode based.*/ + if ((e->key.keysym.sym < 128) || (e->key.keysym.sym & SDLK_SCANCODE_MASK)) strcpy(buf, SDL_GetKeyName(e->key.keysym.sym)); else strcpy(buf, SDL_GetScancodeName(scancode));