2005-12-09 14:11:04

by Jan Engelhardt

[permalink] [raw]
Subject: Mouse button swapping

Hi,


I produced a small patch that allows one to flip the mouse buttons at the
kernel level. This is useful for changing it on a per-system basis, i.e. it
will affect gpm, X and VMware all at once. It is changeable through
/sys/module/mousedev/swap_buttons at runtime. Is this something mainline would
be interested in?

diff -dpru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c 2005-10-22 20:59:22.000000000 +0200
+++ b/drivers/input/mousedev.c 2005-11-22 19:32:01.000000000 +0100
@@ -40,6 +40,10 @@ MODULE_LICENSE("GPL");
#define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
#endif

+static unsigned int swap_buttons = 0;
+module_param(swap_buttons, uint, 0644);
+MODULE_PARM_DESC(swap_buttons, "Swap left and right mouse buttons");
+
static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
module_param(xres, uint, 0);
MODULE_PARM_DESC(xres, "Horizontal screen resolution");
@@ -191,10 +195,10 @@ static void mousedev_key_event(struct mo
case BTN_TOUCH:
case BTN_0:
case BTN_FORWARD:
- case BTN_LEFT: index = 0; break;
+ case BTN_LEFT: index = !!swap_buttons; break;
case BTN_STYLUS:
case BTN_1:
- case BTN_RIGHT: index = 1; break;
+ case BTN_RIGHT: index = !swap_buttons; break;
case BTN_2:
case BTN_STYLUS2:
case BTN_MIDDLE: index = 2; break;
# eof


Jan Engelhardt
--


2005-12-12 11:08:06

by Clemens Koller

[permalink] [raw]
Subject: Re: Mouse button swapping

Hello, Jan!

> I produced a small patch that allows one to flip the mouse buttons at the
> kernel level. This is useful for changing it on a per-system basis, i.e. it
> will affect gpm, X and VMware all at once. It is changeable through
> /sys/module/mousedev/swap_buttons at runtime. Is this something mainline would
> be interested in?

Jup, sounds interesting. Maybe it would be fine to add some more documentation,
otherwise the feature might get lost in space.
I also can imagine to have free button-mapping somewhere... for multi-button
mices, configurable from right to left-handed use on the fly.

Greets,
--
Clemens Koller
_______________________________
R&D Imaging Devices
Anagramm GmbH
Rupert-Mayer-Str. 45/1
81379 Muenchen
Germany

http://www.anagramm.de
Phone: +49-89-741518-50
Fax: +49-89-741518-19

2005-12-13 06:08:33

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: Mouse button swapping

On Friday 09 December 2005 09:10, Jan Engelhardt wrote:
> Hi,
>
>
> I produced a small patch that allows one to flip the mouse buttons at the
> kernel level. This is useful for changing it on a per-system basis, i.e. it
> will affect gpm, X and VMware all at once. It is changeable through
> /sys/module/mousedev/swap_buttons at runtime. Is this something mainline would
> be interested in?

I am not sure if this should be done in kernel. It will also not work for mouse
drivers using event interface (which hopefully will be default someday) instead
of legacy mousedev interface.

--
Dmitry

2005-12-13 07:34:33

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: Mouse button swapping

On Tue, Dec 13, 2005 at 01:08:28AM -0500, Dmitry Torokhov wrote:
> On Friday 09 December 2005 09:10, Jan Engelhardt wrote:
> > Hi,
> >
> >
> > I produced a small patch that allows one to flip the mouse buttons at the
> > kernel level. This is useful for changing it on a per-system basis, i.e. it
> > will affect gpm, X and VMware all at once. It is changeable through
> > /sys/module/mousedev/swap_buttons at runtime. Is this something mainline would
> > be interested in?
>
> I am not sure if this should be done in kernel. It will also not work for mouse
> drivers using event interface (which hopefully will be default someday) instead
> of legacy mousedev interface.

It shouldn't be done by the kernel. Perhaps a shared configuration, but
the same way keymaps aren't handled by the kernel for the applications,
mouse button remapping shouldn't be there.

On the other hand, we have button remapping in joydev, to support old
applications that can't handle it themselves. By the same logic, it
could be in mousedev, to support remapping of buttons on applications
(older vmware), where there is no way to change it.

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2005-12-14 11:44:04

by Pavel Machek

[permalink] [raw]
Subject: Re: Mouse button swapping

Hi!

> I produced a small patch that allows one to flip the mouse buttons at the
> kernel level. This is useful for changing it on a per-system basis, i.e. it
> will affect gpm, X and VMware all at once. It is changeable through
> /sys/module/mousedev/swap_buttons at runtime. Is this something mainline would
> be interested in?

Hopefully not. This should _not_ be done at kernel level. But fixing
X, gpm and vmware to load same config would be nice....
Pavel

> diff -dpru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
> --- a/drivers/input/mousedev.c 2005-10-22 20:59:22.000000000 +0200
> +++ b/drivers/input/mousedev.c 2005-11-22 19:32:01.000000000 +0100
> @@ -40,6 +40,10 @@ MODULE_LICENSE("GPL");
> #define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
> #endif
>
> +static unsigned int swap_buttons = 0;
> +module_param(swap_buttons, uint, 0644);
> +MODULE_PARM_DESC(swap_buttons, "Swap left and right mouse buttons");
> +
> static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
> module_param(xres, uint, 0);
> MODULE_PARM_DESC(xres, "Horizontal screen resolution");
> @@ -191,10 +195,10 @@ static void mousedev_key_event(struct mo
> case BTN_TOUCH:
> case BTN_0:
> case BTN_FORWARD:
> - case BTN_LEFT: index = 0; break;
> + case BTN_LEFT: index = !!swap_buttons; break;
> case BTN_STYLUS:
> case BTN_1:
> - case BTN_RIGHT: index = 1; break;
> + case BTN_RIGHT: index = !swap_buttons; break;
> case BTN_2:
> case BTN_STYLUS2:
> case BTN_MIDDLE: index = 2; break;
> # eof
>
>
> Jan Engelhardt

--
Thanks, Sharp!