xfree86: don't FatalError on "too many input devices".

Just ignore devices after MAXDEVICES has been reached, but warn the user that
the devices are ignored.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
This commit is contained in:
Peter Hutterer 2008-11-26 14:15:04 +10:00
parent 9bf761468f
commit d507f60689
4 changed files with 29 additions and 8 deletions

View File

@ -38,7 +38,7 @@ extern InputDriverPtr *xf86InputDriverList;
extern int xf86NumInputDrivers; extern int xf86NumInputDrivers;
/* xf86Xinput.c */ /* xf86Xinput.c */
void xf86ActivateDevice(InputInfoPtr pInfo); int xf86ActivateDevice(InputInfoPtr pInfo);
/* xf86Helper.c */ /* xf86Helper.c */
InputDriverPtr xf86LookupInputDriver(const char *name); InputDriverPtr xf86LookupInputDriver(const char *name);

View File

@ -1322,7 +1322,9 @@ InitInput(argc, argv)
strcpy((*pDev)->driver, "kbd"); strcpy((*pDev)->driver, "kbd");
} }
xf86NewInputDevice(*pDev, &dev, TRUE); /* If one fails, the others will too */
if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
break;
} }
mieqInit(); mieqInit();

View File

@ -287,12 +287,13 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
/*********************************************************************** /***********************************************************************
* *
* xf86ActivateDevice -- * xf86ActivateDevice --
* *
* Initialize an input device. * Initialize an input device.
* *
* Returns TRUE on success, or FALSE otherwise.
*********************************************************************** ***********************************************************************
*/ */
_X_EXPORT void _X_EXPORT int
xf86ActivateDevice(LocalDevicePtr local) xf86ActivateDevice(LocalDevicePtr local)
{ {
DeviceIntPtr dev; DeviceIntPtr dev;
@ -301,8 +302,13 @@ xf86ActivateDevice(LocalDevicePtr local)
dev = AddInputDevice(serverClient, local->device_control, TRUE); dev = AddInputDevice(serverClient, local->device_control, TRUE);
if (dev == NULL) if (dev == NULL)
FatalError("Too many input devices"); {
xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
local->name);
local->dev = NULL;
return FALSE;
}
local->atom = MakeAtom(local->type_name, local->atom = MakeAtom(local->type_name,
strlen(local->type_name), strlen(local->type_name),
TRUE); TRUE);
@ -334,6 +340,8 @@ xf86ActivateDevice(LocalDevicePtr local)
xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n", xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
local->name, local->type_name); local->name, local->type_name);
} }
return TRUE;
} }
@ -470,6 +478,13 @@ AddOtherInputDevices()
/** /**
* Create a new input device, activate and enable it. * Create a new input device, activate and enable it.
* *
* Possible return codes:
* BadName .. a bad driver name was supplied.
* BadImplementation ... The driver does not have a PreInit function. This
* is a driver bug.
* BadMatch .. device initialization failed.
* BadAlloc .. too many input devices
*
* @param idev The device, already set up with identifier, driver, and the * @param idev The device, already set up with identifier, driver, and the
* options. * options.
* @param pdev Pointer to the new device, if Success was reported. * @param pdev Pointer to the new device, if Success was reported.
@ -519,7 +534,11 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
goto unwind; goto unwind;
} }
xf86ActivateDevice(pInfo); if (!xf86ActivateDevice(pInfo))
{
rval = BadAlloc;
goto unwind;
}
dev = pInfo->dev; dev = pInfo->dev;
ActivateDevice(dev); ActivateDevice(dev);

View File

@ -169,7 +169,7 @@ void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
...); ...);
void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code, void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
int is_down); int is_down);
void xf86ActivateDevice(LocalDevicePtr local); int xf86ActivateDevice(LocalDevicePtr local);
LocalDevicePtr xf86FirstLocalDevice(void); LocalDevicePtr xf86FirstLocalDevice(void);
int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow); int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y); void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);