summary refs log tree commit diff stats
path: root/ui/sdl2-input.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-04-09 12:02:19 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-04-09 12:02:19 +0100
commitb2c1742da0c79dd52080260edacaf0a7b6d309e5 (patch)
tree94fc8886fa904d79c5c01bf31cd65f56c54cb668 /ui/sdl2-input.c
parent2a6bcfdebe4115993a032395d459f5e0cf27a01e (diff)
parent1458da9131c39ca99699b521436d6ce72d7c7981 (diff)
downloadfocaccia-qemu-b2c1742da0c79dd52080260edacaf0a7b6d309e5.tar.gz
focaccia-qemu-b2c1742da0c79dd52080260edacaf0a7b6d309e5.zip
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180409-pull-request' into staging
sdl2: fix kbd regression (compared to sdl1), cleanups.

# gpg: Signature made Mon 09 Apr 2018 10:40:21 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20180409-pull-request:
  sdl2: drop dead code
  sdl2: drop QEMU_KEY_BACKSPACE special case
  sdl2: enable ctrl modifier keys for text consoles
  sdl2: track kbd modifier state unconditionally
  ui: add ctrl modifier support to kbd_put_qcode_console()
  sdl2: Remove unused epoxy include

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/sdl2-input.c')
-rw-r--r--ui/sdl2-input.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index 605d781971..1378b63dd9 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -60,32 +60,8 @@ void sdl2_process_key(struct sdl2_console *scon,
 
     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) {
-            case SDL_SCANCODE_RETURN:
-                kbd_put_keysym_console(con, '\n');
-                break;
-            case SDL_SCANCODE_BACKSPACE:
-                kbd_put_keysym_console(con, QEMU_KEY_BACKSPACE);
-                break;
-            default:
-                kbd_put_qcode_console(con, qcode);
-                break;
-            }
-        }
-        return;
-    }
-
+    /* modifier state tracking */
     switch (ev->keysym.scancode) {
-#if 0
-    case SDL_SCANCODE_NUMLOCKCLEAR:
-    case SDL_SCANCODE_CAPSLOCK:
-        /* SDL does not send the key up event, so we generate it */
-        qemu_input_event_send_key_qcode(con, qcode, true);
-        qemu_input_event_send_key_qcode(con, qcode, false);
-        return;
-#endif
     case SDL_SCANCODE_LCTRL:
     case SDL_SCANCODE_LSHIFT:
     case SDL_SCANCODE_LALT:
@@ -99,8 +75,26 @@ void sdl2_process_key(struct sdl2_console *scon,
         } else {
             modifiers_state[ev->keysym.scancode] = 1;
         }
-        /* fall though */
+        break;
     default:
+        /* nothing */
+        break;
+    }
+
+    if (!qemu_console_is_graphic(con)) {
+        bool ctrl = (modifiers_state[SDL_SCANCODE_LCTRL] ||
+                     modifiers_state[SDL_SCANCODE_RCTRL]);
+        if (ev->type == SDL_KEYDOWN) {
+            switch (ev->keysym.scancode) {
+            case SDL_SCANCODE_RETURN:
+                kbd_put_keysym_console(con, '\n');
+                break;
+            default:
+                kbd_put_qcode_console(con, qcode, ctrl);
+                break;
+            }
+        }
+    } else {
         qemu_input_event_send_key_qcode(con, qcode,
                                         ev->type == SDL_KEYDOWN);
     }