#include "sysemu/sysemu.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
-#include "qapi/qmp/qdict.h"
-#include "qemu/error-report.h"
#include "trace.h"
#include "ui/input.h"
#include "ui/console.h"
return NULL;
}
-void qmp_input_send_event(bool has_device, const char *device,
+void qmp_input_send_event(const char *device,
bool has_head, int64_t head,
InputEventList *events, Error **errp)
{
Error *err = NULL;
con = NULL;
- if (has_device) {
+ if (device) {
if (!has_head) {
head = 0;
}
InputKeyEvent *key;
InputBtnEvent *btn;
InputMoveEvent *move;
+ InputMultiTouchEvent *mtt;
if (src) {
idx = qemu_console_get_index(src);
name = InputAxis_str(move->axis);
trace_input_event_abs(idx, name, move->value);
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:
/* keep gcc happy */
break;
* 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
- * neeed to deal with this mistake
+ * need to deal with this mistake
*/
if (evt->type == INPUT_EVENT_KIND_KEY &&
evt->u.key.data->key->u.qcode.data == Q_KEY_CODE_SYSRQ) {
qemu_input_event_send(src, &evt);
}
+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);
+}
+
void qemu_input_check_mode_change(void)
{
static int current_is_absolute;
return mice_list;
}
-void hmp_mouse_set(Monitor *mon, const QDict *qdict)
+bool qemu_mouse_set(int index, Error **errp)
{
QemuInputHandlerState *s;
- int index = qdict_get_int(qdict, "index");
- int found = 0;
QTAILQ_FOREACH(s, &handlers, node) {
- if (s->id != index) {
- continue;
- }
- if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
- INPUT_EVENT_MASK_ABS))) {
- error_report("Input device '%s' is not a mouse", s->handler->name);
- return;
+ if (s->id == index) {
+ break;
}
- found = 1;
- qemu_input_handler_activate(s);
- break;
}
- if (!found) {
- error_report("Mouse at index '%d' not found", index);
+ if (!s) {
+ error_setg(errp, "Mouse at index '%d' not found", index);
+ return false;
+ }
+
+ 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);
qemu_input_check_mode_change();
+ return true;
}