Add macOS-like three finger drag trackpad gesture to psm(4)

Submitted by:	Yan Ka Chiu <nyan@myuji.xyz>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D20648
This commit is contained in:
philip 2019-06-16 03:06:05 +00:00
parent daabb062f0
commit 11b574d82f

View File

@ -236,6 +236,7 @@ typedef struct synapticsinfo {
int softbutton3_x;
int max_x;
int max_y;
int three_finger_drag;
int natural_scroll;
} synapticsinfo_t;
@ -572,6 +573,7 @@ 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_THREE_FINGER_DRAG = SYN_OFFSET(three_finger_drag),
SYNAPTICS_SYSCTL_NATURAL_SCROLL = SYN_OFFSET(natural_scroll),
#define SYNAPTICS_SYSCTL_LAST SYNAPTICS_SYSCTL_NATURAL_SCROLL
};
@ -3785,6 +3787,7 @@ psmgestures(struct psm_softc *sc, finger_t *fingers, int nfingers,
int vscroll_hor_area, vscroll_ver_area;
int two_finger_scroll;
int max_x, max_y;
int three_finger_drag;
/* Read sysctl. */
/* XXX Verify values? */
@ -3799,7 +3802,7 @@ psmgestures(struct psm_softc *sc, finger_t *fingers, int nfingers,
two_finger_scroll = sc->syninfo.two_finger_scroll;
max_x = sc->syninfo.max_x;
max_y = sc->syninfo.max_y;
three_finger_drag = sc->syninfo.three_finger_drag;
/* Read current absolute position. */
x0 = f->x;
y0 = f->y;
@ -3888,8 +3891,8 @@ psmgestures(struct psm_softc *sc, finger_t *fingers, int nfingers,
~MOUSE_BUTTON1DOWN) | center_button;
}
/* If in tap-hold, add the recorded button. */
if (gest->in_taphold)
/* If in tap-hold or three fingers, add the recorded button. */
if (gest->in_taphold || (nfingers == 3 && three_finger_drag))
ms->button |= gest->tap_button;
/*
@ -5755,6 +5758,7 @@ synaptics_sysctl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
break;
case SYNAPTICS_SYSCTL_TOUCHPAD_OFF:
case SYNAPTICS_SYSCTL_THREE_FINGER_DRAG:
case SYNAPTICS_SYSCTL_NATURAL_SCROLL:
if (arg < 0 || arg > 1)
return (EINVAL);
@ -6148,6 +6152,14 @@ synaptics_sysctl_create_tree(struct psm_softc *sc, const char *name,
synaptics_sysctl, "I",
"Turn off touchpad");
sc->syninfo.three_finger_drag = 0;
SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,
SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
"three_finger_drag", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY,
sc, SYNAPTICS_SYSCTL_THREE_FINGER_DRAG,
synaptics_sysctl, "I",
"Enable dragging with three fingers");
/* hw.psm.synaptics.natural_scroll. */
sc->syninfo.natural_scroll = 0;
SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,