This patch includes the mousedrv(4) device node autodetection into vmmouse.
This fixes the disparity between mousedrv(4) and vmmouse(4x).
It also makes the driver report that it needs a device if one is not
found instead of just failing silently.
Thanks
Michal
diff -ur xserver-xorg-input-vmmouse-12.5.1/src/vmmouse.c xserver-xorg-input-vmmouse-12.5.1.mod/src/vmmouse.c
--- xserver-xorg-input-vmmouse-12.5.1/src/vmmouse.c 2008-12-18 22:18:10.000000000 +0000
+++ xserver-xorg-input-vmmouse-12.5.1.mod/src/vmmouse.c 2008-12-22 14:31:41.434010681 +0000
@@ -289,6 +289,17 @@
*----------------------------------------------------------------------
*/
+static InputInfoPtr FreePriv(InputInfoPtr pInfo) {
+ MouseDevPtr pMse = pInfo->private;
+ if(pMse) {
+ if(pMse->mousePriv)
+ xfree(pMse->mousePriv);
+ xfree(pMse);
+ }
+ pInfo->private = NULL;
+ return pInfo;
+}
+
static InputInfoPtr
VMMousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{
@@ -296,6 +307,9 @@
MouseDevPtr pMse;
VMMousePrivPtr mPriv;
OSMouseInfoPtr osInfo = NULL;
+ MessageType protocolFrom = X_DEFAULT, deviceFrom = X_CONFIG;
+ const char *protocol;
+ const char *device;
/*
* let Xserver init the mouse first
@@ -355,6 +369,7 @@
pInfo->read_input = VMMouseReadInput;
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
pInfo->motion_history_proc = xf86GetMotionEvents;
+ pInfo->history_size = 0;
#endif
pInfo->control_proc = VMMouseControlProc;
pInfo->close_proc = VMMouseCloseProc;
@@ -366,6 +381,7 @@
pInfo->private_flags = 0;
pInfo->always_core_feedback = 0;
pInfo->conf_idev = dev;
+ pInfo->private = NULL;
/* Allocate the MouseDevRec and initialise it. */
if (!(pMse = xcalloc(sizeof(MouseDevRec), 1))) {
@@ -380,10 +396,49 @@
pMse->mousePriv = mPriv;
+ /* Try to detect a mouse device if not specified */
+
+ if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) &&
+ HAVE_FIND_DEVICE && osInfo->FindDevice) {
+
+ xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n",
+ pInfo->name);
+
+ /* Find the protocol type. */
+ protocol = xf86SetStrOption(dev->commonOptions, "Protocol", NULL);
+ if (protocol) {
+ protocolFrom = X_CONFIG;
+ } else if (osInfo->DefaultProtocol) {
+ protocol = osInfo->DefaultProtocol();
+ protocolFrom = X_DEFAULT;
+ }
+ if (!protocol) {
+ xf86Msg(X_ERROR, "%s: No Protocol specified and there is no default for this platform.\n", pInfo->name);
+ return pInfo;
+ }
+ xf86Msg(protocolFrom, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ if (!osInfo->FindDevice(pInfo, protocol, 0)) {
+ xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n",
+ pInfo->name);
+ } else {
+ deviceFrom = X_PROBED;
+ xf86MarkOptionUsedByName(dev->commonOptions, "Device");
+ }
+ }
+
/* Collect the options, and process the common options. */
xf86CollectInputOptions(pInfo, NULL, NULL);
xf86ProcessCommonOptions(pInfo, pInfo->options);
+ device = xf86CheckStrOption(dev->commonOptions, "Device", NULL);
+ if (device)
+ xf86Msg(deviceFrom, "%s: Device: \"%s\"\n", pInfo->name, device);
+ else {
+ xf86Msg(X_ERROR, "%s: Need a mouse device to get notified about mouse events.\n", pInfo->name);
+ return FreePriv(pInfo);
+ }
+
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
@@ -391,11 +446,7 @@
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)
- xfree(pMse->mousePriv);
- xfree(pMse);
- pInfo->private = NULL;
- return pInfo;
+ return FreePriv(pInfo);
}
}
xf86CloseSerial(pInfo->fd);