summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-04-30 20:36:40 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-04-30 20:38:33 -0700
commit88e90dde7a5ffff67da9e091e59c09f2a0828582 (patch)
tree45cc7fbaf42dec81ec3a1cf801bb718e01fa6908
parent580e739de0b15df9b7982213d2e2d9b84413b157 (diff)
downloadxorg-driver-xf86-input-mouse-88e90dde7a5ffff67da9e091e59c09f2a0828582.tar.gz
Expand tabs to spaces
Existing code had a mix of places tab & space characters were used. Make them all spaces for consistency, since that's the new style chosen for xorg-server. "git diff -w" shows no changes - this is pure whitespace adjustment. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/bsd_mouse.c522
-rw-r--r--src/hurd_mouse.c108
-rw-r--r--src/lnx_mouse.c180
-rw-r--r--src/mouse.c4106
-rw-r--r--src/mouse.h252
-rw-r--r--src/mousePriv.h48
-rw-r--r--src/pnp.c504
-rw-r--r--src/sun_mouse.c568
8 files changed, 3144 insertions, 3144 deletions
diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index 2acd6f3..441066f 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -72,25 +72,25 @@ static const char *FindDevice(InputInfoPtr, const char *, int);
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
/* These are for FreeBSD and DragonFly */
-#define DEFAULT_MOUSE_DEV "/dev/mouse"
-#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse"
-#define DEFAULT_PS2_DEV "/dev/psm0"
+#define DEFAULT_MOUSE_DEV "/dev/mouse"
+#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse"
+#define DEFAULT_PS2_DEV "/dev/psm0"
static const char *mouseDevs[] = {
- DEFAULT_MOUSE_DEV,
- DEFAULT_SYSMOUSE_DEV,
- DEFAULT_PS2_DEV,
- NULL
+ DEFAULT_MOUSE_DEV,
+ DEFAULT_SYSMOUSE_DEV,
+ DEFAULT_PS2_DEV,
+ NULL
};
#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
/* Only wsmouse mices are autoconfigured for now on OpenBSD */
-#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse"
-#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0"
+#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse"
+#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0"
static const char *mouseDevs[] = {
- DEFAULT_WSMOUSE_DEV,
- DEFAULT_WSMOUSE0_DEV,
- NULL
+ DEFAULT_WSMOUSE_DEV,
+ DEFAULT_WSMOUSE0_DEV,
+ NULL
};
#endif
@@ -109,12 +109,12 @@ SupportedInterfaces(void)
/* Names of protocols that are handled internally here. */
static const char *internalNames[] = {
#if defined(WSCONS_SUPPORT)
- "WSMouse",
+ "WSMouse",
#endif
#if defined(USBMOUSE_SUPPORT)
- "usb",
+ "usb",
#endif
- NULL
+ NULL
};
/*
@@ -123,9 +123,9 @@ static const char *internalNames[] = {
*/
static const char *miscNames[] = {
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
- "SysMouse",
+ "SysMouse",
#endif
- NULL
+ NULL
};
static const char **
@@ -140,11 +140,11 @@ CheckProtocol(const char *protocol)
int i;
for (i = 0; internalNames[i]; i++)
- if (xf86NameCmp(protocol, internalNames[i]) == 0)
- return TRUE;
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
for (i = 0; miscNames[i]; i++)
- if (xf86NameCmp(protocol, miscNames[i]) == 0)
- return TRUE;
+ if (xf86NameCmp(protocol, miscNames[i]) == 0)
+ return TRUE;
return FALSE;
}
@@ -162,22 +162,22 @@ DefaultProtocol(void)
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE)
static struct {
- int dproto;
- const char *name;
+ int dproto;
+ const char *name;
} devproto[] = {
- { MOUSE_PROTO_MS, "Microsoft" },
- { MOUSE_PROTO_MSC, "MouseSystems" },
- { MOUSE_PROTO_LOGI, "Logitech" },
- { MOUSE_PROTO_MM, "MMSeries" },
- { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" },
- { MOUSE_PROTO_BUS, "BusMouse" },
- { MOUSE_PROTO_INPORT, "BusMouse" },
- { MOUSE_PROTO_PS2, "PS/2" },
- { MOUSE_PROTO_HITTAB, "MMHitTab" },
- { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" },
- { MOUSE_PROTO_INTELLI, "Intellimouse" },
- { MOUSE_PROTO_THINK, "ThinkingMouse" },
- { MOUSE_PROTO_SYSMOUSE, "SysMouse" }
+ { MOUSE_PROTO_MS, "Microsoft" },
+ { MOUSE_PROTO_MSC, "MouseSystems" },
+ { MOUSE_PROTO_LOGI, "Logitech" },
+ { MOUSE_PROTO_MM, "MMSeries" },
+ { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" },
+ { MOUSE_PROTO_BUS, "BusMouse" },
+ { MOUSE_PROTO_INPORT, "BusMouse" },
+ { MOUSE_PROTO_PS2, "PS/2" },
+ { MOUSE_PROTO_HITTAB, "MMHitTab" },
+ { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" },
+ { MOUSE_PROTO_INTELLI, "Intellimouse" },
+ { MOUSE_PROTO_THINK, "ThinkingMouse" },
+ { MOUSE_PROTO_SYSMOUSE, "SysMouse" }
};
static const char *
@@ -188,7 +188,7 @@ SetupAuto(InputInfoPtr pInfo, int *protoPara)
mousemode_t mode;
if (pInfo->fd == -1)
- return NULL;
+ return NULL;
/* set the driver operation level, if applicable */
i = 1;
@@ -199,21 +199,21 @@ SetupAuto(InputInfoPtr pInfo, int *protoPara)
hw.model = MOUSE_MODEL_GENERIC;
ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw);
xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n",
- pInfo->name, hw.iftype, hw.model);
+ pInfo->name, hw.iftype, hw.model);
if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) {
- for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) {
- if (mode.protocol == devproto[i].dproto) {
- /* override some parameters */
- if (protoPara) {
- protoPara[4] = mode.packetsize;
- protoPara[0] = mode.syncmask[0];
- protoPara[1] = mode.syncmask[1];
- }
- xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
- pInfo->name, devproto[i].name);
- return devproto[i].name;
- }
- }
+ for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) {
+ if (mode.protocol == devproto[i].dproto) {
+ /* override some parameters */
+ if (protoPara) {
+ protoPara[4] = mode.packetsize;
+ protoPara[0] = mode.syncmask[0];
+ protoPara[1] = mode.syncmask[1];
+ }
+ xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
+ pInfo->name, devproto[i].name);
+ return devproto[i].name;
+ }
+ }
}
return NULL;
}
@@ -231,15 +231,15 @@ SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
mode.accelfactor = -1;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
if (pMse->autoProbe ||
- (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
- /*
- * As the FreeBSD sysmouse driver defaults to protocol level 0
- * everytime it is opened we enforce protocol level 1 again at
- * this point.
- */
- mode.level = 1;
+ (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
+ /*
+ * As the FreeBSD sysmouse driver defaults to protocol level 0
+ * everytime it is opened we enforce protocol level 1 again at
+ * this point.
+ */
+ mode.level = 1;
} else
- mode.level = -1;
+ mode.level = -1;
#else
mode.level = -1;
#endif
@@ -262,13 +262,13 @@ MousedRunning(void)
unsigned int pid;
if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) {
- if (fscanf(f, "%u", &pid) == 1 && pid > 0) {
- if (kill(pid, 0) == 0) {
- fclose(f);
- return TRUE;
- }
- }
- fclose(f);
+ if (fscanf(f, "%u", &pid) == 1 && pid > 0) {
+ if (kill(pid, 0) == 0) {
+ fclose(f);
+ return TRUE;
+ }
+ }
+ fclose(f);
}
return FALSE;
}
@@ -283,56 +283,56 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
struct stat sb;
for (pdev = mouseDevs; *pdev; pdev++) {
- SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
- if (fd == -1) {
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
#ifdef DEBUG
- ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
+ ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
#endif
- } else {
- /*
- * /dev/mouse is held until checks for matches with other devices
- * are done. This is so that when it points to /dev/sysmouse,
- * the test for whether /dev/sysmouse is usable can be made.
- */
- if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
- if (fstat(fd, &devMouseStat) == 0)
- devMouse = TRUE;
- close(fd);
- continue;
- } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
- /* Check if /dev/mouse is the same as /dev/sysmouse. */
- if (devMouse && fstat(fd, &sb) == 0 &&
- devMouseStat.st_dev == sb.st_dev &&
- devMouseStat.st_ino == sb.st_ino) {
- /* If the same, use /dev/sysmouse. */
- devMouse = FALSE;
- }
- close(fd);
- if (MousedRunning())
- break;
- else {
+ } else {
+ /*
+ * /dev/mouse is held until checks for matches with other devices
+ * are done. This is so that when it points to /dev/sysmouse,
+ * the test for whether /dev/sysmouse is usable can be made.
+ */
+ if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
+ if (fstat(fd, &devMouseStat) == 0)
+ devMouse = TRUE;
+ close(fd);
+ continue;
+ } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
+ /* Check if /dev/mouse is the same as /dev/sysmouse. */
+ if (devMouse && fstat(fd, &sb) == 0 &&
+ devMouseStat.st_dev == sb.st_dev &&
+ devMouseStat.st_ino == sb.st_ino) {
+ /* If the same, use /dev/sysmouse. */
+ devMouse = FALSE;
+ }
+ close(fd);
+ if (MousedRunning())
+ break;
+ else {
#ifdef DEBUG
- ErrorF("moused isn't running\n");
+ ErrorF("moused isn't running\n");
#endif
- }
- } else {
- close(fd);
- break;
- }
- }
+ }
+ } else {
+ close(fd);
+ break;
+ }
+ }
}
if (*pdev)
- dev = *pdev;
+ dev = *pdev;
else if (devMouse)
- dev = DEFAULT_MOUSE_DEV;
+ dev = DEFAULT_MOUSE_DEV;
if (dev) {
- /* Set the Device option. */
- pInfo->options =
- xf86AddNewOption(pInfo->options, "Device", dev);
- xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
- pInfo->name, dev);
+ /* Set the Device option. */
+ pInfo->options =
+ xf86AddNewOption(pInfo->options, "Device", dev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, dev);
}
return *pdev;
@@ -347,7 +347,7 @@ SetupAuto(InputInfoPtr pInfo, int *protoPara)
{
xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
- pInfo->name, "wsmouse");
+ pInfo->name, "wsmouse");
return "wsmouse";
}
@@ -356,7 +356,7 @@ SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
{
xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n",
- pInfo->name, protocol, rate, res);
+ pInfo->name, protocol, rate, res);
}
static const char *
@@ -366,17 +366,17 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
const char **pdev;
for (pdev = mouseDevs; *pdev; pdev++) {
- SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
- if (fd != -1) {
- /* Set the Device option. */
- pInfo->options =
- xf86AddNewOption(pInfo->options,
- "Device", *pdev);
- xf86Msg(X_INFO, "%s: found Device \"%s\"\n",
- pInfo->name, *pdev);
- close(fd);
- break;
- }
+ SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd != -1) {
+ /* Set the Device option. */
+ pInfo->options =
+ xf86AddNewOption(pInfo->options,
+ "Device", *pdev);
+ xf86Msg(X_INFO, "%s: found Device \"%s\"\n",
+ pInfo->name, *pdev);
+ close(fd);
+ break;
+ }
}
return *pdev;
}
@@ -400,49 +400,49 @@ wsconsReadInput(InputInfoPtr pInfo)
pBuf = (unsigned char *)eventList;
n = 0;
while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) {
- pBuf[n++] = (unsigned char)c;
+ pBuf[n++] = (unsigned char)c;
}
if (n == 0)
- return;
+ return;
n /= sizeof(struct wscons_event);
while( n-- ) {
- int buttons = pMse->lastButtons;
- int dx = 0, dy = 0, dz = 0, dw = 0;
- switch (event->type) {
- case WSCONS_EVENT_MOUSE_UP:
+ int buttons = pMse->lastButtons;
+ int dx = 0, dy = 0, dz = 0, dw = 0;
+ switch (event->type) {
+ case WSCONS_EVENT_MOUSE_UP:
#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value))
- buttons &= ~BUTBIT;
- break;
- case WSCONS_EVENT_MOUSE_DOWN:
- buttons |= BUTBIT;
- break;
- case WSCONS_EVENT_MOUSE_DELTA_X:
- dx = event->value;
- break;
- case WSCONS_EVENT_MOUSE_DELTA_Y:
- dy = -event->value;
- break;
+ buttons &= ~BUTBIT;
+ break;
+ case WSCONS_EVENT_MOUSE_DOWN:
+ buttons |= BUTBIT;
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_X:
+ dx = event->value;
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_Y:
+ dy = -event->value;
+ break;
#ifdef WSCONS_EVENT_MOUSE_DELTA_Z
- case WSCONS_EVENT_MOUSE_DELTA_Z:
- dz = event->value;
- break;
+ case WSCONS_EVENT_MOUSE_DELTA_Z:
+ dz = event->value;
+ break;
#endif
#ifdef WSCONS_EVENT_MOUSE_DELTA_W
- case WSCONS_EVENT_MOUSE_DELTA_W:
- dw = event->value;
- break;
+ case WSCONS_EVENT_MOUSE_DELTA_W:
+ dw = event->value;
+ break;
#endif
- default:
- xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
- event->type);
- ++event;
- continue;
- }
-
- pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
- ++event;
+ default:
+ xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
+ event->type);
+ ++event;
+ continue;
+ }
+
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+ ++event;
}
return;
}
@@ -470,10 +470,10 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
typedef struct _UsbMseRec {
int packetSize;
int iid;
- hid_item_t loc_x; /* x locator item */
- hid_item_t loc_y; /* y locator item */
- hid_item_t loc_z; /* z (wheel) locator item */
- hid_item_t loc_w; /* z (wheel) locator item */
+ hid_item_t loc_x; /* x locator item */
+ hid_item_t loc_y; /* y locator item */
+ hid_item_t loc_z; /* z (wheel) locator item */
+ hid_item_t loc_w; /* z (wheel) locator item */
hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */
unsigned char *buffer;
} UsbMseRec, *UsbMsePtr;
@@ -494,70 +494,70 @@ usbMouseProc(DeviceIntPtr pPointer, int what)
switch (what) {
case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
- map[nbuttons + 1] = nbuttons + 1;
-
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- min(pMse->buttons, MSE_MAXBUTTONS),
- miPointerGetMotionEvents,
- pMse->Ctrl,
- miPointerGetMotionBufferSize());
-
- /* X valuator */
- xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
- xf86InitValuatorDefaults(pPointer, 0);
- /* Y valuator */
- xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
- xf86InitValuatorDefaults(pPointer, 1);
- xf86MotionHistoryAllocate(pInfo);
- break;
+ pPointer->public.on = FALSE;
+
+ for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
+ map[nbuttons + 1] = nbuttons + 1;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ min(pMse->buttons, MSE_MAXBUTTONS),
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ break;
case DEVICE_ON:
- pInfo->fd = xf86OpenSerial(pInfo->options);
- if (pInfo->fd == -1)
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
- pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize);
- if (!pMse->buffer) {
- free(pMse);
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- } else {
- xf86FlushInput(pInfo->fd);
- if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput,
- pInfo))
- AddEnabledDevice(pInfo->fd);
- }
- }
- pMse->lastButtons = 0;
- pMse->lastMappedButtons = 0;
- pMse->emulateState = 0;
- pPointer->public.on = TRUE;
- break;
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize);
+ if (!pMse->buffer) {
+ free(pMse);
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ } else {
+ xf86FlushInput(pInfo->fd);
+ if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput,
+ pInfo))
+ AddEnabledDevice(pInfo->fd);
+ }
+ }
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ break;
case DEVICE_OFF:
case DEVICE_CLOSE:
- if (pInfo->fd != -1) {
- RemoveEnabledDevice(pInfo->fd);
- if (pUsbMse->packetSize > 8 && pUsbMse->buffer) {
- free(pUsbMse->buffer);
- }
- if (pMse->buffer) {
- XisbFree(pMse->buffer);
- pMse->buffer = NULL;
- }
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- }
- pPointer->public.on = FALSE;
- usleep(300000);
- break;
+ if (pInfo->fd != -1) {
+ RemoveEnabledDevice(pInfo->fd);
+ if (pUsbMse->packetSize > 8 && pUsbMse->buffer) {
+ free(pUsbMse->buffer);
+ }
+ if (pMse->buffer) {
+ XisbFree(pMse->buffer);
+ pMse->buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ pPointer->public.on = FALSE;
+ usleep(300000);
+ break;
default:
- return BadValue;
+ return BadValue;
}
return Success;
}
@@ -579,19 +579,19 @@ usbReadInput(InputInfoPtr pInfo)
pBuf = pUsbMse->buffer;
n = 0;
while ((c = XisbRead(pMse->buffer)) >= 0 && n < pUsbMse->packetSize) {
- pBuf[n++] = (unsigned char)c;
+ pBuf[n++] = (unsigned char)c;
}
if (n == 0)
- return;
+ return;
if (n != pUsbMse->packetSize) {
- xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name,
- n);
+ xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name,
+ n);
}
/* discard packets with an id that don't match the mouse */
/* XXX this is probably not the right thing */
if (pUsbMse->iid != 0) {
- if (*pBuf++ != pUsbMse->iid)
- return;
+ if (*pBuf++ != pUsbMse->iid)
+ return;
}
dx = hid_get_data(pBuf, &pUsbMse->loc_x);
dy = hid_get_data(pBuf, &pUsbMse->loc_y);
@@ -600,8 +600,8 @@ usbReadInput(InputInfoPtr pInfo)
buttons = 0;
for (n = 0; n < pMse->buttons; n++) {
- if (hid_get_data(pBuf, &pUsbMse->loc_btn[n]))
- buttons |= (1 << UMS_BUT(n));
+ if (hid_get_data(pBuf, &pUsbMse->loc_btn[n]))
+ buttons |= (1 << UMS_BUT(n));
}
pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
return;
@@ -624,9 +624,9 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
pUsbMse = malloc(sizeof(UsbMseRec));
if (pUsbMse == NULL) {
- xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name);
- free(pMse);
- return FALSE;
+ xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name);
+ free(pMse);
+ return FALSE;
}
pMse->protocol = protocol;
@@ -639,77 +639,77 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
- if (xf86GetAllowMouseOpenFail())
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
- xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
- free(pUsbMse);
- free(pMse);
- return FALSE;
- }
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ free(pUsbMse);
+ free(pMse);
+ return FALSE;
+ }
}
/* Get USB informations */
reportDesc = hid_get_report_desc(pInfo->fd);
/* Get packet size & iid */
#ifdef USB_NEW_HID
if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) {
- xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n",
- pInfo->name, strerror(errno));
- return FALSE;
+ xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n",
+ pInfo->name, strerror(errno));
+ return FALSE;
}
pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
- pUsbMse->iid);
+ pUsbMse->iid);
#else
pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
- &pUsbMse->iid);
+ &pUsbMse->iid);
#endif
/* Allocate buffer */
if (pUsbMse->packetSize <= 8) {
- pUsbMse->buffer = pMse->protoBuf;
+ pUsbMse->buffer = pMse->protoBuf;
} else {
- pUsbMse->buffer = malloc(pUsbMse->packetSize);
+ pUsbMse->buffer = malloc(pUsbMse->packetSize);
}
if (pUsbMse->buffer == NULL) {
- xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name);
- free(pUsbMse);
- free(pMse);
- xf86CloseSerial(pInfo->fd);
- return FALSE;
+ xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name);
+ free(pUsbMse);
+ free(pMse);
+ xf86CloseSerial(pInfo->fd);
+ return FALSE;
}
#ifdef USB_NEW_HID
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
- hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) {
- xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
+ hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) {
+ xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
}
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
- hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) {
- xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
+ hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) {
+ xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
}
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
- hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) {
+ hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) {
}
#else
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
- hid_input, &pUsbMse->loc_x) < 0) {
- xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
+ hid_input, &pUsbMse->loc_x) < 0) {
+ xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
}
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
- hid_input, &pUsbMse->loc_y) < 0) {
- xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
+ hid_input, &pUsbMse->loc_y) < 0) {
+ xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
}
if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
- hid_input, &pUsbMse->loc_z) < 0) {
+ hid_input, &pUsbMse->loc_z) < 0) {
}
#endif
/* Probe for number of buttons */
for (i = 1; i <= MSE_MAXBUTTONS; i++) {
- if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i),
- hid_input, &pUsbMse->loc_btn[i-1]
+ if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i),
+ hid_input, &pUsbMse->loc_btn[i-1]
#ifdef USB_NEW_HID
- , pUsbMse->iid
+ , pUsbMse->iid
#endif
- ))
- break;
+ ))
+ break;
}
pMse->buttons = i-1;
@@ -739,12 +739,12 @@ bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
/* The protocol is guaranteed to be one of the internalNames[] */
#ifdef WSCONS_SUPPORT
if (xf86NameCmp(protocol, "WSMouse") == 0) {
- return wsconsPreInit(pInfo, protocol, flags);
+ return wsconsPreInit(pInfo, protocol, flags);
}
#endif
#ifdef USBMOUSE_SUPPORT
if (xf86NameCmp(protocol, "usb") == 0) {
- return usbPreInit(pInfo, protocol, flags);
+ return usbPreInit(pInfo, protocol, flags);
}
#endif
return TRUE;
@@ -757,7 +757,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
- return NULL;
+ return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->BuiltinNames = BuiltinNames;
p->DefaultProtocol = DefaultProtocol;
diff --git a/src/hurd_mouse.c b/src/hurd_mouse.c
index 846b6d8..16ae945 100644
--- a/src/hurd_mouse.c
+++ b/src/hurd_mouse.c
@@ -46,36 +46,36 @@
#include <mach.h>
#include <sys/ioctl.h>
-#define DEFAULT_MOUSE_DEV "/dev/mouse"
+#define DEFAULT_MOUSE_DEV "/dev/mouse"
-typedef unsigned short kev_type; /* kd event type */
+typedef unsigned short kev_type; /* kd event type */
typedef unsigned char Scancode;
struct mouse_motion {
- short mm_deltaX; /* units? */
+ short mm_deltaX; /* units? */
short mm_deltaY;
};
typedef struct {
- kev_type type; /* see below */
- struct timeval time; /* timestamp */
- union { /* value associated with event */
- boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
- Scancode sc; /* KEYBD_EVENT */
- struct mouse_motion mmotion; /* MOUSE_MOTION */
+ kev_type type; /* see below */
+ struct timeval time; /* timestamp */
+ union { /* value associated with event */
+ boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
+ Scancode sc; /* KEYBD_EVENT */
+ struct mouse_motion mmotion; /* MOUSE_MOTION */
} value;
} kd_event;
/*
* kd_event ID's.
*/
-#define MOUSE_LEFT 1 /* mouse left button up/down */
-#define MOUSE_MIDDLE 2
-#define MOUSE_RIGHT 3
-#define MOUSE_MOTION 4 /* mouse motion */
-#define KEYBD_EVENT 5 /* key up/down */
+#define MOUSE_LEFT 1 /* mouse left button up/down */
+#define MOUSE_MIDDLE 2
+#define MOUSE_RIGHT 3
+#define MOUSE_MOTION 4 /* mouse motion */
+#define KEYBD_EVENT 5 /* key up/down */
-#define NUMEVENTS 64
+#define NUMEVENTS 64
/*
* OsMouseReadInput --
@@ -97,36 +97,36 @@ OsMouseReadInput(InputInfoPtr pInfo)
pBuf = (unsigned char *)eventList;
n = remainder;
while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0)
- pBuf[n++] = (unsigned char)c;
+ pBuf[n++] = (unsigned char)c;
if (n == remainder)
- return;
+ return;
remainder = n % sizeof(kd_event);
n /= sizeof(kd_event);
while( n-- ) {
- int buttons = pMse->lastButtons;
- int dx = 0, dy = 0;
- switch (event->type) {
- case MOUSE_RIGHT:
- buttons = (buttons & 6) |(event->value.up ? 0 : 1);
- break;
- case MOUSE_MIDDLE:
- buttons = (buttons & 5) |(event->value.up ? 0 : 2);
- break;
- case MOUSE_LEFT:
- buttons = (buttons & 3) |(event->value.up ? 0 : 4) ;
- break;
- case MOUSE_MOTION:
- dx = event->value.mmotion.mm_deltaX;
- dy = - event->value.mmotion.mm_deltaY;
- break;
- default:
- ErrorF("Bad mouse event (%d)\n",event->type);
- continue;
- }
- pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
- ++event;
+ int buttons = pMse->lastButtons;
+ int dx = 0, dy = 0;
+ switch (event->type) {
+ case MOUSE_RIGHT:
+ buttons = (buttons & 6) |(event->value.up ? 0 : 1);
+ break;
+ case MOUSE_MIDDLE:
+ buttons = (buttons & 5) |(event->value.up ? 0 : 2);
+ break;
+ case MOUSE_LEFT:
+ buttons = (buttons & 3) |(event->value.up ? 0 : 4) ;
+ break;
+ case MOUSE_MOTION:
+ dx = event->value.mmotion.mm_deltaX;
+ dy = - event->value.mmotion.mm_deltaY;
+ break;
+ default:
+ ErrorF("Bad mouse event (%d)\n",event->type);
+ continue;
+ }
+ pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
+ ++event;
}
memcpy(eventList, event, remainder);
return;
@@ -158,13 +158,13 @@ OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
- if (xf86GetAllowMouseOpenFail())
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
- xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
- free(pMse);
- return FALSE;
- }
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ free(pMse);
+ return FALSE;
+ }
}
xf86CloseSerial(pInfo->fd);
pInfo->fd = -1;
@@ -190,13 +190,13 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
SYSCALL (fd = open(path, O_RDWR | O_NONBLOCK | O_EXCL));
if (fd == -1)
- return NULL;
+ return NULL;
close(fd);
pInfo->options =
- xf86AddNewOption(pInfo->options, "Device", path);
+ xf86AddNewOption(pInfo->options, "Device", path);
xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", pInfo->name,
- path);
+ path);
return path;
}
@@ -209,8 +209,8 @@ SupportedInterfaces(void)
}
static const char *internalNames[] = {
- "OSMouse",
- NULL
+ "OSMouse",
+ NULL
};
static const char **
@@ -225,8 +225,8 @@ CheckProtocol(const char *protocol)
int i;
for (i = 0; internalNames[i]; i++)
- if (xf86NameCmp(protocol, internalNames[i]) == 0)
- return TRUE;
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
return FALSE;
}
@@ -243,7 +243,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
- return NULL;
+ return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->BuiltinNames = BuiltinNames;
p->FindDevice = FindDevice;
diff --git a/src/lnx_mouse.c b/src/lnx_mouse.c
index 32b83b7..a55b5f9 100644
--- a/src/lnx_mouse.c
+++ b/src/lnx_mouse.c
@@ -29,36 +29,36 @@ DefaultProtocol(void)
return "Auto";
}
-#define DEFAULT_MOUSE_DEV "/dev/input/mice"
-#define DEFAULT_PS2_DEV "/dev/psaux"
-#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata"
-#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata"
+#define DEFAULT_MOUSE_DEV "/dev/input/mice"
+#define DEFAULT_PS2_DEV "/dev/psaux"
+#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata"
+#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata"
static const char *mouseDevs[] = {
- DEFAULT_MOUSE_DEV,
- DEFAULT_PS2_DEV,
- DEFAULT_GPM_DATA_DEV,
- NULL
+ DEFAULT_MOUSE_DEV,
+ DEFAULT_PS2_DEV,
+ DEFAULT_GPM_DATA_DEV,
+ NULL
};
typedef enum {
- MOUSE_PROTO_UNKNOWN = 0,
- MOUSE_PROTO_SERIAL,
- MOUSE_PROTO_PS2,
- MOUSE_PROTO_MSC,
- MOUSE_PROTO_GPM,
- MOUSE_PROTO_EXPPS2,
+ MOUSE_PROTO_UNKNOWN = 0,
+ MOUSE_PROTO_SERIAL,
+ MOUSE_PROTO_PS2,
+ MOUSE_PROTO_MSC,
+ MOUSE_PROTO_GPM,
+ MOUSE_PROTO_EXPPS2,
} protocolTypes;
static struct {
- protocolTypes proto;
- const char *name;
+ protocolTypes proto;
+ const char *name;
} devproto[] = {
- { MOUSE_PROTO_UNKNOWN, NULL },
- { MOUSE_PROTO_PS2, "PS/2" },
- { MOUSE_PROTO_MSC, "MouseSystems" },
- { MOUSE_PROTO_GPM, "GPM" },
- { MOUSE_PROTO_EXPPS2, "ExplorerPS/2" },
+ { MOUSE_PROTO_UNKNOWN, NULL },
+ { MOUSE_PROTO_PS2, "PS/2" },
+ { MOUSE_PROTO_MSC, "MouseSystems" },
+ { MOUSE_PROTO_GPM, "GPM" },
+ { MOUSE_PROTO_EXPPS2, "ExplorerPS/2" },
};
static const char *
@@ -68,22 +68,22 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
const char **pdev;
for (pdev = mouseDevs; *pdev; pdev++) {
- SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL));
- if (fd == -1) {
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL));
+ if (fd == -1) {
#ifdef DEBUG
- ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
+ ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
#endif
- } else
- break;
+ } else
+ break;
}
if (*pdev) {
- close(fd);
- /* Set the Device option. */
- pInfo->options =
- xf86AddNewOption(pInfo->options, "Device", *pdev);
- xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
- pInfo->name, *pdev);
+ close(fd);
+ /* Set the Device option. */
+ pInfo->options =
+ xf86AddNewOption(pInfo->options, "Device", *pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, *pdev);
}
return *pdev;
@@ -102,92 +102,92 @@ lnxMouseMagic(InputInfoPtr pInfo)
dev = xf86SetStrOption(pInfo->options, "Device", NULL);
if (!dev) {
#ifdef DEBUG
- ErrorF("xf86SetStrOption failed to return the device name\n");
+ ErrorF("xf86SetStrOption failed to return the device name\n");
#endif
- return NULL;
+ return NULL;
}
/* Look at the device name to guess the protocol. */
realdev = NULL;
if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) {
- if (lstat(dev, &sbuf) != 0) {
+ if (lstat(dev, &sbuf) != 0) {
#ifdef DEBUG
- ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno));
+ ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno));
#endif
- return NULL;
- }
- if (S_ISLNK(sbuf.st_mode)) {
- realdev = xnfalloc(PATH_MAX + 1);
- i = readlink(dev, realdev, PATH_MAX);
- if (i <= 0) {
+ return NULL;
+ }
+ if (S_ISLNK(sbuf.st_mode)) {
+ realdev = xnfalloc(PATH_MAX + 1);
+ i = readlink(dev, realdev, PATH_MAX);
+ if (i <= 0) {
#ifdef DEBUG
- ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
+ ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
#endif
- free(realdev);
- return NULL;
- }
- realdev[i] = '\0';
- }
+ free(realdev);
+ return NULL;
+ }
+ realdev[i] = '\0';
+ }
}
if (!realdev)
- realdev = xnfstrdup(dev);
+ realdev = xnfstrdup(dev);
else {
- /* If realdev doesn't contain a '/' then prepend "/dev/" */
- if (!strchr(realdev, '/')) {
- char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
- sprintf(tmp, "/dev/%s", realdev);
- free(realdev);
- realdev = tmp;
- }
+ /* If realdev doesn't contain a '/' then prepend "/dev/" */
+ if (!strchr(realdev, '/')) {
+ char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
+ sprintf(tmp, "/dev/%s", realdev);
+ free(realdev);
+ realdev = tmp;
+ }
}
if (strcmp(realdev, DEFAULT_MOUSE_DEV) == 0)
- proto = MOUSE_PROTO_EXPPS2;
+ proto = MOUSE_PROTO_EXPPS2;
else if (strcmp(realdev, DEFAULT_PS2_DEV) == 0)
- proto = MOUSE_PROTO_EXPPS2;
+ proto = MOUSE_PROTO_EXPPS2;
else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0)
- proto = MOUSE_PROTO_MSC;
+ proto = MOUSE_PROTO_MSC;
else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0)
- proto = MOUSE_PROTO_GPM;
+ proto = MOUSE_PROTO_GPM;
free(realdev);
/*
* If the protocol can't be guessed from the device name,
* try to characterise it.
*/
if (proto == MOUSE_PROTO_UNKNOWN) {
- SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL));
- if (isatty(fd)) {
- /* Serial PnP has already failed, so give up. */
- } else {
- if (fstat(fd, &sbuf) != 0) {
+ SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL));
+ if (isatty(fd)) {
+ /* Serial PnP has already failed, so give up. */
+ } else {
+ if (fstat(fd, &sbuf) != 0) {
#ifdef DEBUG
- ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno));
+ ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno));
#endif
- close(fd);
- return NULL;
- }
- if (S_ISFIFO(sbuf.st_mode)) {
- /* Assume GPM data in MSC format. */
- proto = MOUSE_PROTO_MSC;
- } else {
- /* Default to PS/2 */
- proto = MOUSE_PROTO_PS2;
- }
- }
- close(fd);
+ close(fd);
+ return NULL;
+ }
+ if (S_ISFIFO(sbuf.st_mode)) {
+ /* Assume GPM data in MSC format. */
+ proto = MOUSE_PROTO_MSC;
+ } else {
+ /* Default to PS/2 */
+ proto = MOUSE_PROTO_PS2;
+ }
+ }
+ close(fd);
}
if (proto == MOUSE_PROTO_UNKNOWN) {
- xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n",
- pInfo->name);
- return NULL;
+ xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n",
+ pInfo->name);
+ return NULL;
} else {
- for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) {
- if (devproto[i].proto == proto) {
- xf86Msg(X_INFO,
- "%s: Setting mouse protocol to \"%s\"\n",
- pInfo->name, devproto[i].name);
- return devproto[i].name;
- }
- }
+ for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) {
+ if (devproto[i].proto == proto) {
+ xf86Msg(X_INFO,
+ "%s: Setting mouse protocol to \"%s\"\n",
+ pInfo->name, devproto[i].name);
+ return devproto[i].name;
+ }
+ }
}
return NULL;
}
@@ -211,7 +211,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
- return NULL;
+ return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->DefaultProtocol = DefaultProtocol;
p->FindDevice = FindDevice;
diff --git a/src/mouse.c b/src/mouse.c
index 7cdd8a2..7d1ee1b 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -125,10 +125,10 @@ static int MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
static int MouseProc(DeviceIntPtr device, int what);
static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
static void MousePostEvent(InputInfoPtr pInfo, int buttons,
- int dx, int dy, int dz, int dw);
+ int dx, int dy, int dz, int dw);
static void MouseReadInput(InputInfoPtr pInfo);
static void MouseBlockHandler(pointer data, struct timeval **waitTime,
- pointer LastSelectMask);
+ pointer LastSelectMask);
static void MouseWakeupHandler(pointer data, int i, pointer LastSelectMask);
static void FlushButtons(MouseDevPtr pMse);
@@ -138,7 +138,7 @@ static Bool initMouseHW(InputInfoPtr pInfo);
static Bool mouseReset(InputInfoPtr pInfo, unsigned char val);
static void ps2WakeupHandler(pointer data, int i, pointer LastSelectMask);
static void ps2BlockHandler(pointer data, struct timeval **waitTime,
- pointer LastSelectMask);
+ pointer LastSelectMask);
#endif
static void Emulate3ButtonsSetEnabled(InputInfoPtr pInfo, Bool enable);
@@ -152,12 +152,12 @@ static Bool autoGood(MouseDevPtr pMse);
#undef MOUSE
_X_EXPORT InputDriverRec MOUSE = {
- 1,
- "mouse",
- NULL,
- MousePreInit,
- NULL,
- NULL,
+ 1,
+ "mouse",
+ NULL,
+ MousePreInit,
+ NULL,
+ NULL,
};
#define RETRY_COUNT 4
@@ -171,101 +171,101 @@ static Atom prop_mbtimeout = 0; /* Middle button timeout property */
* ALPS GlidePoint, Thinking Mouse.
*/
static const char *msDefaults[] = {
- "BaudRate", "1200",
- "DataBits", "7",
- "StopBits", "1",
- "Parity", "None",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "1200",
+ "DataBits", "7",
+ "StopBits", "1",
+ "Parity", "None",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
/* MouseSystems */
static const char *mlDefaults[] = {
- "BaudRate", "1200",
- "DataBits", "8",
- "StopBits", "2",
- "Parity", "None",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "1200",
+ "DataBits", "8",
+ "StopBits", "2",
+ "Parity", "None",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
/* MMSeries */
static const char *mmDefaults[] = {
- "BaudRate", "1200",
- "DataBits", "8",
- "StopBits", "1",
- "Parity", "Odd",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "1200",
+ "DataBits", "8",
+ "StopBits", "1",
+ "Parity", "Odd",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
/* Hitachi Tablet */
static const char *mmhitDefaults[] = {
- "BaudRate", "1200",
- "DataBits", "8",
- "StopBits", "1",
- "Parity", "None",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "1200",
+ "DataBits", "8",
+ "StopBits", "1",
+ "Parity", "None",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
/* AceCad Tablet */
static const char *acecadDefaults[] = {
- "BaudRate", "9600",
- "DataBits", "8",
- "StopBits", "1",
- "Parity", "Odd",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "9600",
+ "DataBits", "8",
+ "StopBits", "1",
+ "Parity", "Odd",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
static MouseProtocolRec mouseProtocols[] = {
/* Serial protocols */
- { "Microsoft", MSE_SERIAL, msDefaults, PROT_MS },
- { "MouseSystems", MSE_SERIAL, mlDefaults, PROT_MSC },
- { "MMSeries", MSE_SERIAL, mmDefaults, PROT_MM },
- { "Logitech", MSE_SERIAL, mlDefaults, PROT_LOGI },
- { "MouseMan", MSE_SERIAL, msDefaults, PROT_LOGIMAN },
- { "MMHitTab", MSE_SERIAL, mmhitDefaults, PROT_MMHIT },
- { "GlidePoint", MSE_SERIAL, msDefaults, PROT_GLIDE },
- { "IntelliMouse", MSE_SERIAL, msDefaults, PROT_IMSERIAL },
- { "ThinkingMouse", MSE_SERIAL, msDefaults, PROT_THINKING },
- { "AceCad", MSE_SERIAL, acecadDefaults, PROT_ACECAD },
- { "ValuMouseScroll", MSE_SERIAL, msDefaults, PROT_VALUMOUSESCROLL },
+ { "Microsoft", MSE_SERIAL, msDefaults, PROT_MS },
+ { "MouseSystems", MSE_SERIAL, mlDefaults, PROT_MSC },
+ { "MMSeries", MSE_SERIAL, mmDefaults, PROT_MM },
+ { "Logitech", MSE_SERIAL, mlDefaults, PROT_LOGI },
+ { "MouseMan", MSE_SERIAL, msDefaults, PROT_LOGIMAN },
+ { "MMHitTab", MSE_SERIAL, mmhitDefaults, PROT_MMHIT },
+ { "GlidePoint", MSE_SERIAL, msDefaults, PROT_GLIDE },
+ { "IntelliMouse", MSE_SERIAL, msDefaults, PROT_IMSERIAL },
+ { "ThinkingMouse", MSE_SERIAL, msDefaults, PROT_THINKING },
+ { "AceCad", MSE_SERIAL, acecadDefaults, PROT_ACECAD },
+ { "ValuMouseScroll", MSE_SERIAL, msDefaults, PROT_VALUMOUSESCROLL },
/* Standard PS/2 */
- { "PS/2", MSE_PS2, NULL, PROT_PS2 },
- { "GenericPS/2", MSE_PS2, NULL, PROT_GENPS2 },
+ { "PS/2", MSE_PS2, NULL, PROT_PS2 },
+ { "GenericPS/2", MSE_PS2, NULL, PROT_GENPS2 },
/* Extended PS/2 */
- { "ImPS/2", MSE_XPS2, NULL, PROT_IMPS2 },
- { "ExplorerPS/2", MSE_XPS2, NULL, PROT_EXPPS2 },
- { "ThinkingMousePS/2", MSE_XPS2, NULL, PROT_THINKPS2 },
- { "MouseManPlusPS/2", MSE_XPS2, NULL, PROT_MMPS2 },
- { "GlidePointPS/2", MSE_XPS2, NULL, PROT_GLIDEPS2 },
- { "NetMousePS/2", MSE_XPS2, NULL, PROT_NETPS2 },
- { "NetScrollPS/2", MSE_XPS2, NULL, PROT_NETSCPS2 },
+ { "ImPS/2", MSE_XPS2, NULL, PROT_IMPS2 },
+ { "ExplorerPS/2", MSE_XPS2, NULL, PROT_EXPPS2 },
+ { "ThinkingMousePS/2", MSE_XPS2, NULL, PROT_THINKPS2 },
+ { "MouseManPlusPS/2", MSE_XPS2, NULL, PROT_MMPS2 },
+ { "GlidePointPS/2", MSE_XPS2, NULL, PROT_GLIDEPS2 },
+ { "NetMousePS/2", MSE_XPS2, NULL, PROT_NETPS2 },
+ { "NetScrollPS/2", MSE_XPS2, NULL, PROT_NETSCPS2 },
/* Bus Mouse */
- { "BusMouse", MSE_BUS, NULL, PROT_BM },
+ { "BusMouse", MSE_BUS, NULL, PROT_BM },
/* Auto-detect (PnP) */
- { "Auto", MSE_AUTO, NULL, PROT_AUTO },
+ { "Auto", MSE_AUTO, NULL, PROT_AUTO },
/* Misc (usually OS-specific) */
- { "SysMouse", MSE_MISC, mlDefaults, PROT_SYSMOUSE },
- { "WSMouse", MSE_MISC, NULL, PROT_WSMOUSE },
- { "VUID", MSE_MISC, NULL, PROT_VUID },
+ { "SysMouse", MSE_MISC, mlDefaults, PROT_SYSMOUSE },
+ { "WSMouse", MSE_MISC, NULL, PROT_WSMOUSE },
+ { "VUID", MSE_MISC, NULL, PROT_VUID },
/* end of list */
- { NULL, MSE_NONE, NULL, PROT_UNKNOWN }
+ { NULL, MSE_NONE, NULL, PROT_UNKNOWN }
};
/* Process options common to all mouse types. */
@@ -282,291 +282,291 @@ MouseCommonOptions(InputInfoPtr pInfo)
pMse->buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
if (!pMse->buttons) {
- pMse->buttons = MSE_DFLTBUTTONS;
- buttons_from = X_DEFAULT;
+ pMse->buttons = MSE_DFLTBUTTONS;
+ buttons_from = X_DEFAULT;
}
origButtons = pMse->buttons;
pMse->emulate3Buttons = xf86SetBoolOption(pInfo->options,
- "Emulate3Buttons", FALSE);
+ "Emulate3Buttons", FALSE);
if (!xf86FindOptionValue(pInfo->options,"Emulate3Buttons")) {
- pMse->emulate3ButtonsSoft = TRUE;
- pMse->emulate3Buttons = TRUE;
+ pMse->emulate3ButtonsSoft = TRUE;
+ pMse->emulate3Buttons = TRUE;
}
pMse->emulate3Timeout = xf86SetIntOption(pInfo->options,
- "Emulate3Timeout", 50);
+ "Emulate3Timeout", 50);
if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) {
- MessageType from = X_CONFIG;
- if (pMse->emulate3ButtonsSoft)
- from = X_DEFAULT;
- xf86Msg(from, "%s: Emulate3Buttons, Emulate3Timeout: %d\n",
- pInfo->name, pMse->emulate3Timeout);
+ MessageType from = X_CONFIG;
+ if (pMse->emulate3ButtonsSoft)
+ from = X_DEFAULT;
+ xf86Msg(from, "%s: Emulate3Buttons, Emulate3Timeout: %d\n",
+ pInfo->name, pMse->emulate3Timeout);
}
pMse->chordMiddle = xf86SetBoolOption(pInfo->options, "ChordMiddle", FALSE);
pMse->flipXY = xf86SetBoolOption(pInfo->options, "FlipXY", FALSE);
if (xf86SetBoolOption(pInfo->options, "InvX", FALSE)) {
- pMse->invX = -1;
+ pMse->invX = -1;
} else
- pMse->invX = 1;
+ pMse->invX = 1;
if (xf86SetBoolOption(pInfo->options, "InvY", FALSE)) {
- pMse->invY = -1;
+ pMse->invY = -1;
} else
- pMse->invY = 1;
+ pMse->invY = 1;
pMse->angleOffset = xf86SetIntOption(pInfo->options, "AngleOffset", 0);
if (pMse->pDragLock)
- free(pMse->pDragLock);
+ free(pMse->pDragLock);
pMse->pDragLock = NULL;
s = xf86SetStrOption(pInfo->options, "DragLockButtons", NULL);
if (s) {
- int lock; /* lock button */
- int target; /* target button */
- int lockM,targetM; /* bitmasks for drag lock, target */
- int i, j; /* indexes */
- char *s1; /* parse input string */
- DragLockPtr pLock;
-
- pLock = pMse->pDragLock = calloc(1, sizeof(DragLockRec));
- /* init code */
-
- /* initial string to be taken apart */
- s1 = s;
-
- /* keep getting numbers which are buttons */
- while ((s1 != NULL) && (lock = strtol(s1, &s1, 10)) != 0) {
-
- /* check sanity for a button */
- if ((lock < 0) || (lock > MSE_MAXBUTTONS)) {
- xf86Msg(X_WARNING, "DragLock: Invalid button number = %d\n",
- lock);
- break;
- };
- /* turn into a button mask */
- lockM = 1 << (lock - 1);
-
- /* try to get drag lock button */
- if ((s1 == NULL) || ((target=strtol(s1, &s1, 10)) == 0)) {
- /*if no target, must be a master drag lock button */
- /* save master drag lock mask */
- pLock->masterLockM = lockM;
- xf86Msg(X_CONFIG,
- "DragLock button %d is master drag lock",
- lock);
- } else {
- /* have target button number*/
- /* check target button number for sanity */
- if ((target < 0) || (target > MSE_MAXBUTTONS)) {
- xf86Msg(X_WARNING,
- "DragLock: Invalid button number for target=%d\n",
- target);
- break;
- }
-
- /* target button mask */
- targetM = 1 << (target - 1);
-
- xf86Msg(X_CONFIG,
- "DragLock: button %d is drag lock for button %d\n",
- lock,target);
- lock--;
-
- /* initialize table that maps drag lock mask to target mask */
- pLock->nib_table[lock / NIB_BITS][1 << (lock % NIB_BITS)] =
- targetM;
-
- /* add new drag lock to mask of drag locks */
- pLock->lockButtonsM |= lockM;
- }
-
- }
-
- /*
- * fill out rest of map that maps sets of drag lock buttons
- * to sets of target buttons, in the form of masks
- */
-
- /* for each nibble */
- for (i = 0; i < NIB_COUNT; i++) {
- /* for each possible set of bits for that nibble */
- for (j = 0; j < NIB_SIZE; j++) {
- int ff, fM, otherbits;
-
- /* get first bit set in j*/
- ff = ffs(j) - 1;
- /* if 0 bits set nothing to do */
- if (ff >= 0) {
- /* form mask for fist bit set */
- fM = 1 << ff;
- /* mask off first bit set to get remaining bits set*/
- otherbits = j & ~fM;
- /*
- * if otherbits =0 then only 1 bit set
- * so j=fM
- * nib_table[i][fM] already calculated if fM has
- * only 1 bit set.
- * nib_table[i][j] has already been filled in
- * by previous loop. otherwise
- * otherbits < j so nibtable[i][otherbits]
- * has already been calculated.
- */
- if (otherbits)
- pLock->nib_table[i][j] =
- pLock->nib_table[i][fM] |
- pLock->nib_table[i][otherbits];
-
- }
- }
- }
- free(s);
+ int lock; /* lock button */
+ int target; /* target button */
+ int lockM,targetM; /* bitmasks for drag lock, target */
+ int i, j; /* indexes */
+ char *s1; /* parse input string */
+ DragLockPtr pLock;
+
+ pLock = pMse->pDragLock = calloc(1, sizeof(DragLockRec));
+ /* init code */
+
+ /* initial string to be taken apart */
+ s1 = s;
+
+ /* keep getting numbers which are buttons */
+ while ((s1 != NULL) && (lock = strtol(s1, &s1, 10)) != 0) {
+
+ /* check sanity for a button */
+ if ((lock < 0) || (lock > MSE_MAXBUTTONS)) {
+ xf86Msg(X_WARNING, "DragLock: Invalid button number = %d\n",
+ lock);
+ break;
+ };
+ /* turn into a button mask */
+ lockM = 1 << (lock - 1);
+
+ /* try to get drag lock button */
+ if ((s1 == NULL) || ((target=strtol(s1, &s1, 10)) == 0)) {
+ /*if no target, must be a master drag lock button */
+ /* save master drag lock mask */
+ pLock->masterLockM = lockM;
+ xf86Msg(X_CONFIG,
+ "DragLock button %d is master drag lock",
+ lock);
+ } else {
+ /* have target button number*/
+ /* check target button number for sanity */
+ if ((target < 0) || (target > MSE_MAXBUTTONS)) {
+ xf86Msg(X_WARNING,
+ "DragLock: Invalid button number for target=%d\n",
+ target);
+ break;
+ }
+
+ /* target button mask */
+ targetM = 1 << (target - 1);
+
+ xf86Msg(X_CONFIG,
+ "DragLock: button %d is drag lock for button %d\n",
+ lock,target);
+ lock--;
+
+ /* initialize table that maps drag lock mask to target mask */
+ pLock->nib_table[lock / NIB_BITS][1 << (lock % NIB_BITS)] =
+ targetM;
+
+ /* add new drag lock to mask of drag locks */
+ pLock->lockButtonsM |= lockM;
+ }
+
+ }
+
+ /*
+ * fill out rest of map that maps sets of drag lock buttons
+ * to sets of target buttons, in the form of masks
+ */
+
+ /* for each nibble */
+ for (i = 0; i < NIB_COUNT; i++) {
+ /* for each possible set of bits for that nibble */
+ for (j = 0; j < NIB_SIZE; j++) {
+ int ff, fM, otherbits;
+
+ /* get first bit set in j*/
+ ff = ffs(j) - 1;
+ /* if 0 bits set nothing to do */
+ if (ff >= 0) {
+ /* form mask for fist bit set */
+ fM = 1 << ff;
+ /* mask off first bit set to get remaining bits set*/
+ otherbits = j & ~fM;
+ /*
+ * if otherbits =0 then only 1 bit set
+ * so j=fM
+ * nib_table[i][fM] already calculated if fM has
+ * only 1 bit set.
+ * nib_table[i][j] has already been filled in
+ * by previous loop. otherwise
+ * otherbits < j so nibtable[i][otherbits]
+ * has already been calculated.
+ */
+ if (otherbits)
+ pLock->nib_table[i][j] =
+ pLock->nib_table[i][fM] |
+ pLock->nib_table[i][otherbits];
+
+ }
+ }
+ }
+ free(s);
}
s = xf86SetStrOption(pInfo->options, "ZAxisMapping", "4 5");
if (s) {
- int b1 = 0, b2 = 0, b3 = 0, b4 = 0;
- char *msg = NULL;
-
- pMse->negativeZ = pMse->positiveZ = MSE_NOAXISMAP;
- pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
- if (!xf86NameCmp(s, "x")) {
- pMse->negativeZ = pMse->positiveZ = MSE_MAPTOX;
- msg = xstrdup("X axis");
- } else if (!xf86NameCmp(s, "y")) {
- pMse->negativeZ = pMse->positiveZ = MSE_MAPTOY;
- msg = xstrdup("Y axis");
- } else if (sscanf(s, "%d %d %d %d", &b1, &b2, &b3, &b4) >= 2 &&
- b1 > 0 && b1 <= MSE_MAXBUTTONS &&
- b2 > 0 && b2 <= MSE_MAXBUTTONS) {
- msg = xstrdup("buttons XX and YY");
- if (msg)
- sprintf(msg, "buttons %d and %d", b1, b2);
- pMse->negativeZ = 1 << (b1-1);
- pMse->positiveZ = 1 << (b2-1);
- if (b3 > 0 && b3 <= MSE_MAXBUTTONS &&
- b4 > 0 && b4 <= MSE_MAXBUTTONS) {
- if (msg)
- free(msg);
- msg = xstrdup("buttons XX, YY, ZZ and WW");
- if (msg)
- sprintf(msg, "buttons %d, %d, %d and %d", b1, b2, b3, b4);
- pMse->negativeW = 1 << (b3-1);
- pMse->positiveW = 1 << (b4-1);
- }
- if (b1 > pMse->buttons) pMse->buttons = b1;
- if (b2 > pMse->buttons) pMse->buttons = b2;
- if (b3 > pMse->buttons) pMse->buttons = b3;
- if (b4 > pMse->buttons) pMse->buttons = b4;
- }
- if (msg) {
- xf86Msg(X_CONFIG, "%s: ZAxisMapping: %s\n", pInfo->name, msg);
- free(msg);
- } else {
- xf86Msg(X_WARNING, "%s: Invalid ZAxisMapping value: \"%s\"\n",
- pInfo->name, s);
- }
- free(s);
+ int b1 = 0, b2 = 0, b3 = 0, b4 = 0;
+ char *msg = NULL;
+
+ pMse->negativeZ = pMse->positiveZ = MSE_NOAXISMAP;
+ pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
+ if (!xf86NameCmp(s, "x")) {
+ pMse->negativeZ = pMse->positiveZ = MSE_MAPTOX;
+ msg = xstrdup("X axis");
+ } else if (!xf86NameCmp(s, "y")) {
+ pMse->negativeZ = pMse->positiveZ = MSE_MAPTOY;
+ msg = xstrdup("Y axis");
+ } else if (sscanf(s, "%d %d %d %d", &b1, &b2, &b3, &b4) >= 2 &&
+ b1 > 0 && b1 <= MSE_MAXBUTTONS &&
+ b2 > 0 && b2 <= MSE_MAXBUTTONS) {
+ msg = xstrdup("buttons XX and YY");
+ if (msg)
+ sprintf(msg, "buttons %d and %d", b1, b2);
+ pMse->negativeZ = 1 << (b1-1);
+ pMse->positiveZ = 1 << (b2-1);
+ if (b3 > 0 && b3 <= MSE_MAXBUTTONS &&
+ b4 > 0 && b4 <= MSE_MAXBUTTONS) {
+ if (msg)
+ free(msg);
+ msg = xstrdup("buttons XX, YY, ZZ and WW");
+ if (msg)
+ sprintf(msg, "buttons %d, %d, %d and %d", b1, b2, b3, b4);
+ pMse->negativeW = 1 << (b3-1);
+ pMse->positiveW = 1 << (b4-1);
+ }
+ if (b1 > pMse->buttons) pMse->buttons = b1;
+ if (b2 > pMse->buttons) pMse->buttons = b2;
+ if (b3 > pMse->buttons) pMse->buttons = b3;
+ if (b4 > pMse->buttons) pMse->buttons = b4;
+ }
+ if (msg) {
+ xf86Msg(X_CONFIG, "%s: ZAxisMapping: %s\n", pInfo->name, msg);
+ free(msg);
+ } else {
+ xf86Msg(X_WARNING, "%s: Invalid ZAxisMapping value: \"%s\"\n",
+ pInfo->name, s);
+ }
+ free(s);
}
if (xf86SetBoolOption(pInfo->options, "EmulateWheel", FALSE)) {
- Bool yFromConfig = FALSE;
- int wheelButton;
-
- pMse->emulateWheel = TRUE;
- wheelButton = xf86SetIntOption(pInfo->options,
- "EmulateWheelButton", 4);
- if (wheelButton < 0 || wheelButton > MSE_MAXBUTTONS) {
- xf86Msg(X_WARNING, "%s: Invalid EmulateWheelButton value: %d\n",
- pInfo->name, wheelButton);
- wheelButton = 4;
- }
- pMse->wheelButton = wheelButton;
-
- pMse->wheelInertia = xf86SetIntOption(pInfo->options,
- "EmulateWheelInertia", 10);
- if (pMse->wheelInertia <= 0) {
- xf86Msg(X_WARNING, "%s: Invalid EmulateWheelInertia value: %d\n",
- pInfo->name, pMse->wheelInertia);
- pMse->wheelInertia = 10;
- }
- pMse->wheelButtonTimeout = xf86SetIntOption(pInfo->options,
- "EmulateWheelTimeout", 200);
- if (pMse->wheelButtonTimeout <= 0) {
- xf86Msg(X_WARNING, "%s: Invalid EmulateWheelTimeout value: %d\n",
- pInfo->name, pMse->wheelButtonTimeout);
- pMse->wheelButtonTimeout = 200;
- }
-
- pMse->negativeX = MSE_NOAXISMAP;
- pMse->positiveX = MSE_NOAXISMAP;
- s = xf86SetStrOption(pInfo->options, "XAxisMapping", NULL);
- if (s) {
- int b1 = 0, b2 = 0;
- char *msg = NULL;
-
- if ((sscanf(s, "%d %d", &b1, &b2) == 2) &&
- b1 > 0 && b1 <= MSE_MAXBUTTONS &&
- b2 > 0 && b2 <= MSE_MAXBUTTONS) {
- msg = xstrdup("buttons XX and YY");
- if (msg)
- sprintf(msg, "buttons %d and %d", b1, b2);
- pMse->negativeX = b1;
- pMse->positiveX = b2;
- if (b1 > pMse->buttons) pMse->buttons = b1;
- if (b2 > pMse->buttons) pMse->buttons = b2;
- } else {
- xf86Msg(X_WARNING, "%s: Invalid XAxisMapping value: \"%s\"\n",
- pInfo->name, s);
- }
- if (msg) {
- xf86Msg(X_CONFIG, "%s: XAxisMapping: %s\n", pInfo->name, msg);
- free(msg);
- }
- free(s);
- }
- s = xf86SetStrOption(pInfo->options, "YAxisMapping", NULL);
- if (s) {
- int b1 = 0, b2 = 0;
- char *msg = NULL;
-
- if ((sscanf(s, "%d %d", &b1, &b2) == 2) &&
- b1 > 0 && b1 <= MSE_MAXBUTTONS &&
- b2 > 0 && b2 <= MSE_MAXBUTTONS) {
- msg = xstrdup("buttons XX and YY");
- if (msg)
- sprintf(msg, "buttons %d and %d", b1, b2);
- pMse->negativeY = b1;
- pMse->positiveY = b2;
- if (b1 > pMse->buttons) pMse->buttons = b1;
- if (b2 > pMse->buttons) pMse->buttons = b2;
- yFromConfig = TRUE;
- } else {
- xf86Msg(X_WARNING, "%s: Invalid YAxisMapping value: \"%s\"\n",
- pInfo->name, s);
- }
- if (msg) {
- xf86Msg(X_CONFIG, "%s: YAxisMapping: %s\n", pInfo->name, msg);
- free(msg);
- }
- free(s);
- }
- if (!yFromConfig) {
- pMse->negativeY = 4;
- pMse->positiveY = 5;
- if (pMse->negativeY > pMse->buttons)
- pMse->buttons = pMse->negativeY;
- if (pMse->positiveY > pMse->buttons)
- pMse->buttons = pMse->positiveY;
- xf86Msg(X_DEFAULT, "%s: YAxisMapping: buttons %d and %d\n",
- pInfo->name, pMse->negativeY, pMse->positiveY);
- }
- xf86Msg(X_CONFIG, "%s: EmulateWheel, EmulateWheelButton: %d, "
- "EmulateWheelInertia: %d, "
- "EmulateWheelTimeout: %d\n",
- pInfo->name, wheelButton, pMse->wheelInertia,
- pMse->wheelButtonTimeout);
+ Bool yFromConfig = FALSE;
+ int wheelButton;
+
+ pMse->emulateWheel = TRUE;
+ wheelButton = xf86SetIntOption(pInfo->options,
+ "EmulateWheelButton", 4);
+ if (wheelButton < 0 || wheelButton > MSE_MAXBUTTONS) {
+ xf86Msg(X_WARNING, "%s: Invalid EmulateWheelButton value: %d\n",
+ pInfo->name, wheelButton);
+ wheelButton = 4;
+ }
+ pMse->wheelButton = wheelButton;
+
+ pMse->wheelInertia = xf86SetIntOption(pInfo->options,
+ "EmulateWheelInertia", 10);
+ if (pMse->wheelInertia <= 0) {
+ xf86Msg(X_WARNING, "%s: Invalid EmulateWheelInertia value: %d\n",
+ pInfo->name, pMse->wheelInertia);
+ pMse->wheelInertia = 10;
+ }
+ pMse->wheelButtonTimeout = xf86SetIntOption(pInfo->options,
+ "EmulateWheelTimeout", 200);
+ if (pMse->wheelButtonTimeout <= 0) {
+ xf86Msg(X_WARNING, "%s: Invalid EmulateWheelTimeout value: %d\n",
+ pInfo->name, pMse->wheelButtonTimeout);
+ pMse->wheelButtonTimeout = 200;
+ }
+
+ pMse->negativeX = MSE_NOAXISMAP;
+ pMse->positiveX = MSE_NOAXISMAP;
+ s = xf86SetStrOption(pInfo->options, "XAxisMapping", NULL);
+ if (s) {
+ int b1 = 0, b2 = 0;
+ char *msg = NULL;
+
+ if ((sscanf(s, "%d %d", &b1, &b2) == 2) &&
+ b1 > 0 && b1 <= MSE_MAXBUTTONS &&
+ b2 > 0 && b2 <= MSE_MAXBUTTONS) {
+ msg = xstrdup("buttons XX and YY");
+ if (msg)
+ sprintf(msg, "buttons %d and %d", b1, b2);
+ pMse->negativeX = b1;
+ pMse->positiveX = b2;
+ if (b1 > pMse->buttons) pMse->buttons = b1;
+ if (b2 > pMse->buttons) pMse->buttons = b2;
+ } else {
+ xf86Msg(X_WARNING, "%s: Invalid XAxisMapping value: \"%s\"\n",
+ pInfo->name, s);
+ }
+ if (msg) {
+ xf86Msg(X_CONFIG, "%s: XAxisMapping: %s\n", pInfo->name, msg);
+ free(msg);
+ }
+ free(s);
+ }
+ s = xf86SetStrOption(pInfo->options, "YAxisMapping", NULL);
+ if (s) {
+ int b1 = 0, b2 = 0;
+ char *msg = NULL;
+
+ if ((sscanf(s, "%d %d", &b1, &b2) == 2) &&
+ b1 > 0 && b1 <= MSE_MAXBUTTONS &&
+ b2 > 0 && b2 <= MSE_MAXBUTTONS) {
+ msg = xstrdup("buttons XX and YY");
+ if (msg)
+ sprintf(msg, "buttons %d and %d", b1, b2);
+ pMse->negativeY = b1;
+ pMse->positiveY = b2;
+ if (b1 > pMse->buttons) pMse->buttons = b1;
+ if (b2 > pMse->buttons) pMse->buttons = b2;
+ yFromConfig = TRUE;
+ } else {
+ xf86Msg(X_WARNING, "%s: Invalid YAxisMapping value: \"%s\"\n",
+ pInfo->name, s);
+ }
+ if (msg) {
+ xf86Msg(X_CONFIG, "%s: YAxisMapping: %s\n", pInfo->name, msg);
+ free(msg);
+ }
+ free(s);
+ }
+ if (!yFromConfig) {
+ pMse->negativeY = 4;
+ pMse->positiveY = 5;
+ if (pMse->negativeY > pMse->buttons)
+ pMse->buttons = pMse->negativeY;
+ if (pMse->positiveY > pMse->buttons)
+ pMse->buttons = pMse->positiveY;
+ xf86Msg(X_DEFAULT, "%s: YAxisMapping: buttons %d and %d\n",
+ pInfo->name, pMse->negativeY, pMse->positiveY);
+ }
+ xf86Msg(X_CONFIG, "%s: EmulateWheel, EmulateWheelButton: %d, "
+ "EmulateWheelInertia: %d, "
+ "EmulateWheelTimeout: %d\n",
+ pInfo->name, wheelButton, pMse->wheelInertia,
+ pMse->wheelButtonTimeout);
}
s = xf86SetStrOption(pInfo->options, "ButtonMapping", NULL);
if (s) {
@@ -574,25 +574,25 @@ MouseCommonOptions(InputInfoPtr pInfo)
char *s1 = s;
/* keep getting numbers which are buttons */
while (s1 && n < MSE_MAXBUTTONS && (b = strtol(s1, &s1, 10)) != 0) {
- /* check sanity for a button */
- if (b < 0 || b > MSE_MAXBUTTONS) {
- xf86Msg(X_WARNING,
- "ButtonMapping: Invalid button number = %d\n", b);
- break;
- };
- pMse->buttonMap[n++] = 1 << (b-1);
- if (b > pMse->buttons) pMse->buttons = b;
+ /* check sanity for a button */
+ if (b < 0 || b > MSE_MAXBUTTONS) {
+ xf86Msg(X_WARNING,
+ "ButtonMapping: Invalid button number = %d\n", b);
+ break;
+ };
+ pMse->buttonMap[n++] = 1 << (b-1);
+ if (b > pMse->buttons) pMse->buttons = b;
}
free(s);
}
/* get maximum of mapped buttons */
for (i = pMse->buttons-1; i >= 0; i--) {
- int f = ffs (pMse->buttonMap[i]);
- if (f > pMse->buttons)
- pMse->buttons = f;
+ int f = ffs (pMse->buttonMap[i]);
+ if (f > pMse->buttons)
+ pMse->buttons = f;
}
if (origButtons != pMse->buttons)
- buttons_from = X_CONFIG;
+ buttons_from = X_CONFIG;
xf86Msg(buttons_from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons);
pMse->doubleClickSourceButtonMask = 0;
@@ -621,7 +621,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
xf86Msg(X_CONFIG, "%s: DoubleClickButtons: %s\n", pInfo->name, msg);
free(msg);
}
- free(s);
+ free(s);
}
}
/*
@@ -645,10 +645,10 @@ lock2targetMap(DragLockPtr pLock, int lockMask)
* need to be used.
*/
for (i = 0; (i < NIB_COUNT) && lockMask; i++) {
- result |= pLock->nib_table[i][lockMask& NIB_MASK];
+ result |= pLock->nib_table[i][lockMask& NIB_MASK];
- lockMask &= ~NIB_MASK;
- lockMask >>= NIB_BITS;
+ lockMask &= ~NIB_MASK;
+ lockMask >>= NIB_BITS;
}
return result;
}
@@ -660,11 +660,11 @@ MouseHWOptions(InputInfoPtr pInfo)
mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv;
if (mPriv == NULL)
- return;
+ return;
if ((mPriv->soft
- = xf86SetBoolOption(pInfo->options, "AutoSoft", FALSE))) {
- xf86Msg(X_CONFIG, "Don't initialize mouse when auto-probing\n");
+ = xf86SetBoolOption(pInfo->options, "AutoSoft", FALSE))) {
+ xf86Msg(X_CONFIG, "Don't initialize mouse when auto-probing\n");
}
pMse->sampleRate = xf86SetIntOption(pInfo->options, "SampleRate", 0);
pMse->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0);
@@ -685,8 +685,8 @@ ProtocolNameToID(const char *name)
int i;
for (i = 0; mouseProtocols[i].name; i++)
- if (xf86NameCmp(name, mouseProtocols[i].name) == 0)
- return mouseProtocols[i].id;
+ if (xf86NameCmp(name, mouseProtocols[i].name) == 0)
+ return mouseProtocols[i].id;
return PROT_UNKNOWN;
}
@@ -697,16 +697,16 @@ ProtocolIDToName(MouseProtocolID id)
switch (id) {
case PROT_UNKNOWN:
- return "Unknown";
- break;
+ return "Unknown";
+ break;
case PROT_UNSUP:
- return "Unsupported";
- break;
+ return "Unsupported";
+ break;
default:
- for (i = 0; mouseProtocols[i].name; i++)
- if (id == mouseProtocols[i].id)
- return mouseProtocols[i].name;
- return "Invalid";
+ for (i = 0; mouseProtocols[i].name; i++)
+ if (id == mouseProtocols[i].id)
+ return mouseProtocols[i].name;
+ return "Invalid";
}
}
@@ -718,13 +718,13 @@ ProtocolIDToClass(MouseProtocolID id)
switch (id) {
case PROT_UNKNOWN:
case PROT_UNSUP:
- return MSE_NONE;
- break;
+ return MSE_NONE;
+ break;
default:
- for (i = 0; mouseProtocols[i].name; i++)
- if (id == mouseProtocols[i].id)
- return mouseProtocols[i].class;
- return MSE_NONE;
+ for (i = 0; mouseProtocols[i].name; i++)
+ if (id == mouseProtocols[i].id)
+ return mouseProtocols[i].class;
+ return MSE_NONE;
}
}
@@ -735,14 +735,14 @@ GetProtocol(MouseProtocolID id) {
switch (id) {
case PROT_UNKNOWN:
case PROT_UNSUP:
- return NULL;
- break;
+ return NULL;
+ break;
default:
- for (i = 0; mouseProtocols[i].name; i++)
- if (id == mouseProtocols[i].id) {
- return &mouseProtocols[i];
- }
- return NULL;
+ for (i = 0; mouseProtocols[i].name; i++)
+ if (id == mouseProtocols[i].id) {
+ return &mouseProtocols[i];
+ }
+ return NULL;
}
}
@@ -756,35 +756,35 @@ InitProtocols(void)
const char *osname = NULL;
if (osInfo)
- return TRUE;
+ return TRUE;
osInfo = OSMouseInit(0);
if (!osInfo)
- return FALSE;
+ return FALSE;
if (!osInfo->SupportedInterfaces)
- return FALSE;
+ return FALSE;
classes = osInfo->SupportedInterfaces();
if (!classes)
- return FALSE;
+ return FALSE;
/* Mark unsupported interface classes. */
for (i = 0; mouseProtocols[i].name; i++)
- if (!(mouseProtocols[i].class & classes))
- mouseProtocols[i].id = PROT_UNSUP;
+ if (!(mouseProtocols[i].class & classes))
+ mouseProtocols[i].id = PROT_UNSUP;
for (i = 0; mouseProtocols[i].name; i++)
- if (mouseProtocols[i].class & MSE_MISC)
- if (!osInfo->CheckProtocol ||
- !osInfo->CheckProtocol(mouseProtocols[i].name))
- mouseProtocols[i].id = PROT_UNSUP;
+ if (mouseProtocols[i].class & MSE_MISC)
+ if (!osInfo->CheckProtocol ||
+ !osInfo->CheckProtocol(mouseProtocols[i].name))
+ mouseProtocols[i].id = PROT_UNSUP;
/* NetBSD uses PROT_BM for "PS/2". */
xf86GetOS(&osname, NULL, NULL, NULL);
if (osname && xf86NameCmp(osname, "netbsd") == 0)
- for (i = 0; mouseProtocols[i].name; i++)
- if (mouseProtocols[i].id == PROT_PS2)
- mouseProtocols[i].id = PROT_BM;
+ for (i = 0; mouseProtocols[i].name; i++)
+ if (mouseProtocols[i].id == PROT_PS2)
+ mouseProtocols[i].id = PROT_BM;
return TRUE;
}
@@ -800,16 +800,16 @@ MouseFindDevice(InputInfoPtr pInfo, const char* protocol)
xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n", pInfo->name);
device = osInfo->FindDevice(pInfo, protocol, 0);
if (!device)
- xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n", pInfo->name);
+ xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n", pInfo->name);
else
- xf86Msg(X_PROBED, "%s: Device: \"%s\"\n", pInfo->name, device);
+ xf86Msg(X_PROBED, "%s: Device: \"%s\"\n", pInfo->name, device);
return device;
}
static const char*
MousePickProtocol(InputInfoPtr pInfo, const char* device,
- const char *protocol, MouseProtocolID *protocolID_out)
+ const char *protocol, MouseProtocolID *protocolID_out)
{
MouseProtocolID protocolID = *protocolID_out;
@@ -817,14 +817,14 @@ MousePickProtocol(InputInfoPtr pInfo, const char* device,
if (protocolID == PROT_AUTO)
{
- const char *osProt;
- if (osInfo->SetupAuto && (osProt = osInfo->SetupAuto(pInfo,NULL))) {
- MouseProtocolID id = ProtocolNameToID(osProt);
- if (id == PROT_UNKNOWN || id == PROT_UNSUP) {
- protocolID = id;
- protocol = osProt;
- }
- }
+ const char *osProt;
+ if (osInfo->SetupAuto && (osProt = osInfo->SetupAuto(pInfo,NULL))) {
+ MouseProtocolID id = ProtocolNameToID(osProt);
+ if (id == PROT_UNKNOWN || id == PROT_UNSUP) {
+ protocolID = id;
+ protocol = osProt;
+ }
+ }
}
switch (protocolID) {
@@ -833,28 +833,28 @@ MousePickProtocol(InputInfoPtr pInfo, const char* device,
if (osInfo->PreInit)
osInfo->PreInit(pInfo, protocol, 0);
break;
- case PROT_UNKNOWN:
- /* Check for a builtin OS-specific protocol,
- * and call its PreInit. */
- if (osInfo->CheckProtocol
- && osInfo->CheckProtocol(protocol)) {
- if (!device)
- MouseFindDevice(pInfo, protocol);
- if (osInfo->PreInit) {
- osInfo->PreInit(pInfo, protocol, 0);
- }
- break;
- }
- xf86Msg(X_ERROR, "%s: Unknown protocol \"%s\"\n",
- pInfo->name, protocol);
- break;
- case PROT_UNSUP:
- xf86Msg(X_ERROR,
- "%s: Protocol \"%s\" is not supported on this "
- "platform\n", pInfo->name, protocol);
- break;
- default:
- break;
+ case PROT_UNKNOWN:
+ /* Check for a builtin OS-specific protocol,
+ * and call its PreInit. */
+ if (osInfo->CheckProtocol
+ && osInfo->CheckProtocol(protocol)) {
+ if (!device)
+ MouseFindDevice(pInfo, protocol);
+ if (osInfo->PreInit) {
+ osInfo->PreInit(pInfo, protocol, 0);
+ }
+ break;
+ }
+ xf86Msg(X_ERROR, "%s: Unknown protocol \"%s\"\n",
+ pInfo->name, protocol);
+ break;
+ case PROT_UNSUP:
+ xf86Msg(X_ERROR,
+ "%s: Protocol \"%s\" is not supported on this "
+ "platform\n", pInfo->name, protocol);
+ break;
+ default:
+ break;
}
*protocolID_out = protocolID;
@@ -872,7 +872,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
InputInfoPtr pInfo;
if (!(pInfo = xf86AllocateInput(drv, 0)))
- return NULL;
+ return NULL;
pInfo->name = dev->identifier;
pInfo->flags = XI86_SEND_DRAG_EVENTS;
@@ -917,7 +917,7 @@ MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
int rc = Success;
if (!InitProtocols())
- return BadAlloc;
+ return BadAlloc;
/* Initialise the InputInfoRec. */
pInfo->type_name = XI_MOUSE;
@@ -931,8 +931,8 @@ MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* Allocate the MouseDevRec and initialise it. */
if (!(pMse = calloc(sizeof(MouseDevRec), 1)))
{
- rc = BadAlloc;
- goto out;
+ rc = BadAlloc;
+ goto out;
}
pInfo->private = pMse;
@@ -943,22 +943,22 @@ MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* Find the protocol type. */
protocol = xf86SetStrOption(pInfo->options, "Protocol", NULL);
if (protocol) {
- protocolFrom = X_CONFIG;
+ protocolFrom = X_CONFIG;
} else if (osInfo->DefaultProtocol) {
- protocol = osInfo->DefaultProtocol();
- protocolFrom = X_DEFAULT;
+ protocol = osInfo->DefaultProtocol();
+ protocolFrom = X_DEFAULT;
}
if (!protocol) {
- xf86Msg(X_ERROR, "%s: No Protocol specified\n", pInfo->name);
- rc = BadValue;
- goto out;
+ xf86Msg(X_ERROR, "%s: No Protocol specified\n", pInfo->name);
+ rc = BadValue;
+ goto out;
}
device = xf86SetStrOption(pInfo->options, "Device", NULL);
/* Default Mapping: 1 2 3 8 9 10 11 ... */
for (i = 0; i < MSE_MAXBUTTONS; i++)
- pMse->buttonMap[i] = 1 << (i > 2 && i < MSE_MAXBUTTONS-4 ? i+4 : i);
+ pMse->buttonMap[i] = 1 << (i > 2 && i < MSE_MAXBUTTONS-4 ? i+4 : i);
protocol = MousePickProtocol(pInfo, device, protocol, &protocolID);
@@ -970,8 +970,8 @@ MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
goto out;
if (!(pProto = GetProtocol(protocolID)))
{
- rc = BadValue;
- goto out;
+ rc = BadValue;
+ goto out;
}
pMse->protocolID = protocolID;
@@ -993,25 +993,25 @@ MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
- if (xf86GetAllowMouseOpenFail())
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
- xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
- if (pMse->mousePriv)
- free(pMse->mousePriv);
- free(pMse);
- pInfo->private = NULL;
- rc = BadValue;
- goto out;
- }
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ if (pMse->mousePriv)
+ free(pMse->mousePriv);
+ free(pMse);
+ pInfo->private = NULL;
+ rc = BadValue;
+ goto out;
+ }
}
xf86CloseSerial(pInfo->fd);
pInfo->fd = -1;
if (!(mPriv = (pointer) calloc(sizeof(mousePrivRec), 1)))
{
- rc = BadAlloc;
- goto out;
+ rc = BadAlloc;
+ goto out;
}
pMse->mousePriv = mPriv;
@@ -1048,7 +1048,7 @@ static void MouseInitButtonLabels(Atom *btn_labels)
static int
MouseSetProperty(DeviceIntPtr device, Atom atom,
- XIPropertyValuePtr val, BOOL checkonly)
+ XIPropertyValuePtr val, BOOL checkonly)
{
InputInfoPtr pInfo = device->public.devicePrivate;
MouseDevPtr pMse = pInfo->private;
@@ -1153,7 +1153,7 @@ MouseReadInput(InputInfoPtr pInfo)
pBuf = pMse->protoBuf;
if (pInfo->fd == -1)
- return;
+ return;
/*
* Set blocking to -1 on the first call because we know there is data to
@@ -1164,483 +1164,483 @@ MouseReadInput(InputInfoPtr pInfo)
XisbBlockDuration(pMse->buffer, -1);
while ((c = XisbRead(pMse->buffer)) >= 0) {
- u = (unsigned char)c;
+ u = (unsigned char)c;
#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG)
- ErrorF("mouse byte: %2.2x\n",u);
+ ErrorF("mouse byte: %2.2x\n",u);
#endif
- /* if we do autoprobing collect the data */
- if (pMse->collectData && pMse->autoProbe)
- if (pMse->collectData(pMse,u))
- continue;
+ /* if we do autoprobing collect the data */
+ if (pMse->collectData && pMse->autoProbe)
+ if (pMse->collectData(pMse,u))
+ continue;
#ifdef SUPPORT_MOUSE_RESET
- if (mouseReset(pInfo,u)) {
- pBufP = 0;
- continue;
- }
+ if (mouseReset(pInfo,u)) {
+ pBufP = 0;
+ continue;
+ }
#endif
- if (pBufP >= pMse->protoPara[4]) {
- /*
- * Buffer contains a full packet, which has already been processed:
- * Empty the buffer and check for optional 4th byte, which will be
- * processed directly, without being put into the buffer first.
- */
- pBufP = 0;
- if ((u & pMse->protoPara[0]) != pMse->protoPara[1] &&
- (u & pMse->protoPara[5]) == pMse->protoPara[6]) {
- /*
- * Hack for Logitech MouseMan Mouse - Middle button
- *
- * Unfortunately this mouse has variable length packets: the
- * standard Microsoft 3 byte packet plus an optional 4th byte
- * whenever the middle button status changes.
- *
- * We have already processed the standard packet with the
- * movement and button info. Now post an event message with
- * the old status of the left and right buttons and the
- * updated middle button.
- */
- /*
- * Even worse, different MouseMen and TrackMen differ in the
- * 4th byte: some will send 0x00/0x20, others 0x01/0x21, or
- * even 0x02/0x22, so I have to strip off the lower bits.
- * [CHRIS-211092]
- *
- * [JCH-96/01/21]
- * HACK for ALPS "fourth button". (It's bit 0x10 of the
- * "fourth byte" and it is activated by tapping the glidepad
- * with the finger! 8^) We map it to bit bit3, and the
- * reverse map in xf86Events just has to be extended so that
- * it is identified as Button 4. The lower half of the
- * reverse-map may remain unchanged.
- */
- /*
- * [KAZU-030897]
- * Receive the fourth byte only when preceeding three bytes
- * have been detected (pBufP >= pMse->protoPara[4]). In the
- * previous versions, the test was pBufP == 0; we may have
- * mistakingly received a byte even if we didn't see anything
- * preceeding the byte.
- */
+ if (pBufP >= pMse->protoPara[4]) {
+ /*
+ * Buffer contains a full packet, which has already been processed:
+ * Empty the buffer and check for optional 4th byte, which will be
+ * processed directly, without being put into the buffer first.
+ */
+ pBufP = 0;
+ if ((u & pMse->protoPara[0]) != pMse->protoPara[1] &&
+ (u & pMse->protoPara[5]) == pMse->protoPara[6]) {
+ /*
+ * Hack for Logitech MouseMan Mouse - Middle button
+ *
+ * Unfortunately this mouse has variable length packets: the
+ * standard Microsoft 3 byte packet plus an optional 4th byte
+ * whenever the middle button status changes.
+ *
+ * We have already processed the standard packet with the
+ * movement and button info. Now post an event message with
+ * the old status of the left and right buttons and the
+ * updated middle button.
+ */
+ /*
+ * Even worse, different MouseMen and TrackMen differ in the
+ * 4th byte: some will send 0x00/0x20, others 0x01/0x21, or
+ * even 0x02/0x22, so I have to strip off the lower bits.
+ * [CHRIS-211092]
+ *
+ * [JCH-96/01/21]
+ * HACK for ALPS "fourth button". (It's bit 0x10 of the
+ * "fourth byte" and it is activated by tapping the glidepad
+ * with the finger! 8^) We map it to bit bit3, and the
+ * reverse map in xf86Events just has to be extended so that
+ * it is identified as Button 4. The lower half of the
+ * reverse-map may remain unchanged.
+ */
+ /*
+ * [KAZU-030897]
+ * Receive the fourth byte only when preceeding three bytes
+ * have been detected (pBufP >= pMse->protoPara[4]). In the
+ * previous versions, the test was pBufP == 0; we may have
+ * mistakingly received a byte even if we didn't see anything
+ * preceeding the byte.
+ */
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse 4th byte %02x\n",u);
+ ErrorF("mouse 4th byte %02x\n",u);
#endif
- dx = dy = dz = dw = 0;
- buttons = 0;
- switch (pMse->protocolID) {
-
- /*
- * [KAZU-221197]
- * IntelliMouse, NetMouse (including NetMouse Pro) and Mie
- * Mouse always send the fourth byte, whereas the fourth byte
- * is optional for GlidePoint and ThinkingMouse. The fourth
- * byte is also optional for MouseMan+ and FirstMouse+ in
- * their native mode. It is always sent if they are in the
- * IntelliMouse compatible mode.
- */
- case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse,
- MouseMan+ */
- dz = (u & 0x08) ?
- (u & 0x0f) - 16 : (u & 0x0f);
- if ((dz >= 7) || (dz <= -7))
- dz = 0;
- buttons |= ((int)(u & 0x10) >> 3)
- | ((int)(u & 0x20) >> 2)
- | (pMse->lastButtons & 0x05);
- break;
-
- case PROT_GLIDE:
- case PROT_THINKING:
- buttons |= ((int)(u & 0x10) >> 1);
- /* fall through */
-
- default:
- buttons |= ((int)(u & 0x20) >> 4) |
- (pMse->lastButtons & 0x05);
- break;
- }
- goto post_event;
- }
- }
- /* End of packet buffer flush and 4th byte hack. */
-
- /*
- * Append next byte to buffer (which is empty or contains an
- * incomplete packet); iterate if packet (still) not complete.
- */
- pBuf[pBufP++] = u;
- if (pBufP != pMse->protoPara[4]) continue;
+ dx = dy = dz = dw = 0;
+ buttons = 0;
+ switch (pMse->protocolID) {
+
+ /*
+ * [KAZU-221197]
+ * IntelliMouse, NetMouse (including NetMouse Pro) and Mie
+ * Mouse always send the fourth byte, whereas the fourth byte
+ * is optional for GlidePoint and ThinkingMouse. The fourth
+ * byte is also optional for MouseMan+ and FirstMouse+ in
+ * their native mode. It is always sent if they are in the
+ * IntelliMouse compatible mode.
+ */
+ case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse,
+ MouseMan+ */
+ dz = (u & 0x08) ?
+ (u & 0x0f) - 16 : (u & 0x0f);
+ if ((dz >= 7) || (dz <= -7))
+ dz = 0;
+ buttons |= ((int)(u & 0x10) >> 3)
+ | ((int)(u & 0x20) >> 2)
+ | (pMse->lastButtons & 0x05);
+ break;
+
+ case PROT_GLIDE:
+ case PROT_THINKING:
+ buttons |= ((int)(u & 0x10) >> 1);
+ /* fall through */
+
+ default:
+ buttons |= ((int)(u & 0x20) >> 4) |
+ (pMse->lastButtons & 0x05);
+ break;
+ }
+ goto post_event;
+ }
+ }
+ /* End of packet buffer flush and 4th byte hack. */
+
+ /*
+ * Append next byte to buffer (which is empty or contains an
+ * incomplete packet); iterate if packet (still) not complete.
+ */
+ pBuf[pBufP++] = u;
+ if (pBufP != pMse->protoPara[4]) continue;
#ifdef EXTMOUSEDEBUG2
- {
- int i;
- ErrorF("received %d bytes",pBufP);
- for ( i=0; i < pBufP; i++)
- ErrorF(" %02x",pBuf[i]);
- ErrorF("\n");
- }
+ {
+ int i;
+ ErrorF("received %d bytes",pBufP);
+ for ( i=0; i < pBufP; i++)
+ ErrorF(" %02x",pBuf[i]);
+ ErrorF("\n");
+ }
#endif
- /*
- * Hack for resyncing: We check here for a package that is:
- * a) illegal (detected by wrong data-package header)
- * b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
- * c) bad header-package
- *
- * NOTE: b) is a violation of the MouseSystems-Protocol, since values
- * of -128 are allowed, but since they are very seldom we can
- * easily use them as package-header with no button pressed.
- * NOTE/2: On a PS/2 mouse any byte is valid as a data byte.
- * Furthermore, 0x80 is not valid as a header byte. For a PS/2
- * mouse we skip checking data bytes. For resyncing a PS/2
- * mouse we require the two most significant bits in the header
- * byte to be 0. These are the overflow bits, and in case of
- * an overflow we actually lose sync. Overflows are very rare,
- * however, and we quickly gain sync again after an overflow
- * condition. This is the best we can do. (Actually, we could
- * use bit 0x08 in the header byte for resyncing, since that
- * bit is supposed to be always on, but nobody told Microsoft...)
- */
-
- /*
- * [KAZU,OYVIND-120398]
- * The above hack is wrong! Because of b) above, we shall see
- * erroneous mouse events so often when the MouseSystem mouse is
- * moved quickly. As for the PS/2 and its variants, we don't need
- * to treat them as special cases, because protoPara[2] and
- * protoPara[3] are both 0x00 for them, thus, any data bytes will
- * never be discarded. 0x80 is rejected for MMSeries, Logitech
- * and MMHittab protocols, because protoPara[2] and protoPara[3]
- * are 0x80 and 0x00 respectively. The other protocols are 7-bit
- * protocols; there is no use checking 0x80.
- *
- * All in all we should check the condition a) only.
- */
-
- /*
- * [OYVIND-120498]
- * Check packet for valid data:
- * If driver is in sync with datastream, the packet is considered
- * bad if any byte (header and/or data) contains an invalid value.
- *
- * If packet is bad, we discard the first byte and shift the buffer.
- * Next iteration will then check the new situation for validity.
- *
- * If flag MF_SAFE is set in proto[7] and the driver
- * is out of sync, the packet is also considered bad if
- * any of the data bytes contains a valid header byte value.
- * This situation could occur if the buffer contains
- * the tail of one packet and the header of the next.
- *
- * Note: The driver starts in out-of-sync mode (pMse->inSync = 0).
- */
-
- baddata = 0;
-
- /* All databytes must be valid. */
- for (j = 1; j < pBufP; j++ )
- if ((pBuf[j] & pMse->protoPara[2]) != pMse->protoPara[3])
- baddata = 1;
-
- /* If out of sync, don't mistake a header byte for data. */
- if ((pMse->protoPara[7] & MPF_SAFE) && !pMse->inSync)
- for (j = 1; j < pBufP; j++ )
- if ((pBuf[j] & pMse->protoPara[0]) == pMse->protoPara[1])
- baddata = 1;
-
- /* Accept or reject the packet ? */
- if ((pBuf[0] & pMse->protoPara[0]) != pMse->protoPara[1] || baddata) {
- if (pMse->inSync) {
+ /*
+ * Hack for resyncing: We check here for a package that is:
+ * a) illegal (detected by wrong data-package header)
+ * b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
+ * c) bad header-package
+ *
+ * NOTE: b) is a violation of the MouseSystems-Protocol, since values
+ * of -128 are allowed, but since they are very seldom we can
+ * easily use them as package-header with no button pressed.
+ * NOTE/2: On a PS/2 mouse any byte is valid as a data byte.
+ * Furthermore, 0x80 is not valid as a header byte. For a PS/2
+ * mouse we skip checking data bytes. For resyncing a PS/2
+ * mouse we require the two most significant bits in the header
+ * byte to be 0. These are the overflow bits, and in case of
+ * an overflow we actually lose sync. Overflows are very rare,
+ * however, and we quickly gain sync again after an overflow
+ * condition. This is the best we can do. (Actually, we could
+ * use bit 0x08 in the header byte for resyncing, since that
+ * bit is supposed to be always on, but nobody told Microsoft...)
+ */
+
+ /*
+ * [KAZU,OYVIND-120398]
+ * The above hack is wrong! Because of b) above, we shall see
+ * erroneous mouse events so often when the MouseSystem mouse is
+ * moved quickly. As for the PS/2 and its variants, we don't need
+ * to treat them as special cases, because protoPara[2] and
+ * protoPara[3] are both 0x00 for them, thus, any data bytes will
+ * never be discarded. 0x80 is rejected for MMSeries, Logitech
+ * and MMHittab protocols, because protoPara[2] and protoPara[3]
+ * are 0x80 and 0x00 respectively. The other protocols are 7-bit
+ * protocols; there is no use checking 0x80.
+ *
+ * All in all we should check the condition a) only.
+ */
+
+ /*
+ * [OYVIND-120498]
+ * Check packet for valid data:
+ * If driver is in sync with datastream, the packet is considered
+ * bad if any byte (header and/or data) contains an invalid value.
+ *
+ * If packet is bad, we discard the first byte and shift the buffer.
+ * Next iteration will then check the new situation for validity.
+ *
+ * If flag MF_SAFE is set in proto[7] and the driver
+ * is out of sync, the packet is also considered bad if
+ * any of the data bytes contains a valid header byte value.
+ * This situation could occur if the buffer contains
+ * the tail of one packet and the header of the next.
+ *
+ * Note: The driver starts in out-of-sync mode (pMse->inSync = 0).
+ */
+
+ baddata = 0;
+
+ /* All databytes must be valid. */
+ for (j = 1; j < pBufP; j++ )
+ if ((pBuf[j] & pMse->protoPara[2]) != pMse->protoPara[3])
+ baddata = 1;
+
+ /* If out of sync, don't mistake a header byte for data. */
+ if ((pMse->protoPara[7] & MPF_SAFE) && !pMse->inSync)
+ for (j = 1; j < pBufP; j++ )
+ if ((pBuf[j] & pMse->protoPara[0]) == pMse->protoPara[1])
+ baddata = 1;
+
+ /* Accept or reject the packet ? */
+ if ((pBuf[0] & pMse->protoPara[0]) != pMse->protoPara[1] || baddata) {
+ if (pMse->inSync) {
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse driver lost sync\n");
+ ErrorF("mouse driver lost sync\n");
#endif
- }
+ }
#ifdef EXTMOUSEDEBUG
- ErrorF("skipping byte %02x\n",*pBuf);
+ ErrorF("skipping byte %02x\n",*pBuf);
#endif
- /* Tell auto probe that we are out of sync */
- if (pMse->autoProbeMouse && pMse->autoProbe)
- pMse->autoProbeMouse(pInfo, FALSE, pMse->inSync);
- pMse->protoBufTail = --pBufP;
- for (j = 0; j < pBufP; j++)
- pBuf[j] = pBuf[j+1];
- pMse->inSync = 0;
- continue;
- }
- /* Tell auto probe that we were successful */
- if (pMse->autoProbeMouse && pMse->autoProbe)
- pMse->autoProbeMouse(pInfo, TRUE, FALSE);
-
- if (!pMse->inSync) {
+ /* Tell auto probe that we are out of sync */
+ if (pMse->autoProbeMouse && pMse->autoProbe)
+ pMse->autoProbeMouse(pInfo, FALSE, pMse->inSync);
+ pMse->protoBufTail = --pBufP;
+ for (j = 0; j < pBufP; j++)
+ pBuf[j] = pBuf[j+1];
+ pMse->inSync = 0;
+ continue;
+ }
+ /* Tell auto probe that we were successful */
+ if (pMse->autoProbeMouse && pMse->autoProbe)
+ pMse->autoProbeMouse(pInfo, TRUE, FALSE);
+
+ if (!pMse->inSync) {
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse driver back in sync\n");
+ ErrorF("mouse driver back in sync\n");
#endif
- pMse->inSync = 1;
- }
+ pMse->inSync = 1;
+ }
- if (!pMse->dataGood(pMse))
- continue;
+ if (!pMse->dataGood(pMse))
+ continue;
- /*
- * Packet complete and verified, now process it ...
- */
+ /*
+ * Packet complete and verified, now process it ...
+ */
REDO_INTERPRET:
- dz = dw = 0;
- switch (pMse->protocolID) {
- case PROT_LOGIMAN: /* MouseMan / TrackMan [CHRIS-211092] */
- case PROT_MS: /* Microsoft */
- if (pMse->chordMiddle)
- buttons = (((int) pBuf[0] & 0x30) == 0x30) ? 2 :
- ((int)(pBuf[0] & 0x20) >> 3)
- | ((int)(pBuf[0] & 0x10) >> 4);
- else
- buttons = (pMse->lastButtons & 2)
- | ((int)(pBuf[0] & 0x20) >> 3)
- | ((int)(pBuf[0] & 0x10) >> 4);
- dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
- dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
- break;
-
- case PROT_GLIDE: /* ALPS GlidePoint */
- case PROT_THINKING: /* ThinkingMouse */
- case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse, MouseMan+ */
- buttons = (pMse->lastButtons & (8 + 2))
- | ((int)(pBuf[0] & 0x20) >> 3)
- | ((int)(pBuf[0] & 0x10) >> 4);
- dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
- dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
- break;
-
- case PROT_MSC: /* Mouse Systems Corp */
- buttons = (~pBuf[0]) & 0x07;
- dx = (signed char)(pBuf[1]) + (char)(pBuf[3]);
- dy = - ((signed char)(pBuf[2]) + (char)(pBuf[4]));
- break;
-
- case PROT_MMHIT: /* MM_HitTablet */
- buttons = pBuf[0] & 0x07;
- if (buttons != 0)
- buttons = 1 << (buttons - 1);
- dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
- dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
- break;
-
- case PROT_ACECAD: /* ACECAD */
- /* ACECAD is almost exactly like MM but the buttons are different */
- buttons = (pBuf[0] & 0x02) | ((pBuf[0] & 0x04) >> 2) |
- ((pBuf[0] & 1) << 2);
- dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
- dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
- break;
-
- case PROT_MM: /* MM Series */
- case PROT_LOGI: /* Logitech Mice */
- buttons = pBuf[0] & 0x07;
- dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
- dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
- break;
-
- case PROT_BM: /* BusMouse */
- buttons = (~pBuf[0]) & 0x07;
- dx = (signed char)pBuf[1];
- dy = - (signed char)pBuf[2];
- break;
-
- case PROT_PS2: /* PS/2 mouse */
- case PROT_GENPS2: /* generic PS/2 mouse */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2; /* Left */
- dx = (pBuf[0] & 0x10) ? (int)pBuf[1]-256 : (int)pBuf[1];
- dy = (pBuf[0] & 0x20) ? -((int)pBuf[2]-256) : -(int)pBuf[2];
- break;
-
- /* PS/2 mouse variants */
- case PROT_IMPS2: /* IntelliMouse PS/2 */
- case PROT_NETPS2: /* NetMouse PS/2 */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2 | /* Left */
- (pBuf[0] & 0x40) >> 3 | /* button 4 */
- (pBuf[0] & 0x80) >> 3; /* button 5 */
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- /*
- * The next cast must be 'signed char' for platforms (like PPC)
- * where char defaults to unsigned.
- */
- dz = (signed char)(pBuf[3] | ((pBuf[3] & 0x08) ? 0xf8 : 0));
- if ((pBuf[3] & 0xf8) && ((pBuf[3] & 0xf8) != 0xf8)) {
- if (pMse->autoProbe) {
- SetMouseProto(pMse, PROT_EXPPS2);
- xf86Msg(X_INFO,
- "Mouse autoprobe: Changing protocol to %s\n",
- pMse->protocol);
-
- goto REDO_INTERPRET;
- } else
- dz = 0;
- }
- break;
-
- case PROT_EXPPS2: /* IntelliMouse Explorer PS/2 */
- if (pMse->autoProbe && (pBuf[3] & 0xC0)) {
- SetMouseProto(pMse, PROT_IMPS2);
- xf86Msg(X_INFO,"Mouse autoprobe: Changing protocol to %s\n",
- pMse->protocol);
- goto REDO_INTERPRET;
- }
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2 | /* Left */
- (pBuf[3] & 0x10) >> 1 | /* button 4 */
- (pBuf[3] & 0x20) >> 1; /* button 5 */
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- if (pMse->negativeW != MSE_NOAXISMAP) {
- switch (pBuf[3] & 0x0f) {
- case 0x00: break;
- case 0x01: dz = 1; break;
- case 0x02: dw = 1; break;
- case 0x0e: dw = -1; break;
- case 0x0f: dz = -1; break;
- default:
- xf86Msg(X_INFO,
- "Mouse autoprobe: Disabling secondary wheel\n");
- pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
- }
- }
- if (pMse->negativeW == MSE_NOAXISMAP)
- dz = (pBuf[3]&0x08) ? (pBuf[3]&0x0f) - 16 : (pBuf[3]&0x0f);
- break;
-
- case PROT_MMPS2: /* MouseMan+ PS/2 */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2; /* Left */
- dx = (pBuf[0] & 0x10) ? pBuf[1] - 256 : pBuf[1];
- if (((pBuf[0] & 0x48) == 0x48) &&
- (abs(dx) > 191) &&
- ((((pBuf[2] & 0x03) << 2) | 0x02) == (pBuf[1] & 0x0f))) {
- /* extended data packet */
- switch ((((pBuf[0] & 0x30) >> 2) | ((pBuf[1] & 0x30) >> 4))) {
- case 1: /* wheel data packet */
- buttons |= ((pBuf[2] & 0x10) ? 0x08 : 0) | /* 4th button */
- ((pBuf[2] & 0x20) ? 0x10 : 0); /* 5th button */
- dx = dy = 0;
- dz = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 :
- (pBuf[2] & 0x0f);
- break;
- case 2: /* Logitech reserves this packet type */
- /*
- * IBM ScrollPoint uses this packet to encode its
- * stick movement.
- */
- buttons |= (pMse->lastButtons & ~0x07);
- dx = dy = 0;
- dz = (pBuf[2] & 0x80) ? ((pBuf[2] >> 4) & 0x0f) - 16 :
- ((pBuf[2] >> 4) & 0x0f);
- dw = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 :
- (pBuf[2] & 0x0f);
- break;
- case 0: /* device type packet - shouldn't happen */
- default:
- buttons |= (pMse->lastButtons & ~0x07);
- dx = dy = 0;
- dz = 0;
- break;
- }
- } else {
- buttons |= (pMse->lastButtons & ~0x07);
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- }
- break;
-
- case PROT_GLIDEPS2: /* GlidePoint PS/2 */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2 | /* Left */
- ((pBuf[0] & 0x08) ? 0 : 0x08);/* fourth button */
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- break;
-
- case PROT_NETSCPS2: /* NetScroll PS/2 */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2 | /* Left */
- ((pBuf[3] & 0x02) ? 0x08 : 0) | /* button 4 */
- ((pBuf[3] & 0x01) ? 0x10 : 0); /* button 5 */
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- dz = (pBuf[3] & 0x10) ? pBuf[4] - 256 : pBuf[4];
- break;
-
- case PROT_THINKPS2: /* ThinkingMouse PS/2 */
- buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
- (pBuf[0] & 0x02) >> 1 | /* Right */
- (pBuf[0] & 0x01) << 2 | /* Left */
- ((pBuf[0] & 0x08) ? 0x08 : 0);/* fourth button */
- pBuf[1] |= (pBuf[0] & 0x40) ? 0x80 : 0x00;
- dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
- dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
- break;
-
- case PROT_SYSMOUSE: /* sysmouse */
- buttons = (~pBuf[0]) & 0x07;
- dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]);
- dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4]));
- /* FreeBSD sysmouse sends additional data bytes */
- if (pMse->protoPara[4] >= 8) {
- /*
- * These casts must be 'signed char' for platforms (like PPC)
- * where char defaults to unsigned.
- */
- dz = ((signed char)(pBuf[5] << 1) +
- (signed char)(pBuf[6] << 1)) >> 1;
- buttons |= (int)(~pBuf[7] & 0x7f) << 3;
- }
- break;
-
- case PROT_VALUMOUSESCROLL: /* Kensington ValuMouseScroll */
+ dz = dw = 0;
+ switch (pMse->protocolID) {
+ case PROT_LOGIMAN: /* MouseMan / TrackMan [CHRIS-211092] */
+ case PROT_MS: /* Microsoft */
+ if (pMse->chordMiddle)
+ buttons = (((int) pBuf[0] & 0x30) == 0x30) ? 2 :
+ ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ else
+ buttons = (pMse->lastButtons & 2)
+ | ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
+ dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
+ break;
+
+ case PROT_GLIDE: /* ALPS GlidePoint */
+ case PROT_THINKING: /* ThinkingMouse */
+ case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse, MouseMan+ */
+ buttons = (pMse->lastButtons & (8 + 2))
+ | ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
+ dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
+ break;
+
+ case PROT_MSC: /* Mouse Systems Corp */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = (signed char)(pBuf[1]) + (char)(pBuf[3]);
+ dy = - ((signed char)(pBuf[2]) + (char)(pBuf[4]));
+ break;
+
+ case PROT_MMHIT: /* MM_HitTablet */
+ buttons = pBuf[0] & 0x07;
+ if (buttons != 0)
+ buttons = 1 << (buttons - 1);
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case PROT_ACECAD: /* ACECAD */
+ /* ACECAD is almost exactly like MM but the buttons are different */
+ buttons = (pBuf[0] & 0x02) | ((pBuf[0] & 0x04) >> 2) |
+ ((pBuf[0] & 1) << 2);
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case PROT_MM: /* MM Series */
+ case PROT_LOGI: /* Logitech Mice */
+ buttons = pBuf[0] & 0x07;
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case PROT_BM: /* BusMouse */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = (signed char)pBuf[1];
+ dy = - (signed char)pBuf[2];
+ break;
+
+ case PROT_PS2: /* PS/2 mouse */
+ case PROT_GENPS2: /* generic PS/2 mouse */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2; /* Left */
+ dx = (pBuf[0] & 0x10) ? (int)pBuf[1]-256 : (int)pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -((int)pBuf[2]-256) : -(int)pBuf[2];
+ break;
+
+ /* PS/2 mouse variants */
+ case PROT_IMPS2: /* IntelliMouse PS/2 */
+ case PROT_NETPS2: /* NetMouse PS/2 */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2 | /* Left */
+ (pBuf[0] & 0x40) >> 3 | /* button 4 */
+ (pBuf[0] & 0x80) >> 3; /* button 5 */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ /*
+ * The next cast must be 'signed char' for platforms (like PPC)
+ * where char defaults to unsigned.
+ */
+ dz = (signed char)(pBuf[3] | ((pBuf[3] & 0x08) ? 0xf8 : 0));
+ if ((pBuf[3] & 0xf8) && ((pBuf[3] & 0xf8) != 0xf8)) {
+ if (pMse->autoProbe) {
+ SetMouseProto(pMse, PROT_EXPPS2);
+ xf86Msg(X_INFO,
+ "Mouse autoprobe: Changing protocol to %s\n",
+ pMse->protocol);
+
+ goto REDO_INTERPRET;
+ } else
+ dz = 0;
+ }
+ break;
+
+ case PROT_EXPPS2: /* IntelliMouse Explorer PS/2 */
+ if (pMse->autoProbe && (pBuf[3] & 0xC0)) {
+ SetMouseProto(pMse, PROT_IMPS2);
+ xf86Msg(X_INFO,"Mouse autoprobe: Changing protocol to %s\n",
+ pMse->protocol);
+ goto REDO_INTERPRET;
+ }
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2 | /* Left */
+ (pBuf[3] & 0x10) >> 1 | /* button 4 */
+ (pBuf[3] & 0x20) >> 1; /* button 5 */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ if (pMse->negativeW != MSE_NOAXISMAP) {
+ switch (pBuf[3] & 0x0f) {
+ case 0x00: break;
+ case 0x01: dz = 1; break;
+ case 0x02: dw = 1; break;
+ case 0x0e: dw = -1; break;
+ case 0x0f: dz = -1; break;
+ default:
+ xf86Msg(X_INFO,
+ "Mouse autoprobe: Disabling secondary wheel\n");
+ pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
+ }
+ }
+ if (pMse->negativeW == MSE_NOAXISMAP)
+ dz = (pBuf[3]&0x08) ? (pBuf[3]&0x0f) - 16 : (pBuf[3]&0x0f);
+ break;
+
+ case PROT_MMPS2: /* MouseMan+ PS/2 */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2; /* Left */
+ dx = (pBuf[0] & 0x10) ? pBuf[1] - 256 : pBuf[1];
+ if (((pBuf[0] & 0x48) == 0x48) &&
+ (abs(dx) > 191) &&
+ ((((pBuf[2] & 0x03) << 2) | 0x02) == (pBuf[1] & 0x0f))) {
+ /* extended data packet */
+ switch ((((pBuf[0] & 0x30) >> 2) | ((pBuf[1] & 0x30) >> 4))) {
+ case 1: /* wheel data packet */
+ buttons |= ((pBuf[2] & 0x10) ? 0x08 : 0) | /* 4th button */
+ ((pBuf[2] & 0x20) ? 0x10 : 0); /* 5th button */
+ dx = dy = 0;
+ dz = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 :
+ (pBuf[2] & 0x0f);
+ break;
+ case 2: /* Logitech reserves this packet type */
+ /*
+ * IBM ScrollPoint uses this packet to encode its
+ * stick movement.
+ */
+ buttons |= (pMse->lastButtons & ~0x07);
+ dx = dy = 0;
+ dz = (pBuf[2] & 0x80) ? ((pBuf[2] >> 4) & 0x0f) - 16 :
+ ((pBuf[2] >> 4) & 0x0f);
+ dw = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 :
+ (pBuf[2] & 0x0f);
+ break;
+ case 0: /* device type packet - shouldn't happen */
+ default:
+ buttons |= (pMse->lastButtons & ~0x07);
+ dx = dy = 0;
+ dz = 0;
+ break;
+ }
+ } else {
+ buttons |= (pMse->lastButtons & ~0x07);
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ }
+ break;
+
+ case PROT_GLIDEPS2: /* GlidePoint PS/2 */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2 | /* Left */
+ ((pBuf[0] & 0x08) ? 0 : 0x08);/* fourth button */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ break;
+
+ case PROT_NETSCPS2: /* NetScroll PS/2 */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2 | /* Left */
+ ((pBuf[3] & 0x02) ? 0x08 : 0) | /* button 4 */
+ ((pBuf[3] & 0x01) ? 0x10 : 0); /* button 5 */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ dz = (pBuf[3] & 0x10) ? pBuf[4] - 256 : pBuf[4];
+ break;
+
+ case PROT_THINKPS2: /* ThinkingMouse PS/2 */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2 | /* Left */
+ ((pBuf[0] & 0x08) ? 0x08 : 0);/* fourth button */
+ pBuf[1] |= (pBuf[0] & 0x40) ? 0x80 : 0x00;
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ break;
+
+ case PROT_SYSMOUSE: /* sysmouse */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]);
+ dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4]));
+ /* FreeBSD sysmouse sends additional data bytes */
+ if (pMse->protoPara[4] >= 8) {
+ /*
+ * These casts must be 'signed char' for platforms (like PPC)
+ * where char defaults to unsigned.
+ */
+ dz = ((signed char)(pBuf[5] << 1) +
+ (signed char)(pBuf[6] << 1)) >> 1;
+ buttons |= (int)(~pBuf[7] & 0x7f) << 3;
+ }
+ break;
+
+ case PROT_VALUMOUSESCROLL: /* Kensington ValuMouseScroll */
buttons = ((int)(pBuf[0] & 0x20) >> 3)
| ((int)(pBuf[0] & 0x10) >> 4)
| ((int)(pBuf[3] & 0x10) >> 3);
dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
- dz = (pBuf[3] & 0x08) ? ((int)(pBuf[3] & 0x0F) - 0x10) :
+ dz = (pBuf[3] & 0x08) ? ((int)(pBuf[3] & 0x0F) - 0x10) :
((int)(pBuf[3] & 0x0F));
- break;
+ break;
- default: /* There's a table error */
+ default: /* There's a table error */
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse table error\n");
+ ErrorF("mouse table error\n");
#endif
- continue;
- }
+ continue;
+ }
#ifdef EXTMOUSEDEBUG
- ErrorF("packet");
- for ( j=0; j < pBufP; j++)
- ErrorF(" %02x",pBuf[j]);
- ErrorF("\n");
+ ErrorF("packet");
+ for ( j=0; j < pBufP; j++)
+ ErrorF(" %02x",pBuf[j]);
+ ErrorF("\n");
#endif
post_event:
#ifdef EXTMOUSEDEBUG
- ErrorF("dx=%i dy=%i dz=%i dw=%i buttons=%x\n",dx,dy,dz,dw,buttons);
+ ErrorF("dx=%i dy=%i dz=%i dw=%i buttons=%x\n",dx,dy,dz,dw,buttons);
#endif
- /* When auto-probing check if data makes sense */
- if (pMse->checkMovements && pMse->autoProbe)
- pMse->checkMovements(pInfo,dx,dy);
- /* post an event */
- pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
-
- /*
- * We don't reset pBufP here yet, as there may be an additional data
- * byte in some protocols. See above.
- */
+ /* When auto-probing check if data makes sense */
+ if (pMse->checkMovements && pMse->autoProbe)
+ pMse->checkMovements(pInfo,dx,dy);
+ /* post an event */
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+
+ /*
+ * We don't reset pBufP here yet, as there may be an additional data
+ * byte in some protocols. See above.
+ */
}
pMse->protoBufTail = pBufP;
}
@@ -1685,13 +1685,13 @@ MouseProc(DeviceIntPtr device, int what)
switch (what)
{
case DEVICE_INIT:
- device->public.on = FALSE;
- /*
- * [KAZU-241097] We don't know exactly how many buttons the
- * device has, so setup the map with the maximum number.
- */
- for (i = 0; i < MSE_MAXBUTTONS; i++)
- map[i + 1] = i + 1;
+ device->public.on = FALSE;
+ /*
+ * [KAZU-241097] We don't know exactly how many buttons the
+ * device has, so setup the map with the maximum number.
+ */
+ for (i = 0; i < MSE_MAXBUTTONS; i++)
+ map[i + 1] = i + 1;
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
MouseInitButtonLabels(btn_labels);
@@ -1699,8 +1699,8 @@ MouseProc(DeviceIntPtr device, int what)
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
#endif
- InitPointerDeviceStruct((DevicePtr)device, map,
- min(pMse->buttons, MSE_MAXBUTTONS),
+ InitPointerDeviceStruct((DevicePtr)device, map,
+ min(pMse->buttons, MSE_MAXBUTTONS),
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
btn_labels,
#endif
@@ -1711,8 +1711,8 @@ MouseProc(DeviceIntPtr device, int what)
#endif
);
- /* X valuator */
- xf86InitValuatorAxisStruct(device, 0,
+ /* X valuator */
+ xf86InitValuatorAxisStruct(device, 0,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
axes_labels[0],
#endif
@@ -1721,9 +1721,9 @@ MouseProc(DeviceIntPtr device, int what)
, Relative
#endif
);
- xf86InitValuatorDefaults(device, 0);
- /* Y valuator */
- xf86InitValuatorAxisStruct(device, 1,
+ xf86InitValuatorDefaults(device, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(device, 1,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
axes_labels[1],
#endif
@@ -1732,93 +1732,93 @@ MouseProc(DeviceIntPtr device, int what)
, Relative
#endif
);
- xf86InitValuatorDefaults(device, 1);
+ xf86InitValuatorDefaults(device, 1);
#ifdef EXTMOUSEDEBUG
- ErrorF("assigning %p atom=%d name=%s\n", device, pInfo->atom,
- pInfo->name);
+ ErrorF("assigning %p atom=%d name=%s\n", device, pInfo->atom,
+ pInfo->name);
#endif
- MouseInitProperties(device);
- break;
+ MouseInitProperties(device);
+ break;
case DEVICE_ON:
- pInfo->fd = xf86OpenSerial(pInfo->options);
- if (pInfo->fd == -1)
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
- if (pMse->xisbscale)
- pMse->buffer = XisbNew(pInfo->fd, pMse->xisbscale * 4);
- else
- pMse->buffer = XisbNew(pInfo->fd, 64);
- if (!pMse->buffer) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- } else {
- if (!SetupMouse(pInfo)) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- XisbFree(pMse->buffer);
- pMse->buffer = NULL;
- } else {
- mPriv = (mousePrivPtr)pMse->mousePriv;
- if (mPriv != NULL) {
- if ( pMse->protocolID != PROT_AUTO) {
- pMse->inSync = TRUE; /* @@@ */
- if (mPriv->soft)
- mPriv->autoState = AUTOPROBE_GOOD;
- else
- mPriv->autoState = AUTOPROBE_H_GOOD;
- } else {
- if (mPriv->soft)
- mPriv->autoState = AUTOPROBE_NOPROTO;
- else
- mPriv->autoState = AUTOPROBE_H_NOPROTO;
- }
- }
- xf86FlushInput(pInfo->fd);
- xf86AddEnabledDevice(pInfo);
- if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) {
- RegisterBlockAndWakeupHandlers (MouseBlockHandler,
- MouseWakeupHandler,
- (pointer) pInfo);
- }
- }
- }
- }
- pMse->lastButtons = 0;
- pMse->lastMappedButtons = 0;
- pMse->emulateState = 0;
- pMse->emulate3Pending = FALSE;
- pMse->wheelButtonExpires = GetTimeInMillis ();
- device->public.on = TRUE;
- FlushButtons(pMse);
- break;
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ if (pMse->xisbscale)
+ pMse->buffer = XisbNew(pInfo->fd, pMse->xisbscale * 4);
+ else
+ pMse->buffer = XisbNew(pInfo->fd, 64);
+ if (!pMse->buffer) {
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ } else {
+ if (!SetupMouse(pInfo)) {
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ XisbFree(pMse->buffer);
+ pMse->buffer = NULL;
+ } else {
+ mPriv = (mousePrivPtr)pMse->mousePriv;
+ if (mPriv != NULL) {
+ if ( pMse->protocolID != PROT_AUTO) {
+ pMse->inSync = TRUE; /* @@@ */
+ if (mPriv->soft)
+ mPriv->autoState = AUTOPROBE_GOOD;
+ else
+ mPriv->autoState = AUTOPROBE_H_GOOD;
+ } else {
+ if (mPriv->soft)
+ mPriv->autoState = AUTOPROBE_NOPROTO;
+ else
+ mPriv->autoState = AUTOPROBE_H_NOPROTO;
+ }
+ }
+ xf86FlushInput(pInfo->fd);
+ xf86AddEnabledDevice(pInfo);
+ if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) {
+ RegisterBlockAndWakeupHandlers (MouseBlockHandler,
+ MouseWakeupHandler,
+ (pointer) pInfo);
+ }
+ }
+ }
+ }
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pMse->emulate3Pending = FALSE;
+ pMse->wheelButtonExpires = GetTimeInMillis ();
+ device->public.on = TRUE;
+ FlushButtons(pMse);
+ break;
case DEVICE_OFF:
- if (pInfo->fd != -1) {
- xf86RemoveEnabledDevice(pInfo);
- if (pMse->buffer) {
- XisbFree(pMse->buffer);
- pMse->buffer = NULL;
- }
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
- {
- RemoveBlockAndWakeupHandlers (MouseBlockHandler,
- MouseWakeupHandler,
- (pointer) pInfo);
- }
- }
- device->public.on = FALSE;
- break;
+ if (pInfo->fd != -1) {
+ xf86RemoveEnabledDevice(pInfo);
+ if (pMse->buffer) {
+ XisbFree(pMse->buffer);
+ pMse->buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
+ {
+ RemoveBlockAndWakeupHandlers (MouseBlockHandler,
+ MouseWakeupHandler,
+ (pointer) pInfo);
+ }
+ }
+ device->public.on = FALSE;
+ break;
case DEVICE_CLOSE:
- free(pMse->mousePriv);
- pMse->mousePriv = NULL;
- break;
+ free(pMse->mousePriv);
+ pMse->mousePriv = NULL;
+ break;
default:
- return BadValue;
+ return BadValue;
}
return Success;
}
@@ -1991,22 +1991,22 @@ static signed char stateTab[11][5][3] = {
* 0 | 4th | 3rd | 2nd | 1st
*/
static char reverseMap[16] = { 0, 4, 2, 6,
- 1, 5, 3, 7,
- 8, 12, 10, 14,
- 9, 13, 11, 15 };
+ 1, 5, 3, 7,
+ 8, 12, 10, 14,
+ 9, 13, 11, 15 };
static char hitachMap[16] = { 0, 2, 1, 3,
- 8, 10, 9, 11,
- 4, 6, 5, 7,
- 12, 14, 13, 15 };
+ 8, 10, 9, 11,
+ 4, 6, 5, 7,
+ 12, 14, 13, 15 };
-#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
+#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
static CARD32
buttonTimer(InputInfoPtr pInfo)
{
MouseDevPtr pMse;
- int sigstate;
+ int sigstate;
int id;
pMse = pInfo->private;
@@ -2057,7 +2057,7 @@ Emulate3ButtonsSoft(InputInfoPtr pInfo)
MouseDevPtr pMse = pInfo->private;
if (!pMse->emulate3ButtonsSoft)
- return TRUE;
+ return TRUE;
xf86Msg(X_INFO,"3rd Button detected: disabling emulate3Button\n");
@@ -2067,35 +2067,35 @@ Emulate3ButtonsSoft(InputInfoPtr pInfo)
}
static void MouseBlockHandler(pointer data,
- struct timeval **waitTime,
- pointer LastSelectMask)
+ struct timeval **waitTime,
+ pointer LastSelectMask)
{
InputInfoPtr pInfo = (InputInfoPtr) data;
- MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
- int ms;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ int ms;
if (pMse->emulate3Pending)
{
- ms = pMse->emulate3Expires - GetTimeInMillis ();
- if (ms <= 0)
- ms = 0;
- AdjustWaitForDelay (waitTime, ms);
+ ms = pMse->emulate3Expires - GetTimeInMillis ();
+ if (ms <= 0)
+ ms = 0;
+ AdjustWaitForDelay (waitTime, ms);
}
}
static void MouseWakeupHandler(pointer data,
- int i,
- pointer LastSelectMask)
+ int i,
+ pointer LastSelectMask)
{
InputInfoPtr pInfo = (InputInfoPtr) data;
- MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
- int ms;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ int ms;
if (pMse->emulate3Pending)
{
- ms = pMse->emulate3Expires - GetTimeInMillis ();
- if (ms <= 0)
- buttonTimer (pInfo);
+ ms = pMse->emulate3Expires - GetTimeInMillis ();
+ if (ms <= 0)
+ buttonTimer (pInfo);
}
}
@@ -2148,180 +2148,180 @@ MouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy)
}
if (pMse->emulateWheel) {
- /* Emulate wheel button handling */
- if(pMse->wheelButton == 0)
- wheelButtonMask = 0;
- else
- wheelButtonMask = 1 << (pMse->wheelButton - 1);
-
- if (change & wheelButtonMask) {
- if (buttons & wheelButtonMask) {
- /* Start timeout handling */
- pMse->wheelButtonExpires = GetTimeInMillis () + pMse->wheelButtonTimeout;
- ms = - pMse->wheelButtonTimeout;
- } else {
- ms = pMse->wheelButtonExpires - GetTimeInMillis ();
-
- if (0 < ms) {
- /*
- * If the button is released early enough emit the button
- * press/release events
- */
- xf86PostButtonEvent(pInfo->dev, 0, pMse->wheelButton, 1, 0, 0);
- xf86PostButtonEvent(pInfo->dev, 0, pMse->wheelButton, 0, 0, 0);
- }
- }
- } else
- ms = pMse->wheelButtonExpires - GetTimeInMillis ();
-
- /* Intercept wheel emulation if the necessary button is depressed or
+ /* Emulate wheel button handling */
+ if(pMse->wheelButton == 0)
+ wheelButtonMask = 0;
+ else
+ wheelButtonMask = 1 << (pMse->wheelButton - 1);
+
+ if (change & wheelButtonMask) {
+ if (buttons & wheelButtonMask) {
+ /* Start timeout handling */
+ pMse->wheelButtonExpires = GetTimeInMillis () + pMse->wheelButtonTimeout;
+ ms = - pMse->wheelButtonTimeout;
+ } else {
+ ms = pMse->wheelButtonExpires - GetTimeInMillis ();
+
+ if (0 < ms) {
+ /*
+ * If the button is released early enough emit the button
+ * press/release events
+ */
+ xf86PostButtonEvent(pInfo->dev, 0, pMse->wheelButton, 1, 0, 0);
+ xf86PostButtonEvent(pInfo->dev, 0, pMse->wheelButton, 0, 0, 0);
+ }
+ }
+ } else
+ ms = pMse->wheelButtonExpires - GetTimeInMillis ();
+
+ /* Intercept wheel emulation if the necessary button is depressed or
if no button is necessary */
- if ((buttons & wheelButtonMask) || wheelButtonMask==0) {
- if (ms <= 0 || wheelButtonMask==0) {
- /* Y axis movement */
- if (pMse->negativeY != MSE_NOAXISMAP) {
- pMse->wheelYDistance += dy;
- if (pMse->wheelYDistance < 0) {
- emuWheelDelta = -pMse->wheelInertia;
- emuWheelButton = pMse->negativeY;
- } else {
- emuWheelDelta = pMse->wheelInertia;
- emuWheelButton = pMse->positiveY;
- }
- emuWheelButtonMask = 1 << (emuWheelButton - 1);
- while (abs(pMse->wheelYDistance) > pMse->wheelInertia) {
- pMse->wheelYDistance -= emuWheelDelta;
-
- pMse->wheelXDistance = 0;
- /*
- * Synthesize the press and release, but not when
- * the button to be synthesized is already pressed
- * "for real".
- */
- if (!(emuWheelButtonMask & buttons) ||
- (emuWheelButtonMask & wheelButtonMask)) {
- xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 1, 0, 0);
- xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 0, 0, 0);
- }
- }
- }
-
- /* X axis movement */
- if (pMse->negativeX != MSE_NOAXISMAP) {
- pMse->wheelXDistance += dx;
- if (pMse->wheelXDistance < 0) {
- emuWheelDelta = -pMse->wheelInertia;
- emuWheelButton = pMse->negativeX;
- } else {
- emuWheelDelta = pMse->wheelInertia;
- emuWheelButton = pMse->positiveX;
- }
- emuWheelButtonMask = 1 << (emuWheelButton - 1);
- while (abs(pMse->wheelXDistance) > pMse->wheelInertia) {
- pMse->wheelXDistance -= emuWheelDelta;
-
- pMse->wheelYDistance = 0;
- /*
- * Synthesize the press and release, but not when
- * the button to be synthesized is already pressed
- * "for real".
- */
- if (!(emuWheelButtonMask & buttons) ||
- (emuWheelButtonMask & wheelButtonMask)) {
- xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 1, 0, 0);
- xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 0, 0, 0);
- }
- }
- }
- }
-
- /* Absorb the mouse movement while the wheel button is pressed. */
- dx = 0;
- dy = 0;
- }
- /*
- * Button events for the wheel button are only emitted through
- * the timeout code.
- */
- buttons &= ~wheelButtonMask;
- change &= ~wheelButtonMask;
+ if ((buttons & wheelButtonMask) || wheelButtonMask==0) {
+ if (ms <= 0 || wheelButtonMask==0) {
+ /* Y axis movement */
+ if (pMse->negativeY != MSE_NOAXISMAP) {
+ pMse->wheelYDistance += dy;
+ if (pMse->wheelYDistance < 0) {
+ emuWheelDelta = -pMse->wheelInertia;
+ emuWheelButton = pMse->negativeY;
+ } else {
+ emuWheelDelta = pMse->wheelInertia;
+ emuWheelButton = pMse->positiveY;
+ }
+ emuWheelButtonMask = 1 << (emuWheelButton - 1);
+ while (abs(pMse->wheelYDistance) > pMse->wheelInertia) {
+ pMse->wheelYDistance -= emuWheelDelta;
+
+ pMse->wheelXDistance = 0;
+ /*
+ * Synthesize the press and release, but not when
+ * the button to be synthesized is already pressed
+ * "for real".
+ */
+ if (!(emuWheelButtonMask & buttons) ||
+ (emuWheelButtonMask & wheelButtonMask)) {
+ xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 1, 0, 0);
+ xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 0, 0, 0);
+ }
+ }
+ }
+
+ /* X axis movement */
+ if (pMse->negativeX != MSE_NOAXISMAP) {
+ pMse->wheelXDistance += dx;
+ if (pMse->wheelXDistance < 0) {
+ emuWheelDelta = -pMse->wheelInertia;
+ emuWheelButton = pMse->negativeX;
+ } else {
+ emuWheelDelta = pMse->wheelInertia;
+ emuWheelButton = pMse->positiveX;
+ }
+ emuWheelButtonMask = 1 << (emuWheelButton - 1);
+ while (abs(pMse->wheelXDistance) > pMse->wheelInertia) {
+ pMse->wheelXDistance -= emuWheelDelta;
+
+ pMse->wheelYDistance = 0;
+ /*
+ * Synthesize the press and release, but not when
+ * the button to be synthesized is already pressed
+ * "for real".
+ */
+ if (!(emuWheelButtonMask & buttons) ||
+ (emuWheelButtonMask & wheelButtonMask)) {
+ xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 1, 0, 0);
+ xf86PostButtonEvent(pInfo->dev, 0, emuWheelButton, 0, 0, 0);
+ }
+ }
+ }
+ }
+
+ /* Absorb the mouse movement while the wheel button is pressed. */
+ dx = 0;
+ dy = 0;
+ }
+ /*
+ * Button events for the wheel button are only emitted through
+ * the timeout code.
+ */
+ buttons &= ~wheelButtonMask;
+ change &= ~wheelButtonMask;
}
if (pMse->emulate3ButtonsSoft && pMse->emulate3Pending && (dx || dy))
- buttonTimer(pInfo);
+ buttonTimer(pInfo);
if (dx || dy)
- xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy);
+ xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy);
if (change) {
- /*
- * adjust buttons state for drag locks!
- * if there is drag locks
- */
+ /*
+ * adjust buttons state for drag locks!
+ * if there is drag locks
+ */
if (pMse->pDragLock) {
- DragLockPtr pLock;
- int tarOfGoingDown, tarOfDown;
- int realbuttons;
+ DragLockPtr pLock;
+ int tarOfGoingDown, tarOfDown;
+ int realbuttons;
- /* get drag lock block */
- pLock = pMse->pDragLock;
- /* save real buttons */
- realbuttons = buttons;
+ /* get drag lock block */
+ pLock = pMse->pDragLock;
+ /* save real buttons */
+ realbuttons = buttons;
- /* if drag lock used */
+ /* if drag lock used */
- /* state of drag lock buttons not seen always up */
+ /* state of drag lock buttons not seen always up */
- buttons &= ~pLock->lockButtonsM;
+ buttons &= ~pLock->lockButtonsM;
- /*
- * if lock buttons being depressed changes state of
- * targets simulatedDown.
- */
- tarOfGoingDown = lock2targetMap(pLock,
- realbuttons & change & pLock->lockButtonsM);
- pLock->simulatedDown ^= tarOfGoingDown;
+ /*
+ * if lock buttons being depressed changes state of
+ * targets simulatedDown.
+ */
+ tarOfGoingDown = lock2targetMap(pLock,
+ realbuttons & change & pLock->lockButtonsM);
+ pLock->simulatedDown ^= tarOfGoingDown;
- /* targets of drag locks down */
- tarOfDown = lock2targetMap(pLock,
- realbuttons & pLock->lockButtonsM);
+ /* targets of drag locks down */
+ tarOfDown = lock2targetMap(pLock,
+ realbuttons & pLock->lockButtonsM);
- /*
- * when simulatedDown set and target pressed,
- * simulatedDown goes false
- */
- pLock->simulatedDown &= ~(realbuttons & change);
+ /*
+ * when simulatedDown set and target pressed,
+ * simulatedDown goes false
+ */
+ pLock->simulatedDown &= ~(realbuttons & change);
- /*
- * if master drag lock released
- * then master drag lock state on
- */
- pLock->masterTS |= (~realbuttons & change) & pLock->masterLockM;
+ /*
+ * if master drag lock released
+ * then master drag lock state on
+ */
+ pLock->masterTS |= (~realbuttons & change) & pLock->masterLockM;
- /* if master state, buttons going down are simulatedDown */
- if (pLock->masterTS)
- pLock->simulatedDown |= (realbuttons & change);
+ /* if master state, buttons going down are simulatedDown */
+ if (pLock->masterTS)
+ pLock->simulatedDown |= (realbuttons & change);
- /* if any button pressed, no longer in master drag lock state */
- if (realbuttons & change)
- pLock->masterTS = 0;
+ /* if any button pressed, no longer in master drag lock state */
+ if (realbuttons & change)
+ pLock->masterTS = 0;
- /* if simulatedDown or drag lock down, simulate down */
- buttons |= (pLock->simulatedDown | tarOfDown);
+ /* if simulatedDown or drag lock down, simulate down */
+ buttons |= (pLock->simulatedDown | tarOfDown);
- /* master button not seen */
- buttons &= ~(pLock->masterLockM);
+ /* master button not seen */
+ buttons &= ~(pLock->masterLockM);
- /* buttons changed since last time */
- change = buttons ^ pLock->lockLastButtons;
+ /* buttons changed since last time */
+ change = buttons ^ pLock->lockLastButtons;
- /* save this time for next last time. */
- pLock->lockLastButtons = buttons;
- }
+ /* save this time for next last time. */
+ pLock->lockLastButtons = buttons;
+ }
if (pMse->emulate3Buttons
- && (!(buttons & 0x02) || Emulate3ButtonsSoft(pInfo))) {
+ && (!(buttons & 0x02) || Emulate3ButtonsSoft(pInfo))) {
/* handle all but buttons 1 & 3 normally */
@@ -2340,26 +2340,26 @@ MouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy)
stateTab[pMse->emulateState][emulateButtons][2];
if (stateTab[pMse->emulateState][4][0] != 0) {
- pMse->emulate3Expires = GetTimeInMillis () + pMse->emulate3Timeout;
- pMse->emulate3Pending = TRUE;
+ pMse->emulate3Expires = GetTimeInMillis () + pMse->emulate3Timeout;
+ pMse->emulate3Pending = TRUE;
} else {
- pMse->emulate3Pending = FALSE;
+ pMse->emulate3Pending = FALSE;
}
}
- while (change) {
- id = ffs(change);
- change &= ~(1 << (id - 1));
- xf86PostButtonEvent(pInfo->dev, 0, id,
- (buttons & (1 << (id - 1))), 0, 0);
- }
+ while (change) {
+ id = ffs(change);
+ change &= ~(1 << (id - 1));
+ xf86PostButtonEvent(pInfo->dev, 0, id,
+ (buttons & (1 << (id - 1))), 0, 0);
+ }
}
}
static void
MousePostEvent(InputInfoPtr pInfo, int truebuttons,
- int dx, int dy, int dz, int dw)
+ int dx, int dy, int dz, int dw)
{
MouseDevPtr pMse;
mousePrivPtr mousepriv;
@@ -2370,114 +2370,114 @@ MousePostEvent(InputInfoPtr pInfo, int truebuttons,
mousepriv = (mousePrivPtr)pMse->mousePriv;
if (pMse->protocolID == PROT_MMHIT)
- b = reverseBits(hitachMap, truebuttons);
+ b = reverseBits(hitachMap, truebuttons);
else
- b = reverseBits(reverseMap, truebuttons);
+ b = reverseBits(reverseMap, truebuttons);
/* Remap mouse buttons */
b &= (1<<MSE_MAXBUTTONS)-1;
for (i = 0; b; i++) {
if (b & 1)
- buttons |= pMse->buttonMap[i];
+ buttons |= pMse->buttonMap[i];
b >>= 1;
}
/* Map the Z axis movement. */
/* XXX Could this go in the conversion_proc? */
switch (pMse->negativeZ) {
- case MSE_NOZMAP: /* do nothing */
- dz = 0;
- break;
+ case MSE_NOZMAP: /* do nothing */
+ dz = 0;
+ break;
case MSE_MAPTOX:
- if (dz != 0) {
- dx = dz;
- dz = 0;
- }
- break;
+ if (dz != 0) {
+ dx = dz;
+ dz = 0;
+ }
+ break;
case MSE_MAPTOY:
- if (dz != 0) {
- dy = dz;
- dz = 0;
- }
- break;
- default: /* buttons */
- buttons &= ~(pMse->negativeZ | pMse->positiveZ);
- if (dz < 0) {
- zbutton = pMse->negativeZ;
- zbuttoncount = -dz;
- } else if (dz > 0) {
- zbutton = pMse->positiveZ;
- zbuttoncount = dz;
- }
- dz = 0;
- break;
+ if (dz != 0) {
+ dy = dz;
+ dz = 0;
+ }
+ break;
+ default: /* buttons */
+ buttons &= ~(pMse->negativeZ | pMse->positiveZ);
+ if (dz < 0) {
+ zbutton = pMse->negativeZ;
+ zbuttoncount = -dz;
+ } else if (dz > 0) {
+ zbutton = pMse->positiveZ;
+ zbuttoncount = dz;
+ }
+ dz = 0;
+ break;
}
switch (pMse->negativeW) {
- case MSE_NOZMAP: /* do nothing */
- dw = 0;
- break;
+ case MSE_NOZMAP: /* do nothing */
+ dw = 0;
+ break;
case MSE_MAPTOX:
- if (dw != 0) {
- dx = dw;
- dw = 0;
- }
- break;
+ if (dw != 0) {
+ dx = dw;
+ dw = 0;
+ }
+ break;
case MSE_MAPTOY:
- if (dw != 0) {
- dy = dw;
- dw = 0;
- }
- break;
- default: /* buttons */
- buttons &= ~(pMse->negativeW | pMse->positiveW);
- if (dw < 0) {
- wbutton = pMse->negativeW;
- wbuttoncount = -dw;
- } else if (dw > 0) {
- wbutton = pMse->positiveW;
- wbuttoncount = dw;
- }
- dw = 0;
- break;
+ if (dw != 0) {
+ dy = dw;
+ dw = 0;
+ }
+ break;
+ default: /* buttons */
+ buttons &= ~(pMse->negativeW | pMse->positiveW);
+ if (dw < 0) {
+ wbutton = pMse->negativeW;
+ wbuttoncount = -dw;
+ } else if (dw > 0) {
+ wbutton = pMse->positiveW;
+ wbuttoncount = dw;
+ }
+ dw = 0;
+ break;
}
/* Apply angle offset */
if (pMse->angleOffset != 0) {
- double rad = 3.141592653 * pMse->angleOffset / 180.0;
- int ndx = dx;
- dx = (int)((dx * cos(rad)) + (dy * sin(rad)) + 0.5);
- dy = (int)((dy * cos(rad)) - (ndx * sin(rad)) + 0.5);
+ double rad = 3.141592653 * pMse->angleOffset / 180.0;
+ int ndx = dx;
+ dx = (int)((dx * cos(rad)) + (dy * sin(rad)) + 0.5);
+ dy = (int)((dy * cos(rad)) - (ndx * sin(rad)) + 0.5);
}
dx = pMse->invX * dx;
dy = pMse->invY * dy;
if (pMse->flipXY) {
- int tmp = dx;
- dx = dy;
- dy = tmp;
+ int tmp = dx;
+ dx = dy;
+ dy = tmp;
}
/* Accumulate the scaled dx, dy in the private variables
fracdx,fracdy and return the integer number part */
if (mousepriv) {
- mousepriv->fracdx += mousepriv->sensitivity*dx;
- mousepriv->fracdy += mousepriv->sensitivity*dy;
- mousepriv->fracdx -= ( dx=(int)(mousepriv->fracdx) );
- mousepriv->fracdy -= ( dy=(int)(mousepriv->fracdy) );
+ mousepriv->fracdx += mousepriv->sensitivity*dx;
+ mousepriv->fracdy += mousepriv->sensitivity*dy;
+ mousepriv->fracdx -= ( dx=(int)(mousepriv->fracdx) );
+ mousepriv->fracdy -= ( dy=(int)(mousepriv->fracdy) );
}
/* If mouse wheel movement has to be mapped on a button, we need to
* loop for button press and release events. */
do {
MouseDoPostEvent(pInfo, buttons | zbutton | wbutton, dx, dy);
- dx = dy = 0;
- if (zbutton || wbutton)
- MouseDoPostEvent(pInfo, buttons, 0, 0);
- if (--zbuttoncount <= 0)
- zbutton = 0;
- if (--wbuttoncount <= 0)
- wbutton = 0;
+ dx = dy = 0;
+ if (zbutton || wbutton)
+ MouseDoPostEvent(pInfo, buttons, 0, 0);
+ if (--zbuttoncount <= 0)
+ zbutton = 0;
+ if (--wbuttoncount <= 0)
+ wbutton = 0;
} while (zbutton || wbutton);
pMse->lastButtons = truebuttons;
@@ -2494,7 +2494,7 @@ MousePostEvent(InputInfoPtr pInfo, int truebuttons,
static unsigned char proto[PROT_NUMPROTOS][8] = {
/* --header-- ---data--- packet -4th-byte- mouse */
/* mask id mask id bytes mask id flags */
- /* Serial mice */
+ /* Serial mice */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x23, 0x00, MPF_NONE }, /* MicroSoft */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_SAFE }, /* MouseSystems */
{ 0xe0, 0x80, 0x80, 0x00, 3, 0x00, 0xff, MPF_NONE }, /* MMSeries */
@@ -2506,7 +2506,7 @@ static unsigned char proto[PROT_NUMPROTOS][8] = {
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00, MPF_NONE }, /* ThinkingMouse */
{ 0x80, 0x80, 0x80, 0x00, 3, 0x00, 0xff, MPF_NONE }, /* ACECAD */
{ 0x40, 0x40, 0x40, 0x00, 4, 0x00, 0xff, MPF_NONE }, /* ValuMouseScroll */
- /* PS/2 variants */
+ /* PS/2 variants */
{ 0xc0, 0x00, 0x00, 0x00, 3, 0x00, 0xff, MPF_NONE }, /* PS/2 mouse */
{ 0xc8, 0x08, 0x00, 0x00, 3, 0x00, 0x00, MPF_NONE }, /* genericPS/2 mouse*/
{ 0x08, 0x08, 0x00, 0x00, 4, 0x00, 0xff, MPF_NONE }, /* IntelliMouse */
@@ -2516,7 +2516,7 @@ static unsigned char proto[PROT_NUMPROTOS][8] = {
{ 0xc0, 0x00, 0x00, 0x00, 3, 0x00, 0xff, MPF_NONE }, /* GlidePoint */
{ 0x08, 0x08, 0x00, 0x00, 4, 0x00, 0xff, MPF_NONE }, /* NetMouse */
{ 0xc0, 0x00, 0x00, 0x00, 6, 0x00, 0xff, MPF_NONE }, /* NetScroll */
- /* Bus Mouse */
+ /* Bus Mouse */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* BusMouse */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* Auto (dummy) */
{ 0xf8, 0x80, 0x00, 0x00, 8, 0x00, 0xff, MPF_NONE }, /* SysMouse */
@@ -2525,7 +2525,7 @@ static unsigned char proto[PROT_NUMPROTOS][8] = {
/*
* SetupMouse --
- * Sets up the mouse parameters
+ * Sets up the mouse parameters
*/
static Bool
SetupMouse(InputInfoPtr pInfo)
@@ -2540,35 +2540,35 @@ SetupMouse(InputInfoPtr pInfo)
/* Handle the "Auto" protocol. */
if (pMse->protocolID == PROT_AUTO) {
- /*
- * We come here when user specifies protocol "auto" in
- * the configuration file or thru the xf86misc extensions.
- * So we initialize autoprobing here.
- * Probe for PnP/OS mouse first. If unsuccessful
- * try to guess protocol from incoming data.
- */
- automatic = TRUE;
- pMse->autoProbe = TRUE;
- name = autoOSProtocol(pInfo,protoPara);
- if (name) {
+ /*
+ * We come here when user specifies protocol "auto" in
+ * the configuration file or thru the xf86misc extensions.
+ * So we initialize autoprobing here.
+ * Probe for PnP/OS mouse first. If unsuccessful
+ * try to guess protocol from incoming data.
+ */
+ automatic = TRUE;
+ pMse->autoProbe = TRUE;
+ name = autoOSProtocol(pInfo,protoPara);
+ if (name) {
#ifdef EXTMOUSEDEBUG
- ErrorF("PnP/OS Mouse detected: %s\n",name);
+ ErrorF("PnP/OS Mouse detected: %s\n",name);
#endif
- }
+ }
}
SetMouseProto(pMse, pMse->protocolID);
if (automatic) {
- if (name) {
- /* Possible protoPara overrides from SetupAuto. */
- for (i = 0; i < sizeof(pMse->protoPara); i++)
- if (protoPara[i] != -1)
- pMse->protoPara[i] = protoPara[i];
- /* if we come here PnP/OS mouse probing was successful */
- } else {
- /* PnP/OS mouse probing wasn't successful; we look at data */
- }
+ if (name) {
+ /* Possible protoPara overrides from SetupAuto. */
+ for (i = 0; i < sizeof(pMse->protoPara); i++)
+ if (protoPara[i] != -1)
+ pMse->protoPara[i] = protoPara[i];
+ /* if we come here PnP/OS mouse probing was successful */
+ } else {
+ /* PnP/OS mouse probing wasn't successful; we look at data */
+ }
}
/*
@@ -2576,30 +2576,30 @@ SetupMouse(InputInfoPtr pInfo)
* for the new protocol.
*/
if (pMse->oldProtocolID != pMse->protocolID) {
- if ((pMse->protocolID >= 0)
- && (pMse->protocolID < PROT_NUMPROTOS)
- && mouseProtocols[pMse->protocolID].defaults) {
- pointer tmp = xf86OptionListCreate(
- mouseProtocols[pMse->protocolID].defaults, -1, 0);
- pInfo->options = xf86OptionListMerge(pInfo->options, tmp);
- }
- /*
- * If baudrate is set write it back to the option
- * list so that the serial interface code can access
- * the new value. Not set means default.
- */
- if (pMse->baudRate)
- xf86ReplaceIntOption(pInfo->options, "BaudRate", pMse->baudRate);
- pMse->oldProtocolID = pMse->protocolID; /* hack */
+ if ((pMse->protocolID >= 0)
+ && (pMse->protocolID < PROT_NUMPROTOS)
+ && mouseProtocols[pMse->protocolID].defaults) {
+ pointer tmp = xf86OptionListCreate(
+ mouseProtocols[pMse->protocolID].defaults, -1, 0);
+ pInfo->options = xf86OptionListMerge(pInfo->options, tmp);
+ }
+ /*
+ * If baudrate is set write it back to the option
+ * list so that the serial interface code can access
+ * the new value. Not set means default.
+ */
+ if (pMse->baudRate)
+ xf86ReplaceIntOption(pInfo->options, "BaudRate", pMse->baudRate);
+ pMse->oldProtocolID = pMse->protocolID; /* hack */
}
/* Set the port parameters. */
if (!automatic)
- xf86SetSerial(pInfo->fd, pInfo->options);
+ xf86SetSerial(pInfo->fd, pInfo->options);
if (!initMouseHW(pInfo))
- return FALSE;
+ return FALSE;
pMse->protoBufTail = 0;
pMse->inSync = 0;
@@ -2635,8 +2635,8 @@ SetupMouse(InputInfoPtr pInfo)
** be sent at 1200 Baud.
** - each command starts with a '*'.
** - whenever the MouseMan receives a '*', it will switch back
-** to 1200 Baud. Hence I have to select the desired protocol
-** first, then select the baud rate.
+** to 1200 Baud. Hence I have to select the desired protocol
+** first, then select the baud rate.
**
** The protocols supported by the (European) MouseMan are:
** - 5 byte packed binary protocol, as with the Mouse Systems
@@ -2680,324 +2680,324 @@ initMouseHW(InputInfoPtr pInfo)
Bool ps2Init = TRUE;
switch (pMse->protocolID) {
- case PROT_LOGI: /* Logitech Mice */
- /*
- * The baud rate selection command must be sent at the current
- * baud rate; try all likely settings.
- */
- speed = pMse->baudRate;
- switch (speed) {
- case 9600:
- s = "*q";
- break;
- case 4800:
- s = "*p";
- break;
- case 2400:
- s = "*o";
- break;
- case 1200:
- s = "*n";
- break;
- default:
- /* Fallback value */
- speed = 1200;
- s = "*n";
- }
- xf86SetSerialSpeed(pInfo->fd, 9600);
- xf86WriteSerial(pInfo->fd, s, 2);
- usleep(100000);
- xf86SetSerialSpeed(pInfo->fd, 4800);
- xf86WriteSerial(pInfo->fd, s, 2);
- usleep(100000);
- xf86SetSerialSpeed(pInfo->fd, 2400);
- xf86WriteSerial(pInfo->fd, s, 2);
- usleep(100000);
- xf86SetSerialSpeed(pInfo->fd, 1200);
- xf86WriteSerial(pInfo->fd, s, 2);
- usleep(100000);
- xf86SetSerialSpeed(pInfo->fd, speed);
-
- /* Select MM series data format. */
- xf86WriteSerial(pInfo->fd, "S", 1);
- usleep(100000);
- /* Set the parameters up for the MM series protocol. */
- options = pInfo->options;
- COLLECT_INPUT_OPTIONS(pInfo, mmDefaults);
- xf86SetSerial(pInfo->fd, pInfo->options);
- pInfo->options = options;
-
- /* Select report rate/frequency. */
- if (pMse->sampleRate <= 0) c = 'O'; /* 100 */
- else if (pMse->sampleRate <= 15) c = 'J'; /* 10 */
- else if (pMse->sampleRate <= 27) c = 'K'; /* 20 */
- else if (pMse->sampleRate <= 42) c = 'L'; /* 35 */
- else if (pMse->sampleRate <= 60) c = 'R'; /* 50 */
- else if (pMse->sampleRate <= 85) c = 'M'; /* 67 */
- else if (pMse->sampleRate <= 125) c = 'Q'; /* 100 */
- else c = 'N'; /* 150 */
- xf86WriteSerial(pInfo->fd, &c, 1);
- break;
-
- case PROT_LOGIMAN:
- speed = pMse->baudRate;
- switch (speed) {
- case 9600:
- s = "*q";
- break;
- case 1200:
- s = "*n";
- break;
- default:
- /* Fallback value */
- speed = 1200;
- s = "*n";
- }
- xf86SetSerialSpeed(pInfo->fd, 1200);
- xf86WriteSerial(pInfo->fd, "*n", 2);
- xf86WriteSerial(pInfo->fd, "*X", 2);
- xf86WriteSerial(pInfo->fd, s, 2);
- usleep(100000);
- xf86SetSerialSpeed(pInfo->fd, speed);
- break;
-
- case PROT_MMHIT: /* MM_HitTablet */
- /*
- * Initialize Hitachi PUMA Plus - Model 1212E to desired settings.
- * The tablet must be configured to be in MM mode, NO parity,
- * Binary Format. pMse->sampleRate controls the sensitivity
- * of the tablet. We only use this tablet for it's 4-button puck
- * so we don't run in "Absolute Mode".
- */
- xf86WriteSerial(pInfo->fd, "z8", 2); /* Set Parity = "NONE" */
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "zb", 2); /* Set Format = "Binary" */
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "@", 1); /* Set Report Mode = "Stream" */
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "R", 1); /* Set Output Rate = "45 rps" */
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "I\x20", 2); /* Set Incrememtal Mode "20" */
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "E", 1); /* Set Data Type = "Relative */
- usleep(50000);
- /*
- * These sample rates translate to 'lines per inch' on the Hitachi
- * tablet.
- */
- if (pMse->sampleRate <= 40) c = 'g';
- else if (pMse->sampleRate <= 100) c = 'd';
- else if (pMse->sampleRate <= 200) c = 'e';
- else if (pMse->sampleRate <= 500) c = 'h';
- else if (pMse->sampleRate <= 1000) c = 'j';
- else c = 'd';
- xf86WriteSerial(pInfo->fd, &c, 1);
- usleep(50000);
- xf86WriteSerial(pInfo->fd, "\021", 1); /* Resume DATA output */
- break;
-
- case PROT_THINKING: /* ThinkingMouse */
- /* This mouse may send a PnP ID string, ignore it. */
- usleep(200000);
- xf86FlushInput(pInfo->fd);
- /* Send the command to initialize the beast. */
- for (s = "E5E5"; *s; ++s) {
- xf86WriteSerial(pInfo->fd, s, 1);
- if ((xf86WaitForInput(pInfo->fd, 1000000) <= 0))
- break;
- xf86ReadSerial(pInfo->fd, &c, 1);
- if (c != *s)
- break;
- }
- break;
-
- case PROT_MSC: /* MouseSystems Corp */
- usleep(100000);
- xf86FlushInput(pInfo->fd);
- break;
-
- case PROT_ACECAD:
- /* initialize */
- /* A nul character resets. */
- xf86WriteSerial(pInfo->fd, "", 1);
- usleep(50000);
- /* Stream out relative mode high resolution increments of 1. */
- xf86WriteSerial(pInfo->fd, "@EeI!", 5);
- break;
-
- case PROT_BM: /* bus/InPort mouse */
- if (osInfo->SetBMRes)
- osInfo->SetBMRes(pInfo, pMse->protocol, pMse->sampleRate,
- pMse->resolution);
- break;
-
- case PROT_GENPS2:
- ps2Init = FALSE;
- break;
-
- case PROT_PS2:
- case PROT_GLIDEPS2:
- break;
-
- case PROT_IMPS2: /* IntelliMouse */
- {
- static unsigned char seq[] = { 243, 200, 243, 100, 243, 80 };
- param = seq;
- paramlen = sizeof(seq);
- }
- break;
-
- case PROT_EXPPS2: /* IntelliMouse Explorer */
- {
- static unsigned char seq[] = { 243, 200, 243, 100, 243, 80,
- 243, 200, 243, 200, 243, 80 };
-
- param = seq;
- paramlen = sizeof(seq);
- }
- break;
-
- case PROT_NETPS2: /* NetMouse, NetMouse Pro, Mie Mouse */
- case PROT_NETSCPS2: /* NetScroll */
- {
- static unsigned char seq[] = { 232, 3, 230, 230, 230, 233 };
-
- param = seq;
- paramlen = sizeof(seq);
- }
- break;
-
- case PROT_MMPS2: /* MouseMan+, FirstMouse+ */
- {
- static unsigned char seq[] = { 230, 232, 0, 232, 3, 232, 2, 232, 1,
- 230, 232, 3, 232, 1, 232, 2, 232, 3 };
- param = seq;
- paramlen = sizeof(seq);
- }
- break;
-
- case PROT_THINKPS2: /* ThinkingMouse */
- {
- static unsigned char seq[] = { 243, 10, 232, 0, 243, 20, 243, 60,
- 243, 40, 243, 20, 243, 20, 243, 60,
- 243, 40, 243, 20, 243, 20 };
- param = seq;
- paramlen = sizeof(seq);
- }
- break;
- case PROT_SYSMOUSE:
- if (osInfo->SetMiscRes)
- osInfo->SetMiscRes(pInfo, pMse->protocol, pMse->sampleRate,
- pMse->resolution);
- break;
-
- default:
- /* Nothing to do. */
- break;
+ case PROT_LOGI: /* Logitech Mice */
+ /*
+ * The baud rate selection command must be sent at the current
+ * baud rate; try all likely settings.
+ */
+ speed = pMse->baudRate;
+ switch (speed) {
+ case 9600:
+ s = "*q";
+ break;
+ case 4800:
+ s = "*p";
+ break;
+ case 2400:
+ s = "*o";
+ break;
+ case 1200:
+ s = "*n";
+ break;
+ default:
+ /* Fallback value */
+ speed = 1200;
+ s = "*n";
+ }
+ xf86SetSerialSpeed(pInfo->fd, 9600);
+ xf86WriteSerial(pInfo->fd, s, 2);
+ usleep(100000);
+ xf86SetSerialSpeed(pInfo->fd, 4800);
+ xf86WriteSerial(pInfo->fd, s, 2);
+ usleep(100000);
+ xf86SetSerialSpeed(pInfo->fd, 2400);
+ xf86WriteSerial(pInfo->fd, s, 2);
+ usleep(100000);
+ xf86SetSerialSpeed(pInfo->fd, 1200);
+ xf86WriteSerial(pInfo->fd, s, 2);
+ usleep(100000);
+ xf86SetSerialSpeed(pInfo->fd, speed);
+
+ /* Select MM series data format. */
+ xf86WriteSerial(pInfo->fd, "S", 1);
+ usleep(100000);
+ /* Set the parameters up for the MM series protocol. */
+ options = pInfo->options;
+ COLLECT_INPUT_OPTIONS(pInfo, mmDefaults);
+ xf86SetSerial(pInfo->fd, pInfo->options);
+ pInfo->options = options;
+
+ /* Select report rate/frequency. */
+ if (pMse->sampleRate <= 0) c = 'O'; /* 100 */
+ else if (pMse->sampleRate <= 15) c = 'J'; /* 10 */
+ else if (pMse->sampleRate <= 27) c = 'K'; /* 20 */
+ else if (pMse->sampleRate <= 42) c = 'L'; /* 35 */
+ else if (pMse->sampleRate <= 60) c = 'R'; /* 50 */
+ else if (pMse->sampleRate <= 85) c = 'M'; /* 67 */
+ else if (pMse->sampleRate <= 125) c = 'Q'; /* 100 */
+ else c = 'N'; /* 150 */
+ xf86WriteSerial(pInfo->fd, &c, 1);
+ break;
+
+ case PROT_LOGIMAN:
+ speed = pMse->baudRate;
+ switch (speed) {
+ case 9600:
+ s = "*q";
+ break;
+ case 1200:
+ s = "*n";
+ break;
+ default:
+ /* Fallback value */
+ speed = 1200;
+ s = "*n";
+ }
+ xf86SetSerialSpeed(pInfo->fd, 1200);
+ xf86WriteSerial(pInfo->fd, "*n", 2);
+ xf86WriteSerial(pInfo->fd, "*X", 2);
+ xf86WriteSerial(pInfo->fd, s, 2);
+ usleep(100000);
+ xf86SetSerialSpeed(pInfo->fd, speed);
+ break;
+
+ case PROT_MMHIT: /* MM_HitTablet */
+ /*
+ * Initialize Hitachi PUMA Plus - Model 1212E to desired settings.
+ * The tablet must be configured to be in MM mode, NO parity,
+ * Binary Format. pMse->sampleRate controls the sensitivity
+ * of the tablet. We only use this tablet for it's 4-button puck
+ * so we don't run in "Absolute Mode".
+ */
+ xf86WriteSerial(pInfo->fd, "z8", 2); /* Set Parity = "NONE" */
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "zb", 2); /* Set Format = "Binary" */
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "@", 1); /* Set Report Mode = "Stream" */
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "R", 1); /* Set Output Rate = "45 rps" */
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "I\x20", 2); /* Set Incrememtal Mode "20" */
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "E", 1); /* Set Data Type = "Relative */
+ usleep(50000);
+ /*
+ * These sample rates translate to 'lines per inch' on the Hitachi
+ * tablet.
+ */
+ if (pMse->sampleRate <= 40) c = 'g';
+ else if (pMse->sampleRate <= 100) c = 'd';
+ else if (pMse->sampleRate <= 200) c = 'e';
+ else if (pMse->sampleRate <= 500) c = 'h';
+ else if (pMse->sampleRate <= 1000) c = 'j';
+ else c = 'd';
+ xf86WriteSerial(pInfo->fd, &c, 1);
+ usleep(50000);
+ xf86WriteSerial(pInfo->fd, "\021", 1); /* Resume DATA output */
+ break;
+
+ case PROT_THINKING: /* ThinkingMouse */
+ /* This mouse may send a PnP ID string, ignore it. */
+ usleep(200000);
+ xf86FlushInput(pInfo->fd);
+ /* Send the command to initialize the beast. */
+ for (s = "E5E5"; *s; ++s) {
+ xf86WriteSerial(pInfo->fd, s, 1);
+ if ((xf86WaitForInput(pInfo->fd, 1000000) <= 0))
+ break;
+ xf86ReadSerial(pInfo->fd, &c, 1);
+ if (c != *s)
+ break;
+ }
+ break;
+
+ case PROT_MSC: /* MouseSystems Corp */
+ usleep(100000);
+ xf86FlushInput(pInfo->fd);
+ break;
+
+ case PROT_ACECAD:
+ /* initialize */
+ /* A nul character resets. */
+ xf86WriteSerial(pInfo->fd, "", 1);
+ usleep(50000);
+ /* Stream out relative mode high resolution increments of 1. */
+ xf86WriteSerial(pInfo->fd, "@EeI!", 5);
+ break;
+
+ case PROT_BM: /* bus/InPort mouse */
+ if (osInfo->SetBMRes)
+ osInfo->SetBMRes(pInfo, pMse->protocol, pMse->sampleRate,
+ pMse->resolution);
+ break;
+
+ case PROT_GENPS2:
+ ps2Init = FALSE;
+ break;
+
+ case PROT_PS2:
+ case PROT_GLIDEPS2:
+ break;
+
+ case PROT_IMPS2: /* IntelliMouse */
+ {
+ static unsigned char seq[] = { 243, 200, 243, 100, 243, 80 };
+ param = seq;
+ paramlen = sizeof(seq);
+ }
+ break;
+
+ case PROT_EXPPS2: /* IntelliMouse Explorer */
+ {
+ static unsigned char seq[] = { 243, 200, 243, 100, 243, 80,
+ 243, 200, 243, 200, 243, 80 };
+
+ param = seq;
+ paramlen = sizeof(seq);
+ }
+ break;
+
+ case PROT_NETPS2: /* NetMouse, NetMouse Pro, Mie Mouse */
+ case PROT_NETSCPS2: /* NetScroll */
+ {
+ static unsigned char seq[] = { 232, 3, 230, 230, 230, 233 };
+
+ param = seq;
+ paramlen = sizeof(seq);
+ }
+ break;
+
+ case PROT_MMPS2: /* MouseMan+, FirstMouse+ */
+ {
+ static unsigned char seq[] = { 230, 232, 0, 232, 3, 232, 2, 232, 1,
+ 230, 232, 3, 232, 1, 232, 2, 232, 3 };
+ param = seq;
+ paramlen = sizeof(seq);
+ }
+ break;
+
+ case PROT_THINKPS2: /* ThinkingMouse */
+ {
+ static unsigned char seq[] = { 243, 10, 232, 0, 243, 20, 243, 60,
+ 243, 40, 243, 20, 243, 20, 243, 60,
+ 243, 40, 243, 20, 243, 20 };
+ param = seq;
+ paramlen = sizeof(seq);
+ }
+ break;
+ case PROT_SYSMOUSE:
+ if (osInfo->SetMiscRes)
+ osInfo->SetMiscRes(pInfo, pMse->protocol, pMse->sampleRate,
+ pMse->resolution);
+ break;
+
+ default:
+ /* Nothing to do. */
+ break;
}
if (pMse->class & (MSE_PS2 | MSE_XPS2)) {
- /*
- * If one part of the PS/2 mouse initialization fails
- * redo complete initialization. There are mice which
- * have occasional problems with initialization and
- * are in an unknown state.
- */
- if (ps2Init) {
- REDO:
- do_ps2Reset(pInfo);
- if (paramlen > 0) {
- if (!ps2SendPacket(pInfo,param,paramlen)) {
- usleep(30000);
- xf86FlushInput(pInfo->fd);
- if (!count--)
- return TRUE;
- goto REDO;
- }
- ps2GetDeviceID(pInfo);
- usleep(30000);
- xf86FlushInput(pInfo->fd);
- }
-
- if (osInfo->SetPS2Res) {
- osInfo->SetPS2Res(pInfo, pMse->protocol, pMse->sampleRate,
- pMse->resolution);
- } else {
- unsigned char c2[2];
-
- c = 0xE6; /*230*/ /* 1:1 scaling */
- if (!ps2SendPacket(pInfo,&c,1)) {
- if (!count--)
- return TRUE;
- goto REDO;
- }
- c2[0] = 0xF3; /*243*/ /* set sampling rate */
- if (pMse->sampleRate > 0) {
- if (pMse->sampleRate >= 200)
- c2[1] = 200;
- else if (pMse->sampleRate >= 100)
- c2[1] = 100;
- else if (pMse->sampleRate >= 80)
- c2[1] = 80;
- else if (pMse->sampleRate >= 60)
- c2[1] = 60;
- else if (pMse->sampleRate >= 40)
- c2[1] = 40;
- else
- c2[1] = 20;
- } else {
- c2[1] = 100;
- }
- if (!ps2SendPacket(pInfo,c2,2)) {
- if (!count--)
- return TRUE;
- goto REDO;
- }
- c2[0] = 0xE8; /*232*/ /* set device resolution */
- if (pMse->resolution > 0) {
- if (pMse->resolution >= 200)
- c2[1] = 3;
- else if (pMse->resolution >= 100)
- c2[1] = 2;
- else if (pMse->resolution >= 50)
- c2[1] = 1;
- else
- c2[1] = 0;
- } else {
- c2[1] = 3; /* used to be 2, W. uses 3 */
- }
- if (!ps2SendPacket(pInfo,c2,2)) {
- if (!count--)
- return TRUE;
- goto REDO;
- }
- usleep(30000);
- xf86FlushInput(pInfo->fd);
- if (!ps2EnableDataReporting(pInfo)) {
- xf86Msg(X_INFO, "%s: ps2EnableDataReporting: failed\n",
- pInfo->name);
- xf86FlushInput(pInfo->fd);
- if (!count--)
- return TRUE;
- goto REDO;
- } else {
- xf86Msg(X_INFO, "%s: ps2EnableDataReporting: succeeded\n",
- pInfo->name);
- }
- }
- /*
- * The PS/2 reset handling needs to be rechecked.
- * We need to wait until after the 4.3 release.
- */
- }
+ /*
+ * If one part of the PS/2 mouse initialization fails
+ * redo complete initialization. There are mice which
+ * have occasional problems with initialization and
+ * are in an unknown state.
+ */
+ if (ps2Init) {
+ REDO:
+ do_ps2Reset(pInfo);
+ if (paramlen > 0) {
+ if (!ps2SendPacket(pInfo,param,paramlen)) {
+ usleep(30000);
+ xf86FlushInput(pInfo->fd);
+ if (!count--)
+ return TRUE;
+ goto REDO;
+ }
+ ps2GetDeviceID(pInfo);
+ usleep(30000);
+ xf86FlushInput(pInfo->fd);
+ }
+
+ if (osInfo->SetPS2Res) {
+ osInfo->SetPS2Res(pInfo, pMse->protocol, pMse->sampleRate,
+ pMse->resolution);
+ } else {
+ unsigned char c2[2];
+
+ c = 0xE6; /*230*/ /* 1:1 scaling */
+ if (!ps2SendPacket(pInfo,&c,1)) {
+ if (!count--)
+ return TRUE;
+ goto REDO;
+ }
+ c2[0] = 0xF3; /*243*/ /* set sampling rate */
+ if (pMse->sampleRate > 0) {
+ if (pMse->sampleRate >= 200)
+ c2[1] = 200;
+ else if (pMse->sampleRate >= 100)
+ c2[1] = 100;
+ else if (pMse->sampleRate >= 80)
+ c2[1] = 80;
+ else if (pMse->sampleRate >= 60)
+ c2[1] = 60;
+ else if (pMse->sampleRate >= 40)
+ c2[1] = 40;
+ else
+ c2[1] = 20;
+ } else {
+ c2[1] = 100;
+ }
+ if (!ps2SendPacket(pInfo,c2,2)) {
+ if (!count--)
+ return TRUE;
+ goto REDO;
+ }
+ c2[0] = 0xE8; /*232*/ /* set device resolution */
+ if (pMse->resolution > 0) {
+ if (pMse->resolution >= 200)
+ c2[1] = 3;
+ else if (pMse->resolution >= 100)
+ c2[1] = 2;
+ else if (pMse->resolution >= 50)
+ c2[1] = 1;
+ else
+ c2[1] = 0;
+ } else {
+ c2[1] = 3; /* used to be 2, W. uses 3 */
+ }
+ if (!ps2SendPacket(pInfo,c2,2)) {
+ if (!count--)
+ return TRUE;
+ goto REDO;
+ }
+ usleep(30000);
+ xf86FlushInput(pInfo->fd);
+ if (!ps2EnableDataReporting(pInfo)) {
+ xf86Msg(X_INFO, "%s: ps2EnableDataReporting: failed\n",
+ pInfo->name);
+ xf86FlushInput(pInfo->fd);
+ if (!count--)
+ return TRUE;
+ goto REDO;
+ } else {
+ xf86Msg(X_INFO, "%s: ps2EnableDataReporting: succeeded\n",
+ pInfo->name);
+ }
+ }
+ /*
+ * The PS/2 reset handling needs to be rechecked.
+ * We need to wait until after the 4.3 release.
+ */
+ }
} else {
- if (paramlen > 0) {
- if (xf86WriteSerial(pInfo->fd, param, paramlen) != paramlen)
- xf86Msg(X_ERROR, "%s: Mouse initialization failed\n",
- pInfo->name);
- usleep(30000);
- xf86FlushInput(pInfo->fd);
- }
+ if (paramlen > 0) {
+ if (xf86WriteSerial(pInfo->fd, param, paramlen) != paramlen)
+ xf86Msg(X_ERROR, "%s: Mouse initialization failed\n",
+ pInfo->name);
+ usleep(30000);
+ xf86FlushInput(pInfo->fd);
+ }
}
return TRUE;
@@ -3030,18 +3030,18 @@ mouseReset(InputInfoPtr pInfo, unsigned char val)
*/
if (mousepriv->current == 0
- && (mousepriv->lastEvent - prevEvent) < 4000)
- return FALSE;
+ && (mousepriv->lastEvent - prevEvent) < 4000)
+ return FALSE;
if (mousepriv->current > 0
- && (mousepriv->lastEvent - prevEvent) >= 1000) {
- mousepriv->inReset = FALSE;
- mousepriv->current = 0;
- return FALSE;
+ && (mousepriv->lastEvent - prevEvent) >= 1000) {
+ mousepriv->inReset = FALSE;
+ mousepriv->current = 0;
+ return FALSE;
}
if (mousepriv->inReset)
- mousepriv->inReset = FALSE;
+ mousepriv->inReset = FALSE;
#ifdef EXTMOUSEDEBUG
ErrorF("Mouse Current: %i 0x%x\n",mousepriv->current, val);
@@ -3056,79 +3056,79 @@ mouseReset(InputInfoPtr pInfo, unsigned char val)
/* PS/2 */
{
- unsigned char seq[] = { 0xaa, 0x00 };
- int len = sizeof(seq);
+ unsigned char seq[] = { 0xaa, 0x00 };
+ int len = sizeof(seq);
- if (seq[mousepriv->current] == val)
- expectReset = TRUE;
+ if (seq[mousepriv->current] == val)
+ expectReset = TRUE;
- if (len == mousepriv->current + 1) {
- mousepriv->inReset = TRUE;
- mousepriv->expires = GetTimeInMillis() + 1000;
+ if (len == mousepriv->current + 1) {
+ mousepriv->inReset = TRUE;
+ mousepriv->expires = GetTimeInMillis() + 1000;
#ifdef EXTMOUSEDEBUG
- ErrorF("Found PS/2 Reset string\n");
+ ErrorF("Found PS/2 Reset string\n");
#endif
- RegisterBlockAndWakeupHandlers (ps2BlockHandler,
- ps2WakeupHandler, (pointer) pInfo);
- ret = TRUE;
- }
+ RegisterBlockAndWakeupHandlers (ps2BlockHandler,
+ ps2WakeupHandler, (pointer) pInfo);
+ ret = TRUE;
+ }
}
- if (!expectReset)
- mousepriv->current = 0;
- else
- mousepriv->current++;
- return ret;
+ if (!expectReset)
+ mousepriv->current = 0;
+ else
+ mousepriv->current++;
+ return ret;
}
static void
ps2BlockHandler(pointer data, struct timeval **waitTime,
- pointer LastSelectMask)
+ pointer LastSelectMask)
{
InputInfoPtr pInfo = (InputInfoPtr) data;
- MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
mousePrivPtr mousepriv = (mousePrivPtr)pMse->mousePriv;
- int ms;
+ int ms;
if (mousepriv->inReset) {
- ms = mousepriv->expires - GetTimeInMillis ();
- if (ms <= 0)
- ms = 0;
- AdjustWaitForDelay (waitTime, ms);
+ ms = mousepriv->expires - GetTimeInMillis ();
+ if (ms <= 0)
+ ms = 0;
+ AdjustWaitForDelay (waitTime, ms);
} else
- RemoveBlockAndWakeupHandlers (ps2BlockHandler, ps2WakeupHandler,
- (pointer) pInfo);
+ RemoveBlockAndWakeupHandlers (ps2BlockHandler, ps2WakeupHandler,
+ (pointer) pInfo);
}
static void
ps2WakeupHandler(pointer data, int i, pointer LastSelectMask)
{
InputInfoPtr pInfo = (InputInfoPtr) data;
- MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
mousePrivPtr mousepriv = (mousePrivPtr)pMse->mousePriv;
- int ms;
+ int ms;
if (mousepriv->inReset) {
- unsigned char val;
- int blocked;
+ unsigned char val;
+ int blocked;
- ms = mousepriv->expires - GetTimeInMillis();
- if (ms > 0)
- return;
+ ms = mousepriv->expires - GetTimeInMillis();
+ if (ms > 0)
+ return;
- blocked = xf86BlockSIGIO ();
+ blocked = xf86BlockSIGIO ();
- xf86MsgVerb(X_INFO,3,
- "Got reinsert event: reinitializing PS/2 mouse\n");
- val = 0xf4;
- if (xf86WriteSerial(pInfo->fd, &val, 1) != 1)
- xf86Msg(X_ERROR, "%s: Write to mouse failed\n",
- pInfo->name);
- xf86UnblockSIGIO(blocked);
+ xf86MsgVerb(X_INFO,3,
+ "Got reinsert event: reinitializing PS/2 mouse\n");
+ val = 0xf4;
+ if (xf86WriteSerial(pInfo->fd, &val, 1) != 1)
+ xf86Msg(X_ERROR, "%s: Write to mouse failed\n",
+ pInfo->name);
+ xf86UnblockSIGIO(blocked);
}
RemoveBlockAndWakeupHandlers (ps2BlockHandler, ps2WakeupHandler,
- (pointer) pInfo);
+ (pointer) pInfo);
}
#endif /* SUPPORT_MOUSE_RESET */
@@ -3146,29 +3146,29 @@ ps2WakeupHandler(pointer data, int i, pointer LastSelectMask)
#endif
static
-MouseProtocolID hardProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
- PROT_LOGIMAN, PROT_MMHIT,
- PROT_GLIDE, PROT_IMSERIAL,
- PROT_THINKING, PROT_ACECAD,
- PROT_THINKPS2, PROT_MMPS2,
- PROT_GLIDEPS2,
- PROT_NETSCPS2, PROT_EXPPS2,PROT_IMPS2,
- PROT_GENPS2, PROT_NETPS2,
- PROT_MS,
- PROT_UNKNOWN
+MouseProtocolID hardProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
+ PROT_LOGIMAN, PROT_MMHIT,
+ PROT_GLIDE, PROT_IMSERIAL,
+ PROT_THINKING, PROT_ACECAD,
+ PROT_THINKPS2, PROT_MMPS2,
+ PROT_GLIDEPS2,
+ PROT_NETSCPS2, PROT_EXPPS2,PROT_IMPS2,
+ PROT_GENPS2, PROT_NETPS2,
+ PROT_MS,
+ PROT_UNKNOWN
};
static
-MouseProtocolID softProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
- PROT_LOGIMAN, PROT_MMHIT,
- PROT_GLIDE, PROT_IMSERIAL,
- PROT_THINKING, PROT_ACECAD,
- PROT_THINKPS2, PROT_MMPS2,
- PROT_GLIDEPS2,
- PROT_NETSCPS2 ,PROT_IMPS2,
- PROT_GENPS2,
- PROT_MS,
- PROT_UNKNOWN
+MouseProtocolID softProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
+ PROT_LOGIMAN, PROT_MMHIT,
+ PROT_GLIDE, PROT_IMSERIAL,
+ PROT_THINKING, PROT_ACECAD,
+ PROT_THINKPS2, PROT_MMPS2,
+ PROT_GLIDEPS2,
+ PROT_NETSCPS2 ,PROT_IMPS2,
+ PROT_GENPS2,
+ PROT_MS,
+ PROT_UNKNOWN
};
static const char *
@@ -3180,46 +3180,46 @@ autoOSProtocol(InputInfoPtr pInfo, int *protoPara)
/* Check if the OS has a detection mechanism. */
if (osInfo->SetupAuto) {
- name = osInfo->SetupAuto(pInfo, protoPara);
- if (name) {
- protocolID = ProtocolNameToID(name);
- switch (protocolID) {
- case PROT_UNKNOWN:
- /* Check for a builtin OS-specific protocol. */
- if (osInfo->CheckProtocol && osInfo->CheckProtocol(name)) {
- /* We can only come here if the protocol has been
- * changed to auto thru the xf86misc extension
- * and we have detected an OS specific builtin
- * protocol. Currently we cannot handle this */
- name = NULL;
- } else
- name = NULL;
- break;
- case PROT_UNSUP:
- name = NULL;
- break;
- default:
- break;
- }
- }
+ name = osInfo->SetupAuto(pInfo, protoPara);
+ if (name) {
+ protocolID = ProtocolNameToID(name);
+ switch (protocolID) {
+ case PROT_UNKNOWN:
+ /* Check for a builtin OS-specific protocol. */
+ if (osInfo->CheckProtocol && osInfo->CheckProtocol(name)) {
+ /* We can only come here if the protocol has been
+ * changed to auto thru the xf86misc extension
+ * and we have detected an OS specific builtin
+ * protocol. Currently we cannot handle this */
+ name = NULL;
+ } else
+ name = NULL;
+ break;
+ case PROT_UNSUP:
+ name = NULL;
+ break;
+ default:
+ break;
+ }
+ }
}
if (!name) {
- /* A PnP serial mouse? */
- protocolID = MouseGetPnpProtocol(pInfo);
- if (protocolID >= 0 && protocolID < PROT_NUMPROTOS) {
- name = ProtocolIDToName(protocolID);
- xf86Msg(X_PROBED, "%s: PnP-detected protocol: \"%s\"\n",
- pInfo->name, name);
- }
+ /* A PnP serial mouse? */
+ protocolID = MouseGetPnpProtocol(pInfo);
+ if (protocolID >= 0 && protocolID < PROT_NUMPROTOS) {
+ name = ProtocolIDToName(protocolID);
+ xf86Msg(X_PROBED, "%s: PnP-detected protocol: \"%s\"\n",
+ pInfo->name, name);
+ }
}
if (!name && osInfo->GuessProtocol) {
- name = osInfo->GuessProtocol(pInfo, 0);
- if (name)
- protocolID = ProtocolNameToID(name);
+ name = osInfo->GuessProtocol(pInfo, 0);
+ if (name)
+ protocolID = ProtocolNameToID(name);
}
if (name) {
- pMse->protocolID = protocolID;
+ pMse->protocolID = protocolID;
}
return name;
@@ -3241,116 +3241,116 @@ createProtoList(MouseDevPtr pMse, MouseProtocolID *protoList)
AP_DBGC(("Autoprobe: "));
for (i = 0; i < mPriv->count; i++)
- AP_DBGC(("%2.2x ", (unsigned char) mPriv->data[i]));
+ AP_DBGC(("%2.2x ", (unsigned char) mPriv->data[i]));
AP_DBGC(("\n"));
blocked = xf86BlockSIGIO ();
/* create a private copy first so we can write in the old list */
if ((tmplist = malloc(sizeof(MouseProtocolID) * NUM_AUTOPROBE_PROTOS))){
- for (i = 0; protoList[i] != PROT_UNKNOWN; i++) {
- tmplist[i] = protoList[i];
- }
- tmplist[i] = PROT_UNKNOWN;
- protoList = tmplist;
+ for (i = 0; protoList[i] != PROT_UNKNOWN; i++) {
+ tmplist[i] = protoList[i];
+ }
+ tmplist[i] = PROT_UNKNOWN;
+ protoList = tmplist;
} else
- return;
+ return;
for (i = 0; ((prot = protoList[i]) != PROT_UNKNOWN
- && (k < NUM_AUTOPROBE_PROTOS - 1)) ; i++) {
- Bool bad = TRUE;
- unsigned char byte = 0;
- int count = 0;
- int next_header_candidate = 0;
- int header_count = 0;
+ && (k < NUM_AUTOPROBE_PROTOS - 1)) ; i++) {
+ Bool bad = TRUE;
+ unsigned char byte = 0;
+ int count = 0;
+ int next_header_candidate = 0;
+ int header_count = 0;
- if (!GetProtocol(prot))
- continue;
- para = proto[prot];
+ if (!GetProtocol(prot))
+ continue;
+ para = proto[prot];
- AP_DBG(("Protocol: %s ", ProtocolIDToName(prot)));
+ AP_DBG(("Protocol: %s ", ProtocolIDToName(prot)));
#ifdef EXTMOUSEDEBUG
- for (j = 0; j < 7; j++)
- AP_DBGC(("%2.2x ", (unsigned char) para[j]));
- AP_DBGC(("\n"));
+ for (j = 0; j < 7; j++)
+ AP_DBGC(("%2.2x ", (unsigned char) para[j]));
+ AP_DBGC(("\n"));
#endif
- j = 0;
- while (1) {
- /* look for header */
- while (j < mPriv->count) {
- if (((byte = mPriv->data[j++]) & para[0]) == para[1]){
- AP_DBG(("found header %2.2x\n",byte));
- next_header_candidate = j;
- count = 1;
- break;
- } else {
- /*
- * Bail out if number of bytes per package have
- * been tested for header.
- * Take bytes per package of leading garbage into
- * account.
- */
- if (j > para[4] && ++header_count > para[4]) {
- j = mPriv->count;
- break;
- }
- }
- }
- /* check if remaining data matches protocol */
- while (j < mPriv->count) {
- byte = mPriv->data[j++];
- if (count == para[4]) {
- count = 0;
- /* check and eat excess byte */
- if (((byte & para[0]) != para[1])
- && ((byte & para[5]) == para[6])) {
- AP_DBG(("excess byte found\n"));
- continue;
- }
- }
- if (count == 0) {
- /* validate next header */
- bad = FALSE;
- AP_DBG(("Complete set found\n"));
- if ((byte & para[0]) != para[1]) {
- AP_DBG(("Autoprobe: header bad\n"));
- bad = TRUE;
- break;
- } else {
- count++;
- continue;
- }
- }
- /* validate data */
- else if (((byte & para[2]) != para[3])
- || ((para[7] & MPF_SAFE)
- && ((byte & para[0]) == para[1]))) {
- AP_DBG(("data bad\n"));
- bad = TRUE;
- break;
- } else {
- count ++;
- continue;
- }
- }
- if (!bad) {
- /* this is a matching protocol */
- mPriv->protoList[k++] = prot;
- AP_DBG(("Autoprobe: Adding protocol %s to list (entry %i)\n",
- ProtocolIDToName(prot),k-1));
- break;
- }
- j = next_header_candidate;
- next_header_candidate = 0;
- /* we have tested number of bytes per package for header */
- if (j > para[4] && ++header_count > para[4])
- break;
- /* we have not found anything that looks like a header */
- if (!next_header_candidate)
- break;
- AP_DBG(("Looking for new header\n"));
- }
+ j = 0;
+ while (1) {
+ /* look for header */
+ while (j < mPriv->count) {
+ if (((byte = mPriv->data[j++]) & para[0]) == para[1]){
+ AP_DBG(("found header %2.2x\n",byte));
+ next_header_candidate = j;
+ count = 1;
+ break;
+ } else {
+ /*
+ * Bail out if number of bytes per package have
+ * been tested for header.
+ * Take bytes per package of leading garbage into
+ * account.
+ */
+ if (j > para[4] && ++header_count > para[4]) {
+ j = mPriv->count;
+ break;
+ }
+ }
+ }
+ /* check if remaining data matches protocol */
+ while (j < mPriv->count) {
+ byte = mPriv->data[j++];
+ if (count == para[4]) {
+ count = 0;
+ /* check and eat excess byte */
+ if (((byte & para[0]) != para[1])
+ && ((byte & para[5]) == para[6])) {
+ AP_DBG(("excess byte found\n"));
+ continue;
+ }
+ }
+ if (count == 0) {
+ /* validate next header */
+ bad = FALSE;
+ AP_DBG(("Complete set found\n"));
+ if ((byte & para[0]) != para[1]) {
+ AP_DBG(("Autoprobe: header bad\n"));
+ bad = TRUE;
+ break;
+ } else {
+ count++;
+ continue;
+ }
+ }
+ /* validate data */
+ else if (((byte & para[2]) != para[3])
+ || ((para[7] & MPF_SAFE)
+ && ((byte & para[0]) == para[1]))) {
+ AP_DBG(("data bad\n"));
+ bad = TRUE;
+ break;
+ } else {
+ count ++;
+ continue;
+ }
+ }
+ if (!bad) {
+ /* this is a matching protocol */
+ mPriv->protoList[k++] = prot;
+ AP_DBG(("Autoprobe: Adding protocol %s to list (entry %i)\n",
+ ProtocolIDToName(prot),k-1));
+ break;
+ }
+ j = next_header_candidate;
+ next_header_candidate = 0;
+ /* we have tested number of bytes per package for header */
+ if (j > para[4] && ++header_count > para[4])
+ break;
+ /* we have not found anything that looks like a header */
+ if (!next_header_candidate)
+ break;
+ AP_DBG(("Looking for new header\n"));
+ }
}
xf86UnblockSIGIO(blocked);
@@ -3377,16 +3377,16 @@ createSerialDefaultsList(void)
serialDefaultsList[0] = NULL;
for (j = 0; mouseProtocols[j].name; j++) {
- if (!mouseProtocols[j].defaults)
- continue;
- for (k = 0; k < i; k++)
- if (mouseProtocols[j].defaults == serialDefaultsList[k])
- continue;
- i++;
- serialDefaultsList = (void**)xnfrealloc(serialDefaultsList,
- sizeof(void*)*(i+1));
- serialDefaultsList[i-1] = mouseProtocols[j].defaults;
- serialDefaultsList[i] = NULL;
+ if (!mouseProtocols[j].defaults)
+ continue;
+ for (k = 0; k < i; k++)
+ if (mouseProtocols[j].defaults == serialDefaultsList[k])
+ continue;
+ i++;
+ serialDefaultsList = (void**)xnfrealloc(serialDefaultsList,
+ sizeof(void*)*(i+1));
+ serialDefaultsList[i-1] = mouseProtocols[j].defaults;
+ serialDefaultsList[i] = NULL;
}
}
@@ -3406,14 +3406,14 @@ static validState
validCount(mousePrivPtr mPriv, Bool inSync, Bool lostSync)
{
if (inSync) {
- if (!--mPriv->goodCount) {
- /* we are sure to have found the correct protocol */
- mPriv->badCount = 0;
- return STATE_VALID;
- }
- AP_DBG(("%i successful rounds to go\n",
- mPriv->goodCount));
- return STATE_UNCERTAIN;
+ if (!--mPriv->goodCount) {
+ /* we are sure to have found the correct protocol */
+ mPriv->badCount = 0;
+ return STATE_VALID;
+ }
+ AP_DBG(("%i successful rounds to go\n",
+ mPriv->goodCount));
+ return STATE_UNCERTAIN;
}
@@ -3421,24 +3421,24 @@ validCount(mousePrivPtr mPriv, Bool inSync, Bool lostSync)
mPriv->goodCount = PROBE_UNCERTAINTY;
/* We increase uncertainty of having the correct protocol */
mPriv->badCount+= lostSync ? BAD_INC_CERTAINTY_WHEN_SYNC_LOST
- : BAD_INC_CERTAINTY;
+ : BAD_INC_CERTAINTY;
if (mPriv->badCount < BAD_CERTAINTY) {
- /* We are not convinced yet to have the wrong protocol */
- AP_DBG(("Changing protocol after: %i rounds\n",
- BAD_CERTAINTY - mPriv->badCount));
- return STATE_UNCERTAIN;
+ /* We are not convinced yet to have the wrong protocol */
+ AP_DBG(("Changing protocol after: %i rounds\n",
+ BAD_CERTAINTY - mPriv->badCount));
+ return STATE_UNCERTAIN;
}
return STATE_INVALID;
}
-#define RESET_VALIDATION mPriv->goodCount = PROBE_UNCERTAINTY;\
- mPriv->badCount = 0;\
- mPriv->prevDx = 0;\
- mPriv->prevDy = 0;\
- mPriv->accDx = 0;\
- mPriv->accDy = 0;\
- mPriv->acc = 0;
+#define RESET_VALIDATION mPriv->goodCount = PROBE_UNCERTAINTY;\
+ mPriv->badCount = 0;\
+ mPriv->prevDx = 0;\
+ mPriv->prevDy = 0;\
+ mPriv->accDx = 0;\
+ mPriv->accDy = 0;\
+ mPriv->acc = 0;
static void
autoProbeMouse(InputInfoPtr pInfo, Bool inSync, Bool lostSync)
@@ -3449,193 +3449,193 @@ autoProbeMouse(InputInfoPtr pInfo, Bool inSync, Bool lostSync)
MouseProtocolID *protocolList = NULL;
while (1) {
- switch (mPriv->autoState) {
- case AUTOPROBE_GOOD:
- if (inSync)
- return;
- AP_DBG(("State GOOD\n"));
- RESET_VALIDATION;
- mPriv->autoState = AUTOPROBE_VALIDATE1;
- return;
- case AUTOPROBE_H_GOOD:
- if (inSync)
- return;
- AP_DBG(("State H_GOOD\n"));
- RESET_VALIDATION;
- mPriv->autoState = AUTOPROBE_H_VALIDATE2;
- return;
- case AUTOPROBE_H_NOPROTO:
- AP_DBG(("State H_NOPROTO\n"));
- mPriv->protocolID = 0;
- mPriv->autoState = AUTOPROBE_H_SETPROTO;
- break;
- case AUTOPROBE_H_SETPROTO:
- AP_DBG(("State H_SETPROTO\n"));
- if ((pMse->protocolID = hardProtocolList[mPriv->protocolID++])
- == PROT_UNKNOWN) {
- mPriv->protocolID = 0;
- break;
- } else if (GetProtocol(pMse->protocolID) && SetupMouse(pInfo)) {
- FlushButtons(pMse);
- RESET_VALIDATION;
- AP_DBG(("Autoprobe: Trying Protocol: %s\n",
- ProtocolIDToName(pMse->protocolID)));
- mPriv->autoState = AUTOPROBE_H_VALIDATE1;
- return;
- }
- break;
- case AUTOPROBE_H_VALIDATE1:
- AP_DBG(("State H_VALIDATE1\n"));
- switch (validCount(mPriv,inSync,lostSync)) {
- case STATE_INVALID:
- mPriv->autoState = AUTOPROBE_H_SETPROTO;
- break;
- case STATE_VALID:
- xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
- ProtocolIDToName(pMse->protocolID));
- mPriv->autoState = AUTOPROBE_H_GOOD;
- return;
- case STATE_UNCERTAIN:
- return;
- default:
- break;
- }
- break;
- case AUTOPROBE_H_VALIDATE2:
- AP_DBG(("State H_VALIDATE2\n"));
- switch (validCount(mPriv,inSync,lostSync)) {
- case STATE_INVALID:
- mPriv->autoState = AUTOPROBE_H_AUTODETECT;
- break;
- case STATE_VALID:
- xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
- ProtocolIDToName(pMse->protocolID));
- mPriv->autoState = AUTOPROBE_H_GOOD;
- return;
- case STATE_UNCERTAIN:
- return;
- }
- break;
- case AUTOPROBE_H_AUTODETECT:
- AP_DBG(("State H_AUTODETECT\n"));
- pMse->protocolID = PROT_AUTO;
- AP_DBG(("Looking for PnP/OS mouse\n"));
- mPriv->count = 0;
- SetupMouse(pInfo);
- if (pMse->protocolID != PROT_AUTO)
- mPriv->autoState = AUTOPROBE_H_GOOD;
- else
- mPriv->autoState = AUTOPROBE_H_NOPROTO;
- break;
- case AUTOPROBE_NOPROTO:
- AP_DBG(("State NOPROTO\n"));
- mPriv->count = 0;
- mPriv->serialDefaultsNum = -1;
- mPriv->autoState = AUTOPROBE_COLLECT;
- break;
- case AUTOPROBE_COLLECT:
- AP_DBG(("State COLLECT\n"));
- if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES)
- return;
- protocolList = softProtocolList;
- mPriv->autoState = AUTOPROBE_CREATE_PROTOLIST;
- break;
- case AUTOPROBE_CREATE_PROTOLIST:
- AP_DBG(("State CREATE_PROTOLIST\n"));
- createProtoList(pMse, protocolList);
- mPriv->protocolID = 0;
- mPriv->autoState = AUTOPROBE_SWITCH_PROTOCOL;
- break;
- case AUTOPROBE_AUTODETECT:
- AP_DBG(("State AUTODETECT\n"));
- pMse->protocolID = PROT_AUTO;
- AP_DBG(("Looking for PnP/OS mouse\n"));
- mPriv->count = 0;
- SetupMouse(pInfo);
- if (pMse->protocolID != PROT_AUTO)
- mPriv->autoState = AUTOPROBE_GOOD;
- else
- mPriv->autoState = AUTOPROBE_NOPROTO;
- break;
- case AUTOPROBE_VALIDATE1:
- AP_DBG(("State VALIDATE1\n"));
- switch (validCount(mPriv,inSync,lostSync)) {
- case STATE_INVALID:
- mPriv->autoState = AUTOPROBE_AUTODETECT;
- break;
- case STATE_VALID:
- xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
- ProtocolIDToName(pMse->protocolID));
- mPriv->autoState = AUTOPROBE_GOOD;
- break;
- case STATE_UNCERTAIN:
- return;
- }
- break;
- case AUTOPROBE_VALIDATE2:
- AP_DBG(("State VALIDATE2\n"));
- switch (validCount(mPriv,inSync,lostSync)) {
- case STATE_INVALID:
- protocolList = &mPriv->protoList[mPriv->protocolID];
- mPriv->autoState = AUTOPROBE_CREATE_PROTOLIST;
- break;
- case STATE_VALID:
- xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
- ProtocolIDToName(pMse->protocolID));
- mPriv->autoState = AUTOPROBE_GOOD;
- break;
- case STATE_UNCERTAIN:
- return;
- }
- break;
- case AUTOPROBE_SWITCHSERIAL:
- {
- pointer serialDefaults;
- AP_DBG(("State SWITCHSERIAL\n"));
-
- if (!serialDefaultsList)
- createSerialDefaultsList();
-
- AP_DBG(("Switching serial params\n"));
- if ((serialDefaults =
- serialDefaultsList[++mPriv->serialDefaultsNum]) == NULL) {
- mPriv->serialDefaultsNum = 0;
- } else {
- pointer tmp = xf86OptionListCreate(serialDefaults, -1, 0);
- xf86SetSerial(pInfo->fd, tmp);
- xf86OptionListFree(tmp);
- mPriv->count = 0;
- mPriv->autoState = AUTOPROBE_COLLECT;
- }
- break;
- }
- case AUTOPROBE_SWITCH_PROTOCOL:
- {
- MouseProtocolID proto;
- MouseProtocolPtr pProto;
- void *defaults;
- AP_DBG(("State SWITCH_PROTOCOL\n"));
- proto = mPriv->protoList[mPriv->protocolID++];
- if (proto == PROT_UNKNOWN)
- mPriv->autoState = AUTOPROBE_SWITCHSERIAL;
- else if (!((pProto = GetProtocol(proto)) &&
- ((defaults = pProto->defaults)))
- || (mPriv->serialDefaultsNum == -1
- && (defaults == msDefaults))
- || (mPriv->serialDefaultsNum != -1
- && serialDefaultsList[mPriv->serialDefaultsNum]
- == defaults)) {
- AP_DBG(("Changing Protocol to %s\n",
- ProtocolIDToName(proto)));
- SetMouseProto(pMse,proto);
- FlushButtons(pMse);
- RESET_VALIDATION;
- mPriv->autoState = AUTOPROBE_VALIDATE2;
- return;
- }
- break;
- }
- }
+ switch (mPriv->autoState) {
+ case AUTOPROBE_GOOD:
+ if (inSync)
+ return;
+ AP_DBG(("State GOOD\n"));
+ RESET_VALIDATION;
+ mPriv->autoState = AUTOPROBE_VALIDATE1;
+ return;
+ case AUTOPROBE_H_GOOD:
+ if (inSync)
+ return;
+ AP_DBG(("State H_GOOD\n"));
+ RESET_VALIDATION;
+ mPriv->autoState = AUTOPROBE_H_VALIDATE2;
+ return;
+ case AUTOPROBE_H_NOPROTO:
+ AP_DBG(("State H_NOPROTO\n"));
+ mPriv->protocolID = 0;
+ mPriv->autoState = AUTOPROBE_H_SETPROTO;
+ break;
+ case AUTOPROBE_H_SETPROTO:
+ AP_DBG(("State H_SETPROTO\n"));
+ if ((pMse->protocolID = hardProtocolList[mPriv->protocolID++])
+ == PROT_UNKNOWN) {
+ mPriv->protocolID = 0;
+ break;
+ } else if (GetProtocol(pMse->protocolID) && SetupMouse(pInfo)) {
+ FlushButtons(pMse);
+ RESET_VALIDATION;
+ AP_DBG(("Autoprobe: Trying Protocol: %s\n",
+ ProtocolIDToName(pMse->protocolID)));
+ mPriv->autoState = AUTOPROBE_H_VALIDATE1;
+ return;
+ }
+ break;
+ case AUTOPROBE_H_VALIDATE1:
+ AP_DBG(("State H_VALIDATE1\n"));
+ switch (validCount(mPriv,inSync,lostSync)) {
+ case STATE_INVALID:
+ mPriv->autoState = AUTOPROBE_H_SETPROTO;
+ break;
+ case STATE_VALID:
+ xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
+ ProtocolIDToName(pMse->protocolID));
+ mPriv->autoState = AUTOPROBE_H_GOOD;
+ return;
+ case STATE_UNCERTAIN:
+ return;
+ default:
+ break;
+ }
+ break;
+ case AUTOPROBE_H_VALIDATE2:
+ AP_DBG(("State H_VALIDATE2\n"));
+ switch (validCount(mPriv,inSync,lostSync)) {
+ case STATE_INVALID:
+ mPriv->autoState = AUTOPROBE_H_AUTODETECT;
+ break;
+ case STATE_VALID:
+ xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
+ ProtocolIDToName(pMse->protocolID));
+ mPriv->autoState = AUTOPROBE_H_GOOD;
+ return;
+ case STATE_UNCERTAIN:
+ return;
+ }
+ break;
+ case AUTOPROBE_H_AUTODETECT:
+ AP_DBG(("State H_AUTODETECT\n"));
+ pMse->protocolID = PROT_AUTO;
+ AP_DBG(("Looking for PnP/OS mouse\n"));
+ mPriv->count = 0;
+ SetupMouse(pInfo);
+ if (pMse->protocolID != PROT_AUTO)
+ mPriv->autoState = AUTOPROBE_H_GOOD;
+ else
+ mPriv->autoState = AUTOPROBE_H_NOPROTO;
+ break;
+ case AUTOPROBE_NOPROTO:
+ AP_DBG(("State NOPROTO\n"));
+ mPriv->count = 0;
+ mPriv->serialDefaultsNum = -1;
+ mPriv->autoState = AUTOPROBE_COLLECT;
+ break;
+ case AUTOPROBE_COLLECT:
+ AP_DBG(("State COLLECT\n"));
+ if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES)
+ return;
+ protocolList = softProtocolList;
+ mPriv->autoState = AUTOPROBE_CREATE_PROTOLIST;
+ break;
+ case AUTOPROBE_CREATE_PROTOLIST:
+ AP_DBG(("State CREATE_PROTOLIST\n"));
+ createProtoList(pMse, protocolList);
+ mPriv->protocolID = 0;
+ mPriv->autoState = AUTOPROBE_SWITCH_PROTOCOL;
+ break;
+ case AUTOPROBE_AUTODETECT:
+ AP_DBG(("State AUTODETECT\n"));
+ pMse->protocolID = PROT_AUTO;
+ AP_DBG(("Looking for PnP/OS mouse\n"));
+ mPriv->count = 0;
+ SetupMouse(pInfo);
+ if (pMse->protocolID != PROT_AUTO)
+ mPriv->autoState = AUTOPROBE_GOOD;
+ else
+ mPriv->autoState = AUTOPROBE_NOPROTO;
+ break;
+ case AUTOPROBE_VALIDATE1:
+ AP_DBG(("State VALIDATE1\n"));
+ switch (validCount(mPriv,inSync,lostSync)) {
+ case STATE_INVALID:
+ mPriv->autoState = AUTOPROBE_AUTODETECT;
+ break;
+ case STATE_VALID:
+ xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
+ ProtocolIDToName(pMse->protocolID));
+ mPriv->autoState = AUTOPROBE_GOOD;
+ break;
+ case STATE_UNCERTAIN:
+ return;
+ }
+ break;
+ case AUTOPROBE_VALIDATE2:
+ AP_DBG(("State VALIDATE2\n"));
+ switch (validCount(mPriv,inSync,lostSync)) {
+ case STATE_INVALID:
+ protocolList = &mPriv->protoList[mPriv->protocolID];
+ mPriv->autoState = AUTOPROBE_CREATE_PROTOLIST;
+ break;
+ case STATE_VALID:
+ xf86Msg(X_INFO,"Mouse autoprobe: selecting %s protocol\n",
+ ProtocolIDToName(pMse->protocolID));
+ mPriv->autoState = AUTOPROBE_GOOD;
+ break;
+ case STATE_UNCERTAIN:
+ return;
+ }
+ break;
+ case AUTOPROBE_SWITCHSERIAL:
+ {
+ pointer serialDefaults;
+ AP_DBG(("State SWITCHSERIAL\n"));
+
+ if (!serialDefaultsList)
+ createSerialDefaultsList();
+
+ AP_DBG(("Switching serial params\n"));
+ if ((serialDefaults =
+ serialDefaultsList[++mPriv->serialDefaultsNum]) == NULL) {
+ mPriv->serialDefaultsNum = 0;
+ } else {
+ pointer tmp = xf86OptionListCreate(serialDefaults, -1, 0);
+ xf86SetSerial(pInfo->fd, tmp);
+ xf86OptionListFree(tmp);
+ mPriv->count = 0;
+ mPriv->autoState = AUTOPROBE_COLLECT;
+ }
+ break;
+ }
+ case AUTOPROBE_SWITCH_PROTOCOL:
+ {
+ MouseProtocolID proto;
+ MouseProtocolPtr pProto;
+ void *defaults;
+ AP_DBG(("State SWITCH_PROTOCOL\n"));
+ proto = mPriv->protoList[mPriv->protocolID++];
+ if (proto == PROT_UNKNOWN)
+ mPriv->autoState = AUTOPROBE_SWITCHSERIAL;
+ else if (!((pProto = GetProtocol(proto)) &&
+ ((defaults = pProto->defaults)))
+ || (mPriv->serialDefaultsNum == -1
+ && (defaults == msDefaults))
+ || (mPriv->serialDefaultsNum != -1
+ && serialDefaultsList[mPriv->serialDefaultsNum]
+ == defaults)) {
+ AP_DBG(("Changing Protocol to %s\n",
+ ProtocolIDToName(proto)));
+ SetMouseProto(pMse,proto);
+ FlushButtons(pMse);
+ RESET_VALIDATION;
+ mPriv->autoState = AUTOPROBE_VALIDATE2;
+ return;
+ }
+ break;
+ }
+ }
}
}
@@ -3645,20 +3645,20 @@ autoGood(MouseDevPtr pMse)
mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv;
if (!pMse->autoProbe)
- return TRUE;
+ return TRUE;
switch (mPriv->autoState) {
case AUTOPROBE_GOOD:
case AUTOPROBE_H_GOOD:
- return TRUE;
+ return TRUE;
case AUTOPROBE_VALIDATE1: /* @@@ */
case AUTOPROBE_H_VALIDATE1: /* @@@ */
case AUTOPROBE_VALIDATE2:
case AUTOPROBE_H_VALIDATE2:
- if (mPriv->goodCount < PROBE_UNCERTAINTY/2)
- return TRUE;
+ if (mPriv->goodCount < PROBE_UNCERTAINTY/2)
+ return TRUE;
default:
- return FALSE;
+ return FALSE;
}
}
@@ -3676,50 +3676,50 @@ checkForErraticMovements(InputInfoPtr pInfo, int dx, int dy)
mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv;
if (!mPriv->goodCount)
- return;
+ return;
#if 0
if (abs(dx - mPriv->prevDx) > 300
- || abs(dy - mPriv->prevDy) > 300)
- AP_DBG(("erratic1 behaviour\n"));
+ || abs(dy - mPriv->prevDy) > 300)
+ AP_DBG(("erratic1 behaviour\n"));
#endif
if (abs(dx) > VAL_THRESHOLD) {
- if (sign(dx) == sign(mPriv->prevDx)) {
- mPriv->accDx += dx;
- if (abs(mPriv->accDx) > mPriv->acc) {
- mPriv->acc = abs(mPriv->accDx);
- AP_DBG(("acc=%i\n",mPriv->acc));
- }
- else
- AP_DBG(("accDx=%i\n",mPriv->accDx));
- } else {
- mPriv->accDx = 0;
- }
+ if (sign(dx) == sign(mPriv->prevDx)) {
+ mPriv->accDx += dx;
+ if (abs(mPriv->accDx) > mPriv->acc) {
+ mPriv->acc = abs(mPriv->accDx);
+ AP_DBG(("acc=%i\n",mPriv->acc));
+ }
+ else
+ AP_DBG(("accDx=%i\n",mPriv->accDx));
+ } else {
+ mPriv->accDx = 0;
+ }
}
if (abs(dy) > VAL_THRESHOLD) {
- if (sign(dy) == sign(mPriv->prevDy)) {
- mPriv->accDy += dy;
- if (abs(mPriv->accDy) > mPriv->acc) {
- mPriv->acc = abs(mPriv->accDy);
- AP_DBG(("acc: %i\n",mPriv->acc));
- } else
- AP_DBG(("accDy=%i\n",mPriv->accDy));
- } else {
- mPriv->accDy = 0;
- }
+ if (sign(dy) == sign(mPriv->prevDy)) {
+ mPriv->accDy += dy;
+ if (abs(mPriv->accDy) > mPriv->acc) {
+ mPriv->acc = abs(mPriv->accDy);
+ AP_DBG(("acc: %i\n",mPriv->acc));
+ } else
+ AP_DBG(("accDy=%i\n",mPriv->accDy));
+ } else {
+ mPriv->accDy = 0;
+ }
}
mPriv->prevDx = dx;
mPriv->prevDy = dy;
if (mPriv->acc > TOT_THRESHOLD) {
- mPriv->goodCount = PROBE_UNCERTAINTY;
- mPriv->prevDx = 0;
- mPriv->prevDy = 0;
- mPriv->accDx = 0;
- mPriv->accDy = 0;
- mPriv->acc = 0;
- AP_DBG(("erratic2 behaviour\n"));
- autoProbeMouse(pInfo, FALSE,TRUE);
+ mPriv->goodCount = PROBE_UNCERTAINTY;
+ mPriv->prevDx = 0;
+ mPriv->prevDy = 0;
+ mPriv->accDx = 0;
+ mPriv->accDy = 0;
+ mPriv->acc = 0;
+ AP_DBG(("erratic2 behaviour\n"));
+ autoProbeMouse(pInfo, FALSE,TRUE);
}
}
@@ -3730,11 +3730,11 @@ SetMouseProto(MouseDevPtr pMse, MouseProtocolID protocolID)
pMse->protocol = ProtocolIDToName(pMse->protocolID);
pMse->class = ProtocolIDToClass(pMse->protocolID);
if ((pMse->protocolID >= 0) && (pMse->protocolID < PROT_NUMPROTOS))
- memcpy(pMse->protoPara, proto[pMse->protocolID],
- sizeof(pMse->protoPara));
+ memcpy(pMse->protoPara, proto[pMse->protocolID],
+ sizeof(pMse->protoPara));
if (pMse->emulate3ButtonsSoft)
- pMse->emulate3Buttons = TRUE;
+ pMse->emulate3Buttons = TRUE;
}
/*
@@ -3745,10 +3745,10 @@ collectData(MouseDevPtr pMse, unsigned char u)
{
mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv;
if (mPriv->count < NUM_MSE_AUTOPROBE_TOTAL) {
- mPriv->data[mPriv->count++] = u;
- if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES) {
- return TRUE;
- }
+ mPriv->data[mPriv->count++] = u;
+ if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -3757,19 +3757,19 @@ collectData(MouseDevPtr pMse, unsigned char u)
static void
-xf86MouseUnplug(pointer p)
+xf86MouseUnplug(pointer p)
{
}
static pointer
-xf86MousePlug(pointer module,
- pointer options,
- int *errmaj,
- int *errmin)
+xf86MousePlug(pointer module,
+ pointer options,
+ int *errmaj,
+ int *errmin)
{
static Bool Initialised = FALSE;
if (!Initialised)
- Initialised = TRUE;
+ Initialised = TRUE;
xf86AddInputDriver(&MOUSE, module, 0);
@@ -3787,8 +3787,8 @@ static XF86ModuleVersionInfo xf86MouseVersionRec =
ABI_CLASS_XINPUT,
ABI_XINPUT_VERSION,
MOD_CLASS_XINPUT,
- {0, 0, 0, 0} /* signature, to be patched into the file by */
- /* a tool */
+ {0, 0, 0, 0} /* signature, to be patched into the file by */
+ /* a tool */
};
_X_EXPORT XF86ModuleData mouseModuleData = {
diff --git a/src/mouse.h b/src/mouse.h
index 2cc588a..0b3f709 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -40,20 +40,20 @@
/* Mouse interface classes */
-#define MSE_NONE 0x00
-#define MSE_SERIAL 0x01 /* serial port */
-#define MSE_BUS 0x02 /* old bus mouse */
-#define MSE_PS2 0x04 /* standard read-only PS/2 */
-#define MSE_XPS2 0x08 /* extended PS/2 */
-#define MSE_AUTO 0x10 /* auto-detect (PnP) */
-#define MSE_MISC 0x20 /* The OS layer will identify the
- * specific protocol names that are
- * supported for this class. */
+#define MSE_NONE 0x00
+#define MSE_SERIAL 0x01 /* serial port */
+#define MSE_BUS 0x02 /* old bus mouse */
+#define MSE_PS2 0x04 /* standard read-only PS/2 */
+#define MSE_XPS2 0x08 /* extended PS/2 */
+#define MSE_AUTO 0x10 /* auto-detect (PnP) */
+#define MSE_MISC 0x20 /* The OS layer will identify the
+ * specific protocol names that are
+ * supported for this class. */
/* Mouse Protocol IDs. */
typedef enum {
PROT_UNKNOWN = -2,
- PROT_UNSUP = -1, /* protocol is not supported */
+ PROT_UNSUP = -1, /* protocol is not supported */
PROT_MS = 0,
PROT_MSC,
PROT_MM,
@@ -79,7 +79,7 @@ typedef enum {
PROT_SYSMOUSE,
PROT_WSMOUSE,
PROT_VUID,
- PROT_NUMPROTOS /* This must always be last. */
+ PROT_NUMPROTOS /* This must always be last. */
} MouseProtocolID;
struct _MouseDevRec;
@@ -88,13 +88,13 @@ typedef int (*GetInterfaceTypesProc)(void);
typedef const char **(*BuiltinNamesProc)(void);
typedef Bool (*CheckProtocolProc)(const char *protocol);
typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
- int flags);
+ int flags);
typedef const char *(*DefaultProtocolProc)(void);
typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
- int res);
+ int res);
typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
- int flags);
+ int flags);
typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
/*
@@ -102,86 +102,86 @@ typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
* OS-independent mouse driver.
*/
typedef struct {
- GetInterfaceTypesProc SupportedInterfaces;
- BuiltinNamesProc BuiltinNames;
- CheckProtocolProc CheckProtocol;
- BuiltinPreInitProc PreInit;
- DefaultProtocolProc DefaultProtocol;
- SetupAutoProc SetupAuto;
- SetResProc SetPS2Res;
- SetResProc SetBMRes;
- SetResProc SetMiscRes;
- FindDeviceProc FindDevice;
- GuessProtocolProc GuessProtocol;
+ GetInterfaceTypesProc SupportedInterfaces;
+ BuiltinNamesProc BuiltinNames;
+ CheckProtocolProc CheckProtocol;
+ BuiltinPreInitProc PreInit;
+ DefaultProtocolProc DefaultProtocol;
+ SetupAutoProc SetupAuto;
+ SetResProc SetPS2Res;
+ SetResProc SetBMRes;
+ SetResProc SetMiscRes;
+ FindDeviceProc FindDevice;
+ GuessProtocolProc GuessProtocol;
} OSMouseInfoRec, *OSMouseInfoPtr;
/*
* SupportedInterfaces: Returns the mouse interface types that the OS support.
- * If MSE_MISC is returned, then the BuiltinNames and
- * CheckProtocol should be set.
+ * If MSE_MISC is returned, then the BuiltinNames and
+ * CheckProtocol should be set.
*
* BuiltinNames: Returns the names of the protocols that are fully handled
- * in the OS-specific code. These are names that don't appear
- * directly in the main "mouse" driver.
+ * in the OS-specific code. These are names that don't appear
+ * directly in the main "mouse" driver.
*
* CheckProtocol: Checks if the protocol name given is supported by the
- * OS. It should return TRUE for both "builtin" protocols and
- * protocols of type MSE_MISC that are supported by the OS.
+ * OS. It should return TRUE for both "builtin" protocols and
+ * protocols of type MSE_MISC that are supported by the OS.
*
- * PreInit: The PreInit function for protocols that are builtin. This
- * function is passed the protocol name.
+ * PreInit: The PreInit function for protocols that are builtin. This
+ * function is passed the protocol name.
*
* DefaultProtocol: Returns the name of a default protocol that should be used
- * for the OS when none has been supplied in the config file.
- * This should only be set when there is a reasonable default.
+ * for the OS when none has been supplied in the config file.
+ * This should only be set when there is a reasonable default.
*
- * SetupAuto: This function can be used to do OS-specific protocol
- * auto-detection. It returns the name of the detected protocol,
- * or NULL when detection fails. It may also adjust one or more
- * of the "protoPara" values for the detected protocol by setting
- * then to something other than -1. SetupAuto gets called in two
- * ways. The first is before any devices have been opened. This
- * can be used when the protocol "Auto" always maps to a single
- * protocol type. The second is with the device open, allowing
- * OS-specific probing to be done.
+ * SetupAuto: This function can be used to do OS-specific protocol
+ * auto-detection. It returns the name of the detected protocol,
+ * or NULL when detection fails. It may also adjust one or more
+ * of the "protoPara" values for the detected protocol by setting
+ * then to something other than -1. SetupAuto gets called in two
+ * ways. The first is before any devices have been opened. This
+ * can be used when the protocol "Auto" always maps to a single
+ * protocol type. The second is with the device open, allowing
+ * OS-specific probing to be done.
*
- * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
- * protocol types.
+ * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
+ * protocol types.
*
- * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
+ * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
*
- * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
+ * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
*
- * FindDevice: This function gets called when no Device has been specified
- * in the config file. OS-specific methods may be used to guess
- * which input device to use. This function is called after the
- * pre-open attempts at protocol discovery are done, but before
- * the device is open. I.e., after the first SetupAuto() call,
- * after the DefaultProtocol() call, but before the PreInit()
- * call. Available protocol information may be used in locating
- * the default input device.
+ * FindDevice: This function gets called when no Device has been specified
+ * in the config file. OS-specific methods may be used to guess
+ * which input device to use. This function is called after the
+ * pre-open attempts at protocol discovery are done, but before
+ * the device is open. I.e., after the first SetupAuto() call,
+ * after the DefaultProtocol() call, but before the PreInit()
+ * call. Available protocol information may be used in locating
+ * the default input device.
*
* GuessProtocol: A last resort attempt at guessing the mouse protocol by
- * whatever OS-specific means might be available. OS-independent
- * things should be in the mouse driver. This function gets
- * called after the mouse driver's OS-independent methods have
- * failed.
+ * whatever OS-specific means might be available. OS-independent
+ * things should be in the mouse driver. This function gets
+ * called after the mouse driver's OS-independent methods have
+ * failed.
*/
extern OSMouseInfoPtr OSMouseInit(int flags);
/* Z axis mapping */
-#define MSE_NOZMAP 0
-#define MSE_MAPTOX -1
-#define MSE_MAPTOY -2
-#define MSE_MAPTOZ -3
-#define MSE_MAPTOW -4
+#define MSE_NOZMAP 0
+#define MSE_MAPTOX -1
+#define MSE_MAPTOY -2
+#define MSE_MAPTOZ -3
+#define MSE_MAPTOW -4
/* Generalize for other axes. */
-#define MSE_NOAXISMAP MSE_NOZMAP
+#define MSE_NOAXISMAP MSE_NOZMAP
-#define MSE_MAXBUTTONS 24
-#define MSE_DFLTBUTTONS 3
+#define MSE_MAXBUTTONS 24
+#define MSE_DFLTBUTTONS 3
/*
* Mouse device record. This is shared by the mouse driver and the OSMouse
@@ -194,71 +194,71 @@ typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
typedef Bool (*dataGoodProc)(struct _MouseDevRec *);
typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
- int dx, int dy, int dz, int dw);
+ int dx, int dy, int dz, int dw);
typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
typedef struct _MouseDevRec {
- PtrCtrlProcPtr Ctrl;
- PostMseEventProc PostEvent;
- MouseCommonOptProc CommonOptions;
- DeviceIntPtr device;
- const char * protocol;
- MouseProtocolID protocolID;
- MouseProtocolID oldProtocolID; /* hack */
- int class;
- int mseModel;
- int baudRate;
- int oldBaudRate;
- int sampleRate;
- int lastButtons;
- int buttons; /* # of buttons */
- int emulateState; /* automata state for 2 button mode */
- Bool emulate3Buttons;
- Bool emulate3ButtonsSoft;
- int emulate3Timeout;/* Timeout for 3 button emulation */
- Bool chordMiddle;
+ PtrCtrlProcPtr Ctrl;
+ PostMseEventProc PostEvent;
+ MouseCommonOptProc CommonOptions;
+ DeviceIntPtr device;
+ const char * protocol;
+ MouseProtocolID protocolID;
+ MouseProtocolID oldProtocolID; /* hack */
+ int class;
+ int mseModel;
+ int baudRate;
+ int oldBaudRate;
+ int sampleRate;
+ int lastButtons;
+ int buttons; /* # of buttons */
+ int emulateState; /* automata state for 2 button mode */
+ Bool emulate3Buttons;
+ Bool emulate3ButtonsSoft;
+ int emulate3Timeout;/* Timeout for 3 button emulation */
+ Bool chordMiddle;
Bool flipXY;
int invX;
int invY;
- int resolution;
- int negativeZ; /* button mask */
- int positiveZ; /* button mask */
- int negativeW; /* button mask */
- int positiveW; /* button mask */
- pointer buffer; /* usually an XISBuffer* */
- int protoBufTail;
- unsigned char protoBuf[8];
- unsigned char protoPara[8];
- unsigned char inSync; /* driver in sync with datastream */
- pointer mousePriv; /* private area */
- InputInfoPtr pInfo;
- Bool emulate3Pending;/* timer waiting */
- CARD32 emulate3Expires;/* time to fire emulation code */
- Bool emulateWheel;
- int wheelInertia;
- int wheelButton;
- int negativeX; /* Button values. Unlike the Z and */
- int positiveX; /* W equivalents, these are button */
- int negativeY; /* values rather than button masks. */
- int positiveY;
- int wheelYDistance;
- int wheelXDistance;
- Bool autoProbe;
+ int resolution;
+ int negativeZ; /* button mask */
+ int positiveZ; /* button mask */
+ int negativeW; /* button mask */
+ int positiveW; /* button mask */
+ pointer buffer; /* usually an XISBuffer* */
+ int protoBufTail;
+ unsigned char protoBuf[8];
+ unsigned char protoPara[8];
+ unsigned char inSync; /* driver in sync with datastream */
+ pointer mousePriv; /* private area */
+ InputInfoPtr pInfo;
+ Bool emulate3Pending;/* timer waiting */
+ CARD32 emulate3Expires;/* time to fire emulation code */
+ Bool emulateWheel;
+ int wheelInertia;
+ int wheelButton;
+ int negativeX; /* Button values. Unlike the Z and */
+ int positiveX; /* W equivalents, these are button */
+ int negativeY; /* values rather than button masks. */
+ int positiveY;
+ int wheelYDistance;
+ int wheelXDistance;
+ Bool autoProbe;
checkMovementsProc checkMovements;
- autoProbeProc autoProbeMouse;
- collectDataProc collectData;
- dataGoodProc dataGood;
- int angleOffset;
- pointer pDragLock; /* drag lock area */
- int xisbscale; /* buffer size for 1 event */
- int wheelButtonTimeout;/* Timeout for the wheel button emulation */
- CARD32 wheelButtonExpires;
- int doubleClickSourceButtonMask;
- int doubleClickTargetButton;
- int doubleClickTargetButtonMask;
- int doubleClickOldSourceState;
- int lastMappedButtons;
- int buttonMap[MSE_MAXBUTTONS];
+ autoProbeProc autoProbeMouse;
+ collectDataProc collectData;
+ dataGoodProc dataGood;
+ int angleOffset;
+ pointer pDragLock; /* drag lock area */
+ int xisbscale; /* buffer size for 1 event */
+ int wheelButtonTimeout;/* Timeout for the wheel button emulation */
+ CARD32 wheelButtonExpires;
+ int doubleClickSourceButtonMask;
+ int doubleClickTargetButton;
+ int doubleClickTargetButtonMask;
+ int doubleClickOldSourceState;
+ int lastMappedButtons;
+ int buttonMap[MSE_MAXBUTTONS];
} MouseDevRec, *MouseDevPtr;
#endif /* _XF86OSMOUSE_H_ */
diff --git a/src/mousePriv.h b/src/mousePriv.h
index 7afb5aa..b15e461 100644
--- a/src/mousePriv.h
+++ b/src/mousePriv.h
@@ -33,10 +33,10 @@ typedef enum {
} mseAutoProbeStates;
typedef struct {
- const char * name;
- int class;
- const char ** defaults;
- MouseProtocolID id;
+ const char * name;
+ int class;
+ const char ** defaults;
+ MouseProtocolID id;
} MouseProtocolRec, *MouseProtocolPtr;
#define NUM_MSE_AUTOPROBE_BYTES 24 /* multiple of 3,4 and 6 byte packages */
@@ -45,31 +45,31 @@ typedef struct {
typedef struct {
- int current;
- Bool inReset;
- CARD32 lastEvent;
- CARD32 expires;
- Bool soft;
- int goodCount;
- int badCount;
- int protocolID;
- int count;
- char data[NUM_MSE_AUTOPROBE_TOTAL];
+ int current;
+ Bool inReset;
+ CARD32 lastEvent;
+ CARD32 expires;
+ Bool soft;
+ int goodCount;
+ int badCount;
+ int protocolID;
+ int count;
+ char data[NUM_MSE_AUTOPROBE_TOTAL];
mseAutoProbeStates autoState;
MouseProtocolID protoList[NUM_AUTOPROBE_PROTOS];
- int serialDefaultsNum;
- int prevDx, prevDy;
- int accDx, accDy;
- int acc;
- CARD32 pnpLast;
- Bool disablePnPauto;
- float fracdx,fracdy;
- float sensitivity;
+ int serialDefaultsNum;
+ int prevDx, prevDy;
+ int accDx, accDy;
+ int acc;
+ CARD32 pnpLast;
+ Bool disablePnPauto;
+ float fracdx,fracdy;
+ float sensitivity;
} mousePrivRec, *mousePrivPtr;
/* mouse proto flags */
-#define MPF_NONE 0x00
-#define MPF_SAFE 0x01
+#define MPF_NONE 0x00
+#define MPF_SAFE 0x01
/* pnp.c */
MouseProtocolID MouseGetPnpProtocol(InputInfoPtr pInfo);
diff --git a/src/pnp.c b/src/pnp.c
index 8d1159f..6eba24d 100644
--- a/src/pnp.c
+++ b/src/pnp.c
@@ -46,13 +46,13 @@
/* serial PnP ID string */
typedef struct {
- int revision; /* PnP revision, 100 for 1.00 */
- char *eisaid; /* EISA ID including mfr ID and product ID */
- char *serial; /* serial No, optional */
- char *class; /* device class, optional */
- char *compat; /* list of compatible drivers, optional */
- char *description; /* product description, optional */
- int neisaid; /* length of the above fields... */
+ int revision; /* PnP revision, 100 for 1.00 */
+ char *eisaid; /* EISA ID including mfr ID and product ID */
+ char *serial; /* serial No, optional */
+ char *class; /* device class, optional */
+ char *compat; /* list of compatible drivers, optional */
+ char *description; /* product description, optional */
+ int neisaid; /* length of the above fields... */
int nserial;
int nclass;
int ncompat;
@@ -67,79 +67,79 @@ typedef struct {
/* PnP EISA/product IDs */
static symtab_t pnpprod[] = {
- { "KML0001", PROT_THINKING }, /* Kensington ThinkingMouse */
- { "MSH0001", PROT_IMSERIAL }, /* MS IntelliMouse */
- { "MSH0004", PROT_IMSERIAL }, /* MS IntelliMouse TrackBall */
- { "KYEEZ00", PROT_MS }, /* Genius EZScroll */
- { "KYE0001", PROT_MS }, /* Genius PnP Mouse */
- { "KYE0002", PROT_MS }, /* MouseSystem (Genius?) SmartScroll */
- { "KYE0003", PROT_IMSERIAL }, /* Genius NetMouse */
- { "KYE0004", PROT_IMSERIAL }, /* Genius NetScroll+ (serial) */
- { "LGI800C", PROT_IMSERIAL }, /* Logitech MouseMan (4 button model) */
- { "LGI8033", PROT_IMSERIAL }, /* Logitech Cordless MouseMan Wheel */
- { "LGI8050", PROT_IMSERIAL }, /* Logitech MouseMan+ */
- { "LGI8051", PROT_IMSERIAL }, /* Logitech FirstMouse+ */
- { "LGI8001", PROT_LOGIMAN }, /* Logitech serial */
- { "A4W0005", PROT_IMSERIAL }, /* A4 Tech 4D/4D+ Mouse */
- { "PEC9802", PROT_IMSERIAL }, /* 8D Scroll Mouse */
-
- { "PNP0F00", PROT_BM }, /* MS bus */
- { "PNP0F01", PROT_MS }, /* MS serial */
- { "PNP0F02", PROT_BM }, /* MS InPort */
- { "PNP0F03", PROT_PS2 }, /* MS PS/2 */
+ { "KML0001", PROT_THINKING }, /* Kensington ThinkingMouse */
+ { "MSH0001", PROT_IMSERIAL }, /* MS IntelliMouse */
+ { "MSH0004", PROT_IMSERIAL }, /* MS IntelliMouse TrackBall */
+ { "KYEEZ00", PROT_MS }, /* Genius EZScroll */
+ { "KYE0001", PROT_MS }, /* Genius PnP Mouse */
+ { "KYE0002", PROT_MS }, /* MouseSystem (Genius?) SmartScroll */
+ { "KYE0003", PROT_IMSERIAL }, /* Genius NetMouse */
+ { "KYE0004", PROT_IMSERIAL }, /* Genius NetScroll+ (serial) */
+ { "LGI800C", PROT_IMSERIAL }, /* Logitech MouseMan (4 button model) */
+ { "LGI8033", PROT_IMSERIAL }, /* Logitech Cordless MouseMan Wheel */
+ { "LGI8050", PROT_IMSERIAL }, /* Logitech MouseMan+ */
+ { "LGI8051", PROT_IMSERIAL }, /* Logitech FirstMouse+ */
+ { "LGI8001", PROT_LOGIMAN }, /* Logitech serial */
+ { "A4W0005", PROT_IMSERIAL }, /* A4 Tech 4D/4D+ Mouse */
+ { "PEC9802", PROT_IMSERIAL }, /* 8D Scroll Mouse */
+
+ { "PNP0F00", PROT_BM }, /* MS bus */
+ { "PNP0F01", PROT_MS }, /* MS serial */
+ { "PNP0F02", PROT_BM }, /* MS InPort */
+ { "PNP0F03", PROT_PS2 }, /* MS PS/2 */
/*
* EzScroll returns PNP0F04 in the compatible device field; but it
* doesn't look compatible... XXX
*/
- { "PNP0F04", PROT_MSC }, /* MouseSystems */
- { "PNP0F05", PROT_MSC }, /* MouseSystems */
+ { "PNP0F04", PROT_MSC }, /* MouseSystems */
+ { "PNP0F05", PROT_MSC }, /* MouseSystems */
#ifdef notyet
- { "PNP0F06", PROT_??? }, /* Genius Mouse */
- { "PNP0F07", PROT_??? }, /* Genius Mouse */
+ { "PNP0F06", PROT_??? }, /* Genius Mouse */
+ { "PNP0F07", PROT_??? }, /* Genius Mouse */
#endif
- { "PNP0F08", PROT_LOGIMAN }, /* Logitech serial */
- { "PNP0F09", PROT_MS }, /* MS BallPoint serial */
- { "PNP0F0A", PROT_MS }, /* MS PnP serial */
- { "PNP0F0B", PROT_MS }, /* MS PnP BallPoint serial */
- { "PNP0F0C", PROT_MS }, /* MS serial compatible */
- { "PNP0F0D", PROT_BM }, /* MS InPort compatible */
- { "PNP0F0E", PROT_PS2 }, /* MS PS/2 compatible */
- { "PNP0F0F", PROT_MS }, /* MS BallPoint compatible */
+ { "PNP0F08", PROT_LOGIMAN }, /* Logitech serial */
+ { "PNP0F09", PROT_MS }, /* MS BallPoint serial */
+ { "PNP0F0A", PROT_MS }, /* MS PnP serial */
+ { "PNP0F0B", PROT_MS }, /* MS PnP BallPoint serial */
+ { "PNP0F0C", PROT_MS }, /* MS serial compatible */
+ { "PNP0F0D", PROT_BM }, /* MS InPort compatible */
+ { "PNP0F0E", PROT_PS2 }, /* MS PS/2 compatible */
+ { "PNP0F0F", PROT_MS }, /* MS BallPoint compatible */
#ifdef notyet
- { "PNP0F10", PROT_??? }, /* TI QuickPort */
+ { "PNP0F10", PROT_??? }, /* TI QuickPort */
#endif
- { "PNP0F11", PROT_BM }, /* MS bus compatible */
- { "PNP0F12", PROT_PS2 }, /* Logitech PS/2 */
- { "PNP0F13", PROT_PS2 }, /* PS/2 */
+ { "PNP0F11", PROT_BM }, /* MS bus compatible */
+ { "PNP0F12", PROT_PS2 }, /* Logitech PS/2 */
+ { "PNP0F13", PROT_PS2 }, /* PS/2 */
#ifdef notyet
- { "PNP0F14", PROT_??? }, /* MS Kids Mouse */
+ { "PNP0F14", PROT_??? }, /* MS Kids Mouse */
#endif
- { "PNP0F15", PROT_BM }, /* Logitech bus */
+ { "PNP0F15", PROT_BM }, /* Logitech bus */
#ifdef notyet
- { "PNP0F16", PROT_??? }, /* Logitech SWIFT */
+ { "PNP0F16", PROT_??? }, /* Logitech SWIFT */
#endif
- { "PNP0F17", PROT_LOGIMAN }, /* Logitech serial compat */
- { "PNP0F18", PROT_BM }, /* Logitech bus compatible */
- { "PNP0F19", PROT_PS2 }, /* Logitech PS/2 compatible */
+ { "PNP0F17", PROT_LOGIMAN }, /* Logitech serial compat */
+ { "PNP0F18", PROT_BM }, /* Logitech bus compatible */
+ { "PNP0F19", PROT_PS2 }, /* Logitech PS/2 compatible */
#ifdef notyet
- { "PNP0F1A", PROT_??? }, /* Logitech SWIFT compatible */
- { "PNP0F1B", PROT_??? }, /* HP Omnibook */
- { "PNP0F1C", PROT_??? }, /* Compaq LTE TrackBall PS/2 */
- { "PNP0F1D", PROT_??? }, /* Compaq LTE TrackBall serial */
- { "PNP0F1E", PROT_??? }, /* MS Kids Trackball */
+ { "PNP0F1A", PROT_??? }, /* Logitech SWIFT compatible */
+ { "PNP0F1B", PROT_??? }, /* HP Omnibook */
+ { "PNP0F1C", PROT_??? }, /* Compaq LTE TrackBall PS/2 */
+ { "PNP0F1D", PROT_??? }, /* Compaq LTE TrackBall serial */
+ { "PNP0F1E", PROT_??? }, /* MS Kids Trackball */
#endif
- { NULL, PROT_UNKNOWN },
+ { NULL, PROT_UNKNOWN },
};
static const char *pnpSerial[] = {
- "BaudRate", "1200",
- "DataBits", "7",
- "StopBits", "1",
- "Parity", "None",
- "FlowControl", "None",
- "VTime", "0",
- "VMin", "1",
- NULL
+ "BaudRate", "1200",
+ "DataBits", "7",
+ "StopBits", "1",
+ "Parity", "None",
+ "FlowControl", "None",
+ "VTime", "0",
+ "VMin", "1",
+ NULL
};
static int pnpgets(InputInfoPtr, char *, Bool *prePNP);
@@ -153,7 +153,7 @@ static MouseProtocolID probePs2ProtocolPnP(InputInfoPtr pInfo);
static MouseProtocolID
MouseGetSerialPnpProtocol(InputInfoPtr pInfo)
{
- char buf[256]; /* PnP ID string may be up to 256 bytes long */
+ char buf[256]; /* PnP ID string may be up to 256 bytes long */
pnpid_t pnpid;
symtab_t *t;
int len;
@@ -161,15 +161,15 @@ MouseGetSerialPnpProtocol(InputInfoPtr pInfo)
if ((len = pnpgets(pInfo, buf, &prePNP)) > 0)
{
- if (!prePNP) {
- if (pnpparse(pInfo, &pnpid, buf, len) &&
- (t = pnpproto(&pnpid)) != NULL) {
- xf86MsgVerb(X_INFO, 2, "%s: PnP-detected protocol ID: %d\n",
- pInfo->name, t->val);
- return (t->val);
- }
- } else
- return prepnpparse(pInfo,buf);
+ if (!prePNP) {
+ if (pnpparse(pInfo, &pnpid, buf, len) &&
+ (t = pnpproto(&pnpid)) != NULL) {
+ xf86MsgVerb(X_INFO, 2, "%s: PnP-detected protocol ID: %d\n",
+ pInfo->name, t->val);
+ return (t->val);
+ }
+ } else
+ return prepnpparse(pInfo,buf);
}
return PROT_UNKNOWN;
}
@@ -183,35 +183,35 @@ MouseGetPnpProtocol(InputInfoPtr pInfo)
CARD32 last;
if ((val = MouseGetSerialPnpProtocol(pInfo)) != PROT_UNKNOWN) {
- if (val == MouseGetSerialPnpProtocol(pInfo))
- return val;
+ if (val == MouseGetSerialPnpProtocol(pInfo))
+ return val;
}
last = mPriv->pnpLast;
mPriv->pnpLast = currentTime.milliseconds;
if (last) {
- if (last - currentTime.milliseconds < 100
- || (mPriv->disablePnPauto
- && (last - currentTime.milliseconds < 10000))) {
+ if (last - currentTime.milliseconds < 100
+ || (mPriv->disablePnPauto
+ && (last - currentTime.milliseconds < 10000))) {
#ifdef EXTMOUSEDEBUG
- xf86ErrorF("Mouse: Disabling PnP\n");
+ xf86ErrorF("Mouse: Disabling PnP\n");
#endif
- mPriv->disablePnPauto = TRUE;
- return PROT_UNKNOWN;
- }
+ mPriv->disablePnPauto = TRUE;
+ return PROT_UNKNOWN;
+ }
}
#ifdef EXTMOUSEDEBUG
if (mPriv->disablePnPauto)
- xf86ErrorF("Mouse: Enabling PnP\n");
+ xf86ErrorF("Mouse: Enabling PnP\n");
#endif
mPriv->disablePnPauto = FALSE;
if (mPriv->soft)
- return getPs2ProtocolPnP(pInfo);
+ return getPs2ProtocolPnP(pInfo);
else
- return probePs2ProtocolPnP(pInfo);
+ return probePs2ProtocolPnP(pInfo);
}
/*
@@ -246,47 +246,47 @@ pnpgets(InputInfoPtr pInfo, char *buf, Bool *prePNP)
/* port initialization (2.1.2) */
if ((i = xf86GetSerialModemState(pInfo->fd)) == -1)
- return 0;
- i |= XF86_M_DTR; /* DTR = 1 */
- i &= ~XF86_M_RTS; /* RTS = 0 */
+ return 0;
+ i |= XF86_M_DTR; /* DTR = 1 */
+ i &= ~XF86_M_RTS; /* RTS = 0 */
if (xf86SetSerialModemState(pInfo->fd, i) == -1)
- goto disconnect_idle;
+ goto disconnect_idle;
usleep(200000);
if ((i = xf86GetSerialModemState(pInfo->fd)) == -1 ||
- (i & XF86_M_DSR) == 0)
- goto disconnect_idle;
+ (i & XF86_M_DSR) == 0)
+ goto disconnect_idle;
/* port setup, 1st phase (2.1.3) */
pnpOpts = xf86OptionListCreate(pnpSerial, -1, 1);
xf86SetSerial(pInfo->fd, pnpOpts);
- i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
+ i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
xf86SerialModemClearBits(pInfo->fd, i);
usleep(200000);
- i = TIOCM_DTR; /* DTR = 1, RTS = 0 */
+ i = TIOCM_DTR; /* DTR = 1, RTS = 0 */
xf86SerialModemSetBits(pInfo->fd, i);
usleep(200000);
/* wait for response, 1st phase (2.1.4) */
xf86FlushInput(pInfo->fd);
- i = TIOCM_RTS; /* DTR = 1, RTS = 1 */
+ i = TIOCM_RTS; /* DTR = 1, RTS = 1 */
xf86SerialModemSetBits(pInfo->fd, i);
/* try to read something */
if (xf86WaitForInput(pInfo->fd, 200000) <= 0) {
- /* port setup, 2nd phase (2.1.5) */
- i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
- xf86SerialModemClearBits(pInfo->fd, i);
+ /* port setup, 2nd phase (2.1.5) */
+ i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
+ xf86SerialModemClearBits(pInfo->fd, i);
usleep(200000);
- /* wait for response, 2nd phase (2.1.6) */
- xf86FlushInput(pInfo->fd);
- i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
- xf86SerialModemSetBits(pInfo->fd, i);
+ /* wait for response, 2nd phase (2.1.6) */
+ xf86FlushInput(pInfo->fd);
+ i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
+ xf86SerialModemSetBits(pInfo->fd, i);
/* try to read something */
- if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
- goto connect_idle;
+ if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
+ goto connect_idle;
}
#else
/*
@@ -294,11 +294,11 @@ pnpgets(InputInfoPtr pInfo, char *buf, Bool *prePNP)
*/
if ((i = xf86GetSerialModemState(pInfo->fd)) == -1)
- return 0;
- i |= XF86_M_DTR; /* DTR = 1 */
- i &= ~XF86_M_RTS; /* RTS = 0 */
+ return 0;
+ i |= XF86_M_DTR; /* DTR = 1 */
+ i &= ~XF86_M_RTS; /* RTS = 0 */
if (xf86SetSerialModemState(pInfo->fd, i) == -1)
- goto disconnect_idle;
+ goto disconnect_idle;
usleep(200000);
pnpOpts = xf86OptionListCreate(pnpSerial, -1, 1);
@@ -306,7 +306,7 @@ pnpgets(InputInfoPtr pInfo, char *buf, Bool *prePNP)
/* wait for response */
xf86FlushInput(pInfo->fd);
- i = XF86_M_DTR | XF86_M_RTS; /* DTR = 1, RTS = 1 */
+ i = XF86_M_DTR | XF86_M_RTS; /* DTR = 1, RTS = 1 */
xf86SerialModemSetBits(pInfo->fd, i);
/* try to read something */
@@ -318,44 +318,44 @@ pnpgets(InputInfoPtr pInfo, char *buf, Bool *prePNP)
i = 0;
*prePNP = FALSE;
- usleep(200000); /* the mouse must send `Begin ID' within 200msec */
+ usleep(200000); /* the mouse must send `Begin ID' within 200msec */
while (xf86ReadSerial(pInfo->fd, &c, 1) == 1) {
- /* we may see "M", or "M3..." before `Begin ID' */
- if (c == 'M')
- *prePNP = TRUE;
-
- if ((c == 0x08) || (c == 0x28)) { /* Begin ID */
- *prePNP = FALSE;
- buf[0] = c;
- i = 1;
- break;
+ /* we may see "M", or "M3..." before `Begin ID' */
+ if (c == 'M')
+ *prePNP = TRUE;
+
+ if ((c == 0x08) || (c == 0x28)) { /* Begin ID */
+ *prePNP = FALSE;
+ buf[0] = c;
+ i = 1;
+ break;
}
- if (*prePNP)
- buf[i++] = c;
+ if (*prePNP)
+ buf[i++] = c;
- if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
- break;
+ if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
+ break;
}
if (i <= 0) {
- /* we haven't seen `Begin ID' in time... */
- goto connect_idle;
+ /* we haven't seen `Begin ID' in time... */
+ goto connect_idle;
}
if (*prePNP)
- return i;
+ return i;
- ++c; /* make it `End ID' */
+ ++c; /* make it `End ID' */
for (;;) {
- if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
- break;
-
- xf86ReadSerial(pInfo->fd, &buf[i], 1);
- if (buf[i++] == c) /* End ID */
- break;
- if (i >= 256)
- break;
+ if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
+ break;
+
+ xf86ReadSerial(pInfo->fd, &buf[i], 1);
+ if (buf[i++] == c) /* End ID */
+ break;
+ if (i >= 256)
+ break;
}
if (buf[i - 1] != c)
- goto connect_idle;
+ goto connect_idle;
return i;
/*
@@ -365,7 +365,7 @@ pnpgets(InputInfoPtr pInfo, char *buf, Bool *prePNP)
* respond to the PnP enumeration procedure.
*/
disconnect_idle:
- i = XF86_M_DTR | XF86_M_RTS; /* DTR = 1, RTS = 1 */
+ i = XF86_M_DTR | XF86_M_RTS; /* DTR = 1, RTS = 1 */
xf86SerialModemSetBits(pInfo->fd, i);
connect_idle:
return 0;
@@ -395,21 +395,21 @@ pnpparse(InputInfoPtr pInfo, pnpid_t *id, char *buf, int len)
/* calculate checksum */
for (i = 0; i < len - 3; ++i) {
- sum += buf[i];
- buf[i] += offset;
+ sum += buf[i];
+ buf[i] += offset;
}
sum += buf[len - 1];
for (; i < len; ++i)
- buf[i] += offset;
+ buf[i] += offset;
xf86MsgVerb(X_INFO, 2, "%s: PnP ID string: `%*.*s'\n", pInfo->name,
- len, len, buf);
+ len, len, buf);
/* revision */
buf[1] -= offset;
buf[2] -= offset;
id->revision = ((buf[1] & 0x3f) << 6) | (buf[2] & 0x3f);
xf86MsgVerb(X_INFO, 2, "%s: PnP rev %d.%02d\n", pInfo->name,
- id->revision / 100, id->revision % 100);
+ id->revision / 100, id->revision % 100);
/* EISA vender and product ID */
id->eisaid = &buf[3];
@@ -421,56 +421,56 @@ pnpparse(InputInfoPtr pInfo, pnpid_t *id, char *buf, int len)
/* device serial # */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
- break;
+ break;
}
- if (i >= len)
- i -= 3;
- if (i - j == 8) {
+ if (i >= len)
+ i -= 3;
+ if (i - j == 8) {
id->serial = &buf[j];
id->nserial = 8;
- }
+ }
}
if (buf[i] == '\\') {
/* PnP class */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
- break;
+ break;
}
- if (i >= len)
- i -= 3;
- if (i > j + 1) {
+ if (i >= len)
+ i -= 3;
+ if (i > j + 1) {
id->class = &buf[j];
id->nclass = i - j;
}
}
if (buf[i] == '\\') {
- /* compatible driver */
+ /* compatible driver */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
- break;
+ break;
}
- /*
- * PnP COM spec prior to v0.96 allowed '*' in this field,
- * it's not allowed now; just ignore it.
- */
- if (buf[j] == '*')
- ++j;
- if (i >= len)
- i -= 3;
- if (i > j + 1) {
+ /*
+ * PnP COM spec prior to v0.96 allowed '*' in this field,
+ * it's not allowed now; just ignore it.
+ */
+ if (buf[j] == '*')
+ ++j;
+ if (i >= len)
+ i -= 3;
+ if (i > j + 1) {
id->compat = &buf[j];
id->ncompat = i - j;
}
}
if (buf[i] == '\\') {
- /* product description */
+ /* product description */
for (j = ++i; i < len; ++i) {
if (buf[i] == ';')
- break;
+ break;
}
- if (i >= len)
- i -= 3;
- if (i > j + 1) {
+ if (i >= len)
+ i -= 3;
+ if (i > j + 1) {
id->description = &buf[j];
id->ndescription = i - j;
}
@@ -478,17 +478,17 @@ pnpparse(InputInfoPtr pInfo, pnpid_t *id, char *buf, int len)
/* checksum exists if there are any optional fields */
if ((id->nserial > 0) || (id->nclass > 0)
- || (id->ncompat > 0) || (id->ndescription > 0)) {
- xf86MsgVerb(X_INFO, 4, "%s: PnP checksum: 0x%02X\n", pInfo->name, sum);
+ || (id->ncompat > 0) || (id->ndescription > 0)) {
+ xf86MsgVerb(X_INFO, 4, "%s: PnP checksum: 0x%02X\n", pInfo->name, sum);
sprintf(s, "%02X", sum & 0x0ff);
if (strncmp(s, &buf[len - 3], 2) != 0) {
#if 0
/*
- * Checksum error!!
- * I found some mice do not comply with the PnP COM device
- * spec regarding checksum... XXX
- */
- return FALSE;
+ * Checksum error!!
+ * I found some mice do not comply with the PnP COM device
+ * spec regarding checksum... XXX
+ */
+ return FALSE;
#endif
}
}
@@ -501,7 +501,7 @@ static MouseProtocolID
prepnpparse(InputInfoPtr pInfo, char *buf)
{
if (buf[0] == 'M' && buf[1] == '3')
- return PROT_MS;
+ return PROT_MS;
return PROT_UNKNOWN;
}
@@ -513,13 +513,13 @@ pnpproto(pnpid_t *id)
int i, j;
if (id->nclass > 0)
- if (strncmp(id->class, "MOUSE", id->nclass) != 0)
- /* this is not a mouse! */
- return NULL;
+ if (strncmp(id->class, "MOUSE", id->nclass) != 0)
+ /* this is not a mouse! */
+ return NULL;
if (id->neisaid > 0) {
t = gettoken(pnpprod, id->eisaid, id->neisaid);
- if (t->val != -1)
+ if (t->val != -1)
return t;
}
@@ -528,16 +528,16 @@ pnpproto(pnpid_t *id)
* ID separated by ','.
*/
if (id->ncompat <= 0)
- return NULL;
+ return NULL;
for (i = 0; i < id->ncompat; ++i) {
for (j = i; id->compat[i] != ','; ++i)
if (i >= id->ncompat)
- break;
+ break;
if (i > j) {
t = gettoken(pnpprod, id->compat + j, i - j);
- if (t->val != -1)
+ if (t->val != -1)
return t;
- }
+ }
}
return NULL;
@@ -551,8 +551,8 @@ gettoken(symtab_t *tab, char *s, int len)
int i;
for (i = 0; tab[i].name != NULL; ++i) {
- if (strncmp(tab[i].name, s, len) == 0)
- break;
+ if (strncmp(tab[i].name, s, len) == 0)
+ break;
}
return &tab[i];
}
@@ -564,7 +564,7 @@ readMouse(InputInfoPtr pInfo, unsigned char *u)
{
if (xf86WaitForInput(pInfo->fd, 200000) <= 0)
- return FALSE;
+ return FALSE;
xf86ReadSerial(pInfo->fd, u, 1);
return TRUE;
@@ -586,42 +586,42 @@ ps2SendPacket(InputInfoPtr pInfo, unsigned char *bytes, int len)
#ifdef DEBUG
xf86ErrorF("Ps/2 data package:");
for (i = 0; i < len; i++)
- xf86ErrorF(" %x", *(bytes + i));
+ xf86ErrorF(" %x", *(bytes + i));
xf86ErrorF("\n");
#endif
for (i = 0; i < len; i++) {
- for (j = 0; j < 10; j++) {
- xf86WriteSerial(pInfo->fd, bytes + i, 1);
- usleep(10000);
- if (!readMouse(pInfo,&c)) {
+ for (j = 0; j < 10; j++) {
+ xf86WriteSerial(pInfo->fd, bytes + i, 1);
+ usleep(10000);
+ if (!readMouse(pInfo,&c)) {
#ifdef DEBUG
- xf86ErrorF("sending 0x%x to PS/2 unsuccessful\n",*(bytes + i));
+ xf86ErrorF("sending 0x%x to PS/2 unsuccessful\n",*(bytes + i));
#endif
- return FALSE;
- }
+ return FALSE;
+ }
#ifdef DEBUG
- xf86ErrorF("Recieved: 0x%x\n",c);
+ xf86ErrorF("Recieved: 0x%x\n",c);
#endif
- if (c == 0xFA) /* ACK */
- break;
+ if (c == 0xFA) /* ACK */
+ break;
- if (c == 0xFE) /* resend */
- continue;
+ if (c == 0xFE) /* resend */
+ continue;
- if (c == 0xFC) /* error */
- return FALSE;
+ if (c == 0xFC) /* error */
+ return FALSE;
- /* Some mice accidently enter wrap mode during init */
- if (c == *(bytes + i) /* wrap mode */
- && (*(bytes + i) != 0xEC)) /* avoid recursion */
- ps2DisableWrapMode(pInfo);
+ /* Some mice accidently enter wrap mode during init */
+ if (c == *(bytes + i) /* wrap mode */
+ && (*(bytes + i) != 0xEC)) /* avoid recursion */
+ ps2DisableWrapMode(pInfo);
- return FALSE;
- }
- if (j == 10)
- return FALSE;
+ return FALSE;
+ }
+ if (j == 10)
+ return FALSE;
}
return TRUE;
@@ -650,12 +650,12 @@ ps2GetDeviceID(InputInfoPtr pInfo)
usleep(30000);
xf86FlushInput(pInfo->fd);
if (!ps2SendPacket(pInfo, packet, sizeof(packet)))
- return -1;
+ return -1;
while (1) {
- if (!readMouse(pInfo,&u))
- return -1;
- if (u != 0xFA)
- break;
+ if (!readMouse(pInfo,&u))
+ return -1;
+ if (u != 0xFA)
+ break;
}
#ifdef DEBUG
xf86ErrorF("Obtained Mouse Type: %x\n",u);
@@ -674,15 +674,15 @@ ps2Reset(InputInfoPtr pInfo)
xf86ErrorF("PS/2 Mouse reset\n");
#endif
if (!ps2SendPacket(pInfo, packet, sizeof(packet)))
- return FALSE;
+ return FALSE;
/* we need a little delay here */
xf86WaitForInput(pInfo->fd, 500000);
for (i = 0; i < sizeof(reply) ; i++) {
- if (!readMouse(pInfo,&u)) {
- goto EXIT;
- }
- if (u != reply[i])
- goto EXIT;
+ if (!readMouse(pInfo,&u)) {
+ goto EXIT;
+ }
+ if (u != reply[i])
+ goto EXIT;
}
return TRUE;
@@ -702,26 +702,26 @@ probePs2ProtocolPnP(InputInfoPtr pInfo)
ps2DisableDataReporting(pInfo);
if (ps2Reset(pInfo)) { /* Reset PS2 device */
- unsigned char seq[] = { 243, 200, 243, 100, 243, 80 };
- /* Try to identify Intelli Mouse */
- if (ps2SendPacket(pInfo, seq, sizeof(seq))) {
- u = ps2GetDeviceID(pInfo);
- if (u == 0x03) {
- /* found IntelliMouse now try IntelliExplorer */
- unsigned char seq[] = { 243, 200, 243, 200, 243, 80 };
- if (ps2SendPacket(pInfo,seq,sizeof(seq))) {
- u = ps2GetDeviceID(pInfo);
- if (u == 0x04)
- ret = PROT_EXPPS2;
- else
- ret = PROT_IMPS2;
- }
- } else if (ps2Reset(pInfo)) /* reset again to find sane state */
- ret = PROT_PS2;
- }
-
- if (ret != PROT_UNKNOWN)
- ps2EnableDataReporting(pInfo);
+ unsigned char seq[] = { 243, 200, 243, 100, 243, 80 };
+ /* Try to identify Intelli Mouse */
+ if (ps2SendPacket(pInfo, seq, sizeof(seq))) {
+ u = ps2GetDeviceID(pInfo);
+ if (u == 0x03) {
+ /* found IntelliMouse now try IntelliExplorer */
+ unsigned char seq[] = { 243, 200, 243, 200, 243, 80 };
+ if (ps2SendPacket(pInfo,seq,sizeof(seq))) {
+ u = ps2GetDeviceID(pInfo);
+ if (u == 0x04)
+ ret = PROT_EXPPS2;
+ else
+ ret = PROT_IMPS2;
+ }
+ } else if (ps2Reset(pInfo)) /* reset again to find sane state */
+ ret = PROT_PS2;
+ }
+
+ if (ret != PROT_UNKNOWN)
+ ps2EnableDataReporting(pInfo);
}
return ret;
}
@@ -748,30 +748,30 @@ getPs2ProtocolPnP(InputInfoPtr pInfo)
xf86FlushInput(pInfo->fd);
while (--count)
- if (ps2DisableDataReporting(pInfo))
- break;
+ if (ps2DisableDataReporting(pInfo))
+ break;
if (!count) {
- proto = PROT_UNKNOWN;
- goto EXIT;
+ proto = PROT_UNKNOWN;
+ goto EXIT;
}
if ((Id = ps2GetDeviceID(pInfo)) == -1) {
- proto = PROT_UNKNOWN;
- goto EXIT;
+ proto = PROT_UNKNOWN;
+ goto EXIT;
}
if (-1 == ps2EnableDataReporting(pInfo)) {
- proto = PROT_UNKNOWN;
- goto EXIT;
+ proto = PROT_UNKNOWN;
+ goto EXIT;
}
for (i = 0; ps2[i].protoID != PROT_UNKNOWN; i++) {
- if (ps2[i].Id == Id) {
- xf86MsgVerb(X_PROBED,2,"Found PS/2 proto ID %x\n",Id);
- proto = ps2[i].protoID;
- goto EXIT;
- }
+ if (ps2[i].Id == Id) {
+ xf86MsgVerb(X_PROBED,2,"Found PS/2 proto ID %x\n",Id);
+ proto = ps2[i].protoID;
+ goto EXIT;
+ }
}
proto = PROT_UNKNOWN;
diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index 8f1347a..fe27400 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -80,33 +80,33 @@
/* Names of protocols that are handled internally here. */
static const char *internalNames[] = {
- "VUID",
- NULL
+ "VUID",
+ NULL
};
static const char *solarisMouseDevs[] = {
- /* Device file: Protocol: */
- "/dev/mouse", "VUID", /* USB or SPARC */
+ /* Device file: Protocol: */
+ "/dev/mouse", "VUID", /* USB or SPARC */
#if defined(__i386) || defined(__x86)
- "/dev/kdmouse", "PS/2", /* PS/2 */
+ "/dev/kdmouse", "PS/2", /* PS/2 */
#endif
NULL
};
typedef struct _VuidMseRec {
struct _VuidMseRec *next;
- InputInfoPtr pInfo;
- Firm_event event;
- unsigned char * buffer;
- char * strmod;
+ InputInfoPtr pInfo;
+ Firm_event event;
+ unsigned char * buffer;
+ char * strmod;
Bool(*wrapped_device_control)(DeviceIntPtr device, int what);
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
- Ms_screen_resolution absres;
+ Ms_screen_resolution absres;
#endif
- OsTimerPtr remove_timer; /* Callback for removal on ENODEV */
+ OsTimerPtr remove_timer; /* Callback for removal on ENODEV */
} VuidMseRec, *VuidMsePtr;
-static VuidMsePtr vuidMouseList = NULL;
+static VuidMsePtr vuidMouseList = NULL;
static int vuidMouseProc(DeviceIntPtr pPointer, int what);
static void vuidReadInput(InputInfoPtr pInfo);
@@ -135,7 +135,7 @@ VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo)
VuidMsePtr m = vuidMouseList;
while ((m != NULL) && (m->pInfo != pInfo)) {
- m = m->next;
+ m = m->next;
}
return m;
@@ -174,20 +174,20 @@ vuidMouseWheelInit(InputInfoPtr pInfo)
SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel));
if (i != 0)
- return (0);
+ return (0);
SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate));
if (i != 0) {
- xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
- return (0);
+ xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
+ return (0);
}
wstate.stateflags |= VUID_WHEEL_STATE_ENABLED;
SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate));
if (i != 0) {
- xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
- return (0);
+ xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
+ return (0);
}
return (1);
@@ -206,13 +206,13 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
/* Ensure we don't add the same device twice */
if (getVuidMsePriv(pInfo) != NULL)
- return TRUE;
+ return TRUE;
pVuidMse = calloc(sizeof(VuidMseRec), 1);
if (pVuidMse == NULL) {
- xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
- free(pMse);
- return FALSE;
+ xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
+ free(pMse);
+ return FALSE;
}
pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
@@ -240,30 +240,30 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
static void
vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY,
- Bool *absXset, Bool *absYset)
+ Bool *absXset, Bool *absYset)
{
#ifdef DEBUG
ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY,
- *absXset, *absYset);
+ *absXset, *absYset);
#endif
if ((*absXset) && (*absYset)) {
- xf86PostMotionEvent(pInfo->dev,
- /* is_absolute: */ TRUE,
- /* first_valuator: */ 0,
- /* num_valuators: */ 2,
- absX, absY);
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 2,
+ absX, absY);
} else if (*absXset) {
- xf86PostMotionEvent(pInfo->dev,
- /* is_absolute: */ TRUE,
- /* first_valuator: */ 0,
- /* num_valuators: */ 1,
- absX);
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 1,
+ absX);
} else if (*absYset) {
- xf86PostMotionEvent(pInfo->dev,
- /* is_absolute: */ TRUE,
- /* first_valuator: */ 1,
- /* num_valuators: */ 1,
- absY);
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 1,
+ /* num_valuators: */ 1,
+ absY);
}
*absXset = FALSE;
@@ -289,105 +289,105 @@ vuidReadInput(InputInfoPtr pInfo)
n = 0;
do {
- n = read(pInfo->fd, pBuf, sizeof(Firm_event));
-
- if (n == 0) {
- break;
- } else if (n == -1) {
- switch (errno) {
- case EAGAIN: /* Nothing to read now */
- n = 0; /* End loop, go on to flush events & return */
- continue;
- case EINTR: /* Interrupted, try again */
- continue;
- case ENODEV: /* May happen when USB mouse is unplugged */
- /* We use X_NONE here because it doesn't alloc since we
- may be called from SIGIO handler */
- xf86MsgVerb(X_NONE, 0,
- "%s: Device no longer present - removing.\n",
- pInfo->name);
- xf86RemoveEnabledDevice(pInfo);
- pVuidMse->remove_timer =
- TimerSet(pVuidMse->remove_timer, 0, 1,
- vuidRemoveMouse, pInfo);
- return;
- default: /* All other errors */
- /* We use X_NONE here because it doesn't alloc since we
- may be called from SIGIO handler */
- xf86MsgVerb(X_NONE, 0, "%s: Read error: %s\n", pInfo->name,
- strerror(errno));
- return;
- }
- } else if (n != sizeof(Firm_event)) {
- xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n",
- pInfo->name, n);
- }
+ n = read(pInfo->fd, pBuf, sizeof(Firm_event));
+
+ if (n == 0) {
+ break;
+ } else if (n == -1) {
+ switch (errno) {
+ case EAGAIN: /* Nothing to read now */
+ n = 0; /* End loop, go on to flush events & return */
+ continue;
+ case EINTR: /* Interrupted, try again */
+ continue;
+ case ENODEV: /* May happen when USB mouse is unplugged */
+ /* We use X_NONE here because it doesn't alloc since we
+ may be called from SIGIO handler */
+ xf86MsgVerb(X_NONE, 0,
+ "%s: Device no longer present - removing.\n",
+ pInfo->name);
+ xf86RemoveEnabledDevice(pInfo);
+ pVuidMse->remove_timer =
+ TimerSet(pVuidMse->remove_timer, 0, 1,
+ vuidRemoveMouse, pInfo);
+ return;
+ default: /* All other errors */
+ /* We use X_NONE here because it doesn't alloc since we
+ may be called from SIGIO handler */
+ xf86MsgVerb(X_NONE, 0, "%s: Read error: %s\n", pInfo->name,
+ strerror(errno));
+ return;
+ }
+ } else if (n != sizeof(Firm_event)) {
+ xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n",
+ pInfo->name, n);
+ }
#ifdef DEBUG
- ErrorF("vuidReadInput: event type: %3d value: %5d\n",
- pVuidMse->event.id, pVuidMse->event.value);
+ ErrorF("vuidReadInput: event type: %3d value: %5d\n",
+ pVuidMse->event.id, pVuidMse->event.value);
#endif
- if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
- /* button */
- int butnum = pVuidMse->event.id - BUT_FIRST;
-
- if (butnum < 3)
- butnum = 2 - butnum;
- if (!pVuidMse->event.value)
- buttons &= ~(1 << butnum);
- else
- buttons |= (1 << butnum);
- } else if (pVuidMse->event.id >= VLOC_FIRST &&
- pVuidMse->event.id <= VLOC_LAST) {
- /* axis */
- int delta = pVuidMse->event.value;
- switch(pVuidMse->event.id) {
- case LOC_X_DELTA:
- dx += delta;
- break;
- case LOC_Y_DELTA:
- dy -= delta;
- break;
- case LOC_X_ABSOLUTE:
- if (absXset) {
- vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
- }
- absX = delta;
- absXset = TRUE;
- break;
- case LOC_Y_ABSOLUTE:
- if (absYset) {
- vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
- }
- absY = delta;
- absYset = TRUE;
- break;
- }
- }
+ if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
+ /* button */
+ int butnum = pVuidMse->event.id - BUT_FIRST;
+
+ if (butnum < 3)
+ butnum = 2 - butnum;
+ if (!pVuidMse->event.value)
+ buttons &= ~(1 << butnum);
+ else
+ buttons |= (1 << butnum);
+ } else if (pVuidMse->event.id >= VLOC_FIRST &&
+ pVuidMse->event.id <= VLOC_LAST) {
+ /* axis */
+ int delta = pVuidMse->event.value;
+ switch(pVuidMse->event.id) {
+ case LOC_X_DELTA:
+ dx += delta;
+ break;
+ case LOC_Y_DELTA:
+ dy -= delta;
+ break;
+ case LOC_X_ABSOLUTE:
+ if (absXset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absX = delta;
+ absXset = TRUE;
+ break;
+ case LOC_Y_ABSOLUTE:
+ if (absYset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absY = delta;
+ absYset = TRUE;
+ break;
+ }
+ }
#ifdef HAVE_VUID_WHEEL
- else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
- if (vuid_id_offset(pVuidMse->event.id) == 0)
- dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
- else
- dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
- }
+ else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
+ if (vuid_id_offset(pVuidMse->event.id) == 0)
+ dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ else
+ dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ }
#endif
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
- else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
- ScreenPtr ptrCurScreen;
-
- /* force sending absolute resolution scaling ioctl */
- pVuidMse->absres.height = pVuidMse->absres.width = 0;
- ptrCurScreen = miPointerGetScreen(pInfo->dev);
- vuidMouseSendScreenSize(ptrCurScreen, pVuidMse);
- }
+ else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
+ ScreenPtr ptrCurScreen;
+
+ /* force sending absolute resolution scaling ioctl */
+ pVuidMse->absres.height = pVuidMse->absres.width = 0;
+ ptrCurScreen = miPointerGetScreen(pInfo->dev);
+ vuidMouseSendScreenSize(ptrCurScreen, pVuidMse);
+ }
#endif
} while (n != 0);
if (absXset || absYset) {
- vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
}
pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
@@ -402,41 +402,41 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse)
int result;
if (!pScr->currentMode)
- return;
+ return;
if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) ||
- (pVuidMse->absres.height != pScr->currentMode->VDisplay))
+ (pVuidMse->absres.height != pScr->currentMode->VDisplay))
{
- pVuidMse->absres.width = pScr->currentMode->HDisplay;
- pVuidMse->absres.height = pScr->currentMode->VDisplay;
+ pVuidMse->absres.width = pScr->currentMode->HDisplay;
+ pVuidMse->absres.height = pScr->currentMode->VDisplay;
- do {
- result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres));
- } while ( (result != 0) && (errno == EINTR) );
+ do {
+ result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres));
+ } while ( (result != 0) && (errno == EINTR) );
- if (result != 0) {
- xf86Msg(X_WARNING,
- "%s: couldn't set absolute mouse scaling resolution: %s\n",
- pInfo->name, strerror(errno));
+ if (result != 0) {
+ xf86Msg(X_WARNING,
+ "%s: couldn't set absolute mouse scaling resolution: %s\n",
+ pInfo->name, strerror(errno));
#ifdef DEBUG
- } else {
- xf86Msg(X_INFO,
- "%s: absolute mouse scaling resolution set to %d x %d\n",
- pInfo->name,
- pVuidMse->absres.width, pVuidMse->absres.height);
+ } else {
+ xf86Msg(X_INFO,
+ "%s: absolute mouse scaling resolution set to %d x %d\n",
+ pInfo->name,
+ pVuidMse->absres.width, pVuidMse->absres.height);
#endif
- }
+ }
}
}
static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = pScrn->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
xf86AdjustFrameProc *wrappedAdjustFrame
- = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen);
- VuidMsePtr m;
- ScreenPtr ptrCurScreen;
+ = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen);
+ VuidMsePtr m;
+ ScreenPtr ptrCurScreen;
if(wrappedAdjustFrame) {
pScrn->AdjustFrame = wrappedAdjustFrame;
@@ -445,11 +445,11 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
}
for (m = vuidMouseList; m != NULL ; m = m->next) {
- ptrCurScreen = miPointerGetScreen(m->pInfo->dev);
- if (ptrCurScreen == pScreen)
- {
- vuidMouseSendScreenSize(pScreen, m);
- }
+ ptrCurScreen = miPointerGetScreen(m->pInfo->dev);
+ if (ptrCurScreen == pScreen)
+ {
+ vuidMouseSendScreenSize(pScreen, m);
+ }
}
}
#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
@@ -470,7 +470,7 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
pVuidMse = getVuidMsePriv(pInfo);
if (pVuidMse == NULL) {
- return BadImplementation;
+ return BadImplementation;
}
switch (what) {
@@ -479,88 +479,88 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
#if HAS_DEVPRIVATEKEYREC
- if (!dixRegisterPrivateKey(&vuidMouseScreenIndex, PRIVATE_SCREEN, 0))
- return BadAlloc;
+ if (!dixRegisterPrivateKey(&vuidMouseScreenIndex, PRIVATE_SCREEN, 0))
+ return BadAlloc;
#endif /* HAS_DEVPRIVATEKEYREC */
- if (vuidMouseGeneration != serverGeneration) {
- for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame);
- pScrn->AdjustFrame = vuidMouseAdjustFrame;
- }
- vuidMouseGeneration = serverGeneration;
- }
+ if (vuidMouseGeneration != serverGeneration) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame);
+ pScrn->AdjustFrame = vuidMouseAdjustFrame;
+ }
+ vuidMouseGeneration = serverGeneration;
+ }
#endif
- ret = pVuidMse->wrapped_device_control(pPointer, what);
- break;
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
case DEVICE_ON:
- ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON);
-
- if ((ret == Success) && (pInfo->fd != -1)) {
- int fmt = VUID_FIRM_EVENT;
-
- if (pVuidMse->strmod) {
- /* Check to see if module is already pushed */
- SYSCALL(i = ioctl(pInfo->fd, I_FIND, pVuidMse->strmod));
-
- if (i == 0) { /* Not already pushed */
- SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
- if (i < 0) {
- xf86Msg(X_WARNING, "%s: cannot push module '%s' "
- "onto mouse device: %s\n", pInfo->name,
- pVuidMse->strmod, strerror(errno));
- free(pVuidMse->strmod);
- pVuidMse->strmod = NULL;
- }
- }
- }
-
- SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt));
- if (i < 0) {
- xf86Msg(X_WARNING,
- "%s: cannot set mouse device to VUID mode: %s\n",
- pInfo->name, strerror(errno));
- }
- vuidMouseWheelInit(pInfo);
+ ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON);
+
+ if ((ret == Success) && (pInfo->fd != -1)) {
+ int fmt = VUID_FIRM_EVENT;
+
+ if (pVuidMse->strmod) {
+ /* Check to see if module is already pushed */
+ SYSCALL(i = ioctl(pInfo->fd, I_FIND, pVuidMse->strmod));
+
+ if (i == 0) { /* Not already pushed */
+ SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ if (i < 0) {
+ xf86Msg(X_WARNING, "%s: cannot push module '%s' "
+ "onto mouse device: %s\n", pInfo->name,
+ pVuidMse->strmod, strerror(errno));
+ free(pVuidMse->strmod);
+ pVuidMse->strmod = NULL;
+ }
+ }
+ }
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot set mouse device to VUID mode: %s\n",
+ pInfo->name, strerror(errno));
+ }
+ vuidMouseWheelInit(pInfo);
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
- vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse);
+ vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse);
#endif
- xf86FlushInput(pInfo->fd);
+ xf86FlushInput(pInfo->fd);
- /* Allocate here so we don't alloc in ReadInput which may be called
- from SIGIO handler. */
- if (pVuidMse->remove_timer == NULL) {
- pVuidMse->remove_timer = TimerSet(pVuidMse->remove_timer,
- 0, 0, NULL, NULL);
- }
- }
- break;
+ /* Allocate here so we don't alloc in ReadInput which may be called
+ from SIGIO handler. */
+ if (pVuidMse->remove_timer == NULL) {
+ pVuidMse->remove_timer = TimerSet(pVuidMse->remove_timer,
+ 0, 0, NULL, NULL);
+ }
+ }
+ break;
case DEVICE_OFF:
case DEVICE_CLOSE:
- if (pInfo->fd != -1) {
- if (pVuidMse->strmod) {
- SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
- if (i == -1) {
- xf86Msg(X_WARNING,
- "%s: cannot pop module '%s' off mouse device: %s\n",
- pInfo->name, pVuidMse->strmod, strerror(errno));
- }
- }
- }
- if (pVuidMse->remove_timer) {
- TimerFree(pVuidMse->remove_timer);
- pVuidMse->remove_timer = NULL;
- }
- ret = pVuidMse->wrapped_device_control(pPointer, what);
- break;
+ if (pInfo->fd != -1) {
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+ if (i == -1) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+ }
+ }
+ if (pVuidMse->remove_timer) {
+ TimerFree(pVuidMse->remove_timer);
+ pVuidMse->remove_timer = NULL;
+ }
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
default: /* Should never be called, but just in case */
- ret = pVuidMse->wrapped_device_control(pPointer, what);
- break;
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
}
return ret;
}
@@ -570,7 +570,7 @@ sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
{
/* The protocol is guaranteed to be one of the internalNames[] */
if (xf86NameCmp(protocol, "VUID") == 0) {
- return vuidPreInit(pInfo, protocol, flags);
+ return vuidPreInit(pInfo, protocol, flags);
}
return TRUE;
}
@@ -587,8 +587,8 @@ CheckProtocol(const char *protocol)
int i;
for (i = 0; internalNames[i]; i++)
- if (xf86NameCmp(protocol, internalNames[i]) == 0)
- return TRUE;
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
return FALSE;
}
@@ -601,7 +601,7 @@ DefaultProtocol(void)
static Bool
solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
- const char **device)
+ const char **device)
{
const char **pdev, **pproto;
int fd = -1;
@@ -609,54 +609,54 @@ solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
char *strmod;
if (*device == NULL) {
- /* Check to see if xorg.conf or HAL specified a device to use */
- *device = xf86CheckStrOption(pInfo->options, "Device", NULL);
+ /* Check to see if xorg.conf or HAL specified a device to use */
+ *device = xf86CheckStrOption(pInfo->options, "Device", NULL);
}
if (*device != NULL) {
- strmod = xf86CheckStrOption(pInfo->options, "StreamsModule", NULL);
- if (strmod) {
- /* if a device name is already known, and a StreamsModule is
- specified to convert events to VUID, then we don't need to
- probe further */
- *protocol = "VUID";
- return TRUE;
- }
+ strmod = xf86CheckStrOption(pInfo->options, "StreamsModule", NULL);
+ if (strmod) {
+ /* if a device name is already known, and a StreamsModule is
+ specified to convert events to VUID, then we don't need to
+ probe further */
+ *protocol = "VUID";
+ return TRUE;
+ }
}
for (pdev = solarisMouseDevs; *pdev; pdev += 2) {
- pproto = pdev + 1;
- if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) &&
- (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) {
- continue;
- }
- if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
- continue;
- }
+ pproto = pdev + 1;
+ if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) &&
+ (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) {
+ continue;
+ }
+ if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
+ continue;
+ }
SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
- if (fd == -1) {
+ if (fd == -1) {
#ifdef DEBUG
- ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
+ ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
#endif
- } else {
- found = TRUE;
- if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) {
- int i, r;
- SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i));
- if (r < 0) {
- found = FALSE;
- }
- }
- close(fd);
- if (found == TRUE) {
- if (*pproto != NULL) {
- *protocol = *pproto;
- }
- *device = *pdev;
- return TRUE;
- }
- }
+ } else {
+ found = TRUE;
+ if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) {
+ int i, r;
+ SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i));
+ if (r < 0) {
+ found = FALSE;
+ }
+ }
+ close(fd);
+ if (found == TRUE) {
+ if (*pproto != NULL) {
+ *protocol = *pproto;
+ }
+ *device = *pdev;
+ return TRUE;
+ }
+ }
}
return FALSE;
}
@@ -669,20 +669,20 @@ SetupAuto(InputInfoPtr pInfo, int *protoPara)
MouseDevPtr pMse = pInfo->private;
if (pInfo->fd == -1) {
- /* probe to find device/protocol to use */
- if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
- /* Set the Device option. */
- pInfo->options =
- xf86AddNewOption(pInfo->options, "Device", pdev);
- xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
- pInfo->name, pdev);
- }
+ /* probe to find device/protocol to use */
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* Set the Device option. */
+ pInfo->options =
+ xf86AddNewOption(pInfo->options, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
+ }
} else if (pMse->protocolID == PROT_AUTO) {
- pdev = xf86CheckStrOption(pInfo->options,
- "Device", NULL);
- if ((solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) &&
- (pproto != NULL))
- sunMousePreInit(pInfo, pproto, 0);
+ pdev = xf86CheckStrOption(pInfo->options,
+ "Device", NULL);
+ if ((solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) &&
+ (pproto != NULL))
+ sunMousePreInit(pInfo, pproto, 0);
}
return pproto;
}
@@ -694,11 +694,11 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
const char *pproto = protocol;
if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
- /* Set the Device option. */
- pInfo->options =
- xf86AddNewOption(pInfo->options, "Device", pdev);
- xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
- pInfo->name, pdev);
+ /* Set the Device option. */
+ pInfo->options =
+ xf86AddNewOption(pInfo->options, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
}
return pdev;
}
@@ -717,7 +717,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
- return NULL;
+ return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->BuiltinNames = BuiltinNames;
p->CheckProtocol = CheckProtocol;