add input-send-event command
PATCH v2 1/1 add input-send-event command
Which allows specification of absolute/relative,
up/down and console parameters.
Suggested by Gerd Hoffman.
Signed-off-by Marcelo Tosatti <[email protected]>
--- qapi-schema.json | 18 +++++++++++++++ qmp-commands.hx | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/input.c | 31 +++++++++++++++++++++++++++ 3 files changed, 112 insertions(+)
qapi-schema.json +18 -0
@@ -4722,3 +4722,21 @@ 'btn' : 'InputBtnEvent', 'rel' : 'InputMoveEvent', 'abs' : 'InputMoveEvent' } } + +## +# @input-send-event +# +# Send input event(s) to guest. +# +# @console: Which console to send event(s) to. +# +# @events: List of InputEvent union. +# +# Returns: Nothing on success. +# +# Since: 2.1 +# +## +{ 'command': 'input-send-event', + 'data': { 'console':'int', 'events': [ 'InputEvent' ] } } +
qmp-commands.hx +63 -0
66 lines not on this page · raw message
ui/input.c +31 -0
@@ -102,6 +102,37 @@return NULL ; } +void qmp_input_send_event (int64_t console,InputEventList *events, +Error **errp) +{ +InputEventList *e; +QemuConsole *con; + + con =qemu_console_lookup_by_index (console); +if (!con) { +error_setg (errp,"console %" PRId64" not found" , console); +return ; + } + +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; + +if (!qemu_input_find_handler (1 << event->kind, con)) { +error_setg (errp,"Input handler not found for " +"event type %s" , + InputEventKind_lookup[event->kind]); +return ; + } +qemu_input_event_send (con, event); + } +qemu_input_event_sync (); +} +static void qemu_input_transform_abs_rotate (InputEvent *evt) {switch (graphic_rotate) {
Quoted 14 lines · Marcelo Tosatti
Which allows specification of absolute/relative,
up/down and console parameters.Suggested by Gerd Hoffman.
Signed-off-by Marcelo Tosatti <[email protected]>--- qapi-schema.json | 18 +++++++++++++++ qmp-commands.hx | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/input.c | 31 +++++++++++++++++++++++++++ 3 files changed, 112 insertions(+)
qmp-commands.hx line 3599
Quoted 4 lines
qmp-commands.hx +4
-0+ +Example (1): + +Press left mouse button.
Maybe:
Press, then later release, left mouse button.
qmp-commands.hx line 3611
Quoted 12 lines
qmp-commands.hx +12
-0+ +-> { "execute": "input-send-event", + "arguments": { "console": 0, + "events": [ { "type": "btn", + "data" : { "down": true, "button": "Left" } } } } +<- { "return": {} } + +-> { "execute": "input-send-event", + "arguments": { "console": 0, + "events": [ { "type": "btn", + "data" : { "down": false, "button": "Left" } } } } +<- { "return": {} }
to make it clear that both command/response sequences are part of the same example.
but that's cosmetic, so whether or not you change it, I can live with:
Reviewed-by Eric Blake <[email protected]>
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · Marcelo Tosatti
Which allows specification of absolute/relative,
up/down and console parameters.Suggested by Gerd Hoffman.
Signed-off-by Marcelo Tosatti <[email protected]>
Added to input patch queue.
thanks,
Gerd