Module Name: xsrc
Committed By: martin
Date: Thu Oct 15 12:05:46 UTC 2020
Modified Files:
xsrc/external/mit/xf86-input-mouse/dist/src [netbsd-9]: bsd_mouse.c
mouse.h
Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1112):
external/mit/xf86-input-mouse/dist/src/bsd_mouse.c: revision 1.6
external/mit/xf86-input-mouse/dist/src/mouse.h: revision 1.7
If we get an absolute pointer event and we can query the min/max X and Y
values reported and it is in raw mode, use the screen dimensions to scale
the coordinates to fit the screen before feeding the event to the X server.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.4.1 \
xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c
cvs rdiff -u -r1.6 -r1.6.12.1 \
xsrc/external/mit/xf86-input-mouse/dist/src/mouse.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-mouse/dist/src/bsd_mouse.c
diff -u xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5 xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5.4.1
--- xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5 Wed Jul 22 09:42:15 2015
+++ xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c Thu Oct 15 12:05:46 2020
@@ -384,6 +384,42 @@ FindDevice(InputInfoPtr pInfo, const cha
#define NUMEVENTS 64
static void
+wsconsAutoCalibrate(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ int width, height;
+ struct wsmouse_calibcoords cal;
+
+ pMse = pInfo->private;
+ width = screenInfo.screens[pMse->screenNo]->width;
+ height = screenInfo.screens[pMse->screenNo]->height;
+
+ if (width != pMse->lastScreenWidth || height != pMse->lastScreenHeight) {
+ if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, &cal) == 0 &&
+ cal.minx != cal.maxy && cal.miny != cal.maxy) {
+
+ xf86Msg(X_INFO, "%s: auto-calibrating abs pointer for %dx%d screen\n",
+ pInfo->name, width, height);
+
+ pMse->minX = cal.minx;
+ pMse->minY = cal.miny;
+ pMse->maxX = cal.maxx;
+ pMse->maxY = cal.maxy;
+ pMse->translateAbs =
+ cal.samplelen == WSMOUSE_CALIBCOORDS_RESET;
+ }
+ pMse->lastScreenWidth = width;
+ pMse->lastScreenHeight = height;
+ }
+}
+
+static int
+wsconsTranslate(InputInfoPtr pInfo, int scrRange, int rawMin, int rawMax, int rawVal)
+{
+ return ((rawVal - rawMin) * scrRange) / (rawMax - rawMin);
+}
+
+static void
wsconsReadInput(InputInfoPtr pInfo)
{
MouseDevPtr pMse;
@@ -394,6 +430,9 @@ wsconsReadInput(InputInfoPtr pInfo)
pMse = pInfo->private;
+ if (pMse->autoCalibrate)
+ wsconsAutoCalibrate(pInfo);
+
XisbBlockDuration(pMse->buffer, -1);
pBuf = (unsigned char *)eventList;
n = 0;
@@ -434,11 +473,17 @@ wsconsReadInput(InputInfoPtr pInfo)
#endif
case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
x = event->value;
+ if (pMse->translateAbs)
+ x = wsconsTranslate(pInfo, pMse->lastScreenWidth,
+ pMse->minX, pMse->maxX, x);
xf86PostMotionEvent(pInfo->dev, TRUE, 0, 1, x);
++event;
continue;
case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
y = event->value;
+ if (pMse->translateAbs)
+ y = wsconsTranslate(pInfo, pMse->lastScreenWidth,
+ pMse->minY, pMse->maxY, y);
xf86PostMotionEvent(pInfo->dev, TRUE, 1, 1, y);
++event;
continue;
@@ -480,6 +525,19 @@ wsconsPreInit(InputInfoPtr pInfo, const
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
pInfo->flags |= XI86_CONFIGURED;
#endif
+
+ pMse->autoCalibrate = xf86SetBoolOption(pInfo->options, "AutoCalibrate", TRUE);
+ xf86Msg(X_CONFIG, "%s: auto calibration %sabled\n",
+ pInfo->name, pMse->autoCalibrate ? "en" : "dis");
+
+ pMse->screenNo = xf86SetIntOption(pInfo->options, "ScreenNo", 0);
+ if (pMse->screenNo >= screenInfo.numScreens ||
+ pMse->screenNo < 0) {
+ pMse->screenNo = 0;
+ }
+ xf86Msg(X_CONFIG, "%s: associated screen: %d\n",
+ pInfo->name, pMse->screenNo);
+
return TRUE;
}
#endif
Index: xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h
diff -u xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6.12.1
--- xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6 Wed Jun 5 07:11:16 2013
+++ xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h Thu Oct 15 12:05:46 2020
@@ -262,6 +262,15 @@ typedef struct _MouseDevRec {
int doubleClickOldSourceState;
int lastMappedButtons;
int buttonMap[MSE_MAXBUTTONS];
+ int autoCalibrate;
+ int lastScreenWidth;
+ int lastScreenHeight;
+ int screenNo;
+ int minX;
+ int minY;
+ int maxX;
+ int maxY;
+ int translateAbs;
} MouseDevRec, *MouseDevPtr;
#endif /* _XF86OSMOUSE_H_ */