summaryrefslogtreecommitdiff
path: root/ui/sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/sdl.c')
-rw-r--r--ui/sdl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ui/sdl.c b/ui/sdl.c
index c8f102bb9f..a6bff301eb 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -242,6 +242,7 @@ static const guint16 *sdl_get_keymap(size_t *maplen)
static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
{
+ int qcode;
if (!keycode_map) {
return 0;
}
@@ -249,7 +250,13 @@ static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
return 0;
}
- return keycode_map[ev->keysym.scancode];
+ qcode = keycode_map[ev->keysym.scancode];
+
+ if (qcode > qemu_input_map_qcode_to_qnum_len) {
+ return 0;
+ }
+
+ return qemu_input_map_qcode_to_qnum[qcode];
}
static void reset_keys(void)