input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
PATCH 1/2 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
--- include/ui/input.h | 3 ++ ui/input-keymap.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+)
include/ui/input.h +3 -0
@@ -48,6 +48,9 @@ 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_qcode_to_linux (unsigned int qcode); +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); void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
ui/input-keymap.c +145 -0
160 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/2 input: linux evdev support
This patch adds support for reading input events directly from linux evdev devices and forward them to the guest. Unlike virtio-input-host which simply passes on all events to the guest without looking at them this will interpret the events and feed them into the qemu input subsystem.
Therefore this is limited to what the qemu input subsystem and the emulated input devices are able to handle. Also there is no support for absolute coordinates (tablet/touchscreen). So we are talking here about basic mouse and keyboard support.
The advantage is that it'll work without virtio-input drivers in the guest, the events are delivered to the usual ps/2 or usb input devices (depending on what the machine happens to have). And for keyboards qemu is able to switch the keyboard between guest and host on hotkey. The hotkey is hard-coded for now (both control keys), initialy the guest owns the keyboard.
Probably most useful when assigning vga devices with vfio and using a physical monitor instead of vnc/spice/gtk as guest display.
Usage: Add '-input-linux /dev/input/event<nr>' to the qemu command line. Note that udev has rules which populate /dev/input/by-{id,path} with static names, which might be more convinient to use.
--- include/ui/input.h | 2 + qemu-options.hx | 9 +++ ui/Makefile.objs | 1 + ui/input-linux.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vl.c | 11 +++ 5 files changed, 217 insertions(+) create mode 100644 ui/input-linux.c
include/ui/input.h +2 -0
@@ -68,4 +68,6 @@ void qemu_input_check_mode_change(void);void qemu_add_mouse_mode_change_notifier (Notifier *notify);void qemu_remove_mouse_mode_change_notifier (Notifier *notify); +int input_linux_init (void *opaque,QemuOpts *opts,Error **errp); +#endif /* INPUT_H */
qemu-options.hx +9 -0
@@ -1165,6 +1165,15 @@ STEXI Set the initial graphical resolution and depth (PPC, SPARC only). ETEXI +DEF("input-linux", 1, QEMU_OPTION_input_linux, + "-input-linux <evdev>\n" + " Use input device.\n", QEMU_ARCH_ALL) +STEXI +@item -input-linux @var{dev} +@findex -input-linux +Use input device. +ETEXI + DEF("vnc", HAS_ARG, QEMU_OPTION_vnc , "-vnc display start a VNC server on display\n", QEMU_ARCH_ALL) STEXI
ui/Makefile.objs +1 -0
@@ -9,6 +9,7 @@ vnc-obj-y += vnc-jobs.o common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o common-obj-y += input.o input-keymap.o input-legacy.o +common-obj-$(CONFIG_LINUX) += input-linux.o common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o common-obj-$(CONFIG_COCOA) += cocoa.o
ui/input-linux.c new file +194 -0
194 lines not on this page · raw message
vl.c +11 -0
@@ -78,6 +78,7 @@ int main(int argc, char **argv)#include "net/slirp.h" #include "monitor/monitor.h" #include "ui/console.h" +#include "ui/input.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" #include "exec/gdbstub.h"
@@ -3739,6 +3740,12 @@ int main(int argc, char **argv, char **envp)#endif break ; } +case QEMU_OPTION_input_linux: +if (!qemu_opts_parse_noisily (qemu_find_opts ("input-linux" ), + optarg, true)) { +exit (1 ); + } +break ;case QEMU_OPTION_no_acpi: acpi_enabled =0 ;break ;
@@ -4619,6 +4626,10 @@ int main(int argc, char **argv, char **envp)qemu_spice_display_init (); }#endif +#ifdef CONFIG_LINUX +qemu_opts_foreach (qemu_find_opts ("input-linux" ), + input_linux_init,NULL , &error_fatal); +#endif if (foreach_device_config (DEV_GDB , gdbserver_start) <0 ) {exit (1 );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [vfio-users] [PATCH 2/2] input: linux evdev support
2015-11-18 20:55 GMT+03:00 Gerd Hoffmann <[email protected]>:
Quoted 6 lines
The advantage is that it'll work without virtio-input drivers in the guest, the events are delivered to the usual ps/2 or usb input devices (depending on what the machine happens to have). And for keyboards qemu is able to switch the keyboard between guest and host on hotkey. The hotkey is hard-coded for now (both control keys), initialy the guest owns the keyboard.
You might already know that there are
-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]
-ctrl-grab use Right-Ctrl to grab mouse (instead of Ctrl-Alt)
options in regular qemu. Maybe it'd be convenient to use this switch to change the "ungrab" key combination? Or make something similiar?
Personally I use SDL, and i'm pretty much happy with it except random SegFaults.(i see some connection to disk activity, however). SDL creates a surface(which is getting decorated by the WM) which grabs all the input, filters it for ctrl-alt-shift release combination, and sends it to the VM.
The other minor problem is that SDL scales mouse movements relative to surface size.
Before SDL i used qemu's default graphics with all the fancy buttons it provided(it sent the power button event too!), but it doesn't transfer audio(SDL does that) and sometimes the mouse freezes. But it specially required a "graphics" device to be attached, even if it's just -device qxl which isn't touched by the guest system at all.