qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 7/9] spice: add mouse


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 7/9] spice: add mouse
Date: Thu, 19 Aug 2010 09:25:46 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Lightning/1.0b1 Thunderbird/3.0.6

On 08/19/2010 07:40 AM, Gerd Hoffmann wrote:
Open mouse channel.  Now you can move the guests mouse pointer.
No tablet / absolute positioning (yet) though.

Signed-off-by: Gerd Hoffmann<address@hidden>
---
  spice-input.c |   31 +++++++++++++++++++++++++++++++
  1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/spice-input.c b/spice-input.c
index e1014d7..8f3deb4 100644
--- a/spice-input.c
+++ b/spice-input.c
@@ -46,12 +46,43 @@ static void kbd_leds(void *opaque, int ledstate)
      spice_server_kbd_leds(&kbd->sin, ledstate);
  }

+/* mouse bits */
+
+typedef struct QemuSpiceMouse {
+    SpiceMouseInstance sin;
+} QemuSpiceMouse;
+
+static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz,
+                         uint32_t buttons_state)
+{
+    kbd_mouse_event(dx, dy, dz, buttons_state);

dz is an odd interface. We use it to represent additional buttons which really makes no sense. If you still can, I'd suggest moving dz into buttons_state.

Previous comment still applies though, you should explicitly convert the button_states from QEMU format to Spice format to future proof.

Regards,

Anthony Liguori

+}
+
+static void mouse_buttons(SpiceMouseInstance *sin, uint32_t buttons_state)
+{
+    kbd_mouse_event(0, 0, 0, buttons_state);
+}
+
+static const SpiceMouseInterface mouse_interface = {
+    .base.type          = SPICE_INTERFACE_MOUSE,
+    .base.description   = "mouse",
+    .base.major_version = SPICE_INTERFACE_MOUSE_MAJOR,
+    .base.minor_version = SPICE_INTERFACE_MOUSE_MINOR,
+    .motion             = mouse_motion,
+    .buttons            = mouse_buttons,
+};
+
  void qemu_spice_input_init(void)
  {
      QemuSpiceKbd *kbd;
+    QemuSpiceMouse *mouse;

      kbd = qemu_mallocz(sizeof(*kbd));
      kbd->sin.base.sif =&kbd_interface.base;
      spice_server_add_interface(spice_server,&kbd->sin.base);
      qemu_add_led_event_handler(kbd_leds, kbd);
+
+    mouse = qemu_mallocz(sizeof(*mouse));
+    mouse->sin.base.sif =&mouse_interface.base;
+    spice_server_add_interface(spice_server,&mouse->sin.base);
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]