Source-Changes-HG archive

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

[src/trunk]: src synaptics: Emulate scrolling when the middle button is held ...



details:   https://anonhg.NetBSD.org/src/rev/c148e0ac5ab7
branches:  trunk
changeset: 955489:c148e0ac5ab7
user:      nia <nia%NetBSD.org@localhost>
date:      Thu Oct 01 17:13:19 2020 +0000

description:
synaptics: Emulate scrolling when the middle button is held with TrackPoints

idea stolen from various other operating systems.

this configurable with a sysctl in case somebody wants to hold the middle
button, e.g.  with old window managers that close menus when a button is
released.

diffstat:

 share/man/man4/pms.4         |   8 ++++++--
 sys/dev/pckbport/synaptics.c |  31 +++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 4 deletions(-)

diffs (109 lines):

diff -r 2b8d5395bdb7 -r c148e0ac5ab7 share/man/man4/pms.4
--- a/share/man/man4/pms.4      Thu Oct 01 15:08:11 2020 +0000
+++ b/share/man/man4/pms.4      Thu Oct 01 17:13:19 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pms.4,v 1.37 2020/03/16 09:31:41 nia Exp $
+.\" $NetBSD: pms.4,v 1.38 2020/10/01 17:13:19 nia 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 March 14, 2020
+.Dd October 1, 2020
 .Dt PMS 4
 .Os
 .Sh NAME
@@ -215,6 +215,10 @@
 as Z-axis events after the two finger scoll has finished.
 If the variable is set too low then there will be mouse movements observed
 during the two finger scroll.
+.It Dv hw.synaptics.aux_mid_button_scroll
+This causes Y-axis movement on the "passthrough device" (e.g. the TrackPoint
+on ThinkPads) to result in scrolling events instead of Y-axis movement when
+the middle button is held.
 .El
 .Pp
 The following
diff -r 2b8d5395bdb7 -r c148e0ac5ab7 sys/dev/pckbport/synaptics.c
--- a/sys/dev/pckbport/synaptics.c      Thu Oct 01 15:08:11 2020 +0000
+++ b/sys/dev/pckbport/synaptics.c      Thu Oct 01 17:13:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synaptics.c,v 1.69 2020/10/01 15:08:11 nia Exp $       */
+/*     $NetBSD: synaptics.c,v 1.70 2020/10/01 17:13:19 nia 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.69 2020/10/01 15:08:11 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.70 2020/10/01 17:13:19 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -124,6 +124,7 @@
 static int synaptics_fscroll_max = 14;
 static int synaptics_dz_hold = 30;
 static int synaptics_movement_enable = 1;
+static bool synaptics_aux_mid_button_scroll = TRUE;
 
 /* Sysctl nodes. */
 static int synaptics_button_boundary_nodenum;
@@ -152,6 +153,7 @@
 static int synaptics_finger_scroll_max_nodenum;
 static int synaptics_dz_hold_nodenum;
 static int synaptics_movement_enable_nodenum;
+static int synaptics_aux_mid_button_scroll_nodenum;
 
 static int
 synaptics_poll_cmd(struct pms_softc *psc, ...)
@@ -830,6 +832,18 @@
                goto err;
 
        synaptics_dz_hold_nodenum = node->sysctl_num;
+
+       if ((rc = sysctl_createv(clog, 0, NULL, &node,
+           CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+           CTLTYPE_BOOL, "aux_mid_button_scroll",
+           SYSCTL_DESCR("Interpet Y-Axis movement with the middle button held as scrolling on the passthrough device (e.g. TrackPoint)"),
+           pms_sysctl_synaptics_verify, 0,
+           &synaptics_aux_mid_button_scroll,
+           0, CTL_HW, root_num, CTL_CREATE,
+           CTL_EOL)) != 0)
+               goto err;
+
+       synaptics_aux_mid_button_scroll_nodenum = node->sysctl_num;
        return;
 
 err:
@@ -923,6 +937,10 @@
                if (t < 0 || t > 1)
                        return (EINVAL);
        } else
+       if (node.sysctl_num == synaptics_aux_mid_button_scroll_nodenum) {
+               if (t < 0 || t > 1)
+                       return (EINVAL);
+       } else
                return (EINVAL);
 
        *(int *)rnode->sysctl_data = t;
@@ -1174,6 +1192,15 @@
        psc->buttons ^= changed;
 
        if (dx || dy || dz || changed) {
+               /*
+                * If the middle button is held, interpret Y-axis
+                * movement as scrolling.
+                */
+               if (synaptics_aux_mid_button_scroll &&
+                   dy && (psc->buttons & 0x2)) {
+                       dz = -dy;
+                       dx = dy = 0;
+               }
                buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
                s = spltty();
                wsmouse_input(psc->sc_wsmousedev,



Home | Main Index | Thread Index | Old Index