Fri Nov 11 23:50:07 2022 UTC ()
merge xf86-input-mouse 1.9.4.


(mrg)
diff -r1.6 -r1.7 xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c
diff -r1.19 -r1.20 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c
diff -r1.3 -r1.4 xsrc/external/mit/xf86-input-mouse/dist/src/pnp.c

cvs diff -r1.6 -r1.7 xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c 2020/10/10 21:50:53 1.6
+++ xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c 2022/11/11 23:50:07 1.7
@@ -51,49 +51,49 @@ @@ -51,49 +51,49 @@
51#define USB_NEW_HID 51#define USB_NEW_HID
52#endif 52#endif
53 53
54#define HUP_GENERIC_DESKTOP 0x0001 54#define HUP_GENERIC_DESKTOP 0x0001
55#define HUP_BUTTON 0x0009 55#define HUP_BUTTON 0x0009
56 56
57#define HUG_X 0x0030 57#define HUG_X 0x0030
58#define HUG_Y 0x0031 58#define HUG_Y 0x0031
59#define HUG_Z 0x0032 59#define HUG_Z 0x0032
60#define HUG_WHEEL 0x0038 60#define HUG_WHEEL 0x0038
61 61
62#define HID_USAGE2(p,u) (((p) << 16) | u) 62#define HID_USAGE2(p,u) (((p) << 16) | u)
63 63
64/* The UMS mices have middle button as number 3 */ 64/* The UMS mice have middle button as number 3 */
65#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i)) 65#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i))
66#endif /* USBMOUSE_SUPPORT */ 66#endif /* USBMOUSE_SUPPORT */
67 67
68#ifdef USBMOUSE_SUPPORT 68#ifdef USBMOUSE_SUPPORT
69static void usbSigioReadInput (int fd, void *closure); 69static void usbSigioReadInput (int fd, void *closure);
70#endif 70#endif
71static const char *FindDevice(InputInfoPtr, const char *, int); 71static const char *FindDevice(InputInfoPtr, const char *, int);
72 72
73#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 73#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
74/* These are for FreeBSD and DragonFly */ 74/* These are for FreeBSD and DragonFly */
75#define DEFAULT_MOUSE_DEV "/dev/mouse" 75#define DEFAULT_MOUSE_DEV "/dev/mouse"
76#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse" 76#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse"
77#define DEFAULT_PS2_DEV "/dev/psm0" 77#define DEFAULT_PS2_DEV "/dev/psm0"
78 78
79static const char *mouseDevs[] = { 79static const char *mouseDevs[] = {
80 DEFAULT_MOUSE_DEV, 80 DEFAULT_MOUSE_DEV,
81 DEFAULT_SYSMOUSE_DEV, 81 DEFAULT_SYSMOUSE_DEV,
82 DEFAULT_PS2_DEV, 82 DEFAULT_PS2_DEV,
83 NULL 83 NULL
84}; 84};
85#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) 85#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
86/* Only wsmouse mices are autoconfigured for now on OpenBSD */ 86/* Only wsmouse mice are autoconfigured for now on OpenBSD */
87#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse" 87#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse"
88#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0" 88#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0"
89 89
90static const char *mouseDevs[] = { 90static const char *mouseDevs[] = {
91 DEFAULT_WSMOUSE_DEV, 91 DEFAULT_WSMOUSE_DEV,
92 DEFAULT_WSMOUSE0_DEV, 92 DEFAULT_WSMOUSE0_DEV,
93 NULL 93 NULL
94}; 94};
95#endif 95#endif
96 96
97static int 97static int
98SupportedInterfaces(void) 98SupportedInterfaces(void)
99{ 99{
@@ -222,27 +222,27 @@ SetSysMouseRes(InputInfoPtr pInfo, const @@ -222,27 +222,27 @@ SetSysMouseRes(InputInfoPtr pInfo, const
222 mousemode_t mode; 222 mousemode_t mode;
223 MouseDevPtr pMse; 223 MouseDevPtr pMse;
224 224
225 pMse = pInfo->private; 225 pMse = pInfo->private;
226 226
227 mode.rate = rate > 0 ? rate : -1; 227 mode.rate = rate > 0 ? rate : -1;
228 mode.resolution = res > 0 ? res : -1; 228 mode.resolution = res > 0 ? res : -1;
229 mode.accelfactor = -1; 229 mode.accelfactor = -1;
230#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 230#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
231 if (pMse->autoProbe || 231 if (pMse->autoProbe ||
232 (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) { 232 (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
233 /* 233 /*
234 * As the FreeBSD sysmouse driver defaults to protocol level 0 234 * As the FreeBSD sysmouse driver defaults to protocol level 0
235 * everytime it is opened we enforce protocol level 1 again at 235 * every time it is opened we enforce protocol level 1 again at
236 * this point. 236 * this point.
237 */ 237 */
238 mode.level = 1; 238 mode.level = 1;
239 } else 239 } else
240 mode.level = -1; 240 mode.level = -1;
241#else 241#else
242 mode.level = -1; 242 mode.level = -1;
243#endif 243#endif
244 ioctl(pInfo->fd, MOUSE_SETMODE, &mode); 244 ioctl(pInfo->fd, MOUSE_SETMODE, &mode);
245} 245}
246#endif 246#endif
247 247
248#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 248#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
@@ -594,28 +594,30 @@ usbMouseProc(DeviceIntPtr pPointer, int  @@ -594,28 +594,30 @@ usbMouseProc(DeviceIntPtr pPointer, int
594 594
595 case DEVICE_ON: 595 case DEVICE_ON:
596 pInfo->fd = xf86OpenSerial(pInfo->options); 596 pInfo->fd = xf86OpenSerial(pInfo->options);
597 if (pInfo->fd == -1) 597 if (pInfo->fd == -1)
598 xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); 598 xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
599 else { 599 else {
600 pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize); 600 pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize);
601 if (!pMse->buffer) { 601 if (!pMse->buffer) {
602 free(pMse); 602 free(pMse);
603 xf86CloseSerial(pInfo->fd); 603 xf86CloseSerial(pInfo->fd);
604 pInfo->fd = -1; 604 pInfo->fd = -1;
605 } else { 605 } else {
606 xf86FlushInput(pInfo->fd); 606 xf86FlushInput(pInfo->fd);
 607#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 23
607 if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput, 608 if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput,
608 pInfo)) 609 pInfo))
 610#endif
609 AddEnabledDevice(pInfo->fd); 611 AddEnabledDevice(pInfo->fd);
610 } 612 }
611 } 613 }
612 pMse->lastButtons = 0; 614 pMse->lastButtons = 0;
613 pMse->lastMappedButtons = 0; 615 pMse->lastMappedButtons = 0;
614 pMse->emulateState = 0; 616 pMse->emulateState = 0;
615 pPointer->public.on = TRUE; 617 pPointer->public.on = TRUE;
616 break; 618 break;
617 619
618 case DEVICE_OFF: 620 case DEVICE_OFF:
619 case DEVICE_CLOSE: 621 case DEVICE_CLOSE:
620 if (pInfo->fd != -1) { 622 if (pInfo->fd != -1) {
621 RemoveEnabledDevice(pInfo->fd); 623 RemoveEnabledDevice(pInfo->fd);
@@ -716,27 +718,27 @@ usbPreInit(InputInfoPtr pInfo, const cha @@ -716,27 +718,27 @@ usbPreInit(InputInfoPtr pInfo, const cha
716 718
717 /* Check if the device can be opened. */ 719 /* Check if the device can be opened. */
718 pInfo->fd = xf86OpenSerial(pInfo->options); 720 pInfo->fd = xf86OpenSerial(pInfo->options);
719 if (pInfo->fd == -1) { 721 if (pInfo->fd == -1) {
720 if (xf86GetAllowMouseOpenFail()) 722 if (xf86GetAllowMouseOpenFail())
721 xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); 723 xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
722 else { 724 else {
723 xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); 725 xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
724 free(pUsbMse); 726 free(pUsbMse);
725 free(pMse); 727 free(pMse);
726 return FALSE; 728 return FALSE;
727 } 729 }
728 } 730 }
729 /* Get USB informations */ 731 /* Get USB information */
730 reportDesc = hid_get_report_desc(pInfo->fd); 732 reportDesc = hid_get_report_desc(pInfo->fd);
731 /* Get packet size & iid */ 733 /* Get packet size & iid */
732#ifdef USB_NEW_HID 734#ifdef USB_NEW_HID
733 if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) { 735 if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) {
734 xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n", 736 xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n",
735 pInfo->name, strerror(errno)); 737 pInfo->name, strerror(errno));
736 return FALSE; 738 return FALSE;
737 } 739 }
738 pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, 740 pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
739 pUsbMse->iid); 741 pUsbMse->iid);
740#else 742#else
741 pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, 743 pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
742 &pUsbMse->iid); 744 &pUsbMse->iid);

cvs diff -r1.19 -r1.20 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c 2018/12/31 12:01:31 1.19
+++ xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c 2022/11/11 23:50:07 1.20
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 */ 28 */
29/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */ 29/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */
30 30
31/* 31/*
32 * [JCH-96/01/21] Added fourth button support for PROT_GLIDEPOINT mouse 32 * [JCH-96/01/21] Added fourth button support for PROT_GLIDEPOINT mouse
33 * protocol. 33 * protocol.
34 */ 34 */
35 35
36/* 36/*
37 * [TVO-97/03/05] Added microsoft IntelliMouse support 37 * [TVO-97/03/05] Added microsoft IntelliMouse support
38 */ 38 */
39 39
40/* 40/*
41 * [PME-02/08/11] Added suport for drag lock buttons 41 * [PME-02/08/11] Added support for drag lock buttons
42 * for use with 4 button trackballs for convenience 42 * for use with 4 button trackballs for convenience
43 * and to help limited dexterity persons 43 * and to help limited dexterity persons
44 */ 44 */
45 45
46#ifdef HAVE_CONFIG_H 46#ifdef HAVE_CONFIG_H
47#include "config.h" 47#include "config.h"
48#endif 48#endif
49 49
50#include <xorg-server.h> 50#include <xorg-server.h>
51#include <math.h> 51#include <math.h>
52#include <string.h> 52#include <string.h>
53#include <stdio.h> 53#include <stdio.h>
54#include <stdlib.h> 54#include <stdlib.h>
@@ -166,32 +166,38 @@ static void ps2BlockHandler(pointer data @@ -166,32 +166,38 @@ static void ps2BlockHandler(pointer data
166#endif 166#endif
167static void Emulate3ButtonsSetEnabled(InputInfoPtr pInfo, Bool enable); 167static void Emulate3ButtonsSetEnabled(InputInfoPtr pInfo, Bool enable);
168 168
169/* mouse autoprobe stuff */ 169/* mouse autoprobe stuff */
170static const char *autoOSProtocol(InputInfoPtr pInfo, int *protoPara); 170static const char *autoOSProtocol(InputInfoPtr pInfo, int *protoPara);
171static void autoProbeMouse(InputInfoPtr pInfo, Bool inSync, Bool lostSync); 171static void autoProbeMouse(InputInfoPtr pInfo, Bool inSync, Bool lostSync);
172static void checkForErraticMovements(InputInfoPtr pInfo, int dx, int dy); 172static void checkForErraticMovements(InputInfoPtr pInfo, int dx, int dy);
173static Bool collectData(MouseDevPtr pMse, unsigned char u); 173static Bool collectData(MouseDevPtr pMse, unsigned char u);
174static void SetMouseProto(MouseDevPtr pMse, MouseProtocolID protocolID); 174static void SetMouseProto(MouseDevPtr pMse, MouseProtocolID protocolID);
175static Bool autoGood(MouseDevPtr pMse); 175static Bool autoGood(MouseDevPtr pMse);
176 176
177#undef MOUSE 177#undef MOUSE
178_X_EXPORT InputDriverRec MOUSE = { 178_X_EXPORT InputDriverRec MOUSE = {
179 1, 179 .driverVersion = 1,
180 "mouse", 180 .driverName = "mouse",
181 NULL, 181 .Identify = NULL,
182 MousePreInit, 182 .PreInit = MousePreInit,
183 NULL, 183 .UnInit = NULL,
184 NULL, 184 .module = NULL,
 185#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
 186 .default_options = NULL,
 187#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 21
 188 .capabilities = 0
 189#endif
 190#endif
185}; 191};
186 192
187#define RETRY_COUNT 4 193#define RETRY_COUNT 4
188 194
189/* Properties that can be set at runtime via xinput */ 195/* Properties that can be set at runtime via xinput */
190static Atom prop_mbemu = 0; /* Middle button emulation on/off property */ 196static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
191static Atom prop_mbtimeout = 0; /* Middle button timeout property */ 197static Atom prop_mbtimeout = 0; /* Middle button timeout property */
192 198
193/* 199/*
194 * Microsoft (all serial models), Logitech MouseMan, First Mouse, etc, 200 * Microsoft (all serial models), Logitech MouseMan, First Mouse, etc,
195 * ALPS GlidePoint, Thinking Mouse. 201 * ALPS GlidePoint, Thinking Mouse.
196 */ 202 */
197static const char *msDefaults[] = { 203static const char *msDefaults[] = {
@@ -809,28 +815,28 @@ InitProtocols(void) @@ -809,28 +815,28 @@ InitProtocols(void)
809 return FALSE; 815 return FALSE;
810 816
811 /* Mark unsupported interface classes. */ 817 /* Mark unsupported interface classes. */
812 for (i = 0; mouseProtocols[i].name; i++) 818 for (i = 0; mouseProtocols[i].name; i++)
813 if (!(mouseProtocols[i].class & classes)) 819 if (!(mouseProtocols[i].class & classes))
814 mouseProtocols[i].id = PROT_UNSUP; 820 mouseProtocols[i].id = PROT_UNSUP;
815 821
816 for (i = 0; mouseProtocols[i].name; i++) 822 for (i = 0; mouseProtocols[i].name; i++)
817 if (mouseProtocols[i].class & MSE_MISC) 823 if (mouseProtocols[i].class & MSE_MISC)
818 if (!osInfo->CheckProtocol || 824 if (!osInfo->CheckProtocol ||
819 !osInfo->CheckProtocol(mouseProtocols[i].name)) 825 !osInfo->CheckProtocol(mouseProtocols[i].name))
820 mouseProtocols[i].id = PROT_UNSUP; 826 mouseProtocols[i].id = PROT_UNSUP;
821 827
822#ifdef __NetBSD__ 
823 /* NetBSD uses PROT_BM for "PS/2". */ 828 /* NetBSD uses PROT_BM for "PS/2". */
 829#if defined(__NetBSD__)
824 for (i = 0; mouseProtocols[i].name; i++) 830 for (i = 0; mouseProtocols[i].name; i++)
825 if (mouseProtocols[i].id == PROT_PS2) 831 if (mouseProtocols[i].id == PROT_PS2)
826 mouseProtocols[i].id = PROT_BM; 832 mouseProtocols[i].id = PROT_BM;
827#endif 833#endif
828 834
829 return TRUE; 835 return TRUE;
830} 836}
831 837
832static const char* 838static const char*
833MouseFindDevice(InputInfoPtr pInfo, const char* protocol) 839MouseFindDevice(InputInfoPtr pInfo, const char* protocol)
834{ 840{
835 const char *device; 841 const char *device;
836 842
@@ -1185,27 +1191,27 @@ MouseReadInput(InputInfoPtr pInfo) @@ -1185,27 +1191,27 @@ MouseReadInput(InputInfoPtr pInfo)
1185 unsigned char *pBuf, u; 1191 unsigned char *pBuf, u;
1186 1192
1187 1193
1188 pMse = pInfo->private; 1194 pMse = pInfo->private;
1189 pBufP = pMse->protoBufTail; 1195 pBufP = pMse->protoBufTail;
1190 pBuf = pMse->protoBuf; 1196 pBuf = pMse->protoBuf;
1191 1197
1192 if (pInfo->fd == -1) 1198 if (pInfo->fd == -1)
1193 return; 1199 return;
1194 1200
1195 /* 1201 /*
1196 * Set blocking to -1 on the first call because we know there is data to 1202 * Set blocking to -1 on the first call because we know there is data to
1197 * read. Xisb automatically clears it after one successful read so that 1203 * read. Xisb automatically clears it after one successful read so that
1198 * succeeding reads are preceeded by a select with a 0 timeout to prevent 1204 * succeeding reads are preceded by a select with a 0 timeout to prevent
1199 * read from blocking indefinitely. 1205 * read from blocking indefinitely.
1200 */ 1206 */
1201 XisbBlockDuration(pMse->buffer, -1); 1207 XisbBlockDuration(pMse->buffer, -1);
1202 1208
1203 while ((c = XisbRead(pMse->buffer)) >= 0) { 1209 while ((c = XisbRead(pMse->buffer)) >= 0) {
1204 u = (unsigned char)c; 1210 u = (unsigned char)c;
1205 1211
1206#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG) 1212#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG)
1207 LogMessageVerbSigSafe(X_INFO, -1, "mouse byte: %x\n",u); 1213 LogMessageVerbSigSafe(X_INFO, -1, "mouse byte: %x\n",u);
1208#endif 1214#endif
1209 1215
1210 /* if we do autoprobing collect the data */ 1216 /* if we do autoprobing collect the data */
1211 if (pMse->collectData && pMse->autoProbe) 1217 if (pMse->collectData && pMse->autoProbe)
@@ -1245,31 +1251,31 @@ MouseReadInput(InputInfoPtr pInfo) @@ -1245,31 +1251,31 @@ MouseReadInput(InputInfoPtr pInfo)
1245 * even 0x02/0x22, so I have to strip off the lower bits. 1251 * even 0x02/0x22, so I have to strip off the lower bits.
1246 * [CHRIS-211092] 1252 * [CHRIS-211092]
1247 * 1253 *
1248 * [JCH-96/01/21] 1254 * [JCH-96/01/21]
1249 * HACK for ALPS "fourth button". (It's bit 0x10 of the 1255 * HACK for ALPS "fourth button". (It's bit 0x10 of the
1250 * "fourth byte" and it is activated by tapping the glidepad 1256 * "fourth byte" and it is activated by tapping the glidepad
1251 * with the finger! 8^) We map it to bit bit3, and the 1257 * with the finger! 8^) We map it to bit bit3, and the
1252 * reverse map in xf86Events just has to be extended so that 1258 * reverse map in xf86Events just has to be extended so that
1253 * it is identified as Button 4. The lower half of the 1259 * it is identified as Button 4. The lower half of the
1254 * reverse-map may remain unchanged. 1260 * reverse-map may remain unchanged.
1255 */ 1261 */
1256 /* 1262 /*
1257 * [KAZU-030897] 1263 * [KAZU-030897]
1258 * Receive the fourth byte only when preceeding three bytes 1264 * Receive the fourth byte only when preceding three bytes
1259 * have been detected (pBufP >= pMse->protoPara[4]). In the 1265 * have been detected (pBufP >= pMse->protoPara[4]). In the
1260 * previous versions, the test was pBufP == 0; we may have 1266 * previous versions, the test was pBufP == 0; we may have
1261 * mistakingly received a byte even if we didn't see anything 1267 * mistakingly received a byte even if we didn't see anything
1262 * preceeding the byte. 1268 * preceding the byte.
1263 */ 1269 */
1264#ifdef EXTMOUSEDEBUG 1270#ifdef EXTMOUSEDEBUG
1265 LogMessageVerbSigSafe(X_INFO, -1, "mouse 4th byte %x\n",u); 1271 LogMessageVerbSigSafe(X_INFO, -1, "mouse 4th byte %x\n",u);
1266#endif 1272#endif
1267 dx = dy = dz = dw = 0; 1273 dx = dy = dz = dw = 0;
1268 buttons = 0; 1274 buttons = 0;
1269 switch (pMse->protocolID) { 1275 switch (pMse->protocolID) {
1270 1276
1271 /* 1277 /*
1272 * [KAZU-221197] 1278 * [KAZU-221197]
1273 * IntelliMouse, NetMouse (including NetMouse Pro) and Mie 1279 * IntelliMouse, NetMouse (including NetMouse Pro) and Mie
1274 * Mouse always send the fourth byte, whereas the fourth byte 1280 * Mouse always send the fourth byte, whereas the fourth byte
1275 * is optional for GlidePoint and ThinkingMouse. The fourth 1281 * is optional for GlidePoint and ThinkingMouse. The fourth
@@ -1898,27 +1904,27 @@ FlushButtons(MouseDevPtr pMse) @@ -1898,27 +1904,27 @@ FlushButtons(MouseDevPtr pMse)
1898 * pressed now. It's possible (ie, mouse hardware does it) to go from (eg) 1904 * pressed now. It's possible (ie, mouse hardware does it) to go from (eg)
1899 * left down to right down without anything in between, so all cases must be 1905 * left down to right down without anything in between, so all cases must be
1900 * handled. 1906 * handled.
1901 * 1907 *
1902 * a handler consists of three values: 1908 * a handler consists of three values:
1903 * 0: action1 1909 * 0: action1
1904 * 1: action2 1910 * 1: action2
1905 * 2: new emulation state 1911 * 2: new emulation state
1906 * 1912 *
1907 * action > 0: ButtonPress 1913 * action > 0: ButtonPress
1908 * action = 0: nothing 1914 * action = 0: nothing
1909 * action < 0: ButtonRelease 1915 * action < 0: ButtonRelease
1910 * 1916 *
1911 * The comment preceeding each section is the current emulation state. 1917 * The comment preceding each section is the current emulation state.
1912 * The comments to the right are of the form 1918 * The comments to the right are of the form
1913 * <button state> (<events>) -> <new emulation state> 1919 * <button state> (<events>) -> <new emulation state>
1914 * which should be read as 1920 * which should be read as
1915 * If the buttons are in <button state>, generate <events> then go to 1921 * If the buttons are in <button state>, generate <events> then go to
1916 * <new emulation state>. 1922 * <new emulation state>.
1917 */ 1923 */
1918static signed char stateTab[11][5][3] = { 1924static signed char stateTab[11][5][3] = {
1919/* 0 ground */ 1925/* 0 ground */
1920 { 1926 {
1921 { 0, 0, 0 }, /* nothing -> ground (no change) */ 1927 { 0, 0, 0 }, /* nothing -> ground (no change) */
1922 { 0, 0, 1 }, /* left -> delayed left */ 1928 { 0, 0, 1 }, /* left -> delayed left */
1923 { 0, 0, 2 }, /* right -> delayed right */ 1929 { 0, 0, 2 }, /* right -> delayed right */
1924 { 2, 0, 3 }, /* left & right (middle press) -> pressed middle */ 1930 { 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
@@ -2576,58 +2582,57 @@ static unsigned char proto[PROT_NUMPROTO @@ -2576,58 +2582,57 @@ static unsigned char proto[PROT_NUMPROTO
2576 { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* Auto (dummy) */ 2582 { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* Auto (dummy) */
2577 { 0xf8, 0x80, 0x00, 0x00, 8, 0x00, 0xff, MPF_NONE }, /* SysMouse */ 2583 { 0xf8, 0x80, 0x00, 0x00, 8, 0x00, 0xff, MPF_NONE }, /* SysMouse */
2578}; 2584};
2579 2585
2580 2586
2581/* 2587/*
2582 * SetupMouse -- 2588 * SetupMouse --
2583 * Sets up the mouse parameters 2589 * Sets up the mouse parameters
2584 */ 2590 */
2585static Bool 2591static Bool
2586SetupMouse(InputInfoPtr pInfo) 2592SetupMouse(InputInfoPtr pInfo)
2587{ 2593{
2588 MouseDevPtr pMse; 2594 MouseDevPtr pMse;
2589 int i; 
2590 int protoPara[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; 2595 int protoPara[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
2591 const char *name = NULL; 2596 const char *name = NULL;
2592 Bool automatic = FALSE; 2597 Bool automatic = FALSE;
2593 2598
2594 pMse = pInfo->private; 2599 pMse = pInfo->private;
2595 2600
2596 /* Handle the "Auto" protocol. */ 2601 /* Handle the "Auto" protocol. */
2597 if (pMse->protocolID == PROT_AUTO) { 2602 if (pMse->protocolID == PROT_AUTO) {
2598 /* 2603 /*
2599 * We come here when user specifies protocol "auto" in 2604 * We come here when user specifies protocol "auto" in
2600 * the configuration file or thru the xf86misc extensions. 2605 * the configuration file or through the xf86misc extensions.
2601 * So we initialize autoprobing here. 2606 * So we initialize autoprobing here.
2602 * Probe for PnP/OS mouse first. If unsuccessful 2607 * Probe for PnP/OS mouse first. If unsuccessful
2603 * try to guess protocol from incoming data. 2608 * try to guess protocol from incoming data.
2604 */ 2609 */
2605 automatic = TRUE; 2610 automatic = TRUE;
2606 pMse->autoProbe = TRUE; 2611 pMse->autoProbe = TRUE;
2607 name = autoOSProtocol(pInfo,protoPara); 2612 name = autoOSProtocol(pInfo,protoPara);
2608 if (name) { 2613 if (name) {
2609#ifdef EXTMOUSEDEBUG 2614#ifdef EXTMOUSEDEBUG
2610 ErrorF("PnP/OS Mouse detected: %s\n",name); 2615 ErrorF("PnP/OS Mouse detected: %s\n",name);
2611#endif 2616#endif
2612 } 2617 }
2613 } 2618 }
2614 2619
2615 SetMouseProto(pMse, pMse->protocolID); 2620 SetMouseProto(pMse, pMse->protocolID);
2616 2621
2617 if (automatic) { 2622 if (automatic) {
2618 if (name) { 2623 if (name) {
2619 /* Possible protoPara overrides from SetupAuto. */ 2624 /* Possible protoPara overrides from SetupAuto. */
2620 for (i = 0; i < sizeof(pMse->protoPara); i++) 2625 for (size_t i = 0; i < sizeof(pMse->protoPara); i++)
2621 if (protoPara[i] != -1) 2626 if (protoPara[i] != -1)
2622 pMse->protoPara[i] = protoPara[i]; 2627 pMse->protoPara[i] = protoPara[i];
2623 /* if we come here PnP/OS mouse probing was successful */ 2628 /* if we come here PnP/OS mouse probing was successful */
2624 } else { 2629 } else {
2625 /* PnP/OS mouse probing wasn't successful; we look at data */ 2630 /* PnP/OS mouse probing wasn't successful; we look at data */
2626 } 2631 }
2627 } 2632 }
2628 2633
2629 /* 2634 /*
2630 * If protocol has changed fetch the default options 2635 * If protocol has changed fetch the default options
2631 * for the new protocol. 2636 * for the new protocol.
2632 */ 2637 */
2633 if (pMse->oldProtocolID != pMse->protocolID) { 2638 if (pMse->oldProtocolID != pMse->protocolID) {
@@ -3233,27 +3238,27 @@ autoOSProtocol(InputInfoPtr pInfo, int * @@ -3233,27 +3238,27 @@ autoOSProtocol(InputInfoPtr pInfo, int *
3233 const char *name = NULL; 3238 const char *name = NULL;
3234 MouseProtocolID protocolID = PROT_UNKNOWN; 3239 MouseProtocolID protocolID = PROT_UNKNOWN;
3235 3240
3236 /* Check if the OS has a detection mechanism. */ 3241 /* Check if the OS has a detection mechanism. */
3237 if (osInfo->SetupAuto) { 3242 if (osInfo->SetupAuto) {
3238 name = osInfo->SetupAuto(pInfo, protoPara); 3243 name = osInfo->SetupAuto(pInfo, protoPara);
3239 if (name) { 3244 if (name) {
3240 protocolID = ProtocolNameToID(name); 3245 protocolID = ProtocolNameToID(name);
3241 switch (protocolID) { 3246 switch (protocolID) {
3242 case PROT_UNKNOWN: 3247 case PROT_UNKNOWN:
3243 /* Check for a builtin OS-specific protocol. */ 3248 /* Check for a builtin OS-specific protocol. */
3244 if (osInfo->CheckProtocol && osInfo->CheckProtocol(name)) { 3249 if (osInfo->CheckProtocol && osInfo->CheckProtocol(name)) {
3245 /* We can only come here if the protocol has been 3250 /* We can only come here if the protocol has been
3246 * changed to auto thru the xf86misc extension 3251 * changed to auto through the xf86misc extension
3247 * and we have detected an OS specific builtin 3252 * and we have detected an OS specific builtin
3248 * protocol. Currently we cannot handle this */ 3253 * protocol. Currently we cannot handle this */
3249 name = NULL; 3254 name = NULL;
3250 } else 3255 } else
3251 name = NULL; 3256 name = NULL;
3252 break; 3257 break;
3253 case PROT_UNSUP: 3258 case PROT_UNSUP:
3254 name = NULL; 3259 name = NULL;
3255 break; 3260 break;
3256 default: 3261 default:
3257 break; 3262 break;
3258 } 3263 }
3259 } 3264 }
@@ -3712,26 +3717,27 @@ autoGood(MouseDevPtr pMse) @@ -3712,26 +3717,27 @@ autoGood(MouseDevPtr pMse)
3712 if (!pMse->autoProbe) 3717 if (!pMse->autoProbe)
3713 return TRUE; 3718 return TRUE;
3714 3719
3715 switch (mPriv->autoState) { 3720 switch (mPriv->autoState) {
3716 case AUTOPROBE_GOOD: 3721 case AUTOPROBE_GOOD:
3717 case AUTOPROBE_H_GOOD: 3722 case AUTOPROBE_H_GOOD:
3718 return TRUE; 3723 return TRUE;
3719 case AUTOPROBE_VALIDATE1: /* @@@ */ 3724 case AUTOPROBE_VALIDATE1: /* @@@ */
3720 case AUTOPROBE_H_VALIDATE1: /* @@@ */ 3725 case AUTOPROBE_H_VALIDATE1: /* @@@ */
3721 case AUTOPROBE_VALIDATE2: 3726 case AUTOPROBE_VALIDATE2:
3722 case AUTOPROBE_H_VALIDATE2: 3727 case AUTOPROBE_H_VALIDATE2:
3723 if (mPriv->goodCount < PROBE_UNCERTAINTY/2) 3728 if (mPriv->goodCount < PROBE_UNCERTAINTY/2)
3724 return TRUE; 3729 return TRUE;
 3730 /* FALLTHROUGH */
3725 default: 3731 default:
3726 return FALSE; 3732 return FALSE;
3727 } 3733 }
3728} 3734}
3729 3735
3730 3736
3731#define TOT_THRESHOLD 3000 3737#define TOT_THRESHOLD 3000
3732#define VAL_THRESHOLD 40 3738#define VAL_THRESHOLD 40
3733 3739
3734/* 3740/*
3735 * checkForErraticMovements() -- check if mouse 'jumps around'. 3741 * checkForErraticMovements() -- check if mouse 'jumps around'.
3736 */ 3742 */
3737static void 3743static void
@@ -3745,41 +3751,43 @@ checkForErraticMovements(InputInfoPtr pI @@ -3745,41 +3751,43 @@ checkForErraticMovements(InputInfoPtr pI
3745 3751
3746#if 0 3752#if 0
3747 if (abs(dx - mPriv->prevDx) > 300 3753 if (abs(dx - mPriv->prevDx) > 300
3748 || abs(dy - mPriv->prevDy) > 300) 3754 || abs(dy - mPriv->prevDy) > 300)
3749 AP_DBG(("erratic1 behaviour\n")); 3755 AP_DBG(("erratic1 behaviour\n"));
3750#endif 3756#endif
3751 if (abs(dx) > VAL_THRESHOLD) { 3757 if (abs(dx) > VAL_THRESHOLD) {
3752 if (sign(dx) == sign(mPriv->prevDx)) { 3758 if (sign(dx) == sign(mPriv->prevDx)) {
3753 mPriv->accDx += dx; 3759 mPriv->accDx += dx;
3754 if (abs(mPriv->accDx) > mPriv->acc) { 3760 if (abs(mPriv->accDx) > mPriv->acc) {
3755 mPriv->acc = abs(mPriv->accDx); 3761 mPriv->acc = abs(mPriv->accDx);
3756 AP_DBG(("acc=%i\n",mPriv->acc)); 3762 AP_DBG(("acc=%i\n",mPriv->acc));
3757 } 3763 }
3758 else 3764 else {
3759 AP_DBG(("accDx=%i\n",mPriv->accDx)); 3765 AP_DBG(("accDx=%i\n",mPriv->accDx));
 3766 }
3760 } else { 3767 } else {
3761 mPriv->accDx = 0; 3768 mPriv->accDx = 0;
3762 } 3769 }
3763 } 3770 }
3764 3771
3765 if (abs(dy) > VAL_THRESHOLD) { 3772 if (abs(dy) > VAL_THRESHOLD) {
3766 if (sign(dy) == sign(mPriv->prevDy)) { 3773 if (sign(dy) == sign(mPriv->prevDy)) {
3767 mPriv->accDy += dy; 3774 mPriv->accDy += dy;
3768 if (abs(mPriv->accDy) > mPriv->acc) { 3775 if (abs(mPriv->accDy) > mPriv->acc) {
3769 mPriv->acc = abs(mPriv->accDy); 3776 mPriv->acc = abs(mPriv->accDy);
3770 AP_DBG(("acc: %i\n",mPriv->acc)); 3777 AP_DBG(("acc: %i\n",mPriv->acc));
3771 } else 3778 } else {
3772 AP_DBG(("accDy=%i\n",mPriv->accDy)); 3779 AP_DBG(("accDy=%i\n",mPriv->accDy));
 3780 }
3773 } else { 3781 } else {
3774 mPriv->accDy = 0; 3782 mPriv->accDy = 0;
3775 } 3783 }
3776 } 3784 }
3777 mPriv->prevDx = dx; 3785 mPriv->prevDx = dx;
3778 mPriv->prevDy = dy; 3786 mPriv->prevDy = dy;
3779 if (mPriv->acc > TOT_THRESHOLD) { 3787 if (mPriv->acc > TOT_THRESHOLD) {
3780 mPriv->goodCount = PROBE_UNCERTAINTY; 3788 mPriv->goodCount = PROBE_UNCERTAINTY;
3781 mPriv->prevDx = 0; 3789 mPriv->prevDx = 0;
3782 mPriv->prevDy = 0; 3790 mPriv->prevDy = 0;
3783 mPriv->accDx = 0; 3791 mPriv->accDx = 0;
3784 mPriv->accDy = 0; 3792 mPriv->accDy = 0;
3785 mPriv->acc = 0; 3793 mPriv->acc = 0;

cvs diff -r1.3 -r1.4 xsrc/external/mit/xf86-input-mouse/dist/src/pnp.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-input-mouse/dist/src/pnp.c 2013/06/05 07:11:16 1.3
+++ xsrc/external/mit/xf86-input-mouse/dist/src/pnp.c 2022/11/11 23:50:07 1.4
@@ -401,27 +401,27 @@ pnpparse(InputInfoPtr pInfo, pnpid_t *id @@ -401,27 +401,27 @@ pnpparse(InputInfoPtr pInfo, pnpid_t *id
401 sum += buf[len - 1]; 401 sum += buf[len - 1];
402 for (; i < len; ++i) 402 for (; i < len; ++i)
403 buf[i] += offset; 403 buf[i] += offset;
404 xf86MsgVerb(X_INFO, 2, "%s: PnP ID string: `%*.*s'\n", pInfo->name, 404 xf86MsgVerb(X_INFO, 2, "%s: PnP ID string: `%*.*s'\n", pInfo->name,
405 len, len, buf); 405 len, len, buf);
406 406
407 /* revision */ 407 /* revision */
408 buf[1] -= offset; 408 buf[1] -= offset;
409 buf[2] -= offset; 409 buf[2] -= offset;
410 id->revision = ((buf[1] & 0x3f) << 6) | (buf[2] & 0x3f); 410 id->revision = ((buf[1] & 0x3f) << 6) | (buf[2] & 0x3f);
411 xf86MsgVerb(X_INFO, 2, "%s: PnP rev %d.%02d\n", pInfo->name, 411 xf86MsgVerb(X_INFO, 2, "%s: PnP rev %d.%02d\n", pInfo->name,
412 id->revision / 100, id->revision % 100); 412 id->revision / 100, id->revision % 100);
413 413
414 /* EISA vender and product ID */ 414 /* EISA vendor and product ID */
415 id->eisaid = &buf[3]; 415 id->eisaid = &buf[3];
416 id->neisaid = 7; 416 id->neisaid = 7;
417 417
418 /* option strings */ 418 /* option strings */
419 i = 10; 419 i = 10;
420 if (buf[i] == '\\') { 420 if (buf[i] == '\\') {
421 /* device serial # */ 421 /* device serial # */
422 for (j = ++i; i < len; ++i) { 422 for (j = ++i; i < len; ++i) {
423 if (buf[i] == '\\') 423 if (buf[i] == '\\')
424 break; 424 break;
425 } 425 }
426 if (i >= len) 426 if (i >= len)
427 i -= 3; 427 i -= 3;
@@ -591,39 +591,39 @@ ps2SendPacket(InputInfoPtr pInfo, unsign @@ -591,39 +591,39 @@ ps2SendPacket(InputInfoPtr pInfo, unsign
591#endif 591#endif
592 592
593 for (i = 0; i < len; i++) { 593 for (i = 0; i < len; i++) {
594 for (j = 0; j < 10; j++) { 594 for (j = 0; j < 10; j++) {
595 xf86WriteSerial(pInfo->fd, bytes + i, 1); 595 xf86WriteSerial(pInfo->fd, bytes + i, 1);
596 usleep(10000); 596 usleep(10000);
597 if (!readMouse(pInfo,&c)) { 597 if (!readMouse(pInfo,&c)) {
598#ifdef DEBUG 598#ifdef DEBUG
599 xf86ErrorF("sending 0x%x to PS/2 unsuccessful\n",*(bytes + i)); 599 xf86ErrorF("sending 0x%x to PS/2 unsuccessful\n",*(bytes + i));
600#endif 600#endif
601 return FALSE; 601 return FALSE;
602 } 602 }
603#ifdef DEBUG 603#ifdef DEBUG
604 xf86ErrorF("Recieved: 0x%x\n",c); 604 xf86ErrorF("Received: 0x%x\n",c);
605#endif 605#endif
606 if (c == 0xFA) /* ACK */ 606 if (c == 0xFA) /* ACK */
607 break; 607 break;
608 608
609 if (c == 0xFE) /* resend */ 609 if (c == 0xFE) /* resend */
610 continue; 610 continue;
611 611
612 612
613 if (c == 0xFC) /* error */ 613 if (c == 0xFC) /* error */
614 return FALSE; 614 return FALSE;
615 615
616 /* Some mice accidently enter wrap mode during init */ 616 /* Some mice accidentally enter wrap mode during init */
617 if (c == *(bytes + i) /* wrap mode */ 617 if (c == *(bytes + i) /* wrap mode */
618 && (*(bytes + i) != 0xEC)) /* avoid recursion */ 618 && (*(bytes + i) != 0xEC)) /* avoid recursion */
619 ps2DisableWrapMode(pInfo); 619 ps2DisableWrapMode(pInfo);
620 620
621 return FALSE; 621 return FALSE;
622 } 622 }
623 if (j == 10) 623 if (j == 10)
624 return FALSE; 624 return FALSE;
625 } 625 }
626 626
627 return TRUE; 627 return TRUE;
628} 628}
629 629