Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src Pull up following revision(s) (requested by nia in ticket...



details:   https://anonhg.NetBSD.org/src/rev/c5278b52ef48
branches:  netbsd-9
changeset: 963752:c5278b52ef48
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 30 18:45:16 2020 +0000

description:
Pull up following revision(s) (requested by nia in ticket #809):

        sys/dev/pckbport/synaptics.c: revision 1.55
        sys/dev/pckbport/synaptics.c: revision 1.56
        share/man/man4/pms.4: revision 1.35
        share/man/man4/pms.4: revision 1.36

synaptics: Make up_down_emulation useful for single-button clickpads

On devices such as the Thinkpad X250, the clickpad can be pressed
to generate mouse button events 1 and 2. There are also additional
physical buttons which the pms(4) driver recognizes as "up/down" buttons
(mouse buttons 3 and 4). Allow these to be remapped to buttons 1 and 2
and used like normal touchpad buttons with the following sysctl:

While here, adjust the existing "middle button emulation"
(hw.synaptics.up_down_emulation=1) so it works with single-button
clickpads.

XXX: 3 may be a more useful default than the current default,
depending on hardware availability of touchpads with "up/down buttons".

Update the documentation accordingly.

synaptics: Set up_down_emulation=3 by default.

It's a less surprising default for modern hardware.

diffstat:

 share/man/man4/pms.4         |  32 +++++++++++++++++++++++---------
 sys/dev/pckbport/synaptics.c |  37 ++++++++++++++++++++++++++++---------
 2 files changed, 51 insertions(+), 18 deletions(-)

diffs (138 lines):

diff -r a3be6ef6affd -r c5278b52ef48 share/man/man4/pms.4
--- a/share/man/man4/pms.4      Mon Mar 30 18:36:47 2020 +0000
+++ b/share/man/man4/pms.4      Mon Mar 30 18:45:16 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pms.4,v 1.32 2018/11/06 09:14:08 blymn Exp $
+.\" $NetBSD: pms.4,v 1.32.2.1 2020/03/30 18:45:16 martin Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
 .\"
-.Dd February 4, 2018
+.Dd March 30, 2020
 .Dt PMS 4
 .Os
 .Sh NAME
@@ -102,13 +102,22 @@
 variables control behavior of Synaptics touchpads:
 .Bl -tag -width 8n
 .It Dv hw.synaptics.up_down_emulation
-If the touchpad reports the existence of Up/Down buttons, this value
-determines if they should be reported as button 4 and 5 events or if
-they should be used to emulate some other event.
-When set to 0, report Up/Down events as buttons 4 and 5.
-When set to 1, the Up and Down buttons are both mapped to the middle button.
-When set to 2 (default), the Up and Down buttons are used for Z-axis
-emulation, which more closely resembles how mouse wheels operate.
+If the touchpad reports the existence of extra ("Up/Down") buttons, this
+value determines what kind of mouse events they should generate.
+On certain clickpads, the Up/Down buttons may be physical buttons that
+can be used instead of pressing the pad down, or used as additional
+buttons.
+.Bl -bullet
+.It
+If set to 0, Up/Down events generate button 4 and 5 clicks.
+.It
+If set to 1, Up/Down events generate middle button clicks.
+.It
+If set to 2, the Up and Down buttons are used for Z-axis emulation,
+which more closely resembles how mouse wheels operate.
+.It
+If set to 3 (default), Up/Down events generate left/right clicks.
+.El
 .It Dv hw.synaptics.up_down_motion_delta
 When the Up/Down buttons are used for Z-axis emulation, this value specifies
 the emulated delta-Z value per click.
@@ -139,9 +148,14 @@
 More recent touchpads can report the presence of more than one finger
 on the pad.
 This value determines how such events are used.
+.Bl -bullet
+.It
 If set to 0 (default), two-finger events are ignored.
+.It
 If set to 1, two-finger events generate a right button click.
+.It
 If set to 2, two-finger events generate a middle button click.
+.El
 .It Dv hw.synaptics.scale_x
 .It Dv hw.synaptics.scale_y
 .It Dv hw.synaptics.scale_z
diff -r a3be6ef6affd -r c5278b52ef48 sys/dev/pckbport/synaptics.c
--- a/sys/dev/pckbport/synaptics.c      Mon Mar 30 18:36:47 2020 +0000
+++ b/sys/dev/pckbport/synaptics.c      Mon Mar 30 18:45:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synaptics.c,v 1.50 2019/07/05 05:09:24 mlelstv Exp $   */
+/*     $NetBSD: synaptics.c,v 1.50.2.1 2020/03/30 18:45:16 martin Exp $        */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.50 2019/07/05 05:09:24 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.50.2.1 2020/03/30 18:45:16 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -98,7 +98,7 @@
 static int pms_sysctl_synaptics_verify(SYSCTLFN_ARGS);
 
 /* Controlled by sysctl. */
-static int synaptics_up_down_emul = 2;
+static int synaptics_up_down_emul = 3;
 static int synaptics_up_down_motion_delta = 1;
 static int synaptics_gesture_move = 200;
 static int synaptics_gesture_length = 20;
@@ -852,8 +852,11 @@
                return error;
 
        /* Sanity check the params. */
-       if (node.sysctl_num == synaptics_up_down_emul_nodenum ||
-           node.sysctl_num == synaptics_two_fingers_emul_nodenum) {
+       if (node.sysctl_num == synaptics_up_down_emul_nodenum) {
+               if (t < 0 || t > 3)
+                       return (EINVAL);
+       } else
+       if (node.sysctl_num == synaptics_two_fingers_emul_nodenum) {
                if (t < 0 || t > 2)
                        return (EINVAL);
        } else
@@ -1091,13 +1094,29 @@
                        /* Old style Middle Button. */
                        sp.sp_middle = (psc->packet[0] & PMS_LBUTMASK) ^
                            (psc->packet[3] & PMS_LBUTMASK);
-               } else if (synaptics_up_down_emul == 1) {
+               } else if (synaptics_up_down_emul != 1) {
+                       sp.sp_middle = 0;
+               }
+
+               switch (synaptics_up_down_emul) {
+               case 1:
                        /* Do middle button emulation using up/down buttons */
                        sp.sp_middle = sp.sp_up | sp.sp_down;
                        sp.sp_up = sp.sp_down = 0;
-               } else
-                       sp.sp_middle = 0;
-
+                       break;
+               case 3:
+                       /* Do left/right button emulation using up/down buttons */
+                       sp.sp_left = sp.sp_up;
+                       sp.sp_right = sp.sp_down;
+                       sp.sp_up = sp.sp_down = 0;
+                       break;
+               default:
+                       /*
+                        * Don't do any remapping...
+                        * Z-axis emulation is handled in pms_synaptics_process_packet
+                        */
+                       break;
+               }
        }
 
        pms_synaptics_process_packet(psc, &sp);



Home | Main Index | Thread Index | Old Index