From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36647 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om6Hw-0007mx-7O for qemu-devel@nongnu.org; Thu, 19 Aug 2010 10:40:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Om63y-0005Q9-PE for qemu-devel@nongnu.org; Thu, 19 Aug 2010 10:25:51 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:46549) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Om63y-0005Q0-Lr for qemu-devel@nongnu.org; Thu, 19 Aug 2010 10:25:50 -0400 Received: by gxk5 with SMTP id 5so778997gxk.4 for ; Thu, 19 Aug 2010 07:25:50 -0700 (PDT) Message-ID: <4C6D3EEA.4020201@codemonkey.ws> Date: Thu, 19 Aug 2010 09:25:46 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 7/9] spice: add mouse References: <1282221625-29501-1-git-send-email-kraxel@redhat.com> <1282221625-29501-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1282221625-29501-8-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org 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 > --- > 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); > } >