Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/xf86-input-ws/dist/src xf86-input-ws: impleme...
details: https://anonhg.NetBSD.org/xsrc/rev/c66fd4bfda62
branches: trunk
changeset: 10804:c66fd4bfda62
user: nia <nia%NetBSD.org@localhost>
date: Tue Sep 28 06:17:15 2021 +0000
description:
xf86-input-ws: implement support for WSCONS_EVENT_(H|V)SCROLL.
adapted from the OpenBSD code.
diffstat:
external/mit/xf86-input-ws/dist/src/ws.c | 42 ++++++++++++++++++++++++++++++++
external/mit/xf86-input-ws/dist/src/ws.h | 6 +++-
2 files changed, 47 insertions(+), 1 deletions(-)
diffs (103 lines):
diff -r 4bbb12a706bc -r c66fd4bfda62 external/mit/xf86-input-ws/dist/src/ws.c
--- a/external/mit/xf86-input-ws/dist/src/ws.c Sun Sep 05 03:57:27 2021 +0000
+++ b/external/mit/xf86-input-ws/dist/src/ws.c Tue Sep 28 06:17:15 2021 +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);
diff -r 4bbb12a706bc -r c66fd4bfda62 external/mit/xf86-input-ws/dist/src/ws.h
--- a/external/mit/xf86-input-ws/dist/src/ws.h Sun Sep 05 03:57:27 2021 +0000
+++ b/external/mit/xf86-input-ws/dist/src/ws.h Tue Sep 28 06:17:15 2021 +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);
Home |
Main Index |
Thread Index |
Old Index