summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2014-06-03 09:18:23 +0200
committerGerd Hoffmann <kraxel@redhat.com>2014-06-11 14:26:49 +0200
commit932f2d7e0f94c144e5e64adb5934922179c1c440 (patch)
treed7230a9ff4cbb9d456e95d677be4719400497b6c /ui
parentb780bf8eff43fc49b071795292dea5d05990fff3 (diff)
downloadhqemu-932f2d7e0f94c144e5e64adb5934922179c1c440.zip
hqemu-932f2d7e0f94c144e5e64adb5934922179c1c440.tar.gz
gtk: factor out keycode mapping
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index b908936..01d48cc 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -877,22 +877,18 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll,
return TRUE;
}
-static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
+static int gd_map_keycode(GtkDisplayState *s, int gdk_keycode)
{
- VirtualConsole *vc = opaque;
- GtkDisplayState *s = vc->s;
- int gdk_keycode = key->hardware_keycode;
- int i;
+ int qemu_keycode;
#ifdef _WIN32
- UINT qemu_keycode = MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC);
+ qemu_keycode = MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC);
switch (qemu_keycode) {
case 103: /* alt gr */
qemu_keycode = 56 | SCANCODE_GREY;
break;
}
#else
- int qemu_keycode;
if (gdk_keycode < 9) {
qemu_keycode = 0;
@@ -913,6 +909,19 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
}
#endif
+ return qemu_keycode;
+}
+
+static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
+{
+ VirtualConsole *vc = opaque;
+ GtkDisplayState *s = vc->s;
+ int gdk_keycode = key->hardware_keycode;
+ int qemu_keycode;
+ int i;
+
+ qemu_keycode = gd_map_keycode(s, gdk_keycode);
+
trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
OpenPOWER on IntegriCloud