Skip to contentSkip to conversation

genius: add genius serial mouse emulation

PATCH New Romain Naour 1 participant 1 message Jan 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 genius: add genius serial mouse emulation

This patch adds the emulation for a serial Genius mouse using Mouse Systems protocol (5bytes).
This protocol is compatible with most 3-button serial mice.

---
Changes v2 -> v3:
Following Peter Maydell's feedback:
Fixes typos
Duplicated code factored into a common utility function.
Documentation: Prefer msmouse if available.
Fixes build warning when debug is set

Changes v1 -> v2:
Fixes documentation (Paolo Bonzini)
Fixes typos

 backends/Makefile.objs |   2 +-
 backends/gnmouse.c     | 313 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/char.h  |   3 +
 qapi-schema.json       |   1 +
 qemu-char.c            |   4 +
 qemu-options.hx        |  17 ++-
 6 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 backends/gnmouse.c
backends/Makefile.objs +1 -1
index 42557d5..e4b072c 100644
@@ -1,7 +1,7 @@
 common-obj-y += rng.o rng-egd.o
 common-obj-$(CONFIG_POSIX) += rng-random.o
 
-common-obj-y += msmouse.o
+common-obj-y += msmouse.o gnmouse.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 $(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
 
backends/gnmouse.c new file +313 -0

313 lines not on this page · raw message

include/sysemu/char.h +3 -0
index b81a6ff..f769e3b 100644
@@ -306,6 +306,9 @@ CharDriverState *qemu_char_get_next_serial(void);
 /* msmouse */
 CharDriverState *qemu_chr_open_msmouse(void);
 
+/* gnmouse */
+CharDriverState *qemu_chr_open_gnmouse(void);
+
 /* baum.c */
 CharDriverState *chr_baum_init(void);
 
qapi-schema.json +1 -0
index c3c939c..5a5db7f 100644
@@ -3617,6 +3617,7 @@
                                        'null'   : 'ChardevDummy',
                                        'mux'    : 'ChardevMux',
                                        'msmouse': 'ChardevDummy',
+                                       'gnmouse': 'ChardevDummy',
                                        'braille': 'ChardevDummy',
                                        'stdio'  : 'ChardevStdio',
                                        'console': 'ChardevDummy',
qemu-char.c +4 -0
index 418dc69..9766815 100644
@@ -2961,6 +2961,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
     if (strcmp(filename, "null")    == 0 ||
         strcmp(filename, "pty")     == 0 ||
         strcmp(filename, "msmouse") == 0 ||
+        strcmp(filename, "gnmouse") == 0 ||
         strcmp(filename, "braille") == 0 ||
         strcmp(filename, "stdio")   == 0) {
         qemu_opt_set(opts, "backend", filename);
@@ -3732,6 +3733,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
     case CHARDEV_BACKEND_KIND_MSMOUSE:
         chr = qemu_chr_open_msmouse();
         break;
+    case CHARDEV_BACKEND_KIND_GNMOUSE:
+        chr = qemu_chr_open_gnmouse();
+        break;
 #ifdef CONFIG_BRLAPI
     case CHARDEV_BACKEND_KIND_BRAILLE:
         chr = chr_baum_init();
qemu-options.hx +15 -2
index bcfe9ea..4f64d7d 100644
@@ -1792,6 +1792,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
     "-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]\n"
     "         [,localport=localport][,ipv4][,ipv6][,mux=on|off]\n"
     "-chardev msmouse,id=id[,mux=on|off]\n"
+    "-chardev gnmouse,id=id[,mux=on|off]\n"
     "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
     "         [,mux=on|off]\n"
     "-chardev ringbuf,id=id[,size=size]\n"
@@ -1831,6 +1832,7 @@ Backend is one of:
 @option{socket},
 @option{udp},
 @option{msmouse},
+@option{gnmouse},
 @option{vc},
 @option{ringbuf},
 @option{file},
@@ -1927,8 +1929,16 @@ If neither is specified the device may use either protocol.
 
 @item -chardev msmouse ,id=@var{id}
 
-Forward QEMU's emulated msmouse events to the guest. @option{msmouse} does not
-take any options.
+Forward events from QEMU's emulated mouse to the guest using the
+Microsoft protocol. @option{msmouse} does not take any options.
+
+@item -chardev gnmouse ,id=@var{id}
+
+Forward events from QEMU's emulated mouse to the guest using the Genius
+(Mouse Systems) protocol. Use msmouse unless your guest OS only
+supports the Mouse Systems protocol.
+
+@option{gnmouse} does not take any options.
 
 @item -chardev vc ,id=@var{id} [[,width=@var{width}] [,height=@var{height}]] [[,cols=@var{cols}] [,rows=@var{rows}]]
 
@@ -2514,6 +2524,9 @@ or fake device.
 
 @item msmouse
 Three button serial mouse. Configure the guest to use Microsoft protocol.
+
+@item gnmouse
+Three button serial mouse. Configure the guest to use Mouse Systems protocol.
 @end table
 ETEXI
 
Signature · 1 line
1.8.4.2