psm(4): Add natural scrolling support to sysmouse protocol
This change enables natural scrolling with two finger scroll enabled and when user is using a trackpad (mouse and trackpoint are not affected). Depending on trackpad model it can be activated with setting of hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl values to 1. Evdev protocol is not affected by this change too. Tune userland client e.g. libinput to enable natural scrolling in that case. Submitted by: nyan_myuji.xyz Reviewed by: wulf MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20447
This commit is contained in:
parent
d9e8cf281b
commit
3b11e3b6e1
@ -236,6 +236,7 @@ typedef struct synapticsinfo {
|
||||
int softbutton3_x;
|
||||
int max_x;
|
||||
int max_y;
|
||||
int natural_scroll;
|
||||
} synapticsinfo_t;
|
||||
|
||||
typedef struct synapticspacket {
|
||||
@ -571,6 +572,8 @@ enum {
|
||||
SYNAPTICS_SYSCTL_SOFTBUTTONS_Y = SYN_OFFSET(softbuttons_y),
|
||||
SYNAPTICS_SYSCTL_SOFTBUTTON2_X = SYN_OFFSET(softbutton2_x),
|
||||
SYNAPTICS_SYSCTL_SOFTBUTTON3_X = SYN_OFFSET(softbutton3_x),
|
||||
SYNAPTICS_SYSCTL_NATURAL_SCROLL = SYN_OFFSET(natural_scroll),
|
||||
#define SYNAPTICS_SYSCTL_LAST SYNAPTICS_SYSCTL_NATURAL_SCROLL
|
||||
};
|
||||
|
||||
/* packet formatting function */
|
||||
@ -4134,6 +4137,7 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smoother_id,
|
||||
int len, weight_prev_x, weight_prev_y;
|
||||
int div_max_x, div_max_y, div_x, div_y;
|
||||
int is_fuzzy;
|
||||
int natural_scroll;
|
||||
|
||||
/* Read sysctl. */
|
||||
/* XXX Verify values? */
|
||||
@ -4161,6 +4165,7 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smoother_id,
|
||||
two_finger_scroll = sc->syninfo.two_finger_scroll;
|
||||
max_x = sc->syninfo.max_x;
|
||||
max_y = sc->syninfo.max_y;
|
||||
natural_scroll = sc->syninfo.natural_scroll;
|
||||
|
||||
is_fuzzy = (f->flags & PSM_FINGER_FUZZY) != 0;
|
||||
|
||||
@ -4322,14 +4327,24 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smoother_id,
|
||||
smoother_id, dx, dy, dxp, dyp));
|
||||
break;
|
||||
case 1: /* Vertical scrolling. */
|
||||
if (dyp != 0)
|
||||
ms->button |= (dyp > 0) ?
|
||||
MOUSE_BUTTON4DOWN : MOUSE_BUTTON5DOWN;
|
||||
if (dyp != 0) {
|
||||
if (two_finger_scroll && natural_scroll)
|
||||
ms->button |= (dyp > 0) ?
|
||||
MOUSE_BUTTON5DOWN : MOUSE_BUTTON4DOWN;
|
||||
else
|
||||
ms->button |= (dyp > 0) ?
|
||||
MOUSE_BUTTON4DOWN : MOUSE_BUTTON5DOWN;
|
||||
}
|
||||
break;
|
||||
case 2: /* Horizontal scrolling. */
|
||||
if (dxp != 0)
|
||||
ms->button |= (dxp > 0) ?
|
||||
MOUSE_BUTTON7DOWN : MOUSE_BUTTON6DOWN;
|
||||
if (dxp != 0) {
|
||||
if (two_finger_scroll && natural_scroll)
|
||||
ms->button |= (dxp > 0) ?
|
||||
MOUSE_BUTTON6DOWN : MOUSE_BUTTON7DOWN;
|
||||
else
|
||||
ms->button |= (dxp > 0) ?
|
||||
MOUSE_BUTTON7DOWN : MOUSE_BUTTON6DOWN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5641,7 +5656,7 @@ synaptics_sysctl(SYSCTL_HANDLER_ARGS)
|
||||
int error, arg;
|
||||
|
||||
if (oidp->oid_arg1 == NULL || oidp->oid_arg2 < 0 ||
|
||||
oidp->oid_arg2 > SYNAPTICS_SYSCTL_SOFTBUTTON3_X)
|
||||
oidp->oid_arg2 > SYNAPTICS_SYSCTL_LAST)
|
||||
return (EINVAL);
|
||||
|
||||
sc = oidp->oid_arg1;
|
||||
@ -5730,6 +5745,7 @@ synaptics_sysctl(SYSCTL_HANDLER_ARGS)
|
||||
return (EINVAL);
|
||||
break;
|
||||
case SYNAPTICS_SYSCTL_TOUCHPAD_OFF:
|
||||
case SYNAPTICS_SYSCTL_NATURAL_SCROLL:
|
||||
if (arg < 0 || arg > 1)
|
||||
return (EINVAL);
|
||||
break;
|
||||
@ -6122,6 +6138,15 @@ synaptics_sysctl_create_tree(struct psm_softc *sc, const char *name,
|
||||
synaptics_sysctl, "I",
|
||||
"Turn off touchpad");
|
||||
|
||||
/* hw.psm.synaptics.natural_scroll. */
|
||||
sc->syninfo.natural_scroll = 0;
|
||||
SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
|
||||
"natural_scroll", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY,
|
||||
sc, SYNAPTICS_SYSCTL_NATURAL_SCROLL,
|
||||
synaptics_sysctl, "I",
|
||||
"Enable natural scrolling");
|
||||
|
||||
sc->syninfo.softbuttons_y = 0;
|
||||
sc->syninfo.softbutton2_x = 0;
|
||||
sc->syninfo.softbutton3_x = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user