qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH RFC 3/8] ui/input: Use bool for qemu_add_mouse_event


From: Andreas Färber
Subject: [Qemu-devel] [PATCH RFC 3/8] ui/input: Use bool for qemu_add_mouse_event_handler()
Date: Sun, 16 Jun 2013 05:40:00 +0200

Change kbd_mouse_{is,has}_absolute() alongside.

vmmouse uses uint8_t in its VMStateDescription, and Xen uses int in xend
communication, so they cannot easily be changed.

Signed-off-by: Andreas Färber <address@hidden>
---
 backends/msmouse.c   |  3 ++-
 hw/char/escc.c       |  2 +-
 hw/display/ads7846.c |  4 ++--
 hw/input/adb.c       |  2 +-
 hw/input/hid.c       | 10 ++++++----
 hw/input/ps2.c       |  2 +-
 hw/input/tsc2005.c   |  4 ++--
 hw/input/tsc210x.c   |  8 ++++----
 hw/input/vmmouse.c   |  2 +-
 hw/usb/dev-wacom.c   |  8 ++++----
 include/ui/console.h |  6 +++---
 ui/input.c           | 14 +++++++-------
 12 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/backends/msmouse.c b/backends/msmouse.c
index c0dbfcd..1d24ac6 100644
--- a/backends/msmouse.c
+++ b/backends/msmouse.c
@@ -72,7 +72,8 @@ CharDriverState *qemu_chr_open_msmouse(void)
     chr->chr_close = msmouse_chr_close;
     chr->explicit_be_open = true;
 
-    qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft 
Mouse");
+    qemu_add_mouse_event_handler(msmouse_event, chr, false,
+                                 "QEMU Microsoft Mouse");
 
     return chr;
 }
diff --git a/hw/char/escc.c b/hw/char/escc.c
index c2cb07f..68a49cd 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -891,7 +891,7 @@ static int escc_init1(SysBusDevice *dev)
     sysbus_init_mmio(dev, &s->mmio);
 
     if (s->chn[0].type == mouse) {
-        qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,
+        qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], false,
                                      "QEMU Sun Mouse");
     }
     if (s->chn[1].type == kbd) {
diff --git a/hw/display/ads7846.c b/hw/display/ads7846.c
index 5da3dc5..4a02744 100644
--- a/hw/display/ads7846.c
+++ b/hw/display/ads7846.c
@@ -145,8 +145,8 @@ static int ads7846_init(SSISlave *dev)
     s->input[7] = ADS_TEMP1;   /* TEMP1 */
 
     /* We want absolute coordinates */
-    qemu_add_mouse_event_handler(ads7846_ts_event, s, 1,
-                    "QEMU ADS7846-driven Touchscreen");
+    qemu_add_mouse_event_handler(ads7846_ts_event, s, true,
+                                 "QEMU ADS7846-driven Touchscreen");
 
     ads7846_int_update(s);
 
diff --git a/hw/input/adb.c b/hw/input/adb.c
index a75d3fd..104bfc8 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -536,7 +536,7 @@ static void adb_mouse_realizefn(DeviceState *dev, Error 
**errp)
 
     amc->parent_realize(dev, errp);
 
-    qemu_add_mouse_event_handler(adb_mouse_event, s, 0, "QEMU ADB Mouse");
+    qemu_add_mouse_event_handler(adb_mouse_event, s, false, "QEMU ADB Mouse");
 }
 
 static void adb_mouse_initfn(Object *obj)
diff --git a/hw/input/hid.c b/hw/input/hid.c
index 14b3125..7a3a7a4 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -433,11 +433,13 @@ void hid_init(HIDState *hs, int kind, HIDEventFunc event)
     if (hs->kind == HID_KEYBOARD) {
         hs->kbd.eh_entry = qemu_add_kbd_event_handler(hid_keyboard_event, hs);
     } else if (hs->kind == HID_MOUSE) {
-        hs->ptr.eh_entry = qemu_add_mouse_event_handler(hid_pointer_event, hs,
-                                                        0, "QEMU HID Mouse");
+        hs->ptr.eh_entry = qemu_add_mouse_event_handler(hid_pointer_event,
+                                                        hs, false,
+                                                        "QEMU HID Mouse");
     } else if (hs->kind == HID_TABLET) {
-        hs->ptr.eh_entry = qemu_add_mouse_event_handler(hid_pointer_event, hs,
-                                                        1, "QEMU HID Tablet");
+        hs->ptr.eh_entry = qemu_add_mouse_event_handler(hid_pointer_event,
+                                                        hs, true,
+                                                        "QEMU HID Tablet");
     }
 }
 
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 3412079..e555f74 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -670,7 +670,7 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void 
*update_arg)
     s->common.update_irq = update_irq;
     s->common.update_arg = update_arg;
     vmstate_register(NULL, 0, &vmstate_ps2_mouse, s);
-    qemu_add_mouse_event_handler(ps2_mouse_event, s, 0, "QEMU PS/2 Mouse");
+    qemu_add_mouse_event_handler(ps2_mouse_event, s, false, "QEMU PS/2 Mouse");
     qemu_register_reset(ps2_mouse_reset, s);
     return s;
 }
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
index a771cd5..b0d9263 100644
--- a/hw/input/tsc2005.c
+++ b/hw/input/tsc2005.c
@@ -544,8 +544,8 @@ void *tsc2005_init(qemu_irq pintdav)
 
     tsc2005_reset(s);
 
-    qemu_add_mouse_event_handler(tsc2005_touchscreen_event, s, 1,
-                    "QEMU TSC2005-driven Touchscreen");
+    qemu_add_mouse_event_handler(tsc2005_touchscreen_event, s, true,
+                                 "QEMU TSC2005-driven Touchscreen");
 
     qemu_register_reset((void *) tsc2005_reset, s);
     register_savevm(NULL, "tsc2005", -1, 0, tsc2005_save, tsc2005_load, s);
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index 9b854e7..02d3440 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -1137,8 +1137,8 @@ uWireSlave *tsc2102_init(qemu_irq pint)
 
     tsc210x_reset(s);
 
-    qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
-                    "QEMU TSC2102-driven Touchscreen");
+    qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, true,
+                                 "QEMU TSC2102-driven Touchscreen");
 
     AUD_register_card(s->name, &s->card);
 
@@ -1188,8 +1188,8 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, 
qemu_irq dav)
 
     tsc210x_reset(s);
 
-    qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
-                    "QEMU TSC2301-driven Touchscreen");
+    qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, true,
+                                 "QEMU TSC2301-driven Touchscreen");
 
     AUD_register_card(s->name, &s->card);
 
diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c
index a610738..2b2ea88 100644
--- a/hw/input/vmmouse.c
+++ b/hw/input/vmmouse.c
@@ -114,7 +114,7 @@ static void vmmouse_remove_handler(VMMouseState *s)
     }
 }
 
-static void vmmouse_update_handler(VMMouseState *s, int absolute)
+static void vmmouse_update_handler(VMMouseState *s, uint8_t absolute)
 {
     if (s->status != 0) {
         return;
diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
index 3be5cde..78563ff 100644
--- a/hw/usb/dev-wacom.c
+++ b/hw/usb/dev-wacom.c
@@ -170,8 +170,8 @@ static int usb_mouse_poll(USBWacomState *s, uint8_t *buf, 
int len)
     int dx, dy, dz, b, l;
 
     if (!s->mouse_grabbed) {
-        s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s, 0,
-                        "QEMU PenPartner tablet");
+        s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s, false,
+                                                   "QEMU PenPartner tablet");
         qemu_activate_mouse_event_handler(s->eh_entry);
         s->mouse_grabbed = 1;
     }
@@ -208,8 +208,8 @@ static int usb_wacom_poll(USBWacomState *s, uint8_t *buf, 
int len)
     int b;
 
     if (!s->mouse_grabbed) {
-        s->eh_entry = qemu_add_mouse_event_handler(usb_wacom_event, s, 1,
-                        "QEMU PenPartner tablet");
+        s->eh_entry = qemu_add_mouse_event_handler(usb_wacom_event, s, true,
+                                                   "QEMU PenPartner tablet");
         qemu_activate_mouse_event_handler(s->eh_entry);
         s->mouse_grabbed = 1;
     }
diff --git a/include/ui/console.h b/include/ui/console.h
index f1d79f9..e25879f 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -37,7 +37,7 @@ QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent 
*func,
                                             void *opaque);
 void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry);
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
-                                                void *opaque, int absolute,
+                                                void *opaque, bool absolute,
                                                 const char *name);
 void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
 void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
@@ -50,12 +50,12 @@ void kbd_put_ledstate(int ledstate);
 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
 
 /* Does the current mouse generate absolute events */
-int kbd_mouse_is_absolute(void);
+bool kbd_mouse_is_absolute(void);
 void qemu_add_mouse_mode_change_notifier(Notifier *notify);
 void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
 
 /* Of all the mice, is there one that generates absolute events */
-int kbd_mouse_has_absolute(void);
+bool kbd_mouse_has_absolute(void);
 
 struct MouseTransformInfo {
     /* Touchscreen resolution */
diff --git a/ui/input.c b/ui/input.c
index 28353b4..76ded94 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -33,7 +33,7 @@
 struct QEMUPutMouseEntry {
     QEMUPutMouseEvent *put_event;
     void *opaque;
-    int absolute;
+    bool absolute;
     char *name;
 
     int index;
@@ -347,7 +347,7 @@ static void check_mode_change(void)
 }
 
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
-                                                void *opaque, int absolute,
+                                                void *opaque, bool absolute,
                                                 const char *name)
 {
     QEMUPutMouseEntry *s;
@@ -477,7 +477,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int 
buttons_state)
     }
 }
 
-int kbd_mouse_is_absolute(void)
+bool kbd_mouse_is_absolute(void)
 {
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return 0;
@@ -486,17 +486,17 @@ int kbd_mouse_is_absolute(void)
     return QTAILQ_FIRST(&mouse_handlers)->absolute;
 }
 
-int kbd_mouse_has_absolute(void)
+bool kbd_mouse_has_absolute(void)
 {
     QEMUPutMouseEntry *entry;
 
     QTAILQ_FOREACH(entry, &mouse_handlers, node) {
         if (entry->absolute) {
-            return 1;
+            return true;
         }
     }
 
-    return 0;
+    return false;
 }
 
 MouseInfoList *qmp_query_mice(Error **errp)
@@ -510,7 +510,7 @@ MouseInfoList *qmp_query_mice(Error **errp)
         info->value = g_malloc0(sizeof(*info->value));
         info->value->name = g_strdup(cursor->name);
         info->value->index = cursor->index;
-        info->value->absolute = !!cursor->absolute;
+        info->value->absolute = cursor->absolute;
         info->value->current = current;
 
         current = false;
-- 
1.8.1.4




reply via email to

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