Module Name:    xsrc
Committed By:   nia
Date:           Tue Sep 28 06:17:15 UTC 2021

Modified Files:
        xsrc/external/mit/xf86-input-ws/dist/src: ws.c ws.h

Log Message:
xf86-input-ws: implement support for WSCONS_EVENT_(H|V)SCROLL.

adapted from the OpenBSD code.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 xsrc/external/mit/xf86-input-ws/dist/src/ws.c
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xf86-input-ws/dist/src/ws.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.c
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.11 xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.12
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.11	Fri Apr 14 19:19:43 2017
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.c	Tue Sep 28 06:17:15 2021
@@ -450,6 +450,10 @@ wsDeviceInit(DeviceIntPtr pWS)
 		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 @@ wsDeviceInit(DeviceIntPtr pWS)
 	);
 	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 @@ wsReadInput(InputInfoPtr pInfo)
 		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 @@ wsReadInput(InputInfoPtr pInfo)
 			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 @@ wsReadInput(InputInfoPtr pInfo)
 			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: xsrc/external/mit/xf86-input-ws/dist/src/ws.h
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.3 xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.4
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.3	Tue Jan  1 00:34:52 2019
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.h	Tue Sep 28 06:17:15 2021
@@ -27,7 +27,10 @@ extern int ws_debug_level;
 # 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 @@ typedef struct WSDevice {
 		Time expires;     /* time of expiry */
 		Time timeout;
 	} emulateMB;
+	ValuatorMask *scroll_mask;
 } WSDeviceRec, *WSDevicePtr;
 
 extern int wsmbEmuTimer(InputInfoPtr);

Reply via email to