The branch main has been updated by wulf:

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

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

    sysmouse(4): Add wsp(4)-style T-Axis reporting.
    
    Neither the ums(4) nor psm(4) reporting can be used by the wsp(4)
    driver, as they rely on static-length movements, while wsp(4) may need
    to scroll in large amounts per evdev event push.
    
    This style uses a false button-5 press as an indicator that the z-axis
    movement is a horizontal scroll, otherwise a vertical scroll.
    
    Signed-off-by: Joshua Rogers <jos...@joshua.hu>
---
 sys/dev/evdev/evdev.c      |  2 +-
 sys/dev/evdev/evdev.h      |  2 ++
 sys/dev/syscons/sysmouse.c | 14 +++++++++++---
 sys/dev/vt/vt_sysmouse.c   | 14 +++++++++++---
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c
index 87cdaeb91e49..e71f4f389d5c 100644
--- a/sys/dev/evdev/evdev.c
+++ b/sys/dev/evdev/evdev.c
@@ -82,7 +82,7 @@ SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RWTUN, 
&evdev_rcpt_mask, 0,
     "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, "
     "bit2 - mouse hardware, bit3 - keyboard hardware");
 SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RWTUN,
-    &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm");
+    &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm, 
3-wsp");
 #endif
 SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
     "Evdev input devices");
diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h
index 2f00d49c485d..2ee374f184cc 100644
--- a/sys/dev/evdev/evdev.h
+++ b/sys/dev/evdev/evdev.h
@@ -62,12 +62,14 @@ extern int evdev_rcpt_mask;
  * 0 - do not extract horizontal wheel movement (default).
  * 1 - ums(4) horizontal wheel encoding. T-axis is mapped to buttons 6 and 7
  * 2 - psm(4) wheels encoding: z = 1,-1 - vert. wheel, z = 2,-2 - horiz. wheel
+ * 3 - wsp(4) horizontal and vertical encoding. T-axis is mapped to button 5.
  */
 enum
 {
        EVDEV_SYSMOUSE_T_AXIS_NONE = 0,
        EVDEV_SYSMOUSE_T_AXIS_UMS = 1,
        EVDEV_SYSMOUSE_T_AXIS_PSM = 2,
+       EVDEV_SYSMOUSE_T_AXIS_WSP = 3,
 };
 extern int evdev_sysmouse_t_axis;
 
diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c
index 0e38070d613c..05008c50b950 100644
--- a/sys/dev/syscons/sysmouse.c
+++ b/sys/dev/syscons/sysmouse.c
@@ -94,7 +94,15 @@ smdev_evdev_write(int x, int y, int z, int buttons)
        evdev_push_event(sysmouse_evdev, EV_REL, REL_X, x);
        evdev_push_event(sysmouse_evdev, EV_REL, REL_Y, y);
        switch (evdev_sysmouse_t_axis) {
-       case EVDEV_SYSMOUSE_T_AXIS_PSM:
+       case EVDEV_SYSMOUSE_T_AXIS_WSP: /* 3 */
+               if (buttons & (1 << 5)) {
+                       evdev_push_rel(sysmouse_evdev, REL_HWHEEL, z);
+                       buttons &= ~(1 << 5);
+               } else {
+                       evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z);
+               }
+               break;
+       case EVDEV_SYSMOUSE_T_AXIS_PSM: /* 2 */
                switch (z) {
                case 1:
                case -1:
@@ -106,14 +114,14 @@ smdev_evdev_write(int x, int y, int z, int buttons)
                        break;
                }
                break;
-       case EVDEV_SYSMOUSE_T_AXIS_UMS:
+       case EVDEV_SYSMOUSE_T_AXIS_UMS: /* 1 */
                if (buttons & (1 << 6))
                        evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1);
                else if (buttons & (1 << 5))
                        evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1);
                buttons &= ~((1 << 5)|(1 << 6));
                /* PASSTHROUGH */
-       case EVDEV_SYSMOUSE_T_AXIS_NONE:
+       case EVDEV_SYSMOUSE_T_AXIS_NONE: /* 0 */
        default:
                evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z);
        }
diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c
index 5147865fc20f..f2f5a0fa5c3a 100644
--- a/sys/dev/vt/vt_sysmouse.c
+++ b/sys/dev/vt/vt_sysmouse.c
@@ -128,7 +128,15 @@ sysmouse_evdev_store(int x, int y, int z, int buttons)
        evdev_push_event(sysmouse_evdev, EV_REL, REL_X, x);
        evdev_push_event(sysmouse_evdev, EV_REL, REL_Y, y);
        switch (evdev_sysmouse_t_axis) {
-       case EVDEV_SYSMOUSE_T_AXIS_PSM:
+       case EVDEV_SYSMOUSE_T_AXIS_WSP: /* 3 */
+               if (buttons & (1 << 5)) {
+                       evdev_push_rel(sysmouse_evdev, REL_HWHEEL, z);
+                       buttons &= ~(1 << 5);
+               } else {
+                       evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z);
+               }
+               break;
+       case EVDEV_SYSMOUSE_T_AXIS_PSM: /* 2 */
                switch (z) {
                case 1:
                case -1:
@@ -140,14 +148,14 @@ sysmouse_evdev_store(int x, int y, int z, int buttons)
                        break;
                }
                break;
-       case EVDEV_SYSMOUSE_T_AXIS_UMS:
+       case EVDEV_SYSMOUSE_T_AXIS_UMS: /* 1 */
                if (buttons & (1 << 6))
                        evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1);
                else if (buttons & (1 << 5))
                        evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1);
                buttons &= ~((1 << 5)|(1 << 6));
                /* PASSTHROUGH */
-       case EVDEV_SYSMOUSE_T_AXIS_NONE:
+       case EVDEV_SYSMOUSE_T_AXIS_NONE: /* 0 */
        default:
                evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z);
        }

Reply via email to