2016-01-29 18:49:51 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-11-27 10:35:26 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2018-02-01 12:18:31 +01:00
|
|
|
#include "qapi/error.h"
|
2018-02-11 10:36:01 +01:00
|
|
|
#include "qapi/qapi-commands-ui.h"
|
2013-12-04 15:20:05 +01:00
|
|
|
#include "trace.h"
|
2013-11-27 10:35:26 +01:00
|
|
|
#include "ui/input.h"
|
2013-12-04 15:20:05 +01:00
|
|
|
#include "ui/console.h"
|
2015-09-17 18:25:24 +02:00
|
|
|
#include "sysemu/replay.h"
|
2019-08-12 07:23:59 +02:00
|
|
|
#include "sysemu/runstate.h"
|
2013-11-27 10:35:26 +01:00
|
|
|
|
|
|
|
struct QemuInputHandlerState {
|
|
|
|
DeviceState *dev;
|
|
|
|
QemuInputHandler *handler;
|
|
|
|
int id;
|
|
|
|
int events;
|
2014-05-19 15:18:37 +02:00
|
|
|
QemuConsole *con;
|
2013-11-27 10:35:26 +01:00
|
|
|
QTAILQ_ENTRY(QemuInputHandlerState) node;
|
|
|
|
};
|
2014-05-28 13:02:40 +02:00
|
|
|
|
|
|
|
typedef struct QemuInputEventQueue QemuInputEventQueue;
|
2018-12-06 11:56:15 +01:00
|
|
|
typedef QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue)
|
|
|
|
QemuInputEventQueueHead;
|
|
|
|
|
2014-05-28 13:02:40 +02:00
|
|
|
struct QemuInputEventQueue {
|
|
|
|
enum {
|
|
|
|
QEMU_INPUT_QUEUE_DELAY = 1,
|
|
|
|
QEMU_INPUT_QUEUE_EVENT,
|
|
|
|
QEMU_INPUT_QUEUE_SYNC,
|
|
|
|
} type;
|
|
|
|
QEMUTimer *timer;
|
|
|
|
uint32_t delay_ms;
|
|
|
|
QemuConsole *src;
|
|
|
|
InputEvent *evt;
|
|
|
|
QTAILQ_ENTRY(QemuInputEventQueue) node;
|
|
|
|
};
|
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
|
|
|
|
QTAILQ_HEAD_INITIALIZER(handlers);
|
2013-12-05 11:23:42 +01:00
|
|
|
static NotifierList mouse_mode_notifiers =
|
|
|
|
NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
|
2013-11-27 10:35:26 +01:00
|
|
|
|
2018-12-06 11:56:15 +01:00
|
|
|
static QemuInputEventQueueHead kbd_queue = QTAILQ_HEAD_INITIALIZER(kbd_queue);
|
2014-05-28 13:02:40 +02:00
|
|
|
static QEMUTimer *kbd_timer;
|
|
|
|
static uint32_t kbd_default_delay_ms = 10;
|
2017-04-28 10:42:37 +02:00
|
|
|
static uint32_t queue_count;
|
|
|
|
static uint32_t queue_limit = 1024;
|
2014-05-28 13:02:40 +02:00
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
|
|
|
|
QemuInputHandler *handler)
|
|
|
|
{
|
|
|
|
QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
|
|
|
|
static int id = 1;
|
|
|
|
|
|
|
|
s->dev = dev;
|
|
|
|
s->handler = handler;
|
|
|
|
s->id = id++;
|
|
|
|
QTAILQ_INSERT_TAIL(&handlers, s, node);
|
2013-12-05 11:23:42 +01:00
|
|
|
|
2023-09-21 10:29:34 +02:00
|
|
|
notifier_list_notify(&mouse_mode_notifiers, NULL);
|
2013-11-27 10:35:26 +01:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_handler_activate(QemuInputHandlerState *s)
|
|
|
|
{
|
|
|
|
QTAILQ_REMOVE(&handlers, s, node);
|
|
|
|
QTAILQ_INSERT_HEAD(&handlers, s, node);
|
2023-09-21 10:29:34 +02:00
|
|
|
notifier_list_notify(&mouse_mode_notifiers, NULL);
|
2013-11-27 10:35:26 +01:00
|
|
|
}
|
|
|
|
|
2014-03-16 00:38:45 +01:00
|
|
|
void qemu_input_handler_deactivate(QemuInputHandlerState *s)
|
|
|
|
{
|
|
|
|
QTAILQ_REMOVE(&handlers, s, node);
|
|
|
|
QTAILQ_INSERT_TAIL(&handlers, s, node);
|
2023-09-21 10:29:34 +02:00
|
|
|
notifier_list_notify(&mouse_mode_notifiers, NULL);
|
2014-03-16 00:38:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
void qemu_input_handler_unregister(QemuInputHandlerState *s)
|
|
|
|
{
|
|
|
|
QTAILQ_REMOVE(&handlers, s, node);
|
|
|
|
g_free(s);
|
2023-09-21 10:29:34 +02:00
|
|
|
notifier_list_notify(&mouse_mode_notifiers, NULL);
|
2013-11-27 10:35:26 +01:00
|
|
|
}
|
|
|
|
|
2014-05-19 15:18:37 +02:00
|
|
|
void qemu_input_handler_bind(QemuInputHandlerState *s,
|
|
|
|
const char *device_id, int head,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
QemuConsole *con;
|
2016-01-12 11:45:43 +01:00
|
|
|
Error *err = NULL;
|
2014-05-19 15:18:37 +02:00
|
|
|
|
2016-01-12 11:45:43 +01:00
|
|
|
con = qemu_console_lookup_by_device_name(device_id, head, &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
2014-05-19 15:18:37 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->con = con;
|
|
|
|
}
|
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
static QemuInputHandlerState*
|
2014-05-19 15:18:37 +02:00
|
|
|
qemu_input_find_handler(uint32_t mask, QemuConsole *con)
|
2013-11-27 10:35:26 +01:00
|
|
|
{
|
|
|
|
QemuInputHandlerState *s;
|
|
|
|
|
|
|
|
QTAILQ_FOREACH(s, &handlers, node) {
|
2014-05-19 15:18:37 +02:00
|
|
|
if (s->con == NULL || s->con != con) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (mask & s->handler->mask) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QTAILQ_FOREACH(s, &handlers, node) {
|
|
|
|
if (s->con != NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-11-27 10:35:26 +01:00
|
|
|
if (mask & s->handler->mask) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-11-04 17:07:09 +01:00
|
|
|
void qmp_input_send_event(const char *device,
|
2016-01-12 12:39:33 +01:00
|
|
|
bool has_head, int64_t head,
|
|
|
|
InputEventList *events, Error **errp)
|
2014-09-30 23:10:17 +02:00
|
|
|
{
|
|
|
|
InputEventList *e;
|
|
|
|
QemuConsole *con;
|
2016-01-12 12:11:14 +01:00
|
|
|
Error *err = NULL;
|
2014-09-30 23:10:17 +02:00
|
|
|
|
QMP/input-send-event: make console parameter optional
The 'QemuConsole' is the input source for handler, we share some
input handlers to process the input events from different QemuConsole.
Normally we only have one set of keyboard, mouse, usbtablet, etc.
The devices have different mask, it's fine to just checking mask to
insure that the handler has the ability to process the event.
I saw we try to bind console to handler in usb/dev-hid.c, but display
always isn't available at that time.
If we have multiseat setup (as Gerd said), we only have 'problem' in
this case. Actually event from different devices have the same effect
for system, it's fine to always use the first available handler
without caring about the console.
For send-key command, we just pass a NULL for console parameter in
calling qemu_input_event_send_key(NULL, ..), but 'input-send-event'
needs to care more devices.
Conclusion:
Generally assigning the special console is meanless, and we can't
directly remove the QMP parameter for compatibility.
So we can make the parameter optional. The parameter might be useful
for some special condition: we have multiple devices without binding
console and they all have the ability(mask) to process events, and
we don't want to use the first one.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-07 05:41:25 +01:00
|
|
|
con = NULL;
|
2022-11-04 17:07:09 +01:00
|
|
|
if (device) {
|
2016-01-12 12:11:14 +01:00
|
|
|
if (!has_head) {
|
|
|
|
head = 0;
|
|
|
|
}
|
|
|
|
con = qemu_console_lookup_by_device_name(device, head, &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
QMP/input-send-event: make console parameter optional
The 'QemuConsole' is the input source for handler, we share some
input handlers to process the input events from different QemuConsole.
Normally we only have one set of keyboard, mouse, usbtablet, etc.
The devices have different mask, it's fine to just checking mask to
insure that the handler has the ability to process the event.
I saw we try to bind console to handler in usb/dev-hid.c, but display
always isn't available at that time.
If we have multiseat setup (as Gerd said), we only have 'problem' in
this case. Actually event from different devices have the same effect
for system, it's fine to always use the first available handler
without caring about the console.
For send-key command, we just pass a NULL for console parameter in
calling qemu_input_event_send_key(NULL, ..), but 'input-send-event'
needs to care more devices.
Conclusion:
Generally assigning the special console is meanless, and we can't
directly remove the QMP parameter for compatibility.
So we can make the parameter optional. The parameter might be useful
for some special condition: we have multiple devices without binding
console and they all have the ability(mask) to process events, and
we don't want to use the first one.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-07 05:41:25 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-09-30 23:10:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
|
|
|
|
error_setg(errp, "VM not running");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (e = events; e != NULL; e = e->next) {
|
|
|
|
InputEvent *event = e->value;
|
|
|
|
|
2015-10-26 23:34:58 +01:00
|
|
|
if (!qemu_input_find_handler(1 << event->type, con)) {
|
2014-09-30 23:10:17 +02:00
|
|
|
error_setg(errp, "Input handler not found for "
|
|
|
|
"event type %s",
|
2017-08-24 10:46:08 +02:00
|
|
|
InputEventKind_str(event->type));
|
2014-09-30 23:10:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (e = events; e != NULL; e = e->next) {
|
2017-09-29 12:12:00 +02:00
|
|
|
InputEvent *evt = e->value;
|
|
|
|
|
|
|
|
if (evt->type == INPUT_EVENT_KIND_KEY &&
|
|
|
|
evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER) {
|
|
|
|
KeyValue *key = evt->u.key.data->key;
|
2017-10-19 16:28:42 +02:00
|
|
|
QKeyCode code = qemu_input_key_number_to_qcode(key->u.number.data);
|
2017-09-29 12:12:00 +02:00
|
|
|
qemu_input_event_send_key_qcode(con, code, evt->u.key.data->down);
|
|
|
|
} else {
|
|
|
|
qemu_input_event_send(con, evt);
|
|
|
|
}
|
2014-09-30 23:10:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qemu_input_event_sync();
|
|
|
|
}
|
|
|
|
|
2017-05-05 15:39:52 +02:00
|
|
|
static int qemu_input_transform_invert_abs_value(int value)
|
|
|
|
{
|
|
|
|
return (int64_t)INPUT_EVENT_ABS_MAX - value + INPUT_EVENT_ABS_MIN;
|
|
|
|
}
|
|
|
|
|
2013-11-28 11:29:33 +01:00
|
|
|
static void qemu_input_transform_abs_rotate(InputEvent *evt)
|
|
|
|
{
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
InputMoveEvent *move = evt->u.abs.data;
|
2013-11-28 11:29:33 +01:00
|
|
|
switch (graphic_rotate) {
|
|
|
|
case 90:
|
2016-03-03 17:16:49 +01:00
|
|
|
if (move->axis == INPUT_AXIS_X) {
|
|
|
|
move->axis = INPUT_AXIS_Y;
|
|
|
|
} else if (move->axis == INPUT_AXIS_Y) {
|
|
|
|
move->axis = INPUT_AXIS_X;
|
2017-05-05 15:39:52 +02:00
|
|
|
move->value = qemu_input_transform_invert_abs_value(move->value);
|
2013-11-28 11:29:33 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 180:
|
2017-05-05 15:39:52 +02:00
|
|
|
move->value = qemu_input_transform_invert_abs_value(move->value);
|
2013-11-28 11:29:33 +01:00
|
|
|
break;
|
|
|
|
case 270:
|
2016-03-03 17:16:49 +01:00
|
|
|
if (move->axis == INPUT_AXIS_X) {
|
|
|
|
move->axis = INPUT_AXIS_Y;
|
2017-05-05 15:39:52 +02:00
|
|
|
move->value = qemu_input_transform_invert_abs_value(move->value);
|
2016-03-03 17:16:49 +01:00
|
|
|
} else if (move->axis == INPUT_AXIS_Y) {
|
|
|
|
move->axis = INPUT_AXIS_X;
|
2013-11-28 11:29:33 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-04 15:20:05 +01:00
|
|
|
static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
|
|
|
|
{
|
|
|
|
const char *name;
|
2014-05-21 13:49:59 +02:00
|
|
|
int qcode, idx = -1;
|
2016-03-03 17:16:49 +01:00
|
|
|
InputKeyEvent *key;
|
|
|
|
InputBtnEvent *btn;
|
|
|
|
InputMoveEvent *move;
|
2023-05-26 13:29:21 +02:00
|
|
|
InputMultiTouchEvent *mtt;
|
2013-12-04 15:20:05 +01:00
|
|
|
|
|
|
|
if (src) {
|
|
|
|
idx = qemu_console_get_index(src);
|
|
|
|
}
|
2015-10-26 23:34:58 +01:00
|
|
|
switch (evt->type) {
|
2013-12-04 15:20:05 +01:00
|
|
|
case INPUT_EVENT_KIND_KEY:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
key = evt->u.key.data;
|
2016-03-03 17:16:49 +01:00
|
|
|
switch (key->key->type) {
|
2013-12-04 15:20:05 +01:00
|
|
|
case KEY_VALUE_KIND_NUMBER:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
qcode = qemu_input_key_number_to_qcode(key->key->u.number.data);
|
2017-08-24 10:46:08 +02:00
|
|
|
name = QKeyCode_str(qcode);
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
trace_input_event_key_number(idx, key->key->u.number.data,
|
2016-03-03 17:16:49 +01:00
|
|
|
name, key->down);
|
2013-12-04 15:20:05 +01:00
|
|
|
break;
|
|
|
|
case KEY_VALUE_KIND_QCODE:
|
2017-08-24 10:46:08 +02:00
|
|
|
name = QKeyCode_str(key->key->u.qcode.data);
|
2016-03-03 17:16:49 +01:00
|
|
|
trace_input_event_key_qcode(idx, name, key->down);
|
2013-12-04 15:20:05 +01:00
|
|
|
break;
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 09:52:57 +01:00
|
|
|
case KEY_VALUE_KIND__MAX:
|
2013-12-04 15:20:05 +01:00
|
|
|
/* keep gcc happy */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INPUT_EVENT_KIND_BTN:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
btn = evt->u.btn.data;
|
2017-08-24 10:46:08 +02:00
|
|
|
name = InputButton_str(btn->button);
|
2016-03-03 17:16:49 +01:00
|
|
|
trace_input_event_btn(idx, name, btn->down);
|
2013-12-04 15:20:05 +01:00
|
|
|
break;
|
|
|
|
case INPUT_EVENT_KIND_REL:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
move = evt->u.rel.data;
|
2017-08-24 10:46:08 +02:00
|
|
|
name = InputAxis_str(move->axis);
|
2016-03-03 17:16:49 +01:00
|
|
|
trace_input_event_rel(idx, name, move->value);
|
2013-12-04 15:20:05 +01:00
|
|
|
break;
|
|
|
|
case INPUT_EVENT_KIND_ABS:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
move = evt->u.abs.data;
|
2017-08-24 10:46:08 +02:00
|
|
|
name = InputAxis_str(move->axis);
|
2016-03-03 17:16:49 +01:00
|
|
|
trace_input_event_abs(idx, name, move->value);
|
2013-12-04 15:20:05 +01:00
|
|
|
break;
|
2023-05-26 13:29:21 +02:00
|
|
|
case INPUT_EVENT_KIND_MTT:
|
|
|
|
mtt = evt->u.mtt.data;
|
|
|
|
name = InputAxis_str(mtt->axis);
|
|
|
|
trace_input_event_mtt(idx, name, mtt->value);
|
|
|
|
break;
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 09:52:57 +01:00
|
|
|
case INPUT_EVENT_KIND__MAX:
|
2013-12-04 15:20:05 +01:00
|
|
|
/* keep gcc happy */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 13:02:40 +02:00
|
|
|
static void qemu_input_queue_process(void *opaque)
|
|
|
|
{
|
2018-12-06 11:56:15 +01:00
|
|
|
QemuInputEventQueueHead *queue = opaque;
|
2014-05-28 13:02:40 +02:00
|
|
|
QemuInputEventQueue *item;
|
|
|
|
|
|
|
|
g_assert(!QTAILQ_EMPTY(queue));
|
|
|
|
item = QTAILQ_FIRST(queue);
|
|
|
|
g_assert(item->type == QEMU_INPUT_QUEUE_DELAY);
|
|
|
|
QTAILQ_REMOVE(queue, item, node);
|
2017-06-22 09:41:58 +02:00
|
|
|
queue_count--;
|
2014-05-28 13:02:40 +02:00
|
|
|
g_free(item);
|
|
|
|
|
|
|
|
while (!QTAILQ_EMPTY(queue)) {
|
|
|
|
item = QTAILQ_FIRST(queue);
|
|
|
|
switch (item->type) {
|
|
|
|
case QEMU_INPUT_QUEUE_DELAY:
|
2018-10-17 10:24:18 +02:00
|
|
|
timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)
|
2014-05-28 13:02:40 +02:00
|
|
|
+ item->delay_ms);
|
|
|
|
return;
|
|
|
|
case QEMU_INPUT_QUEUE_EVENT:
|
|
|
|
qemu_input_event_send(item->src, item->evt);
|
|
|
|
qapi_free_InputEvent(item->evt);
|
|
|
|
break;
|
|
|
|
case QEMU_INPUT_QUEUE_SYNC:
|
|
|
|
qemu_input_event_sync();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QTAILQ_REMOVE(queue, item, node);
|
2017-04-28 10:42:37 +02:00
|
|
|
queue_count--;
|
2014-05-28 13:02:40 +02:00
|
|
|
g_free(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 11:56:15 +01:00
|
|
|
static void qemu_input_queue_delay(QemuInputEventQueueHead *queue,
|
2014-05-28 13:02:40 +02:00
|
|
|
QEMUTimer *timer, uint32_t delay_ms)
|
|
|
|
{
|
|
|
|
QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
|
|
|
|
bool start_timer = QTAILQ_EMPTY(queue);
|
|
|
|
|
|
|
|
item->type = QEMU_INPUT_QUEUE_DELAY;
|
|
|
|
item->delay_ms = delay_ms;
|
|
|
|
item->timer = timer;
|
|
|
|
QTAILQ_INSERT_TAIL(queue, item, node);
|
2017-04-28 10:42:37 +02:00
|
|
|
queue_count++;
|
2014-05-28 13:02:40 +02:00
|
|
|
|
|
|
|
if (start_timer) {
|
2018-10-17 10:24:18 +02:00
|
|
|
timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)
|
2014-05-28 13:02:40 +02:00
|
|
|
+ item->delay_ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 11:56:15 +01:00
|
|
|
static void qemu_input_queue_event(QemuInputEventQueueHead *queue,
|
2014-05-28 13:02:40 +02:00
|
|
|
QemuConsole *src, InputEvent *evt)
|
|
|
|
{
|
|
|
|
QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
|
|
|
|
|
|
|
|
item->type = QEMU_INPUT_QUEUE_EVENT;
|
|
|
|
item->src = src;
|
|
|
|
item->evt = evt;
|
|
|
|
QTAILQ_INSERT_TAIL(queue, item, node);
|
2017-04-28 10:42:37 +02:00
|
|
|
queue_count++;
|
2014-05-28 13:02:40 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 11:56:15 +01:00
|
|
|
static void qemu_input_queue_sync(QemuInputEventQueueHead *queue)
|
2014-05-28 13:02:40 +02:00
|
|
|
{
|
|
|
|
QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
|
|
|
|
|
|
|
|
item->type = QEMU_INPUT_QUEUE_SYNC;
|
|
|
|
QTAILQ_INSERT_TAIL(queue, item, node);
|
2017-04-28 10:42:37 +02:00
|
|
|
queue_count++;
|
2014-05-28 13:02:40 +02:00
|
|
|
}
|
|
|
|
|
2015-09-17 18:25:24 +02:00
|
|
|
void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt)
|
2013-11-27 10:35:26 +01:00
|
|
|
{
|
|
|
|
QemuInputHandlerState *s;
|
|
|
|
|
2013-12-04 15:20:05 +01:00
|
|
|
qemu_input_event_trace(src, evt);
|
|
|
|
|
2013-11-28 11:29:33 +01:00
|
|
|
/* pre processing */
|
2015-10-26 23:34:58 +01:00
|
|
|
if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) {
|
2013-11-28 11:29:33 +01:00
|
|
|
qemu_input_transform_abs_rotate(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send event */
|
2015-10-26 23:34:58 +01:00
|
|
|
s = qemu_input_find_handler(1 << evt->type, src);
|
2014-03-31 16:07:30 +02:00
|
|
|
if (!s) {
|
|
|
|
return;
|
|
|
|
}
|
2013-11-27 10:35:26 +01:00
|
|
|
s->handler->event(s->dev, src, evt);
|
|
|
|
s->events++;
|
|
|
|
}
|
|
|
|
|
2015-09-17 18:25:24 +02:00
|
|
|
void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
|
2013-11-27 10:35:26 +01:00
|
|
|
{
|
2017-09-29 12:12:00 +02:00
|
|
|
/* Expect all parts of QEMU to send events with QCodes exclusively.
|
|
|
|
* Key numbers are only supported as end-user input via QMP */
|
|
|
|
assert(!(evt->type == INPUT_EVENT_KIND_KEY &&
|
|
|
|
evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER));
|
|
|
|
|
2017-10-19 16:28:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 'sysrq' was mistakenly added to hack around the fact that
|
|
|
|
* the ps2 driver was not generating correct scancodes sequences
|
|
|
|
* when 'alt+print' was pressed. This flaw is now fixed and the
|
|
|
|
* 'sysrq' key serves no further purpose. We normalize it to
|
|
|
|
* 'print', so that downstream receivers of the event don't
|
2022-06-14 12:40:44 +02:00
|
|
|
* need to deal with this mistake
|
2017-10-19 16:28:47 +02:00
|
|
|
*/
|
|
|
|
if (evt->type == INPUT_EVENT_KIND_KEY &&
|
|
|
|
evt->u.key.data->key->u.qcode.data == Q_KEY_CODE_SYSRQ) {
|
|
|
|
evt->u.key.data->key->u.qcode.data = Q_KEY_CODE_PRINT;
|
|
|
|
}
|
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-17 18:25:24 +02:00
|
|
|
replay_input_event(src, evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_event_sync_impl(void)
|
|
|
|
{
|
|
|
|
QemuInputHandlerState *s;
|
|
|
|
|
2013-12-04 15:20:05 +01:00
|
|
|
trace_input_event_sync();
|
|
|
|
|
2013-11-27 10:35:26 +01:00
|
|
|
QTAILQ_FOREACH(s, &handlers, node) {
|
|
|
|
if (!s->events) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (s->handler->sync) {
|
|
|
|
s->handler->sync(s->dev);
|
|
|
|
}
|
|
|
|
s->events = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-11-27 11:38:47 +01:00
|
|
|
|
2015-09-17 18:25:24 +02:00
|
|
|
void qemu_input_event_sync(void)
|
|
|
|
{
|
|
|
|
if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
replay_input_sync_event();
|
|
|
|
}
|
|
|
|
|
2017-09-29 12:12:01 +02:00
|
|
|
static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
|
2013-11-27 11:38:47 +01:00
|
|
|
{
|
|
|
|
InputEvent *evt = g_new0(InputEvent, 1);
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
evt->u.key.data = g_new0(InputKeyEvent, 1);
|
2015-10-26 23:34:58 +01:00
|
|
|
evt->type = INPUT_EVENT_KIND_KEY;
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
evt->u.key.data->key = key;
|
|
|
|
evt->u.key.data->down = down;
|
2013-11-27 11:38:47 +01:00
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down)
|
|
|
|
{
|
|
|
|
InputEvent *evt;
|
|
|
|
evt = qemu_input_event_new_key(key, down);
|
2014-05-28 13:02:40 +02:00
|
|
|
if (QTAILQ_EMPTY(&kbd_queue)) {
|
|
|
|
qemu_input_event_send(src, evt);
|
|
|
|
qemu_input_event_sync();
|
|
|
|
qapi_free_InputEvent(evt);
|
2017-04-28 10:42:37 +02:00
|
|
|
} else if (queue_count < queue_limit) {
|
2014-05-28 13:02:40 +02:00
|
|
|
qemu_input_queue_event(&kbd_queue, src, evt);
|
|
|
|
qemu_input_queue_sync(&kbd_queue);
|
2017-12-25 03:37:30 +01:00
|
|
|
} else {
|
|
|
|
qapi_free_InputEvent(evt);
|
2014-05-28 13:02:40 +02:00
|
|
|
}
|
2013-11-27 11:38:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down)
|
|
|
|
{
|
2017-09-29 12:12:00 +02:00
|
|
|
QKeyCode code = qemu_input_key_number_to_qcode(num);
|
|
|
|
qemu_input_event_send_key_qcode(src, code, down);
|
2013-11-27 11:38:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down)
|
|
|
|
{
|
|
|
|
KeyValue *key = g_new0(KeyValue, 1);
|
2015-10-26 23:34:58 +01:00
|
|
|
key->type = KEY_VALUE_KIND_QCODE;
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-17 23:48:37 +01:00
|
|
|
key->u.qcode.data = q;
|
2013-11-27 11:38:47 +01:00
|
|
|
qemu_input_event_send_key(src, key, down);
|
|
|
|
}
|
2013-11-27 18:24:29 +01:00
|
|
|
|
2014-05-28 13:02:40 +02:00
|
|
|
void qemu_input_event_send_key_delay(uint32_t delay_ms)
|
|
|
|
{
|
2017-04-25 15:05:20 +02:00
|
|
|
if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-28 13:02:40 +02:00
|
|
|
if (!kbd_timer) {
|
2018-10-17 10:24:20 +02:00
|
|
|
kbd_timer = timer_new_full(NULL, QEMU_CLOCK_VIRTUAL,
|
|
|
|
SCALE_MS, QEMU_TIMER_ATTR_EXTERNAL,
|
|
|
|
qemu_input_queue_process, &kbd_queue);
|
2014-05-28 13:02:40 +02:00
|
|
|
}
|
2017-04-28 10:42:37 +02:00
|
|
|
if (queue_count < queue_limit) {
|
|
|
|
qemu_input_queue_delay(&kbd_queue, kbd_timer,
|
|
|
|
delay_ms ? delay_ms : kbd_default_delay_ms);
|
|
|
|
}
|
2014-05-28 13:02:40 +02:00
|
|
|
}
|
|
|
|
|
2013-11-27 18:24:29 +01:00
|
|
|
void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down)
|
|
|
|
{
|
2018-12-10 15:08:08 +01:00
|
|
|
InputBtnEvent bevt = {
|
|
|
|
.button = btn,
|
|
|
|
.down = down,
|
|
|
|
};
|
|
|
|
InputEvent evt = {
|
|
|
|
.type = INPUT_EVENT_KIND_BTN,
|
|
|
|
.u.btn.data = &bevt,
|
|
|
|
};
|
|
|
|
|
|
|
|
qemu_input_event_send(src, &evt);
|
2013-11-27 18:24:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
|
|
|
|
uint32_t button_old, uint32_t button_new)
|
|
|
|
{
|
|
|
|
InputButton btn;
|
|
|
|
uint32_t mask;
|
|
|
|
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 09:52:57 +01:00
|
|
|
for (btn = 0; btn < INPUT_BUTTON__MAX; btn++) {
|
2013-11-27 18:24:29 +01:00
|
|
|
mask = button_map[btn];
|
|
|
|
if ((button_old & mask) == (button_new & mask)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
qemu_input_queue_btn(src, btn, button_new & mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:29:34 +02:00
|
|
|
bool qemu_input_is_absolute(QemuConsole *con)
|
2013-11-28 11:31:09 +01:00
|
|
|
{
|
|
|
|
QemuInputHandlerState *s;
|
|
|
|
|
2014-05-19 15:18:37 +02:00
|
|
|
s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS,
|
2023-09-21 10:29:34 +02:00
|
|
|
con);
|
2013-11-28 11:31:09 +01:00
|
|
|
return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
|
|
|
|
}
|
|
|
|
|
2017-05-05 15:39:52 +02:00
|
|
|
int qemu_input_scale_axis(int value,
|
|
|
|
int min_in, int max_in,
|
|
|
|
int min_out, int max_out)
|
2013-11-27 18:24:29 +01:00
|
|
|
{
|
2017-05-05 15:39:52 +02:00
|
|
|
int64_t range_in = (int64_t)max_in - min_in;
|
|
|
|
int64_t range_out = (int64_t)max_out - min_out;
|
|
|
|
|
|
|
|
if (range_in < 1) {
|
|
|
|
return min_out + range_out / 2;
|
2013-11-27 18:24:29 +01:00
|
|
|
}
|
2017-05-05 15:39:52 +02:00
|
|
|
return ((int64_t)value - min_in) * range_out / range_in + min_out;
|
2013-11-27 18:24:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value)
|
|
|
|
{
|
2018-12-10 15:08:08 +01:00
|
|
|
InputMoveEvent move = {
|
|
|
|
.axis = axis,
|
|
|
|
.value = value,
|
|
|
|
};
|
|
|
|
InputEvent evt = {
|
|
|
|
.type = INPUT_EVENT_KIND_REL,
|
|
|
|
.u.rel.data = &move,
|
|
|
|
};
|
|
|
|
|
|
|
|
qemu_input_event_send(src, &evt);
|
2013-11-27 18:24:29 +01:00
|
|
|
}
|
|
|
|
|
2017-05-05 15:39:52 +02:00
|
|
|
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
|
|
|
|
int min_in, int max_in)
|
2013-11-27 18:24:29 +01:00
|
|
|
{
|
2018-12-10 15:08:08 +01:00
|
|
|
InputMoveEvent move = {
|
|
|
|
.axis = axis,
|
|
|
|
.value = qemu_input_scale_axis(value, min_in, max_in,
|
2017-05-05 15:39:52 +02:00
|
|
|
INPUT_EVENT_ABS_MIN,
|
2018-12-10 15:08:08 +01:00
|
|
|
INPUT_EVENT_ABS_MAX),
|
|
|
|
};
|
|
|
|
InputEvent evt = {
|
|
|
|
.type = INPUT_EVENT_KIND_ABS,
|
|
|
|
.u.abs.data = &move,
|
|
|
|
};
|
|
|
|
|
|
|
|
qemu_input_event_send(src, &evt);
|
2013-11-27 18:24:29 +01:00
|
|
|
}
|
2013-12-05 11:23:42 +01:00
|
|
|
|
2023-05-26 13:29:24 +02:00
|
|
|
void qemu_input_queue_mtt(QemuConsole *src, InputMultiTouchType type,
|
|
|
|
int slot, int tracking_id)
|
|
|
|
{
|
|
|
|
InputMultiTouchEvent mtt = {
|
|
|
|
.type = type,
|
|
|
|
.slot = slot,
|
|
|
|
.tracking_id = tracking_id,
|
|
|
|
};
|
|
|
|
InputEvent evt = {
|
|
|
|
.type = INPUT_EVENT_KIND_MTT,
|
|
|
|
.u.mtt.data = &mtt,
|
|
|
|
};
|
|
|
|
|
|
|
|
qemu_input_event_send(src, &evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
|
|
|
|
int min_in, int max_in, int slot, int tracking_id)
|
|
|
|
{
|
|
|
|
InputMultiTouchEvent mtt = {
|
|
|
|
.type = INPUT_MULTI_TOUCH_TYPE_DATA,
|
|
|
|
.slot = slot,
|
|
|
|
.tracking_id = tracking_id,
|
|
|
|
.axis = axis,
|
|
|
|
.value = qemu_input_scale_axis(value, min_in, max_in,
|
|
|
|
INPUT_EVENT_ABS_MIN,
|
|
|
|
INPUT_EVENT_ABS_MAX),
|
|
|
|
};
|
|
|
|
InputEvent evt = {
|
|
|
|
.type = INPUT_EVENT_KIND_MTT,
|
|
|
|
.u.mtt.data = &mtt,
|
|
|
|
};
|
|
|
|
|
|
|
|
qemu_input_event_send(src, &evt);
|
|
|
|
}
|
|
|
|
|
2013-12-05 11:23:42 +01:00
|
|
|
void qemu_add_mouse_mode_change_notifier(Notifier *notify)
|
|
|
|
{
|
|
|
|
notifier_list_add(&mouse_mode_notifiers, notify);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
|
|
|
|
{
|
|
|
|
notifier_remove(notify);
|
|
|
|
}
|
2013-12-10 17:09:36 +01:00
|
|
|
|
|
|
|
MouseInfoList *qmp_query_mice(Error **errp)
|
|
|
|
{
|
|
|
|
MouseInfoList *mice_list = NULL;
|
2020-11-13 02:13:37 +01:00
|
|
|
MouseInfo *info;
|
2013-12-10 17:09:36 +01:00
|
|
|
QemuInputHandlerState *s;
|
|
|
|
bool current = true;
|
|
|
|
|
|
|
|
QTAILQ_FOREACH(s, &handlers, node) {
|
|
|
|
if (!(s->handler->mask &
|
|
|
|
(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-13 02:13:37 +01:00
|
|
|
info = g_new0(MouseInfo, 1);
|
|
|
|
info->index = s->id;
|
|
|
|
info->name = g_strdup(s->handler->name);
|
|
|
|
info->absolute = s->handler->mask & INPUT_EVENT_MASK_ABS;
|
|
|
|
info->current = current;
|
2013-12-10 17:09:36 +01:00
|
|
|
|
|
|
|
current = false;
|
2020-11-13 02:13:37 +01:00
|
|
|
QAPI_LIST_PREPEND(mice_list, info);
|
2013-12-10 17:09:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return mice_list;
|
|
|
|
}
|
2013-12-10 17:16:03 +01:00
|
|
|
|
2023-01-09 20:03:20 +01:00
|
|
|
bool qemu_mouse_set(int index, Error **errp)
|
2013-12-10 17:16:03 +01:00
|
|
|
{
|
|
|
|
QemuInputHandlerState *s;
|
|
|
|
|
|
|
|
QTAILQ_FOREACH(s, &handlers, node) {
|
2023-01-09 20:03:21 +01:00
|
|
|
if (s->id == index) {
|
|
|
|
break;
|
2014-04-01 00:09:06 +02:00
|
|
|
}
|
2013-12-10 17:16:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-09 20:03:21 +01:00
|
|
|
if (!s) {
|
2023-01-09 20:03:20 +01:00
|
|
|
error_setg(errp, "Mouse at index '%d' not found", index);
|
|
|
|
return false;
|
2013-12-10 17:16:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-09 20:03:21 +01:00
|
|
|
if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
|
|
|
|
INPUT_EVENT_MASK_ABS))) {
|
|
|
|
error_setg(errp, "Input device '%s' is not a mouse",
|
|
|
|
s->handler->name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_input_handler_activate(s);
|
2023-09-21 10:29:34 +02:00
|
|
|
notifier_list_notify(&mouse_mode_notifiers, NULL);
|
2023-01-09 20:03:20 +01:00
|
|
|
return true;
|
2013-12-10 17:16:03 +01:00
|
|
|
}
|