Fix qemu keymaps, part one
cover Fix qemu keymaps, part one
qemu carries a bunch of reverse keymaps in pc-bios/keymaps/, to map keysyms it receives from vnc clients back to keycodes. These keymaps seem to be buggy and incomplete at times. So, to tackle the issue once for all, I've written a tool to generate those maps from xkb keyboard layout data using libxkbcommon.
This patch series only adds the tool, it doesn't touch the maps in pc-bios/keymaps/ yet. I want some testing feedback first ...
How to test:
(1) generate a map: "qemu-keymap -f testmap -l $layout"
(2) use the map: "qemu -vnc $display -k testmap"
Gerd Hoffmann (3):
keysym: add next and prior
ui: move qemu_input_linux_to_qcode()
Add qemu-keymap tool.
configure | 23 +++++ Makefile | 5 ++ include/ui/input.h | 1 + ui/curses_keys.h | 2 + ui/vnc_keysym.h | 2 + qemu-keymap.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/input-keymap.c | 115 +++++++++++++++++++++++++ ui/input-linux.c | 113 ------------------------- 8 files changed, 391 insertions(+), 113 deletions(-) create mode 100644 qemu-keymap.c
Signature · 1 line
2.9.3
PATCH 3/3 Add qemu-keymap tool.
qemu-keymap generates qemu reverse keymaps from xkb keymaps, which can be used with the qemu "-k" command line switch.
--- configure | 23 ++++++ Makefile | 5 ++ qemu-keymap.c | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 qemu-keymap.c
configure +23 -0
@@ -292,6 +292,7 @@ vde="" vnc_sasl="" vnc_jpeg="" vnc_png="" +xkbcommon="" xen="" xen_ctrl_version="" xen_pv_domain_build="no"
@@ -2912,6 +2913,21 @@ EOF fi ########################################## +# xkbcommon probe +if test "$xkbcommon" != "no" ; then + if $pkg_config xkbcommon --exists; then + xkbcommon_cflags=$($pkg_config xkbcommon --cflags) + xkbcommon_libs=$($pkg_config xkbcommon --libs) + xkbcommon=yes + else + if test "$xkbcommon" = "yes" ; then + feature_not_found "xkbcommon" "Install libxkbcommon-devel" + fi + xkbcommon=no + fi +fi + +########################################## # fnmatch() probe, used for ACL routines fnmatch="no" cat > $TMPC << EOF
@@ -5066,6 +5082,9 @@ if test "$softmmu" = yes ; then fi fi fi +if test "$xkbcommon" = "yes"; then + tools="qemu-keymap\$(EXESUF) $tools" +fi # Probe for guest agent support/options
@@ -5562,6 +5581,10 @@ fi if test "$vnc_png" = "yes" ; then echo "CONFIG_VNC_PNG=y" >> $config_host_mak fi +if test "$xkbcommon" = "yes" ; then + echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak + echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak +fi if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi
Makefile +5 -0
@@ -381,6 +381,8 @@ qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) +qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o + fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
@@ -390,6 +392,9 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated +qemu-keymap$(EXESUF): LIBS = $(XKBCOMMON_LIBS) +qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS) + gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
qemu-keymap.c new file +243 -0
243 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 2/3 ui: move qemu_input_linux_to_qcode()
In reply to Gerd HoffmannMove from input-linux.c to input-keymap.c and export it, so the function is available elsewhere too.
--- include/ui/input.h | 1 + ui/input-keymap.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/input-linux.c | 113 ---------------------------------------------------- 3 files changed, 116 insertions(+), 113 deletions(-)
include/ui/input.h +1 -0
@@ -48,6 +48,7 @@ int qemu_input_key_value_to_number(const KeyValue *value);int qemu_input_key_value_to_qcode (const KeyValue *value);int qemu_input_key_value_to_scancode (const KeyValue *value,bool down,int *codes); +int qemu_input_linux_to_qcode (unsigned int lnx);InputEvent *qemu_input_event_new_btn (InputButton btn,bool down);void qemu_input_queue_btn (QemuConsole *src,InputButton btn,bool down);
ui/input-keymap.c +115 -0
127 lines not on this page · raw message
ui/input-linux.c +0 -113
119 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 1/3 keysym: add next and prior
In reply to Gerd HoffmannPage-up and Page-down where renamed. Add the names to the keysym list so we can parse both old and new names. The keypad versions are already present in the vnc map.
--- ui/curses_keys.h | 2 ++ ui/vnc_keysym.h | 2 ++ 2 files changed, 4 insertions(+)
ui/curses_keys.h +2 -0
@@ -480,7 +480,9 @@ static const name2keysym_t name2keysym[] = { { "Left", KEY_LEFT }, { "Up", KEY_UP }, { "Down", KEY_DOWN }, + { "Next", KEY_NPAGE }, { "Page_Down", KEY_NPAGE }, + { "Prior", KEY_PPAGE }, { "Page_Up", KEY_PPAGE }, { "Insert", KEY_IC }, { "Delete", KEY_DC },
ui/vnc_keysym.h +2 -0
@@ -254,7 +254,9 @@ static const name2keysym_t name2keysym[]={ {"Left", 0xff51}, /* XK_Left */ {"Up", 0xff52}, /* XK_Up */ {"Down", 0xff54}, /* XK_Down */ +{"Next", 0xff56}, {"Page_Down", 0xff56}, /* XK_Page_Down */ +{"Prior", 0xff55}, {"Page_Up", 0xff55}, /* XK_Page_Up */ {"Insert", 0xff63}, /* XK_Insert */ {"Delete", 0xffff}, /* XK_Delete */
Signature · 1 line
2.9.3
Quoted 8 lines · Gerd Hoffmann
qemu carries a bunch of reverse keymaps in pc-bios/keymaps/, to map keysyms it receives from vnc clients back to keycodes. These keymaps seem to be buggy and incomplete at times. So, to tackle the issue once for all, I've written a tool to generate those maps from xkb keyboard layout data using libxkbcommon.
This patch series only adds the tool, it doesn't touch the maps in pc-bios/keymaps/ yet. I want some testing feedback first ...
Hmm, we recently split out the keymap database and code for generating lookup tables (that was duplicated across spice-gtk, gtk-vnc, and libvirt) into a shared git sub-module
https://gitlab.com/keycodemap/keycodemapdb/
some other VNC clients were also switching to its use.
I was coincidentally working on a patch to get QEMU to use this too, so all projects are aligned on the same data maps and thus share fixes in this area.
IMHO that'd be preferable than doing something custom in QEMU only.
Quoted 8 lines
How to test:
(1) generate a map: "qemu-keymap -f testmap -l $layout"
(2) use the map: "qemu -vnc $display -k testmap"Gerd Hoffmann (3):
keysym: add next and prior
ui: moveqemu_input_linux_to_qcode()
Add qemu-keymap tool.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 16 lines · Daniel P. Berrange
Quoted 8 lines · Gerd Hoffmann
qemu carries a bunch of reverse keymaps in pc-bios/keymaps/, to map keysyms it receives from vnc clients back to keycodes. These keymaps seem to be buggy and incomplete at times. So, to tackle the issue once for all, I've written a tool to generate those maps from xkb keyboard layout data using libxkbcommon.
This patch series only adds the tool, it doesn't touch the maps in pc-bios/keymaps/ yet. I want some testing feedback first ...
Hmm, we recently split out the keymap database and code for generating lookup tables (that was duplicated across spice-gtk, gtk-vnc, and libvirt) into a shared git sub-module
Quoted 7 lines
some other VNC clients were also switching to its use.
I was coincidentally working on a patch to get QEMU to use this too, so all projects are aligned on the same data maps and thus share fixes in this area.
IMHO that'd be preferable than doing something custom in QEMU only.
Oh actually ignore that - we're talking about different areas of keymapping. The stuff I was doing was primarily targetted as the SDL / GTK frontends in QEMU which must convert from X/GTK key maps to QEMU's XT keycodes, where as you were talking about the VNC keymaps when not using the QEMU scancode extension for VNC. So they're complementary, not mutually exclusive.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 21 lines · Daniel P. Berrange
Quoted 11 lines · Gerd Hoffmann
qemu carries a bunch of reverse keymaps in pc-bios/keymaps/, to map keysyms it receives from vnc clients back to keycodes. These keymaps
seem to be buggy and incomplete at times. So, to tackle the issue once
for all, I've written a tool to generate those maps from xkb keyboard
layout data using libxkbcommon.This patch series only adds the tool, it doesn't touch the maps in pc-bios/keymaps/ yet. I want some testing feedback first ...
Hmm, we recently split out the keymap database and code for generating
lookup tables (that was duplicated across spice-gtk, gtk-vnc, and libvirt)
into a shared git sub-module
Quoted 8 lines
some other VNC clients were also switching to its use.
I was coincidentally working on a patch to get QEMU to use this too, so all projects are aligned on the same data maps and thus share fixes
in this area.IMHO that'd be preferable than doing something custom in QEMU only.
This is a different issue. gtk-vnc & friends have to map keycodes from one system (ps/2, evdev, xorg, ...) to another. qemu has to map keysyms back to keycodes, using a reverse keymap, in case the vnc client doesn't support VNC_ENCODING_EXT_KEY_EVENT.
cheers,
Gerd