Skip to contentSkip to conversation

Genius serial mouse emulation.

PATCH Superseded Romain Naour 3 participants 6 messages Jan 13, 2014 – Jan 14, 2014

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Genius serial mouse emulation.

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

This work was developed for qemu-1.1.0 and rebased on master.

To test this patch you need to start qemu with "-serial gnmouse". Then you need to start gpm (general purpose mouse) on Linux:

# gpm -m /dev/ttyS0 -T -t msc

I validated the emulation by comparing frames with a real mouse Genius (GM-6) with a USB-serial adapter (ttyUSB0).

I also tested with a CDOS operating system.

Best regards,
Romain Naour

[1] MSC protocol:
http://www.zimmers.net/anonftp/pub/cbm/documents/projects/interfaces/mouse/Mouse.html#serial

Romain Naour (1):
genius: add genius serial mouse emulation

 backends/Makefile.objs |   2 +-
 backends/gnmouse.c     | 339 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/char.h  |   3 +
 qapi-schema.json       |   1 +
 qemu-char.c            |   4 +
 qemu-options.hx        |  10 ++
 6 files changed, 358 insertions(+), 1 deletion(-)
 create mode 100644 backends/gnmouse.c
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 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 mouse.

---
 backends/Makefile.objs |   2 +-
 backends/gnmouse.c     | 339 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/char.h  |   3 +
 qapi-schema.json       |   1 +
 qemu-char.c            |   4 +
 qemu-options.hx        |  10 ++
 6 files changed, 358 insertions(+), 1 deletion(-)
 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 +339 -0

339 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 +10 -0
index bcfe9ea..0274e57 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},
@@ -1930,6 +1932,11 @@ If neither is specified the device may use either protocol.
 Forward QEMU's emulated msmouse events to the guest. @option{msmouse} does not
 take any options.
 
+@item -chardev gnmouse ,id=@var{id}
+
+Forward QEMU's emulated gnmouse events to the guest. @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}]]
 
 Connect to a QEMU text console. @option{vc} may optionally be given a specific
@@ -2514,6 +2521,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 Genius protocol.
 @end table
 ETEXI
 
Signature · 1 line
1.8.4.2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/1] genius: add genius serial mouse emulation

Quoted 17 lines · Romain Naour

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

---
 backends/Makefile.objs |   2 +-
 backends/gnmouse.c     | 339 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/char.h  |   3 +
 qapi-schema.json       |   1 +
 qemu-char.c            |   4 +
 qemu-options.hx        |  10 ++
 6 files changed, 358 insertions(+), 1 deletion(-)
 create mode 100644 backends/gnmouse.c

+++ b/backends/gnmouse.c

backends/gnmouse.c line 6

Quoted 6 lines
backends/gnmouse.c new file +6 -0
@@ -0,0 +1,339 @@
+/*
+ * QEMU Genius GM-6 serial mouse emulation
+ *
+ * Adapted from msmouse
+ *
+ * Copyright (c) 2012 Romain Naour

It is now 2014.

qapi-schema.json line 3623

Quoted 9 lines
qapi-schema.json +2 -0
+++ b/qapi-schema.json
@@ -3617,6 +3617,7 @@
                                        'null'   : 'ChardevDummy',
                                        'mux'    : 'ChardevMux',
                                        'msmouse': 'ChardevDummy',
+                                       'gnmouse': 'ChardevDummy',
                                        'braille': 'ChardevDummy',
                                        'stdio'  : 'ChardevStdio',
                                        'console': 'ChardevDummy',

Ideally, you should also document that this branch was not always available in the union (I was expecting to see a doc line with '(since 2.0)' somewhere in the patch); but looking at the existing schema, you're just copying bad practice of adding to an already under-documented union.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH 1/1] genius: add genius serial mouse emulation

Hi,

Thanks for review.

Quoted 16 lines · Eric Blake
Quoted 15 lines · Romain Naour

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

---
  backends/Makefile.objs |   2 +-
  backends/gnmouse.c     | 339 +++++++++++++++++++++++++++++++++++++++++++++++++
  include/sysemu/char.h  |   3 +
  qapi-schema.json       |   1 +
  qemu-char.c            |   4 +
  qemu-options.hx        |  10 ++
  6 files changed, 358 insertions(+), 1 deletion(-)

create mode 100644 backends/gnmouse.c
+++ b/backends/gnmouse.c

Quoted 8 lines

backends/gnmouse.c line 6

Quoted 7 lines
backends/gnmouse.c new file +6 -0
@@ -0,0 +1,339 @@
+/*
+ * QEMU Genius GM-6 serial mouse emulation
+ *
+ * Adapted from msmouse
+ *
+ * Copyright (c) 2012 Romain Naour

It is now 2014.

Fixed

Quoted 17 lines

qapi-schema.json line 3623

Quoted 11 lines
qapi-schema.json +2 -0
+++ b/qapi-schema.json
@@ -3617,6 +3617,7 @@
                                         'null'   : 'ChardevDummy',
                                         'mux'    : 'ChardevMux',
                                         'msmouse': 'ChardevDummy',
+                                       'gnmouse': 'ChardevDummy',
                                         'braille': 'ChardevDummy',
                                         'stdio'  : 'ChardevStdio',
                                         'console': 'ChardevDummy',

Ideally, you should also document that this branch was not always available in the union (I was expecting to see a doc line with '(since 2.0)' somewhere in the patch); but looking at the existing schema, you're just copying bad practice of adding to an already under-documented union.

You mean something like that ?
##
# @ChardevBackendKind:
#
# A union referencing different chardev backend configuration' info. #
# Since: 1.4
#

# gnmouse backend since: 2.0
##
{ 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
[snip]

I will resend a v2 tomorrow.

Best regards,
Romain Naour

#4 lore raw

Re: [Qemu-devel] [PATCH 1/1] genius: add genius serial mouse emulation

Il 14/01/2014 00:47, Romain Naour ha scritto:

Quoted 57 lines

Hi,

Thanks for review.

Quoted 17 lines · Eric Blake
Quoted 16 lines · Romain Naour

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

---
  backends/Makefile.objs |   2 +-
  backends/gnmouse.c     | 339
+++++++++++++++++++++++++++++++++++++++++++++++++
  include/sysemu/char.h  |   3 +
  qapi-schema.json       |   1 +
  qemu-char.c            |   4 +
  qemu-options.hx        |  10 ++
  6 files changed, 358 insertions(+), 1 deletion(-)

create mode 100644 backends/gnmouse.c
+++ b/backends/gnmouse.c

Quoted 8 lines

backends/gnmouse.c line 6

Quoted 7 lines
backends/gnmouse.c new file +6 -0
@@ -0,0 +1,339 @@
+/*
+ * QEMU Genius GM-6 serial mouse emulation
+ *
+ * Adapted from msmouse
+ *
+ * Copyright (c) 2012 Romain Naour

It is now 2014.

Fixed

Quoted 17 lines

qapi-schema.json line 3623

Quoted 11 lines
qapi-schema.json +2 -0
+++ b/qapi-schema.json
@@ -3617,6 +3617,7 @@
                                         'null'   : 'ChardevDummy',
                                         'mux'    : 'ChardevMux',
                                         'msmouse': 'ChardevDummy',
+                                       'gnmouse': 'ChardevDummy',
                                         'braille': 'ChardevDummy',
                                         'stdio'  : 'ChardevStdio',
                                         'console': 'ChardevDummy',

Ideally, you should also document that this branch was not always available in the union (I was expecting to see a doc line with '(since 2.0)' somewhere in the patch); but looking at the existing schema, you're just copying bad practice of adding to an already under-documented union.

You mean something like that ?
##
# @ChardevBackendKind:
#
# A union referencing different chardev backend configuration' info. #
# Since: 1.4
#

Quoted 5 lines
# gnmouse backend since: 2.0
##
{ 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
[snip]

The standard is more like

# A union referencing different chardev backend configuration' info. #
# @gnmouse: Send mouse data using the Genius protocol (since 2.0). #
# Since: 1.4
##

but that format would require doucmenting all items. :(

You can leave this out of v2.

However, I'd be happy if you changed the documentation like this

@item -chardev msmouse,id=@var{id}
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. @option{gnmouse} does not take any options.

#5 lore raw

Re: [Qemu-devel] [PATCH 1/1] genius: add genius serial mouse emulation

Hi,

Quoted 15 lines

The standard is more like

# A union referencing different chardev backend configuration' info. #
# @gnmouse: Send mouse data using the Genius protocol (since 2.0). #
# Since: 1.4
##

but that format would require doucmenting all items. :(

You can leave this out of v2.

However, I'd be happy if you changed the documentation like this

Quoted 8 lines

@item -chardev msmouse,id=@var{id}
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. @option{gnmouse} does not take any options.

Certainly, I changed the documentation accordingly. The v2 in on the way.

Best regards,
Romain Naour