mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-25 04:30:02 +00:00
e0d2bd5195
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. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 1457087116-4379-2-git-send-email-kraxel@redhat.com
71 lines
3.0 KiB
C
71 lines
3.0 KiB
C
#ifndef INPUT_H
|
|
#define INPUT_H
|
|
|
|
#include "qapi-types.h"
|
|
|
|
#define INPUT_EVENT_MASK_KEY (1<<INPUT_EVENT_KIND_KEY)
|
|
#define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN)
|
|
#define INPUT_EVENT_MASK_REL (1<<INPUT_EVENT_KIND_REL)
|
|
#define INPUT_EVENT_MASK_ABS (1<<INPUT_EVENT_KIND_ABS)
|
|
|
|
#define INPUT_EVENT_ABS_SIZE 0x8000
|
|
|
|
typedef struct QemuInputHandler QemuInputHandler;
|
|
typedef struct QemuInputHandlerState QemuInputHandlerState;
|
|
|
|
typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
|
|
InputEvent *evt);
|
|
typedef void (*QemuInputHandlerSync)(DeviceState *dev);
|
|
|
|
struct QemuInputHandler {
|
|
const char *name;
|
|
uint32_t mask;
|
|
QemuInputHandlerEvent event;
|
|
QemuInputHandlerSync sync;
|
|
};
|
|
|
|
QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
|
|
QemuInputHandler *handler);
|
|
void qemu_input_handler_activate(QemuInputHandlerState *s);
|
|
void qemu_input_handler_deactivate(QemuInputHandlerState *s);
|
|
void qemu_input_handler_unregister(QemuInputHandlerState *s);
|
|
void qemu_input_handler_bind(QemuInputHandlerState *s,
|
|
const char *device_id, int head,
|
|
Error **errp);
|
|
void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
|
|
void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
|
|
void qemu_input_event_sync(void);
|
|
void qemu_input_event_sync_impl(void);
|
|
|
|
InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
|
|
void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
|
|
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
|
|
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
|
|
void qemu_input_event_send_key_delay(uint32_t delay_ms);
|
|
int qemu_input_key_number_to_qcode(uint8_t nr);
|
|
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);
|
|
|
|
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,
|
|
uint32_t button_old, uint32_t button_new);
|
|
|
|
bool qemu_input_is_absolute(void);
|
|
int qemu_input_scale_axis(int value, int size_in, int size_out);
|
|
InputEvent *qemu_input_event_new_move(InputEventKind kind,
|
|
InputAxis axis, int value);
|
|
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
|
|
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis,
|
|
int value, int size);
|
|
|
|
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 */
|