* [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
@ 2014-06-05 23:25 Marcelo Tosatti
2014-06-10 8:25 ` Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Marcelo Tosatti @ 2014-06-05 23:25 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Add monitor command to change mouse cursor position when input
device is in absolute mode.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hmp-commands.hx | 22 +++++++++++++++++++---
monitor.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 4 deletions(-)
Index: qemu/hmp-commands.hx
===================================================================
--- qemu.orig/hmp-commands.hx 2014-06-05 20:21:32.310919549 -0300
+++ qemu/hmp-commands.hx 2014-06-05 20:21:44.582879764 -0300
@@ -703,18 +703,34 @@
.name = "mouse_move",
.args_type = "dx_str:s,dy_str:s,dz_str:s?",
.params = "dx dy [dz]",
- .help = "send mouse move events",
- .mhandler.cmd = do_mouse_move,
+ .help = "send mouse move events (relative coordinates)",
+ .mhandler.cmd = do_mouse_move_rel,
},
STEXI
@item mouse_move @var{dx} @var{dy} [@var{dz}]
@findex mouse_move
-Move the active mouse to the specified coordinates @var{dx} @var{dy}
+Move the active mouse to the specified relative coordinates @var{dx} @var{dy}
with optional scroll axis @var{dz}.
ETEXI
{
+ .name = "mouse_move_abs",
+ .args_type = "dx_str:s,dy_str:s,dz_str:s?",
+ .params = "dx dy [dz]",
+ .help = "send mouse move events (absolute coordinates)",
+ .mhandler.cmd = do_mouse_move_abs,
+ },
+
+STEXI
+@item mouse_move_abs @var{dx} @var{dy} [@var{dz}]
+@findex mouse_move_abs
+Move the active mouse to the specified absolute coordinates @var{dx} @var{dy}
+with optional scroll axis @var{dz}.
+ETEXI
+
+
+ {
.name = "mouse_button",
.args_type = "button_state:i",
.params = "state",
Index: qemu/monitor.c
===================================================================
--- qemu.orig/monitor.c 2014-06-05 20:21:32.313919539 -0300
+++ qemu/monitor.c 2014-06-05 20:21:44.583879761 -0300
@@ -1436,7 +1436,7 @@
static int mouse_button_state;
-static void do_mouse_move(Monitor *mon, const QDict *qdict)
+static void do_mouse_move_rel(Monitor *mon, const QDict *qdict)
{
int dx, dy, dz, button;
const char *dx_str = qdict_get_str(qdict, "dx_str");
@@ -1450,6 +1450,39 @@
if (dz_str) {
dz = strtol(dz_str, NULL, 0);
+ if (dz != 0) {
+ button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+ qemu_input_queue_btn(NULL, button, true);
+ qemu_input_event_sync();
+ qemu_input_queue_btn(NULL, button, false);
+ }
+ }
+ qemu_input_event_sync();
+}
+
+static void do_mouse_move_abs(Monitor *mon, const QDict *qdict)
+{
+ int dx, dy, dz, button;
+ const char *dx_str = qdict_get_str(qdict, "dx_str");
+ const char *dy_str = qdict_get_str(qdict, "dy_str");
+ const char *dz_str = qdict_get_try_str(qdict, "dz_str");
+ int weight, height;
+
+ weight = qemu_console_get_width(NULL, 0);
+ height = qemu_console_get_height(NULL, 0);
+
+ if (!height || !weight) {
+ monitor_printf(mon, "failed to retrieve active console size\n");
+ return;
+ }
+
+ dx = strtol(dx_str, NULL, 0);
+ dy = strtol(dy_str, NULL, 0);
+ qemu_input_queue_abs(NULL, INPUT_AXIS_X, dx, weight);
+ qemu_input_queue_abs(NULL, INPUT_AXIS_Y, dy, height);
+
+ if (dz_str) {
+ dz = strtol(dz_str, NULL, 0);
if (dz != 0) {
button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
qemu_input_queue_btn(NULL, button, true);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-05 23:25 [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode Marcelo Tosatti
@ 2014-06-10 8:25 ` Gerd Hoffmann
2014-06-10 11:48 ` Marcelo Tosatti
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2014-06-10 8:25 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, Luiz Capitulino
Hi,
> + .name = "mouse_move_abs",
> + .args_type = "dx_str:s,dy_str:s,dz_str:s?",
> + .params = "dx dy [dz]",
> + .help = "send mouse move events (absolute coordinates)",
> + .mhandler.cmd = do_mouse_move_abs,
> + },
> +
> +STEXI
> +@item mouse_move_abs @var{dx} @var{dy} [@var{dz}]
I think we should drop the dz parameter (you still can send mouse wheel
events via mouse_move 0 0 dz), and add a optional console parameter
instead ...
> +static void do_mouse_move_abs(Monitor *mon, const QDict *qdict)
> +{
> + int dx, dy, dz, button;
> + const char *dx_str = qdict_get_str(qdict, "dx_str");
> + const char *dy_str = qdict_get_str(qdict, "dy_str");
> + const char *dz_str = qdict_get_try_str(qdict, "dz_str");
> + int weight, height;
... then pick the console here (if specified):
QemuConsole *con = NULL;
if (qdict_get_try_str(qdict, "console")) {
con = qemu_console_lookup_by_index(...)
That's a new hmp-only command tough. IIRC there is (or was?) a policy
that no new hmp-only commands are allowed. Luiz?
A completely different approach would be a qmp command allowing to send
any input event. Given that the new input layer already uses qapi-types
internally this should be pretty straight forward to do (see InputEvent
in qapi-schema.json).
cheers,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-10 8:25 ` Gerd Hoffmann
@ 2014-06-10 11:48 ` Marcelo Tosatti
2014-06-10 11:53 ` Marcelo Tosatti
2014-06-10 12:38 ` Eric Blake
2014-06-12 7:12 ` Markus Armbruster
2 siblings, 1 reply; 7+ messages in thread
From: Marcelo Tosatti @ 2014-06-10 11:48 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Luiz Capitulino
On Tue, Jun 10, 2014 at 10:25:47AM +0200, Gerd Hoffmann wrote:
> Hi,
>
> > + .name = "mouse_move_abs",
> > + .args_type = "dx_str:s,dy_str:s,dz_str:s?",
> > + .params = "dx dy [dz]",
> > + .help = "send mouse move events (absolute coordinates)",
> > + .mhandler.cmd = do_mouse_move_abs,
> > + },
> > +
> > +STEXI
> > +@item mouse_move_abs @var{dx} @var{dy} [@var{dz}]
>
> I think we should drop the dz parameter (you still can send mouse wheel
> events via mouse_move 0 0 dz), and add a optional console parameter
> instead ...
>
> > +static void do_mouse_move_abs(Monitor *mon, const QDict *qdict)
> > +{
> > + int dx, dy, dz, button;
> > + const char *dx_str = qdict_get_str(qdict, "dx_str");
> > + const char *dy_str = qdict_get_str(qdict, "dy_str");
> > + const char *dz_str = qdict_get_try_str(qdict, "dz_str");
> > + int weight, height;
>
> ... then pick the console here (if specified):
>
> QemuConsole *con = NULL;
> if (qdict_get_try_str(qdict, "console")) {
> con = qemu_console_lookup_by_index(...)
>
> That's a new hmp-only command tough. IIRC there is (or was?) a policy
> that no new hmp-only commands are allowed. Luiz?
>
>
> A completely different approach would be a qmp command allowing to send
> any input event. Given that the new input layer already uses qapi-types
> internally this should be pretty straight forward to do (see InputEvent
> in qapi-schema.json).
I was just adding a new parameter to sendkey to allow "press"/"release"
behaviour, which is not accepted ATM.
Will go for a new QMP command, then, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-10 11:48 ` Marcelo Tosatti
@ 2014-06-10 11:53 ` Marcelo Tosatti
2014-06-10 12:19 ` Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Marcelo Tosatti @ 2014-06-10 11:53 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Luiz Capitulino
On Tue, Jun 10, 2014 at 08:48:23AM -0300, Marcelo Tosatti wrote:
> On Tue, Jun 10, 2014 at 10:25:47AM +0200, Gerd Hoffmann wrote:
> > Hi,
> >
> > > + .name = "mouse_move_abs",
> > > + .args_type = "dx_str:s,dy_str:s,dz_str:s?",
> > > + .params = "dx dy [dz]",
> > > + .help = "send mouse move events (absolute coordinates)",
> > > + .mhandler.cmd = do_mouse_move_abs,
> > > + },
> > > +
> > > +STEXI
> > > +@item mouse_move_abs @var{dx} @var{dy} [@var{dz}]
> >
> > I think we should drop the dz parameter (you still can send mouse wheel
> > events via mouse_move 0 0 dz), and add a optional console parameter
> > instead ...
> >
> > > +static void do_mouse_move_abs(Monitor *mon, const QDict *qdict)
> > > +{
> > > + int dx, dy, dz, button;
> > > + const char *dx_str = qdict_get_str(qdict, "dx_str");
> > > + const char *dy_str = qdict_get_str(qdict, "dy_str");
> > > + const char *dz_str = qdict_get_try_str(qdict, "dz_str");
> > > + int weight, height;
> >
> > ... then pick the console here (if specified):
> >
> > QemuConsole *con = NULL;
> > if (qdict_get_try_str(qdict, "console")) {
> > con = qemu_console_lookup_by_index(...)
> >
> > That's a new hmp-only command tough. IIRC there is (or was?) a policy
> > that no new hmp-only commands are allowed. Luiz?
> >
> >
> > A completely different approach would be a qmp command allowing to send
> > any input event. Given that the new input layer already uses qapi-types
> > internally this should be pretty straight forward to do (see InputEvent
> > in qapi-schema.json).
>
> I was just adding a new parameter to sendkey to allow "press"/"release"
> behaviour, which is not accepted ATM.
> Will go for a new QMP command, then, thanks.
>
You want console parameter to be console index? Is that visible via
monitor?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-10 11:53 ` Marcelo Tosatti
@ 2014-06-10 12:19 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2014-06-10 12:19 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, Luiz Capitulino
Hi,
> You want console parameter to be console index? Is that visible via
> monitor?
The consoles are visible in the qom tree,
under /backend/console[$index]. They have a device link and head
property, so you can figure which console belongs to which device and
display.
I think using a console index is fine. Luiz, agree? Other/better
suggestions?
I think the command should take a list of events. Send all events to
the guest via qemu_input_event_send, finally call qemu_input_event_sync.
cheers,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-10 8:25 ` Gerd Hoffmann
2014-06-10 11:48 ` Marcelo Tosatti
@ 2014-06-10 12:38 ` Eric Blake
2014-06-12 7:12 ` Markus Armbruster
2 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2014-06-10 12:38 UTC (permalink / raw)
To: Gerd Hoffmann, Marcelo Tosatti; +Cc: qemu-devel, Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 466 bytes --]
On 06/10/2014 02:25 AM, Gerd Hoffmann wrote:
> QemuConsole *con = NULL;
> if (qdict_get_try_str(qdict, "console")) {
> con = qemu_console_lookup_by_index(...)
>
> That's a new hmp-only command tough. IIRC there is (or was?) a policy
> that no new hmp-only commands are allowed. Luiz?
Correct - please expose this through QMP.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode
2014-06-10 8:25 ` Gerd Hoffmann
2014-06-10 11:48 ` Marcelo Tosatti
2014-06-10 12:38 ` Eric Blake
@ 2014-06-12 7:12 ` Markus Armbruster
2 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2014-06-12 7:12 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Marcelo Tosatti, qemu-devel, Luiz Capitulino
Gerd Hoffmann <kraxel@redhat.com> writes:
> Hi,
>
>> + .name = "mouse_move_abs",
>> + .args_type = "dx_str:s,dy_str:s,dz_str:s?",
>> + .params = "dx dy [dz]",
>> + .help = "send mouse move events (absolute coordinates)",
>> + .mhandler.cmd = do_mouse_move_abs,
>> + },
>> +
>> +STEXI
>> +@item mouse_move_abs @var{dx} @var{dy} [@var{dz}]
>
> I think we should drop the dz parameter (you still can send mouse wheel
> events via mouse_move 0 0 dz), and add a optional console parameter
> instead ...
>
>> +static void do_mouse_move_abs(Monitor *mon, const QDict *qdict)
>> +{
>> + int dx, dy, dz, button;
>> + const char *dx_str = qdict_get_str(qdict, "dx_str");
>> + const char *dy_str = qdict_get_str(qdict, "dy_str");
>> + const char *dz_str = qdict_get_try_str(qdict, "dz_str");
>> + int weight, height;
>
> ... then pick the console here (if specified):
>
> QemuConsole *con = NULL;
> if (qdict_get_try_str(qdict, "console")) {
> con = qemu_console_lookup_by_index(...)
>
> That's a new hmp-only command tough. IIRC there is (or was?) a policy
> that no new hmp-only commands are allowed. Luiz?
HMP-only commands are okay only when the functionality they provide does
not make sense in QMP.
For anything else, we need a QMP command first. The command proper is
generally a thin wrapper around an equivalent internal C function. If
an HMP command is desired, it should call that C function.
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-06-12 7:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-05 23:25 [Qemu-devel] [PATCH] add command to position mouse pointer in absolute mode Marcelo Tosatti
2014-06-10 8:25 ` Gerd Hoffmann
2014-06-10 11:48 ` Marcelo Tosatti
2014-06-10 11:53 ` Marcelo Tosatti
2014-06-10 12:19 ` Gerd Hoffmann
2014-06-10 12:38 ` Eric Blake
2014-06-12 7:12 ` Markus Armbruster
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.