tech-x11 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH v2] Precise scrolling for wsmouse
This patch introduces the precise scrolling event types for wscons
originally implemented in OpenBSD, adds a few new wsconsctl variables
(also originally implemented in OpenBSD), and adds support for them to
xf86-input-ws. The synaptics touchpad driver takes advantage of the
new event types for two-finger and trackpoint scrolling.
Index: external/mit/xf86-input-ws/dist/src/ws.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-input-ws/dist/src/ws.c,v
retrieving revision 1.11
diff -u -r1.11 ws.c
--- external/mit/xf86-input-ws/dist/src/ws.c 14 Apr 2017 19:19:43 -0000 1.11
+++ external/mit/xf86-input-ws/dist/src/ws.c 25 Sep 2021 10:54:01 -0000
@@ -450,6 +450,10 @@
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
}
+ axes_labels[HSCROLL_AXIS] =
+ XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
+ axes_labels[VSCROLL_AXIS] =
+ XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
if (!InitValuatorClassDeviceStruct(pWS,
NAXES,
axes_labels,
@@ -478,6 +482,25 @@
);
xf86InitValuatorDefaults(pWS, 1);
+
+ xf86InitValuatorAxisStruct(pWS, HSCROLL_AXIS,
+ axes_labels[HSCROLL_AXIS], 0, -1, 0, 0, 0, Relative);
+ xf86InitValuatorAxisStruct(pWS, VSCROLL_AXIS,
+ axes_labels[VSCROLL_AXIS], 0, -1, 0, 0, 0, Relative);
+ priv->scroll_mask = valuator_mask_new(MAX_VALUATORS);
+ if (!priv->scroll_mask) {
+ return !Success;
+ }
+
+ /*
+ * The value of an HSCROLL or VSCROLL event is the fraction
+ * motion_delta / scroll_distance
+ * in [*.12] fixed-point format. The 'increment' attribute of the
+ * scroll axes is constant:
+ */
+ SetScrollValuator(pWS, HSCROLL_AXIS, SCROLL_TYPE_HORIZONTAL, 4096, 0);
+ SetScrollValuator(pWS, VSCROLL_AXIS, SCROLL_TYPE_VERTICAL, 4096, 0);
+
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
xf86MotionHistoryAllocate(pInfo);
AssignTypeAndName(pWS, pInfo->atom, pInfo->name);
@@ -601,6 +624,7 @@
int buttons = priv->lastButtons;
int dx = 0, dy = 0, dz = 0, dw = 0;
int zbutton = 0, wbutton = 0;
+ int hscroll = 0, vscroll = 0;
ax = 0; ay = 0;
switch (event->type) {
@@ -650,6 +674,14 @@
DBG(4, ErrorF("Relative W %d\n", event->value));
dw = event->value;
break;
+ case WSCONS_EVENT_HSCROLL:
+ hscroll = event->value;
+ DBG(4, ErrorF("Horiz. Scrolling %d\n", event->value));
+ break;
+ case WSCONS_EVENT_VSCROLL:
+ vscroll = event->value;
+ DBG(4, ErrorF("Vert. Scrolling %d\n", event->value));
+ break;
default:
xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n",
pInfo->name, event->type);
@@ -694,6 +726,16 @@
buttons |= wbutton;
dw = 0;
}
+ if (hscroll || vscroll) {
+ xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
+ pInfo->name, hscroll, vscroll);
+ valuator_mask_zero(priv->scroll_mask);
+ valuator_mask_set_double(priv->scroll_mask,
+ HSCROLL_AXIS, (double) hscroll);
+ valuator_mask_set_double(priv->scroll_mask,
+ VSCROLL_AXIS, (double) vscroll);
+ xf86PostMotionEventM(pInfo->dev, FALSE, priv->scroll_mask);
+ }
if (priv->lastButtons != buttons) {
/* button event */
wsSendButtons(pInfo, buttons);
Index: external/mit/xf86-input-ws/dist/src/ws.h
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-input-ws/dist/src/ws.h,v
retrieving revision 1.3
diff -u -r1.3 ws.h
--- external/mit/xf86-input-ws/dist/src/ws.h 1 Jan 2019 00:34:52 -0000 1.3
+++ external/mit/xf86-input-ws/dist/src/ws.h 25 Sep 2021 10:54:01 -0000
@@ -27,7 +27,10 @@
# define DBG(lvl, f)
#endif
-#define NAXES 2 /* X and Y axes only */
+#define NAXES 4 /* X and Y, horizontal and vertical scrolling */
+#define HSCROLL_AXIS 2
+#define VSCROLL_AXIS 3
+
#define NBUTTONS 32 /* max theoretical buttons */
#define DFLTBUTTONS 3 /* default number of buttons */
#define NUMEVENTS 16 /* max # of ws events to read at once */
@@ -56,6 +59,7 @@
Time expires; /* time of expiry */
Time timeout;
} emulateMB;
+ ValuatorMask *scroll_mask;
} WSDeviceRec, *WSDevicePtr;
extern int wsmbEmuTimer(InputInfoPtr);
Index: sbin/wsconsctl/mouse.c
===================================================================
RCS file: /cvsroot/src/sbin/wsconsctl/mouse.c,v
retrieving revision 1.10
diff -u -r1.10 mouse.c
--- sbin/wsconsctl/mouse.c 24 Dec 2012 01:29:20 -0000 1.10
+++ sbin/wsconsctl/mouse.c 25 Sep 2021 10:52:46 -0000
@@ -42,6 +42,9 @@
#include "wsconsctl.h"
+static int reverse_scrolling;
+static int horiz_scroll_dist;
+static int vert_scroll_dist;
static int mstype;
static int resolution;
static int samplerate;
@@ -49,6 +52,9 @@
static char *calibration_samples;
static struct wsmouse_repeat repeat;
+static void mouse_get_parameters(int);
+static void mouse_put_parameters(int);
+
static void mouse_get_calibration(int);
static void mouse_put_calibration(int);
@@ -56,27 +62,30 @@
static void mouse_put_repeat(int);
struct field mouse_field_tab[] = {
- { "resolution", &resolution, FMT_UINT, FLG_WRONLY },
- { "samplerate", &samplerate, FMT_UINT, FLG_WRONLY },
- { "type", &mstype, FMT_MSTYPE, FLG_RDONLY },
+ { "resolution", &resolution, FMT_UINT, FLG_WRONLY },
+ { "samplerate", &samplerate, FMT_UINT, FLG_WRONLY },
+ { "type", &mstype, FMT_MSTYPE, FLG_RDONLY },
+ { "scroll.reverse", &reverse_scrolling, FMT_INT, FLG_MODIFY },
+ { "scroll.distance.x", &horiz_scroll_dist, FMT_INT, FLG_MODIFY },
+ { "scroll.distance.y", &vert_scroll_dist, FMT_INT, FLG_MODIFY },
{ "calibration.minx", &calibration.minx,
- FMT_INT, FLG_MODIFY },
+ FMT_INT, FLG_MODIFY },
{ "calibration.miny", &calibration.miny,
- FMT_INT, FLG_MODIFY },
+ FMT_INT, FLG_MODIFY },
{ "calibration.maxx", &calibration.maxx,
- FMT_INT, FLG_MODIFY },
+ FMT_INT, FLG_MODIFY },
{ "calibration.maxy", &calibration.maxy,
- FMT_INT, FLG_MODIFY },
+ FMT_INT, FLG_MODIFY },
{ "calibration.samples", &calibration_samples,
- FMT_STRING, FLG_MODIFY },
+ FMT_STRING, FLG_MODIFY },
{ "repeat.buttons", &repeat.wr_buttons,
- FMT_BITFIELD, FLG_MODIFY },
+ FMT_BITFIELD, FLG_MODIFY },
{ "repeat.delay.first", &repeat.wr_delay_first,
- FMT_UINT, FLG_MODIFY },
+ FMT_UINT, FLG_MODIFY },
{ "repeat.delay.decrement", &repeat.wr_delay_decrement,
- FMT_UINT, FLG_MODIFY },
+ FMT_UINT, FLG_MODIFY },
{ "repeat.delay.minimum", &repeat.wr_delay_minimum,
- FMT_UINT, FLG_MODIFY },
+ FMT_UINT, FLG_MODIFY },
};
int mouse_field_tab_len = sizeof(mouse_field_tab)/
@@ -102,6 +111,53 @@
field_by_value(&repeat.wr_delay_decrement)->flags & FLG_GET ||
field_by_value(&repeat.wr_delay_minimum)->flags & FLG_GET)
mouse_get_repeat(fd);
+
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET ||
+ field_by_value(&vert_scroll_dist)->flags & FLG_GET ||
+ field_by_value(&reverse_scrolling)->flags & FLG_GET)
+ mouse_get_parameters(fd);
+}
+
+static void
+mouse_get_parameters(int fd)
+{
+ struct wsmouse_param params[WSMOUSECFG_MAX];
+ struct wsmouse_parameters pl;
+ unsigned int i;
+
+ pl.nparams = 0;
+ pl.params = params;
+
+ if (field_by_value(&reverse_scrolling)->flags & FLG_GET)
+ params[pl.nparams++].key = WSMOUSECFG_REVERSE_SCROLLING;
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET)
+ params[pl.nparams++].key = WSMOUSECFG_HORIZSCROLLDIST;
+ if (field_by_value(&vert_scroll_dist)->flags & FLG_GET)
+ params[pl.nparams++].key = WSMOUSECFG_VERTSCROLLDIST;
+
+ if (ioctl(fd, WSMOUSEIO_GETPARAMS, &pl) < 0) {
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET)
+ field_disable_by_value(&horiz_scroll_dist);
+ if (field_by_value(&vert_scroll_dist)->flags & FLG_GET)
+ field_disable_by_value(&vert_scroll_dist);
+ if (field_by_value(&reverse_scrolling)->flags & FLG_GET)
+ field_disable_by_value(&reverse_scrolling);
+ return;
+ }
+
+ for (i = 0; i < pl.nparams; ++i) {
+ switch (params[i].key) {
+ case WSMOUSECFG_REVERSE_SCROLLING:
+ reverse_scrolling = params[i].value;
+ break;
+ case WSMOUSECFG_HORIZSCROLLDIST:
+ horiz_scroll_dist = params[i].value;
+ break;
+ case WSMOUSECFG_VERTSCROLLDIST:
+ vert_scroll_dist = params[i].value;
+ break;
+ }
+ }
}
static void
@@ -205,6 +261,46 @@
field_by_value(&repeat.wr_delay_decrement)->flags & FLG_SET ||
field_by_value(&repeat.wr_delay_minimum)->flags & FLG_SET)
mouse_put_repeat(fd);
+
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET ||
+ field_by_value(&vert_scroll_dist)->flags & FLG_SET ||
+ field_by_value(&reverse_scrolling)->flags & FLG_SET)
+ mouse_put_parameters(fd);
+}
+
+static void
+mouse_put_parameters(int fd)
+{
+ struct wsmouse_param params[WSMOUSECFG_MAX];
+ struct wsmouse_parameters pl;
+
+ pl.nparams = 0;
+ pl.params = params;
+
+ if (field_by_value(&reverse_scrolling)->flags & FLG_SET) {
+ params[pl.nparams].key = WSMOUSECFG_REVERSE_SCROLLING;
+ params[pl.nparams++].value = reverse_scrolling;
+ }
+
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET) {
+ params[pl.nparams].key = WSMOUSECFG_HORIZSCROLLDIST;
+ params[pl.nparams++].value = horiz_scroll_dist;
+ }
+
+ if (field_by_value(&vert_scroll_dist)->flags & FLG_SET) {
+ params[pl.nparams].key = WSMOUSECFG_VERTSCROLLDIST;
+ params[pl.nparams++].value = vert_scroll_dist;
+ }
+
+ if (ioctl(fd, WSMOUSEIO_SETPARAMS, &pl) < 0) {
+ if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET)
+ field_disable_by_value(&horiz_scroll_dist);
+ if (field_by_value(&vert_scroll_dist)->flags & FLG_SET)
+ field_disable_by_value(&vert_scroll_dist);
+ if (field_by_value(&vert_scroll_dist)->flags & FLG_SET)
+ field_disable_by_value(&reverse_scrolling);
+ return;
+ }
}
static void
Index: sys/dev/wscons/wsconsio.h
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsconsio.h,v
retrieving revision 1.125
diff -u -r1.125 wsconsio.h
--- sys/dev/wscons/wsconsio.h 24 Apr 2021 00:15:37 -0000 1.125
+++ sys/dev/wscons/wsconsio.h 25 Sep 2021 10:52:47 -0000
@@ -76,7 +76,8 @@
#define WSCONS_EVENT_ASCII 13 /* key code is already ascii */
#define WSCONS_EVENT_MOUSE_DELTA_W 14 /* W delta amount */
#define WSCONS_EVENT_MOUSE_ABSOLUTE_W 15 /* W location */
-
+#define WSCONS_EVENT_HSCROLL 16 /* X axis precision scrolling */
+#define WSCONS_EVENT_VSCROLL 17 /* Y axis precision scrolling */
/*
* Keyboard ioctls (0 - 31)
@@ -270,6 +271,28 @@
#define WSMOUSEIO_SETVERSION _IOW('W', 41, int)
#define WSMOUSE_EVENT_VERSION WSEVENT_VERSION
+enum wsmousecfg {
+ WSMOUSECFG_REVERSE_SCROLLING = 0,
+ /* Touchpad parameters */
+ WSMOUSECFG_HORIZSCROLLDIST,
+ WSMOUSECFG_VERTSCROLLDIST
+};
+
+struct wsmouse_param {
+ enum wsmousecfg key;
+ int value;
+};
+
+struct wsmouse_parameters {
+ struct wsmouse_param *params;
+ unsigned int nparams;
+};
+
+#define WSMOUSECFG_MAX (128) /* maximum number of wsmouse_params */
+
+#define WSMOUSEIO_GETPARAMS _IOW('W', 42, struct wsmouse_parameters)
+#define WSMOUSEIO_SETPARAMS _IOW('W', 43, struct wsmouse_parameters)
+
/*
* Display ioctls (64 - 95)
*/
Index: sys/dev/wscons/wsmouse.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsmouse.c,v
retrieving revision 1.69
diff -u -r1.69 wsmouse.c
--- sys/dev/wscons/wsmouse.c 27 Dec 2020 16:09:33 -0000 1.69
+++ sys/dev/wscons/wsmouse.c 25 Sep 2021 10:52:47 -0000
@@ -170,6 +170,10 @@
int sc_repeat_button;
callout_t sc_repeat_callout;
unsigned int sc_repeat_delay;
+
+ int sc_reverse_scroll;
+ int sc_horiz_scroll_dist;
+ int sc_vert_scroll_dist;
};
static int wsmouse_match(device_t, cfdata_t, void *);
@@ -177,6 +181,13 @@
static int wsmouse_detach(device_t, int);
static int wsmouse_activate(device_t, enum devact);
+static int wsmouse_set_params(struct wsmouse_softc *,
+ struct wsmouse_param *, size_t);
+static int wsmouse_get_params(struct wsmouse_softc *,
+ struct wsmouse_param *, size_t);
+static int wsmouse_handle_params(struct wsmouse_softc *,
+ struct wsmouse_parameters *, bool);
+
static int wsmouse_do_ioctl(struct wsmouse_softc *, u_long, void *,
int, struct lwp *);
@@ -258,6 +269,9 @@
memset(&sc->sc_repeat, 0, sizeof(sc->sc_repeat));
sc->sc_repeat_button = -1;
sc->sc_repeat_delay = 0;
+ sc->sc_reverse_scroll = 0;
+ sc->sc_horiz_scroll_dist = WSMOUSE_DEFAULT_SCROLL_DIST;
+ sc->sc_vert_scroll_dist = WSMOUSE_DEFAULT_SCROLL_DIST;
callout_init(&sc->sc_repeat_callout, 0);
callout_setfunc(&sc->sc_repeat_callout, wsmouse_repeat, sc);
@@ -516,6 +530,41 @@
}
}
+void
+wsmouse_precision_scroll(device_t wsmousedev, int x, int y)
+{
+ struct wsmouse_softc *sc = device_private(wsmousedev);
+ struct wseventvar *evar;
+ struct wscons_event events[2];
+ int nevents = 0;
+
+ evar = sc->sc_base.me_evp;
+ if (evar == NULL)
+ return;
+
+ if (sc->sc_reverse_scroll) {
+ x = -x;
+ y = -y;
+ }
+
+ x = (x * 4096) / sc->sc_horiz_scroll_dist;
+ y = (y * 4096) / sc->sc_vert_scroll_dist;
+
+ if (x != 0) {
+ events[nevents].type = WSCONS_EVENT_HSCROLL;
+ events[nevents].value = x;
+ nevents++;
+ }
+
+ if (y != 0) {
+ events[nevents].type = WSCONS_EVENT_VSCROLL;
+ events[nevents].value = y;
+ nevents++;
+ }
+
+ (void)wsevent_inject(evar, events, nevents);
+}
+
static void
wsmouse_repeat(void *v)
{
@@ -566,6 +615,88 @@
splx(oldspl);
}
+static int
+wsmouse_set_params(struct wsmouse_softc *sc,
+ struct wsmouse_param *buf, size_t nparams)
+{
+ size_t i = 0;
+
+ for (i = 0; i < nparams; ++i) {
+ switch (buf[i].key) {
+ case WSMOUSECFG_REVERSE_SCROLLING:
+ sc->sc_reverse_scroll = (buf[i].value != 0);
+ break;
+ case WSMOUSECFG_HORIZSCROLLDIST:
+ sc->sc_horiz_scroll_dist = buf[i].value;
+ break;
+ case WSMOUSECFG_VERTSCROLLDIST:
+ sc->sc_vert_scroll_dist = buf[i].value;
+ break;
+ }
+ }
+ return 0;
+}
+
+static int
+wsmouse_get_params(struct wsmouse_softc *sc,
+ struct wsmouse_param *buf, size_t nparams)
+{
+ size_t i = 0;
+
+ for (i = 0; i < nparams; ++i) {
+ switch (buf[i].key) {
+ case WSMOUSECFG_REVERSE_SCROLLING:
+ buf[i].value = sc->sc_reverse_scroll;
+ break;
+ case WSMOUSECFG_HORIZSCROLLDIST:
+ buf[i].value = sc->sc_horiz_scroll_dist;
+ break;
+ case WSMOUSECFG_VERTSCROLLDIST:
+ buf[i].value = sc->sc_vert_scroll_dist;
+ break;
+ }
+ }
+ return 0;
+}
+
+static int
+wsmouse_handle_params(struct wsmouse_softc *sc, struct wsmouse_parameters *upl,
+ bool set)
+{
+ size_t len;
+ struct wsmouse_param *buf;
+ int error = 0;
+
+ if (upl->params == NULL || upl->nparams > WSMOUSECFG_MAX)
+ return EINVAL;
+ if (upl->nparams == 0)
+ return 0;
+
+ len = upl->nparams * sizeof(struct wsmouse_param);
+
+ buf = kmem_alloc(len, KM_SLEEP);
+ if (buf == NULL)
+ return ENOMEM;
+ if ((error = copyin(upl->params, buf, len)) != 0)
+ goto error;
+
+ if (set) {
+ error = wsmouse_set_params(sc, buf, upl->nparams);
+ if (error != 0)
+ goto error;
+ } else {
+ error = wsmouse_get_params(sc, buf, upl->nparams);
+ if (error != 0)
+ goto error;
+ if ((error = copyout(buf, upl->params, len)) != 0)
+ goto error;
+ }
+
+error:
+ kmem_free(buf, len);
+ return error;
+}
+
int
wsmouseopen(dev_t dev, int flags, int mode, struct lwp *l)
{
@@ -762,6 +893,16 @@
case WSMOUSEIO_SETVERSION:
return wsevent_setversion(sc->sc_base.me_evp, *(int *)data);
+
+ case WSMOUSEIO_GETPARAMS:
+ return wsmouse_handle_params(sc,
+ (struct wsmouse_parameters *)data, false);
+
+ case WSMOUSEIO_SETPARAMS:
+ if ((flag & FWRITE) == 0)
+ return EACCES;
+ return wsmouse_handle_params(sc,
+ (struct wsmouse_parameters *)data, true);
}
/*
Index: sys/dev/wscons/wsmousevar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsmousevar.h,v
retrieving revision 1.11
diff -u -r1.11 wsmousevar.h
--- sys/dev/wscons/wsmousevar.h 12 May 2009 14:47:55 -0000 1.11
+++ sys/dev/wscons/wsmousevar.h 25 Sep 2021 10:52:47 -0000
@@ -73,3 +73,5 @@
#define WSMOUSE_INPUT_ABSOLUTE_Z (1<<2)
#define WSMOUSE_INPUT_ABSOLUTE_W (1<<3)
void wsmouse_input(device_t, u_int, int, int, int, int, u_int);
+#define WSMOUSE_DEFAULT_SCROLL_DIST (12)
+void wsmouse_precision_scroll(device_t, int, int);
Index: sys/dev/pckbport/synaptics.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pckbport/synaptics.c,v
retrieving revision 1.71
diff -u -r1.71 synaptics.c
--- sys/dev/pckbport/synaptics.c 30 May 2021 13:20:01 -0000 1.71
+++ sys/dev/pckbport/synaptics.c 25 Sep 2021 10:52:47 -0000
@@ -120,9 +120,6 @@
static int synaptics_max_speed_y = 32;
static int synaptics_max_speed_z = 2;
static int synaptics_movement_threshold = 4;
-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;
static int synaptics_debug = 0;
@@ -159,9 +156,6 @@
static int synaptics_max_speed_y_nodenum;
static int synaptics_max_speed_z_nodenum;
static int synaptics_movement_threshold_nodenum;
-static int synaptics_finger_scroll_min_nodenum;
-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;
@@ -503,7 +497,6 @@
sc->gesture_tap_packet = 0;
sc->gesture_type = 0;
sc->gesture_buttons = 0;
- sc->dz_hold = 0;
for (i = 0; i < SYN_MAX_FINGERS; i++) {
sc->rem_x[i] = sc->rem_y[i] = sc->rem_z[i] = 0;
sc->movement_history[i] = 0;
@@ -809,42 +802,6 @@
if ((rc = sysctl_createv(clog, 0, NULL, &node,
CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
- CTLTYPE_INT, "finger_scroll-min",
- SYSCTL_DESCR("Minimum width at which y cursor movements will be converted to scroll wheel events"),
- pms_sysctl_synaptics_verify, 0,
- &synaptics_fscroll_min,
- 0, CTL_HW, root_num, CTL_CREATE,
- CTL_EOL)) != 0)
- goto err;
-
- synaptics_finger_scroll_min_nodenum = node->sysctl_num;
-
- if ((rc = sysctl_createv(clog, 0, NULL, &node,
- CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
- CTLTYPE_INT, "finger_scroll-max",
- SYSCTL_DESCR("Maximum width at which y cursor movements will be converted to scroll wheel events"),
- pms_sysctl_synaptics_verify, 0,
- &synaptics_fscroll_max,
- 0, CTL_HW, root_num, CTL_CREATE,
- CTL_EOL)) != 0)
- goto err;
-
- synaptics_finger_scroll_max_nodenum = node->sysctl_num;
-
- if ((rc = sysctl_createv(clog, 0, NULL, &node,
- CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
- CTLTYPE_INT, "finger_scroll-hysteresis",
- SYSCTL_DESCR("Number of packets to keep reporting y cursor movements as scroll wheel events"),
- pms_sysctl_synaptics_verify, 0,
- &synaptics_dz_hold,
- 0, CTL_HW, root_num, CTL_CREATE,
- CTL_EOL)) != 0)
- 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,
@@ -943,17 +900,6 @@
if (t < SYNAPTICS_EDGE_LEFT || t > SYNAPTICS_EDGE_RIGHT)
return (EINVAL);
} else
- if (node.sysctl_num == synaptics_finger_scroll_min_nodenum ||
- node.sysctl_num == synaptics_finger_scroll_max_nodenum) {
- /* make sure we avoid the "magic" widths, 4 and below
- are for fingers, 15 is palm detect. */
- if ((t < 5) || (t > 14))
- return (EINVAL);
- } else
- if (node.sysctl_num == synaptics_dz_hold_nodenum) {
- if (t < 0)
- return (EINVAL);
- } else
if (node.sysctl_num == synaptics_movement_enable_nodenum) {
if (t < 0 || t > 1)
return (EINVAL);
@@ -1213,20 +1159,20 @@
psc->buttons ^= changed;
if (dx || dy || dz || changed) {
+ s = spltty();
/*
- * If the middle button is held, interpret Y-axis
- * movement as scrolling.
+ * If the middle button is held, interpret movement as
+ * scrolling.
*/
if (synaptics_aux_mid_button_scroll &&
dy && (psc->buttons & 0x2)) {
- dz = -dy;
- dx = dy = 0;
+ wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy);
+ } else {
+ buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
+ wsmouse_input(psc->sc_wsmousedev,
+ buttons, dx, dy, dz, 0,
+ WSMOUSE_INPUT_DELTA);
}
- buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
- s = spltty();
- wsmouse_input(psc->sc_wsmousedev,
- buttons, dx, dy, dz, 0,
- WSMOUSE_INPUT_DELTA);
splx(s);
}
}
@@ -1650,27 +1596,19 @@
static inline void
synaptics_movement(struct synaptics_softc *sc, struct synaptics_packet *sp,
- int finger, int scroll_emul, int *dxp, int *dyp, int *dzp)
+ int finger, int *dxp, int *dyp, int *dzp)
{
int dx, dy, dz, edge;
dx = dy = dz = 0;
/*
- * Compute the next values of dx and dy and dz. If scroll_emul
- * is non-zero, take the dy and used it as use it as dz so we
- * can emulate a scroll wheel.
+ * Compute the next values of dx and dy and dz.
*/
- if (scroll_emul == 0) {
- dx = synaptics_filter_policy(sc, finger, sc->history_x[finger],
- sp->sp_x);
- dy = synaptics_filter_policy(sc, finger, sc->history_y[finger],
- sp->sp_y);
- } else {
- dz = synaptics_filter_policy(sc, finger, sc->history_z[finger],
- sp->sp_y);
- dx = dy = 0;
- }
+ dx = synaptics_filter_policy(sc, finger, sc->history_x[finger],
+ sp->sp_x);
+ dy = synaptics_filter_policy(sc, finger, sc->history_y[finger],
+ sp->sp_y);
/*
* If we're dealing with a drag gesture, and the finger moves to
@@ -1720,7 +1658,7 @@
struct synaptics_softc *sc = &psc->u.synaptics;
int dx, dy, dz;
int fingers, palm, buttons, changed;
- int s, z_emul;
+ int s;
/*
* Do Z-axis emulation using up/down buttons if required.
@@ -1781,20 +1719,21 @@
*/
if (palm == 0 && synaptics_movement_enable) {
if (fingers == 1) {
- z_emul = 0;
-
- if ((sp->sp_w >= synaptics_fscroll_min) &&
- (sp->sp_w <= synaptics_fscroll_max)) {
- z_emul = 1;
- sc->dz_hold = synaptics_dz_hold;
- }
-
- if (sc->dz_hold > 0) {
- z_emul = 1;
- }
-
+ /*
+ * Single finger - normal movement.
+ */
+ synaptics_movement(sc, sp, sp->sp_finger,
+ &dx, &dy, &dz);
+ } else if (fingers == 2 && sc->gesture_type == 0) {
+ /*
+ * Multiple finger movement. Interpret it as scrolling.
+ */
synaptics_movement(sc, sp, sp->sp_finger,
- z_emul, &dx, &dy, &dz);
+ &dx, &dy, &dz);
+ s = spltty();
+ wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy);
+ splx(s);
+ return;
} else {
/*
* No valid finger. Therefore no movement.
@@ -1812,9 +1751,6 @@
dx = dy = dz = 0;
}
- if (sc->dz_hold > 0)
- sc->dz_hold--;
-
/*
* Pass the final results up to wsmouse_input() if necessary.
*/
Home |
Main Index |
Thread Index |
Old Index