summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-03-11 11:13:29 -0300
committerGerd Hoffmann <kraxel@redhat.com>2010-08-04 15:32:44 +0200
commit6df8a76bac423742d4cc7c228ecd842e0e230299 (patch)
tree1fb383b1f24a9dd833a81450008a30efb57e6e68
parenta546fc7699fa70bef77f334a2236c900785d1aa4 (diff)
spice: add mouse
Open mouse channel. Now you can move the guests mouse pointer. No tablet / absolute positioning (yet) though.
-rw-r--r--spice-input.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/spice-input.c b/spice-input.c
index e1014d78a..8f3deb4aa 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);
+}
+
+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);
}