Module Name: src
Committed By: nia
Date: Thu Oct 1 17:13:19 UTC 2020
Modified Files:
src/share/man/man4: pms.4
src/sys/dev/pckbport: synaptics.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/share/man/man4/pms.4
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pckbport/synaptics.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/man/man4/pms.4
diff -u src/share/man/man4/pms.4:1.37 src/share/man/man4/pms.4:1.38
--- src/share/man/man4/pms.4:1.37 Mon Mar 16 09:31:41 2020
+++ src/share/man/man4/pms.4 Thu Oct 1 17:13:19 2020
@@ -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 @@ If this variable is set too high then mo
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
Index: src/sys/dev/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.69 src/sys/dev/pckbport/synaptics.c:1.70
--- src/sys/dev/pckbport/synaptics.c:1.69 Thu Oct 1 15:08:11 2020
+++ src/sys/dev/pckbport/synaptics.c Thu Oct 1 17:13:19 2020
@@ -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_min = 13;
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_min_n
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 @@ pms_sysctl_synaptics(struct sysctllog **
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 @@ pms_sysctl_synaptics_verify(SYSCTLFN_ARG
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 @@ pms_synaptics_passthrough(struct pms_sof
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,