The branch main has been updated by wulf:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d452a029953e6e3879c4e73fb023ad9b7ac281a3

commit d452a029953e6e3879c4e73fb023ad9b7ac281a3
Author:     Joshua Rogers <jos...@joshua.hu>
AuthorDate: 2025-03-07 17:53:34 +0000
Commit:     Vladimir Kondratyev <w...@freebsd.org>
CommitDate: 2025-03-07 17:53:34 +0000

    wsp: Add hw.usb.wsp.max_scroll_finger_distance for two-finger scrolling
    
    The hw.usb.wsp.max_scroll_finger_distance sysctl may be used to specify
    the maximum distance between two fingers which are registered as a z-axis
    (vertical scroll with mousepad) movement.
    
    Previously, this was shared with the tunable
    hw.usb.wsp.max_double_tap_distance which is used to specify the maximum
    distance between two fingers which register as a right-click.
    
    This patch also cleans up and add new information to the manpage for
    wsp(4).
    
    Signed-off-by: Joshua Rogers <jos...@joshua.hu>
---
 share/man/man4/wsp.4    | 21 ++++++++++++++++++---
 sys/dev/usb/input/wsp.c |  9 +++++++--
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/share/man/man4/wsp.4 b/share/man/man4/wsp.4
index 83a4421fa2ff..b77d5ac99a7b 100644
--- a/share/man/man4/wsp.4
+++ b/share/man/man4/wsp.4
@@ -63,24 +63,39 @@ through nodes under
 Pointer sensitivity can be controlled using the sysctl tunable
 .Nm hw.usb.wsp.scale_factor .
 Tap to left-click can be controlled using the sysctl tunable
-.Nm hw.usb.wsp.enable_single_tap_clicks ,
-set to 0 to disable single tap clicks or 1 to enable them (default).
+.Nm hw.usb.wsp.enable_single_tap_clicks
+with 0 disabling single tap clicks and 1 enabling them (default).
 Movement on the trackpad following a partially-released click can be
 controlled using the sysctl tunable
 .Nm hw.usb.wsp.enable_single_tap_movement ,
-set to 0 to disable the movement on the trackpad until a full release
+with 0 to disable the movement on the trackpad until a full release
 or 1 to allow the continued movement (default).
 .Nm hw.usb.wsp.max_finger_area
 defines the maximum area on the trackpad which is registered as a
 finger (lower for greater palm detection).
+.Nm max_scroll_finger_distance
+defines the maximum distance between two fingers where z-axis
+movements are registered.
 .Nm hw.usb.wsp.max_double_tap_distance
 defines the maximum distance between two finger clicks or taps which may
 register as a double-click.
+.Nm hw.usb.wsp.scr_hor_threshold
+defines the minimum required horizontal movement to register as a forward
+/back button click.
 Z-Axis sensitivity can be controlled using the sysctl tunable
 .Nm hw.usb.wsp.z_factor .
 Z-Axis inversion can be controlled using the sysctl tunable
 .Nm hw.usb.wsp.z_invert ,
 set to 0 to disable (default) or 1 to enable inversion.
+.Pp
+.Nm
+may use evdev data (if enabled during kernel compilation) for gesture support
+using the
+.Xr sysctl 8
+value
+.Nm kern.evdev.rcpt_mask .
+On most MacBooks, setting this value to 3 enables gestures, while 12
+disables them.
 .Sh FILES
 .Nm
 creates a blocking pseudo-device file,
diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c
index f9b85f926221..d74ba1da32b1 100644
--- a/sys/dev/usb/input/wsp.c
+++ b/sys/dev/usb/input/wsp.c
@@ -98,6 +98,7 @@ static struct wsp_tuning {
        int     pressure_tap_threshold;
        int     scr_hor_threshold;
        int     max_finger_area;
+       int     max_scroll_finger_distance;
        int     max_double_tap_distance;
        int     enable_single_tap_clicks;
        int     enable_single_tap_movement;
@@ -112,6 +113,7 @@ static struct wsp_tuning {
        .pressure_tap_threshold = 120,
        .scr_hor_threshold = 50,
        .max_finger_area = 1900,
+       .max_scroll_finger_distance = MAX_FINGER_ORIENTATION/2,
        .max_double_tap_distance = 2500,
        .enable_single_tap_clicks = 1,
        .enable_single_tap_movement = 1,
@@ -127,7 +129,8 @@ wsp_runing_rangecheck(struct wsp_tuning *ptun)
        WSP_CLAMP(ptun->pressure_untouch_threshold, 1, 255);
        WSP_CLAMP(ptun->pressure_tap_threshold, 1, 255);
        WSP_CLAMP(ptun->max_finger_area, 1, 2400);
-       WSP_CLAMP(ptun->max_double_tap_distance, 1, 16384);
+       WSP_CLAMP(ptun->max_scroll_finger_distance, 1, MAX_FINGER_ORIENTATION);
+       WSP_CLAMP(ptun->max_double_tap_distance, 1, MAX_FINGER_ORIENTATION);
        WSP_CLAMP(ptun->scr_hor_threshold, 1, 255);
        WSP_CLAMP(ptun->enable_single_tap_clicks, 0, 1);
        WSP_CLAMP(ptun->enable_single_tap_movement, 0, 1);
@@ -147,6 +150,8 @@ SYSCTL_INT(_hw_usb_wsp, OID_AUTO, pressure_tap_threshold, 
CTLFLAG_RWTUN,
     &wsp_tuning.pressure_tap_threshold, 0, "tap pressure threshold");
 SYSCTL_INT(_hw_usb_wsp, OID_AUTO, max_finger_area, CTLFLAG_RWTUN,
     &wsp_tuning.max_finger_area, 0, "maximum finger area");
+SYSCTL_INT(_hw_usb_wsp, OID_AUTO, max_scroll_finger_distance, CTLFLAG_RWTUN,
+    &wsp_tuning.max_scroll_finger_distance, 0, "maximum scroll finger 
distance");
 SYSCTL_INT(_hw_usb_wsp, OID_AUTO, max_double_tap_distance, CTLFLAG_RWTUN,
     &wsp_tuning.max_double_tap_distance, 0, "maximum double-finger click 
distance");
 SYSCTL_INT(_hw_usb_wsp, OID_AUTO, scr_hor_threshold, CTLFLAG_RWTUN,
@@ -1262,7 +1267,7 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t 
error)
                                dx = dy = 0;
                                if (sc->dz_count == 0)
                                        dz = (sc->dz_sum / tun.z_factor) * 
(tun.z_invert ? -1 : 1);
-                               if (sc->scr_mode == WSP_SCR_HOR || sc->distance 
> tun.max_double_tap_distance)
+                               if (sc->scr_mode == WSP_SCR_HOR || sc->distance 
> tun.max_scroll_finger_distance)
                                        dz = 0;
                        }
                        if (ntouch == 3)

Reply via email to