aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl2-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/sdl2-input.c')
-rw-r--r--ui/sdl2-input.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index 6e315ae800..605d781971 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -30,8 +30,6 @@
#include "ui/sdl2.h"
#include "sysemu/sysemu.h"
-#include "sdl2-keymap.h"
-
static uint8_t modifiers_state[SDL_NUM_SCANCODES];
void sdl2_reset_keys(struct sdl2_console *scon)
@@ -39,9 +37,11 @@ void sdl2_reset_keys(struct sdl2_console *scon)
QemuConsole *con = scon ? scon->dcl.con : NULL;
int i;
- for (i = 0; i < SDL_NUM_SCANCODES; i++) {
+ for (i = 0 ;
+ i < SDL_NUM_SCANCODES && i < qemu_input_map_usb_to_qcode_len ;
+ i++) {
if (modifiers_state[i]) {
- int qcode = sdl2_scancode_to_qcode[i];
+ int qcode = qemu_input_map_usb_to_qcode[i];
qemu_input_event_send_key_qcode(con, qcode, false);
modifiers_state[i] = 0;
}
@@ -51,9 +51,15 @@ void sdl2_reset_keys(struct sdl2_console *scon)
void sdl2_process_key(struct sdl2_console *scon,
SDL_KeyboardEvent *ev)
{
- int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
+ int qcode;
QemuConsole *con = scon ? scon->dcl.con : NULL;
+ if (ev->keysym.scancode >= qemu_input_map_usb_to_qcode_len) {
+ return;
+ }
+
+ qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode];
+
if (!qemu_console_is_graphic(con)) {
if (ev->type == SDL_KEYDOWN) {
switch (ev->keysym.scancode) {