qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons
@ 2016-11-24 13:16 Fabian Lesniak
  2016-11-28 17:32 ` Eric Blake
  2016-11-29  7:51 ` Gerd Hoffmann
  0 siblings, 2 replies; 3+ messages in thread
From: Fabian Lesniak @ 2016-11-24 13:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

This patch introduces the SIDE and EXTRA mouse buttons and implements
appropriate event generation for gtk and input-linux input methods.

The naming was borrowed from evdev since it is more descriptive than
BUTTON4/5.

Note that the guest has to switch the ps2 mouse into IMEX mode,
otherwise events of the extra buttons are ignored. For example on a Windows
guest one needs to manually select the "Microsoft PS/2 Mouse" driver.

Signed-off-by: Fabian Lesniak <fabian@lesniak-it.de>
---
  hw/input/ps2.c   | 6 ++++++
  qapi-schema.json | 2 +-
  ui/gtk.c         | 4 ++++
  ui/input-linux.c | 6 ++++++
  4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 0d14de0..7347da5 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -870,10 +870,16 @@ static void ps2_mouse_send_packet(PS2MouseState *s)
  static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
                              InputEvent *evt)
  {
+    /* the definition of MOUSE_EVENT_WHEELUP/MOUSE_EVENT_WHEELDN
+     * is ambiguous since ps2_mouse_send_packet expects the bits
+     * for buttons 4 and 5 at s->mouse_buttons & 0x18 which
+     * matches MOUSE_EVENT_WHEELUP/MOUSE_EVENT_WHEELDN */
      static const int bmap[INPUT_BUTTON__MAX] = {
          [INPUT_BUTTON_LEFT]   = MOUSE_EVENT_LBUTTON,
          [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
          [INPUT_BUTTON_RIGHT]  = MOUSE_EVENT_RBUTTON,
+        [INPUT_BUTTON_SIDE]   = MOUSE_EVENT_WHEELUP,
+        [INPUT_BUTTON_EXTRA]  = MOUSE_EVENT_WHEELDN,
      };
      PS2MouseState *s = (PS2MouseState *)dev;
      InputMoveEvent *move;
diff --git a/qapi-schema.json b/qapi-schema.json
index f3e9bfc..dc7b28c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4280,7 +4280,7 @@
  # Since: 2.0
  ##
  { 'enum'  : 'InputButton',
-  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] }
+  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 
'side', 'extra' ] }

  ##
  # @InputAxis
diff --git a/ui/gtk.c b/ui/gtk.c
index e816428..9cdce83 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -995,6 +995,10 @@ static gboolean gd_button_event(GtkWidget *widget, 
GdkEventButton *button,
          btn = INPUT_BUTTON_MIDDLE;
      } else if (button->button == 3) {
          btn = INPUT_BUTTON_RIGHT;
+    } else if (button->button == 8) {
+        btn = INPUT_BUTTON_SIDE;
+    } else if (button->button == 9) {
+        btn = INPUT_BUTTON_EXTRA;
      } else {
          return TRUE;
      }
diff --git a/ui/input-linux.c b/ui/input-linux.c
index f345317..ac31f47 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -291,6 +291,12 @@ static void input_linux_handle_mouse(InputLinux 
*il, struct input_event *event)
              qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_DOWN,
                                   event->value);
              break;
+        case BTN_SIDE:
+            qemu_input_queue_btn(NULL, INPUT_BUTTON_SIDE, event->value);
+            break;
+        case BTN_EXTRA:
+            qemu_input_queue_btn(NULL, INPUT_BUTTON_EXTRA, event->value);
+            break;
          };
          break;
      case EV_REL:
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons
  2016-11-24 13:16 [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons Fabian Lesniak
@ 2016-11-28 17:32 ` Eric Blake
  2016-11-29  7:51 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-11-28 17:32 UTC (permalink / raw)
  To: Fabian Lesniak, qemu-devel; +Cc: kraxel

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

On 11/24/2016 07:16 AM, Fabian Lesniak wrote:
> This patch introduces the SIDE and EXTRA mouse buttons and implements
> appropriate event generation for gtk and input-linux input methods.
> 
> The naming was borrowed from evdev since it is more descriptive than
> BUTTON4/5.
> 
> Note that the guest has to switch the ps2 mouse into IMEX mode,
> otherwise events of the extra buttons are ignored. For example on a Windows
> guest one needs to manually select the "Microsoft PS/2 Mouse" driver.
> 
> Signed-off-by: Fabian Lesniak <fabian@lesniak-it.de>
> ---
>  hw/input/ps2.c   | 6 ++++++
>  qapi-schema.json | 2 +-
>  ui/gtk.c         | 4 ++++
>  ui/input-linux.c | 6 ++++++
>  4 files changed, 17 insertions(+), 1 deletion(-)
> 

> +++ b/qapi-schema.json
> @@ -4280,7 +4280,7 @@
>  # Since: 2.0

Please document the new enum members, including the fact that they are
'(since 2.9)'.

>  ##
>  { 'enum'  : 'InputButton',
> -  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] }
> +  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down',
> 'side', 'extra' ] }

Also, please keep this file under 80 columns.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons
  2016-11-24 13:16 [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons Fabian Lesniak
  2016-11-28 17:32 ` Eric Blake
@ 2016-11-29  7:51 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2016-11-29  7:51 UTC (permalink / raw)
  To: Fabian Lesniak; +Cc: qemu-devel

  Hi,

> +    /* the definition of MOUSE_EVENT_WHEELUP/MOUSE_EVENT_WHEELDN
> +     * is ambiguous since ps2_mouse_send_packet expects the bits
> +     * for buttons 4 and 5 at s->mouse_buttons & 0x18 which
> +     * matches MOUSE_EVENT_WHEELUP/MOUSE_EVENT_WHEELDN */
>       static const int bmap[INPUT_BUTTON__MAX] = {
>           [INPUT_BUTTON_LEFT]   = MOUSE_EVENT_LBUTTON,
>           [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
>           [INPUT_BUTTON_RIGHT]  = MOUSE_EVENT_RBUTTON,
> +        [INPUT_BUTTON_SIDE]   = MOUSE_EVENT_WHEELUP,
> +        [INPUT_BUTTON_EXTRA]  = MOUSE_EVENT_WHEELDN,

Please create new #defines for all the ps2 mouse buttons (locally in
ps2.c), that'll be less confusing.

The MOUSE_EVENT_*BUTTON #defines happen to match the ps2 protocol, for
historic reasons.  But they should not be used that way any more.  The
WHEEL defines are not used at all in the code base.  I'll go send a
patch to drop them.

Oh, and please split this patch into multiple smaller ones.  I'd suggest
one json, one for ui/* and one for ps2.

> @@ -4280,7 +4280,7 @@
>   # Since: 2.0
>   ##
>   { 'enum'  : 'InputButton',
> -  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] }
> +  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 
> 'side', 'extra' ] }

Patch looks mangled.  Happens often when you cut+paste patches into a
graphical or web client.  Try "git send-email" instead.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-29  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24 13:16 [Qemu-devel] [PATCH] ps2: add support for mice with extra/side buttons Fabian Lesniak
2016-11-28 17:32 ` Eric Blake
2016-11-29  7:51 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).