Message ID | b89da09c-b0a4-6bfa-6f14-264e0fcf9946@lesniak-it.de |
---|---|
State | New |
Headers | show |
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.
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
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;
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(-) case EV_REL: