linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
@ 2008-09-05  1:19 Henrik Rydberg
  2008-09-10 12:52 ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Rydberg @ 2008-09-05  1:19 UTC (permalink / raw)
  To: akpm, Dmitry Torokhov, linux-input; +Cc: linux-kernel

On most linux-based systems, the right and middle buttons are used
extensively. On computers lacking either of those buttons, such as
the Apple Macbooks, emulation is needed. This patch adds emulation
of the missing buttons via two-fingers-and-click and three-fingers-
and-click operations, which has recently become standard, both in
MacOS and in the Xorg synaptics driver.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/input/mousedev.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 27e1d73..a1e929f 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -53,6 +53,14 @@ static unsigned tap_move = 20;
 module_param(tap_move, uint, 0644);
 MODULE_PARM_DESC(tap_move, "Tap distance for touchpads in absolute mode (res)");

+static unsigned two_finger_code = BTN_RIGHT;
+module_param(two_finger_code, uint, 0644);
+MODULE_PARM_DESC(two_finger_code, "Button code of two-finger click");
+
+static unsigned three_finger_code = BTN_MIDDLE;
+module_param(three_finger_code, uint, 0644);
+MODULE_PARM_DESC(three_finger_code, "Button code of three-finger click");
+
 struct mousedev_hw_data {
 	int dx, dy, dz;
 	int x, y;
@@ -81,6 +89,7 @@ struct mousedev {
 	int frac_dx, frac_dy;
 	unsigned long touch;
 	int touch_dx, touch_dy;
+	int double_tap, triple_tap;
 };

 enum mousedev_emul {
@@ -225,11 +234,31 @@ static void mousedev_rel_event(struct mousedev *mousedev,
 	}
 }

+/* multi-finger emulation of non-existing buttons */
+static unsigned int get_button_code(const struct mousedev *mousedev)
+{
+	unsigned int code = BTN_LEFT;
+	if (mousedev->double_tap)
+		code = two_finger_code;
+	if (mousedev->triple_tap)
+		code = three_finger_code;
+	if (test_bit(code, mousedev->handle.dev->keybit))
+		code = BTN_LEFT;
+	return code;
+}
+
 static void mousedev_key_event(struct mousedev *mousedev,
 				unsigned int code, int value)
 {
 	int index;

+	if (code == BTN_TOOL_DOUBLETAP)
+		mousedev->double_tap = value;
+	if (code == BTN_TOOL_TRIPLETAP)
+		mousedev->triple_tap = value;
+	if (code == BTN_LEFT)
+		code = get_button_code(mousedev);
+
 	switch (code) {

 	case BTN_TOUCH:
@@ -327,6 +356,8 @@ static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
 {
 	if (!value) {
 		if (mousedev->touch &&
+		    !mousedev->double_tap &&
+		    !mousedev->triple_tap &&
 		    abs(mousedev->touch_dx) < tap_move &&
 		    abs(mousedev->touch_dy) < tap_move &&
 		    time_before(jiffies,
-- 
1.5.4.3


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

* Re: [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
  2008-09-05  1:19 [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads Henrik Rydberg
@ 2008-09-10 12:52 ` Dmitry Torokhov
  2008-09-10 14:51   ` Henrik Rydberg
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2008-09-10 12:52 UTC (permalink / raw)
  To: Henrik Rydberg; +Cc: akpm, linux-input, linux-kernel

Hi Henrik,

On Fri, Sep 05, 2008 at 03:19:56AM +0200, Henrik Rydberg wrote:
> On most linux-based systems, the right and middle buttons are used
> extensively. On computers lacking either of those buttons, such as
> the Apple Macbooks, emulation is needed. This patch adds emulation
> of the missing buttons via two-fingers-and-click and three-fingers-
> and-click operations, which has recently become standard, both in
> MacOS and in the Xorg synaptics driver.
> 

The standard way of emulating right and middle button presses for
"button-deficient" devices is to use Macintosh emulation
(MAC_EMUMOUSEBTN) that works not only for touchpads but for regular mice
as well.

Overall I don't think we should enhance mousedev for scenarios where
proper solution is to install Synaptics X driver. This also goes for
your other patch improving tapping in mousedev.

-- 
Dmitry

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

* Re: [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
  2008-09-10 12:52 ` Dmitry Torokhov
@ 2008-09-10 14:51   ` Henrik Rydberg
  2008-09-10 15:32     ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Rydberg @ 2008-09-10 14:51 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: akpm, linux-input, linux-kernel

Greetings Dmitry,

> On Fri, Sep 05, 2008 at 03:19:56AM +0200, Henrik Rydberg wrote:
>> On most linux-based systems, the right and middle buttons are used
>> extensively. On computers lacking either of those buttons, such as
>> the Apple Macbooks, emulation is needed. This patch adds emulation
>> of the missing buttons via two-fingers-and-click and three-fingers-
>> and-click operations, which has recently become standard, both in
>> MacOS and in the Xorg synaptics driver.
>>
> 
> The standard way of emulating right and middle button presses for
> "button-deficient" devices is to use Macintosh emulation
> (MAC_EMUMOUSEBTN) that works not only for touchpads but for regular mice
> as well.

I have a hard time believing that in five years from now, people will
still consider pressing a key on the keyboard the standard way to
emulate a right click. Nevertheless, I can see the point in moving
away from user-land decisions in the kernel. I will not pursue this one
further, although it is a rather neat piece of functionality.

> Overall I don't think we should enhance mousedev for scenarios where
> proper solution is to install Synaptics X driver. This also goes for
> your other patch improving tapping in mousedev.

Regarding the tapping patch; it is addressing the correctness of
already implemented functionality. I can see nothing wrong with that.

Henrik

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

* Re: [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
  2008-09-10 14:51   ` Henrik Rydberg
@ 2008-09-10 15:32     ` Dmitry Torokhov
  2008-09-10 16:05       ` Henrik Rydberg
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2008-09-10 15:32 UTC (permalink / raw)
  To: Henrik Rydberg; +Cc: akpm, linux-input, linux-kernel

On Wed, Sep 10, 2008 at 04:51:52PM +0200, Henrik Rydberg wrote:
> Greetings Dmitry,
> 
> > On Fri, Sep 05, 2008 at 03:19:56AM +0200, Henrik Rydberg wrote:
> >> On most linux-based systems, the right and middle buttons are used
> >> extensively. On computers lacking either of those buttons, such as
> >> the Apple Macbooks, emulation is needed. This patch adds emulation
> >> of the missing buttons via two-fingers-and-click and three-fingers-
> >> and-click operations, which has recently become standard, both in
> >> MacOS and in the Xorg synaptics driver.
> >>
> > 
> > The standard way of emulating right and middle button presses for
> > "button-deficient" devices is to use Macintosh emulation
> > (MAC_EMUMOUSEBTN) that works not only for touchpads but for regular mice
> > as well.
> 
> I have a hard time believing that in five years from now, people will
> still consider pressing a key on the keyboard the standard way to
> emulate a right click.

Well, what other options do you have if your device has only one
button and nothing else (i.e. it's a mouse, not a touchpad)? Anyway, I
hope in 5 years distros will switch to pure evdev-based interfaces and
won't use mousedev at all.

> Nevertheless, I can see the point in moving
> away from user-land decisions in the kernel. I will not pursue this one
> further, although it is a rather neat piece of functionality.
> 
> > Overall I don't think we should enhance mousedev for scenarios where
> > proper solution is to install Synaptics X driver. This also goes for
> > your other patch improving tapping in mousedev.
> 
> Regarding the tapping patch; it is addressing the correctness of
> already implemented functionality. I can see nothing wrong with that.
>

My position that since the isssue can be "fixed" by simply installing
the proper X driver I'd rather not include it. Mousedev purpose is to
provide good enough emulation in absence of a native driver and that's
it. Also, the default value would not work well on high-resiolution
devices (like Synaptics) and would require user fiddling with kernel
parameters - not worth it in my opinion.

-- 
Dmitry

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

* Re: [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
  2008-09-10 15:32     ` Dmitry Torokhov
@ 2008-09-10 16:05       ` Henrik Rydberg
  2008-09-11  6:31         ` Henrik Rydberg
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Rydberg @ 2008-09-10 16:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: akpm, linux-input, linux-kernel

>> Regarding the tapping patch; it is addressing the correctness of
>> already implemented functionality. I can see nothing wrong with that.
>>
> 
> My position that since the isssue can be "fixed" by simply installing
> the proper X driver I'd rather not include it. Mousedev purpose is to
> provide good enough emulation in absence of a native driver and that's
> it. Also, the default value would not work well on high-resiolution
> devices (like Synaptics) and would require user fiddling with kernel
> parameters - not worth it in my opinion.

The parameter could be made dimensionless and the distance test scaled
with the size of the device; the argument invalidates the current patch,
but not the idea itself. Maybe the patch will appear in acceptable form
at some point, but for now, I rest my case.

Henrik

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

* Re: [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads
  2008-09-10 16:05       ` Henrik Rydberg
@ 2008-09-11  6:31         ` Henrik Rydberg
  0 siblings, 0 replies; 6+ messages in thread
From: Henrik Rydberg @ 2008-09-11  6:31 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: akpm, linux-input, linux-kernel

Henrik Rydberg wrote:
>>> Regarding the tapping patch; it is addressing the correctness of
>>> already implemented functionality. I can see nothing wrong with that.
>>>
>> My position that since the isssue can be "fixed" by simply installing
>> the proper X driver I'd rather not include it. Mousedev purpose is to
>> provide good enough emulation in absence of a native driver and that's
>> it. Also, the default value would not work well on high-resiolution
>> devices (like Synaptics) and would require user fiddling with kernel
>> parameters - not worth it in my opinion.
> 
> The parameter could be made dimensionless and the distance test scaled
> with the size of the device; the argument invalidates the current patch,
> but not the idea itself. Maybe the patch will appear in acceptable form
> at some point, but for now, I rest my case.

Actually, the tap_move parameter is already dimensionless - the
mousedev_touchpad functions emulates movements on an imaginary screen
of resolution 256x256. Thus, with the following description change

-MODULE_PARM_DESC(tap_move, "Tap distance for touchpads in absolute mode (res)");
+MODULE_PARM_DESC(tap_move, "Tap move radius (256 * fraction of screen)");

it should be clear that the parameter does not depend on device resolution.
It could even be made a constant in the code, if that is preferred.

Henrik

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

end of thread, other threads:[~2008-09-11  6:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-05  1:19 [PATCH 2/2] input: mousedev: Emulate right and middle buttons for single-button touchpads Henrik Rydberg
2008-09-10 12:52 ` Dmitry Torokhov
2008-09-10 14:51   ` Henrik Rydberg
2008-09-10 15:32     ` Dmitry Torokhov
2008-09-10 16:05       ` Henrik Rydberg
2008-09-11  6:31         ` Henrik Rydberg

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).