aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-02-22 08:05:13 +0100
committerGerd Hoffmann <kraxel@redhat.com>2018-02-22 10:35:32 +0100
commitabb4f2c9655503f14dc55064f29c4f59b07e96ff (patch)
tree2de1661b57cc82aeb53d21aeac9e1c1a54dafd87 /ui/sdl.c
parent23ad24e48cf28ac2542ade657efbf7f802d7c8a0 (diff)
downloadqemu-abb4f2c9655503f14dc55064f29c4f59b07e96ff.zip
qemu-abb4f2c9655503f14dc55064f29c4f59b07e96ff.tar.gz
qemu-abb4f2c9655503f14dc55064f29c4f59b07e96ff.tar.bz2
keymap: consider modifier state when picking a mapping
Pass the modifier state to the keymap lookup function. In case multiple keysym -> keycode mappings exist look at the modifier state and prefer the mapping where the modifier state matches. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-id: 20180222070513.8740-6-kraxel@redhat.com
Diffstat (limited to 'ui/sdl.c')
-rw-r--r--ui/sdl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ui/sdl.c b/ui/sdl.c
index 963cdf7..c4ae7ab 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -201,6 +201,9 @@ static kbd_layout_t *kbd_layout = NULL;
static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
{
+ bool shift = modifiers_state[0x2a] || modifiers_state[0x36];
+ bool altgr = modifiers_state[0xb8];
+ bool ctrl = modifiers_state[0x1d] || modifiers_state[0x9d];
int keysym;
/* workaround for X11+SDL bug with AltGR */
keysym = ev->keysym.sym;
@@ -210,7 +213,8 @@ static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
if (keysym == 92 && ev->keysym.scancode == 133) {
keysym = 0xa5;
}
- return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK;
+ return keysym2scancode(kbd_layout, keysym,
+ shift, altgr, ctrl) & SCANCODE_KEYMASK;
}