Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/netbsd-9]: xsrc/external/mit/xf86-input-mouse/dist/src Pull up followin...



details:   https://anonhg.NetBSD.org/xsrc/rev/62148b0cccb9
branches:  netbsd-9
changeset: 10581:62148b0cccb9
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Oct 15 12:05:46 2020 +0000

description:
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.

diffstat:

 external/mit/xf86-input-mouse/dist/src/bsd_mouse.c |  58 ++++++++++++++++++++++
 external/mit/xf86-input-mouse/dist/src/mouse.h     |   9 +++
 2 files changed, 67 insertions(+), 0 deletions(-)

diffs (113 lines):

diff -r e79da798cfb9 -r 62148b0cccb9 external/mit/xf86-input-mouse/dist/src/bsd_mouse.c
--- a/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c        Thu Oct 08 15:52:11 2020 +0000
+++ b/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c        Thu Oct 15 12:05:46 2020 +0000
@@ -384,6 +384,42 @@
 #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 @@
 
     pMse = pInfo->private;
 
+    if (pMse->autoCalibrate)
+        wsconsAutoCalibrate(pInfo);
+
     XisbBlockDuration(pMse->buffer, -1);
     pBuf = (unsigned char *)eventList;
     n = 0;
@@ -434,11 +473,17 @@
 #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 @@
 #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
diff -r e79da798cfb9 -r 62148b0cccb9 external/mit/xf86-input-mouse/dist/src/mouse.h
--- a/external/mit/xf86-input-mouse/dist/src/mouse.h    Thu Oct 08 15:52:11 2020 +0000
+++ b/external/mit/xf86-input-mouse/dist/src/mouse.h    Thu Oct 15 12:05:46 2020 +0000
@@ -262,6 +262,15 @@
     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_ */



Home | Main Index | Thread Index | Old Index