User interfaces send scrolling to the guest as wheel buttons, one press and release per notch. A host's trackpad scrolls by points, and has the guest follow the fingers only when the guest gets the distance, and the phases of the gesture and of the momentum scrolling after it, which is what a trackpad or Virtualization.framework's pointing device gives a macOS guest. Add an input event kind for that: InputScrollEvent carries a distance in 1/256 pixel on one axis, in the direction of the wheel buttons (up and left above 0), with the gesture's phase and the momentum's. The events up to a synchronization make one report. qemu_input_queue_scroll() queues one, QMP's input-send-event and replay carry them, and the input_event_scroll trace shows them. qemu_input_scrolls_smoothly() tells a user interface whether the device that takes a console's wheel takes them too, as qemu_input_is_absolute() tells it about the pointer; where it does not, the interface keeps sending wheel buttons.
173 lines
6.5 KiB
C
173 lines
6.5 KiB
C
#ifndef INPUT_H
|
|
#define INPUT_H
|
|
|
|
#include "qapi/qapi-types-ui.h"
|
|
#include "qemu/notify.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_MASK_MTT (1<<INPUT_EVENT_KIND_MTT)
|
|
#define INPUT_EVENT_MASK_SCROLL (1 << INPUT_EVENT_KIND_SCROLL)
|
|
|
|
#define INPUT_EVENT_ABS_MIN 0x0000
|
|
#define INPUT_EVENT_ABS_MAX 0x7FFF
|
|
#define INPUT_EVENT_SLOTS_MIN 0x0
|
|
#define INPUT_EVENT_SLOTS_MAX 0xa
|
|
|
|
typedef struct QemuInputHandler QemuInputHandler;
|
|
typedef struct QemuInputHandlerState QemuInputHandlerState;
|
|
|
|
typedef struct QemuInputKeyEvent {
|
|
unsigned int key;
|
|
bool down;
|
|
} QemuInputKeyEvent;
|
|
|
|
typedef struct QemuInputEvent {
|
|
InputEventKind type;
|
|
union {
|
|
QemuInputKeyEvent key;
|
|
InputBtnEvent btn;
|
|
InputMoveEvent rel;
|
|
InputMoveEvent abs;
|
|
InputMultiTouchEvent mtt;
|
|
InputScrollEvent scroll;
|
|
};
|
|
} QemuInputEvent;
|
|
|
|
typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
|
|
QemuInputEvent *evt);
|
|
typedef void (*QemuInputHandlerSync)(DeviceState *dev);
|
|
|
|
struct QemuInputHandler {
|
|
const char *name;
|
|
uint32_t mask;
|
|
QemuInputHandlerEvent event;
|
|
QemuInputHandlerSync sync;
|
|
};
|
|
|
|
G_GNUC_WARN_UNUSED_RESULT
|
|
QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
|
|
const 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, QemuInputEvent *evt);
|
|
void qemu_input_event_send_impl(QemuConsole *src, QemuInputEvent *evt);
|
|
void qemu_input_event_sync(void);
|
|
void qemu_input_event_sync_impl(void);
|
|
|
|
void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx,
|
|
bool down);
|
|
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
|
|
void qemu_input_event_send_key_delay(uint32_t delay_ms);
|
|
int qemu_input_key_number_to_qcode(unsigned int nr);
|
|
unsigned int qemu_input_key_number_to_linux(unsigned int nr);
|
|
unsigned int qemu_input_key_value_to_linux(const KeyValue *value);
|
|
int qemu_input_linux_to_scancode(unsigned int lnx, bool down, int *codes);
|
|
int qemu_input_linux_to_qcode(unsigned int lnx);
|
|
|
|
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(const QemuConsole *con);
|
|
bool qemu_input_scrolls_smoothly(const QemuConsole *con);
|
|
int qemu_input_scale_axis(int value,
|
|
int min_in, int max_in,
|
|
int min_out, int max_out);
|
|
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
|
|
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
|
|
int min_in, int max_in);
|
|
void qemu_input_queue_mtt(QemuConsole *src, InputMultiTouchType type, int slot,
|
|
int tracking_id);
|
|
void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
|
|
int min_in, int max_in,
|
|
int slot, int tracking_id);
|
|
void qemu_input_queue_scroll(QemuConsole *src, InputAxis axis, int value,
|
|
InputScrollPhase phase,
|
|
InputScrollMomentum momentum);
|
|
|
|
/* Touch devices */
|
|
typedef struct touch_slot {
|
|
int x;
|
|
int y;
|
|
int tracking_id;
|
|
} touch_slot;
|
|
|
|
void qemu_input_touch_event(QemuConsole *con,
|
|
struct touch_slot touch_slots[INPUT_EVENT_SLOTS_MAX],
|
|
uint64_t num_slot,
|
|
int width, int height,
|
|
double x, double y,
|
|
InputMultiTouchType type,
|
|
Error **errp);
|
|
|
|
void qemu_add_mouse_mode_change_notifier(Notifier *notify);
|
|
void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
|
|
|
|
extern const guint qemu_input_map_atset1_to_linux_len;
|
|
extern const guint16 qemu_input_map_atset1_to_linux[];
|
|
|
|
extern const guint qemu_input_map_linux_to_qcode_len;
|
|
extern const guint16 qemu_input_map_linux_to_qcode[];
|
|
|
|
extern const guint qemu_input_map_linux_to_atset1_len;
|
|
extern const guint16 qemu_input_map_linux_to_atset1[];
|
|
|
|
extern const guint qemu_input_map_linux_to_atset2_len;
|
|
extern const guint16 qemu_input_map_linux_to_atset2[];
|
|
|
|
extern const guint qemu_input_map_linux_to_atset3_len;
|
|
extern const guint16 qemu_input_map_linux_to_atset3[];
|
|
|
|
extern const guint qemu_input_map_qcode_to_linux_len;
|
|
extern const guint16 qemu_input_map_qcode_to_linux[];
|
|
|
|
extern const guint qemu_input_map_linux_to_qnum_len;
|
|
extern const guint16 qemu_input_map_linux_to_qnum[];
|
|
|
|
extern const guint qemu_input_map_linux_to_sun_len;
|
|
extern const guint16 qemu_input_map_linux_to_sun[];
|
|
|
|
extern const guint qemu_input_map_qnum_to_linux_len;
|
|
extern const guint16 qemu_input_map_qnum_to_linux[];
|
|
|
|
extern const guint qemu_input_map_usb_to_linux_len;
|
|
extern const guint16 qemu_input_map_usb_to_linux[];
|
|
|
|
extern const guint qemu_input_map_win32_to_linux_len;
|
|
extern const guint16 qemu_input_map_win32_to_linux[];
|
|
|
|
extern const guint qemu_input_map_x11_to_linux_len;
|
|
extern const guint16 qemu_input_map_x11_to_linux[];
|
|
|
|
extern const guint qemu_input_map_xorgkbd_to_linux_len;
|
|
extern const guint16 qemu_input_map_xorgkbd_to_linux[];
|
|
|
|
extern const guint qemu_input_map_xorgxquartz_to_linux_len;
|
|
extern const guint16 qemu_input_map_xorgxquartz_to_linux[];
|
|
|
|
extern const guint qemu_input_map_xorgxwin_to_linux_len;
|
|
extern const guint16 qemu_input_map_xorgxwin_to_linux[];
|
|
|
|
extern const guint qemu_input_map_osx_to_linux_len;
|
|
extern const guint16 qemu_input_map_osx_to_linux[];
|
|
|
|
/**
|
|
* qemu_input_get_leds_mask() - get the LED mask for the given console
|
|
* @con: a QemuConsole or NULL
|
|
*
|
|
* If @con is NULL, returns the LED state mask for the default console.
|
|
*/
|
|
uint32_t qemu_input_get_leds_mask(const QemuConsole *con);
|
|
void qemu_input_handler_set_leds_mask(QemuInputHandlerState *s, uint32_t leds_mask);
|
|
void qemu_input_led_notifier_add(Notifier *n);
|
|
void qemu_input_led_notifier_remove(Notifier *n);
|
|
|
|
#endif /* INPUT_H */
|