Skip to contentSkip to conversation

add support for mice with extra/side buttons

PATCH In review Fabian Lesniak 2 participants 6 messages Dec 6, 2016 – Jan 10, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover add support for mice with extra/side buttons

This patch implements event handling for 5-button ps/2 mice and appropriate event generation for gtk and input-linux input methods.

As Gerd suggested, it is now split into three parts and introduces distinct ps2 mouse button definitions instead of using the legacy ones from console.h. Please comment on the location of the new definitions if inappropriate.

The changes to qapi were improved following Eric's hints.

Fabian Lesniak (3):
qapi: add support for mice with extra/side buttons
ps2: add support for mice with extra/side buttons
ui: add support for mice with extra/side buttons

 hw/input/ps2.c         | 8 +++++---
 include/hw/input/ps2.h | 6 ++++++
 qapi-schema.json       | 7 ++++++-
 ui/gtk.c               | 4 ++++
 ui/input-linux.c       | 6 ++++++
 5 files changed, 27 insertions(+), 4 deletions(-)
Signature · 1 line
2.10.2
#1 lore raw

PATCH v3 1/3 qapi: add support for mice with extra/side buttons

Adds "side" and "extra" values to enum InputButton. The naming was borrowed from evdev since it is more descriptive than "button4" and "button5".

---
 qapi-schema.json | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qapi-schema.json +6 -1
index f3e9bfc..7f3272f 100644
@@ -4277,10 +4277,15 @@
 #
 # Button of a pointer input device (mouse, tablet).
 #
+# @side: front side button of a 5-button mouse (since 2.9)
+#
+# @extra: rear side button of a 5-button mouse (since 2.9)
+#
 # Since: 2.0
 ##
 { 'enum'  : 'InputButton',
-  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] }
+  'data'  : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 'side',
+  'extra' ] }
 
 ##
 # @InputAxis
Signature · 1 line
2.10.2
#2 lore raw

PATCH v3 2/3 ps2: add support for mice with extra/side buttons

In reply to Fabian Lesniak

This enables the ps2 controller to process mouse events for buttons 4 and 5. Additionally, distinct definitions for the ps2 mouse button state are introduced. The legacy definitions from console.h are not used anymore.

---
 hw/input/ps2.c         | 8 +++++---
 include/hw/input/ps2.h | 6 ++++++
 2 files changed, 11 insertions(+), 3 deletions(-)
hw/input/ps2.c +5 -3
index 0d14de0..598cc86 100644
@@ -871,9 +871,11 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
                             InputEvent *evt)
 {
     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_LEFT]   = PS2_MOUSE_BUTTON_LEFT,
+        [INPUT_BUTTON_MIDDLE] = PS2_MOUSE_BUTTON_MIDDLE,
+        [INPUT_BUTTON_RIGHT]  = PS2_MOUSE_BUTTON_RIGHT,
+        [INPUT_BUTTON_SIDE]   = PS2_MOUSE_BUTTON_SIDE,
+        [INPUT_BUTTON_EXTRA]  = PS2_MOUSE_BUTTON_EXTRA,
     };
     PS2MouseState *s = (PS2MouseState *)dev;
     InputMoveEvent *move;
include/hw/input/ps2.h +6 -0
index b9ceee4..0fec91c 100644
@@ -25,6 +25,12 @@
 #ifndef HW_PS2_H
 #define HW_PS2_H
 
+#define PS2_MOUSE_BUTTON_LEFT   0x01
+#define PS2_MOUSE_BUTTON_MIDDLE 0x02
+#define PS2_MOUSE_BUTTON_RIGHT  0x04
+#define PS2_MOUSE_BUTTON_SIDE   0x08
+#define PS2_MOUSE_BUTTON_EXTRA  0x10
+
 /* ps2.c */
 void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
 void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
Signature · 1 line
2.10.2
#3 lore raw

PATCH v3 3/3 ui: add support for mice with extra/side buttons

In reply to Fabian Lesniak

Adds input event generation for BTN_SIDE and BTN_EXTRA events to gtk and input-linux methods.

---
 ui/gtk.c         | 4 ++++
 ui/input-linux.c | 6 ++++++
 2 files changed, 10 insertions(+)
ui/gtk.c +4 -0
index e816428..9cdce83 100644
@@ -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;
     }
ui/input-linux.c +6 -0
index f345317..ac31f47 100644
@@ -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:
Signature · 1 line
2.10.2
#4 lore raw
In reply to Fabian Lesniak

Ping.

I forgot to CC Gerd.

http://patchwork.ozlabs.org/patch/703302/

http://patchwork.ozlabs.org/patch/703304/

http://patchwork.ozlabs.org/patch/703303/

Am 06.12.2016 um 20:00 schrieb Fabian Lesniak:

Quoted 22 lines

This patch implements event handling for 5-button ps/2 mice and appropriate event generation for gtk and input-linux input methods.

As Gerd suggested, it is now split into three parts and introduces distinct ps2 mouse button definitions instead of using the legacy ones from console.h. Please comment on the location of the new definitions if inappropriate.

The changes to qapi were improved following Eric's hints.

Fabian Lesniak (3):
qapi: add support for mice with extra/side buttons
ps2: add support for mice with extra/side buttons
ui: add support for mice with extra/side buttons

  hw/input/ps2.c         | 8 +++++---
  include/hw/input/ps2.h | 6 ++++++
  qapi-schema.json       | 7 ++++++-
  ui/gtk.c               | 4 ++++
  ui/input-linux.c       | 6 ++++++
  5 files changed, 27 insertions(+), 4 deletions(-)