ui: add the infrastructure to support MT events
Add the required infrastructure to support generating multitouch events. Signed-off-by: Sergio Lopez <slp@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230526112925.38794-3-slp@redhat.com>
This commit is contained in:
parent
944ae6d9f1
commit
2bfb10dff2
@ -8,9 +8,12 @@
|
|||||||
#define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN)
|
#define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN)
|
||||||
#define INPUT_EVENT_MASK_REL (1<<INPUT_EVENT_KIND_REL)
|
#define INPUT_EVENT_MASK_REL (1<<INPUT_EVENT_KIND_REL)
|
||||||
#define INPUT_EVENT_MASK_ABS (1<<INPUT_EVENT_KIND_ABS)
|
#define INPUT_EVENT_MASK_ABS (1<<INPUT_EVENT_KIND_ABS)
|
||||||
|
#define INPUT_EVENT_MASK_MTT (1<<INPUT_EVENT_KIND_MTT)
|
||||||
|
|
||||||
#define INPUT_EVENT_ABS_MIN 0x0000
|
#define INPUT_EVENT_ABS_MIN 0x0000
|
||||||
#define INPUT_EVENT_ABS_MAX 0x7FFF
|
#define INPUT_EVENT_ABS_MAX 0x7FFF
|
||||||
|
#define INPUT_EVENT_SLOTS_MIN 0x0
|
||||||
|
#define INPUT_EVENT_SLOTS_MAX 0xa
|
||||||
|
|
||||||
typedef struct QemuInputHandler QemuInputHandler;
|
typedef struct QemuInputHandler QemuInputHandler;
|
||||||
typedef struct QemuInputHandlerState QemuInputHandlerState;
|
typedef struct QemuInputHandlerState QemuInputHandlerState;
|
||||||
|
68
qapi/ui.json
68
qapi/ui.json
@ -1055,11 +1055,13 @@
|
|||||||
#
|
#
|
||||||
# @extra: rear side button of a 5-button mouse (since 2.9)
|
# @extra: rear side button of a 5-button mouse (since 2.9)
|
||||||
#
|
#
|
||||||
|
# @touch: screen contact on a multi-touch device (since 8.1)
|
||||||
|
#
|
||||||
# Since: 2.0
|
# Since: 2.0
|
||||||
##
|
##
|
||||||
{ 'enum' : 'InputButton',
|
{ 'enum' : 'InputButton',
|
||||||
'data' : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 'side',
|
'data' : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 'side',
|
||||||
'extra', 'wheel-left', 'wheel-right' ] }
|
'extra', 'wheel-left', 'wheel-right', 'touch' ] }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @InputAxis:
|
# @InputAxis:
|
||||||
@ -1071,6 +1073,17 @@
|
|||||||
{ 'enum' : 'InputAxis',
|
{ 'enum' : 'InputAxis',
|
||||||
'data' : [ 'x', 'y' ] }
|
'data' : [ 'x', 'y' ] }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @InputMultiTouchType:
|
||||||
|
#
|
||||||
|
# Type of a multi-touch event.
|
||||||
|
#
|
||||||
|
# Since: 8.1
|
||||||
|
##
|
||||||
|
{ 'enum' : 'InputMultiTouchType',
|
||||||
|
'data' : [ 'begin', 'update', 'end', 'cancel', 'data' ] }
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @InputKeyEvent:
|
# @InputKeyEvent:
|
||||||
#
|
#
|
||||||
@ -1117,13 +1130,46 @@
|
|||||||
'data' : { 'axis' : 'InputAxis',
|
'data' : { 'axis' : 'InputAxis',
|
||||||
'value' : 'int' } }
|
'value' : 'int' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @InputMultiTouchEvent:
|
||||||
|
#
|
||||||
|
# MultiTouch input event.
|
||||||
|
#
|
||||||
|
# @slot: Which slot has generated the event.
|
||||||
|
#
|
||||||
|
# @tracking-id: ID to correlate this event with previously generated
|
||||||
|
# events.
|
||||||
|
#
|
||||||
|
# @axis: Which axis is referenced by @value.
|
||||||
|
#
|
||||||
|
# @value: Contact position.
|
||||||
|
#
|
||||||
|
# Since: 8.1
|
||||||
|
##
|
||||||
|
{ 'struct' : 'InputMultiTouchEvent',
|
||||||
|
'data' : { 'type' : 'InputMultiTouchType',
|
||||||
|
'slot' : 'int',
|
||||||
|
'tracking-id': 'int',
|
||||||
|
'axis' : 'InputAxis',
|
||||||
|
'value' : 'int' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @InputEventKind:
|
# @InputEventKind:
|
||||||
#
|
#
|
||||||
|
# @key: a keyboard input event
|
||||||
|
#
|
||||||
|
# @btn: a pointer button input event
|
||||||
|
#
|
||||||
|
# @rel: a relative pointer motion input event
|
||||||
|
#
|
||||||
|
# @abs: an absolute pointer motion input event
|
||||||
|
#
|
||||||
|
# @mtt: a multi-touch input event
|
||||||
|
#
|
||||||
# Since: 2.0
|
# Since: 2.0
|
||||||
##
|
##
|
||||||
{ 'enum': 'InputEventKind',
|
{ 'enum': 'InputEventKind',
|
||||||
'data': [ 'key', 'btn', 'rel', 'abs' ] }
|
'data': [ 'key', 'btn', 'rel', 'abs', 'mtt' ] }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @InputKeyEventWrapper:
|
# @InputKeyEventWrapper:
|
||||||
@ -1149,17 +1195,20 @@
|
|||||||
{ 'struct': 'InputMoveEventWrapper',
|
{ 'struct': 'InputMoveEventWrapper',
|
||||||
'data': { 'data': 'InputMoveEvent' } }
|
'data': { 'data': 'InputMoveEvent' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @InputMultiTouchEventWrapper:
|
||||||
|
#
|
||||||
|
# Since: 8.1
|
||||||
|
##
|
||||||
|
{ 'struct': 'InputMultiTouchEventWrapper',
|
||||||
|
'data': { 'data': 'InputMultiTouchEvent' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @InputEvent:
|
# @InputEvent:
|
||||||
#
|
#
|
||||||
# Input event union.
|
# Input event union.
|
||||||
#
|
#
|
||||||
# @type: the input type, one of:
|
# @type: the type of input event
|
||||||
#
|
|
||||||
# - 'key': Input event of Keyboard
|
|
||||||
# - 'btn': Input event of pointer buttons
|
|
||||||
# - 'rel': Input event of relative pointer motion
|
|
||||||
# - 'abs': Input event of absolute pointer motion
|
|
||||||
#
|
#
|
||||||
# Since: 2.0
|
# Since: 2.0
|
||||||
##
|
##
|
||||||
@ -1169,7 +1218,8 @@
|
|||||||
'data' : { 'key' : 'InputKeyEventWrapper',
|
'data' : { 'key' : 'InputKeyEventWrapper',
|
||||||
'btn' : 'InputBtnEventWrapper',
|
'btn' : 'InputBtnEventWrapper',
|
||||||
'rel' : 'InputMoveEventWrapper',
|
'rel' : 'InputMoveEventWrapper',
|
||||||
'abs' : 'InputMoveEventWrapper' } }
|
'abs' : 'InputMoveEventWrapper',
|
||||||
|
'mtt' : 'InputMultiTouchEventWrapper' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @input-send-event:
|
# @input-send-event:
|
||||||
|
@ -22,6 +22,7 @@ void replay_save_input_event(InputEvent *evt)
|
|||||||
InputKeyEvent *key;
|
InputKeyEvent *key;
|
||||||
InputBtnEvent *btn;
|
InputBtnEvent *btn;
|
||||||
InputMoveEvent *move;
|
InputMoveEvent *move;
|
||||||
|
InputMultiTouchEvent *mtt;
|
||||||
replay_put_dword(evt->type);
|
replay_put_dword(evt->type);
|
||||||
|
|
||||||
switch (evt->type) {
|
switch (evt->type) {
|
||||||
@ -58,6 +59,14 @@ void replay_save_input_event(InputEvent *evt)
|
|||||||
replay_put_dword(move->axis);
|
replay_put_dword(move->axis);
|
||||||
replay_put_qword(move->value);
|
replay_put_qword(move->value);
|
||||||
break;
|
break;
|
||||||
|
case INPUT_EVENT_KIND_MTT:
|
||||||
|
mtt = evt->u.mtt.data;
|
||||||
|
replay_put_dword(mtt->type);
|
||||||
|
replay_put_qword(mtt->slot);
|
||||||
|
replay_put_qword(mtt->tracking_id);
|
||||||
|
replay_put_dword(mtt->axis);
|
||||||
|
replay_put_qword(mtt->value);
|
||||||
|
break;
|
||||||
case INPUT_EVENT_KIND__MAX:
|
case INPUT_EVENT_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
break;
|
break;
|
||||||
@ -73,6 +82,7 @@ InputEvent *replay_read_input_event(void)
|
|||||||
InputBtnEvent btn;
|
InputBtnEvent btn;
|
||||||
InputMoveEvent rel;
|
InputMoveEvent rel;
|
||||||
InputMoveEvent abs;
|
InputMoveEvent abs;
|
||||||
|
InputMultiTouchEvent mtt;
|
||||||
|
|
||||||
evt.type = replay_get_dword();
|
evt.type = replay_get_dword();
|
||||||
switch (evt.type) {
|
switch (evt.type) {
|
||||||
@ -109,6 +119,14 @@ InputEvent *replay_read_input_event(void)
|
|||||||
evt.u.abs.data->axis = (InputAxis)replay_get_dword();
|
evt.u.abs.data->axis = (InputAxis)replay_get_dword();
|
||||||
evt.u.abs.data->value = replay_get_qword();
|
evt.u.abs.data->value = replay_get_qword();
|
||||||
break;
|
break;
|
||||||
|
case INPUT_EVENT_KIND_MTT:
|
||||||
|
evt.u.mtt.data = &mtt;
|
||||||
|
evt.u.mtt.data->type = (InputMultiTouchType)replay_get_dword();
|
||||||
|
evt.u.mtt.data->slot = replay_get_qword();
|
||||||
|
evt.u.mtt.data->tracking_id = replay_get_qword();
|
||||||
|
evt.u.mtt.data->axis = (InputAxis)replay_get_dword();
|
||||||
|
evt.u.mtt.data->value = replay_get_qword();
|
||||||
|
break;
|
||||||
case INPUT_EVENT_KIND__MAX:
|
case INPUT_EVENT_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
break;
|
break;
|
||||||
|
@ -212,6 +212,7 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
|
|||||||
InputKeyEvent *key;
|
InputKeyEvent *key;
|
||||||
InputBtnEvent *btn;
|
InputBtnEvent *btn;
|
||||||
InputMoveEvent *move;
|
InputMoveEvent *move;
|
||||||
|
InputMultiTouchEvent *mtt;
|
||||||
|
|
||||||
if (src) {
|
if (src) {
|
||||||
idx = qemu_console_get_index(src);
|
idx = qemu_console_get_index(src);
|
||||||
@ -250,6 +251,11 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
|
|||||||
name = InputAxis_str(move->axis);
|
name = InputAxis_str(move->axis);
|
||||||
trace_input_event_abs(idx, name, move->value);
|
trace_input_event_abs(idx, name, move->value);
|
||||||
break;
|
break;
|
||||||
|
case INPUT_EVENT_KIND_MTT:
|
||||||
|
mtt = evt->u.mtt.data;
|
||||||
|
name = InputAxis_str(mtt->axis);
|
||||||
|
trace_input_event_mtt(idx, name, mtt->value);
|
||||||
|
break;
|
||||||
case INPUT_EVENT_KIND__MAX:
|
case INPUT_EVENT_KIND__MAX:
|
||||||
/* keep gcc happy */
|
/* keep gcc happy */
|
||||||
break;
|
break;
|
||||||
|
@ -90,6 +90,7 @@ input_event_key_qcode(int conidx, const char *qcode, bool down) "con %d, key qco
|
|||||||
input_event_btn(int conidx, const char *btn, bool down) "con %d, button %s, down %d"
|
input_event_btn(int conidx, const char *btn, bool down) "con %d, button %s, down %d"
|
||||||
input_event_rel(int conidx, const char *axis, int value) "con %d, axis %s, value %d"
|
input_event_rel(int conidx, const char *axis, int value) "con %d, axis %s, value %d"
|
||||||
input_event_abs(int conidx, const char *axis, int value) "con %d, axis %s, value 0x%x"
|
input_event_abs(int conidx, const char *axis, int value) "con %d, axis %s, value 0x%x"
|
||||||
|
input_event_mtt(int conidx, const char *axis, int value) "con %d, axis %s, value 0x%x"
|
||||||
input_event_sync(void) ""
|
input_event_sync(void) ""
|
||||||
input_mouse_mode(int absolute) "absolute %d"
|
input_mouse_mode(int absolute) "absolute %d"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user