xorg DDX: implement NewInputDeviceRequest
Implement NewInputDeviceRequest for Xorg, mainly written by Kristian Høgsberg. Move MatchInput to xf86Helper.c, as xf86LookupInputDriver.
This commit is contained in:
parent
02a9531156
commit
c9a3d9baa8
|
@ -142,6 +142,19 @@ xf86DeleteInputDriver(int drvIndex)
|
|||
xf86InputDriverList[drvIndex] = NULL;
|
||||
}
|
||||
|
||||
InputDriverPtr
|
||||
xf86LookupInputDriver(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xf86NumInputDrivers; i++) {
|
||||
if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
|
||||
xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
|
||||
return xf86InputDriverList[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
|
||||
{
|
||||
|
|
|
@ -41,4 +41,7 @@ extern int xf86NumInputDrivers;
|
|||
/* xf86Xinput.c */
|
||||
void xf86ActivateDevice(InputInfoPtr pInfo);
|
||||
|
||||
/* xf86Helper.c */
|
||||
InputDriverPtr xf86LookupInputDriver(const char *name);
|
||||
|
||||
#endif /* _xf86InPriv_h */
|
||||
|
|
|
@ -985,21 +985,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static InputDriverPtr
|
||||
MatchInput(IDevPtr pDev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xf86NumInputDrivers; i++) {
|
||||
if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
|
||||
xf86NameCmp(pDev->driver, xf86InputDriverList[i]->driverName) == 0)
|
||||
return xf86InputDriverList[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* InitInput --
|
||||
* Initialize all supported input devices.
|
||||
|
@ -1033,7 +1018,7 @@ InitInput(argc, argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
if ((pDrv = MatchInput(pDev)) == NULL) {
|
||||
if ((pDrv = xf86LookupInputDriver(pDev->driver)) == NULL) {
|
||||
xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
|
||||
/* XXX For now, just continue. */
|
||||
continue;
|
||||
|
|
|
@ -622,6 +622,82 @@ ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
|
|||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
NewInputDeviceRequest (InputOption *options)
|
||||
{
|
||||
IDevRec *idev = NULL;
|
||||
InputDriverPtr drv = NULL;
|
||||
InputInfoPtr pInfo = NULL;
|
||||
InputOption *option = NULL;
|
||||
DeviceIntPtr dev = NULL;
|
||||
int i;
|
||||
|
||||
idev = xcalloc(sizeof(*idev), 1);
|
||||
if (!idev)
|
||||
return BadAlloc;
|
||||
|
||||
for (option = options; option; option = option->next) {
|
||||
if (strcmp(option->key, "driver") == 0) {
|
||||
if (!xf86LoadOneModule(option->value, NULL))
|
||||
return BadName;
|
||||
drv = xf86LookupInputDriver(option->value);
|
||||
if (!drv) {
|
||||
xf86Msg(X_ERROR, "No input driver matching `%s'\n",
|
||||
option->value);
|
||||
return BadName;
|
||||
}
|
||||
idev->driver = xstrdup(option->value);
|
||||
if (!idev->driver) {
|
||||
xfree(idev);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
if (strcmp(option->key, "name") == 0 ||
|
||||
strcmp(option->key, "identifier") == 0) {
|
||||
idev->identifier = xstrdup(option->value);
|
||||
if (!idev->identifier) {
|
||||
xfree(idev);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!drv->PreInit) {
|
||||
xf86Msg(X_ERROR,
|
||||
"Input driver `%s' has no PreInit function (ignoring)\n",
|
||||
drv->driverName);
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
idev->commonOptions = NULL;
|
||||
for (option = options; option; option = option->next)
|
||||
idev->commonOptions = xf86addNewOption(idev->commonOptions,
|
||||
option->key, option->value);
|
||||
idev->extraOptions = NULL;
|
||||
|
||||
pInfo = drv->PreInit(drv, idev, 0);
|
||||
|
||||
if (!pInfo) {
|
||||
xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
|
||||
return BadMatch;
|
||||
}
|
||||
else if (!(pInfo->flags & XI86_CONFIGURED)) {
|
||||
xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
|
||||
idev->identifier);
|
||||
xf86DeleteInput(pInfo, 0);
|
||||
return BadMatch;
|
||||
}
|
||||
|
||||
xf86ActivateDevice(pInfo);
|
||||
|
||||
dev = pInfo->dev;
|
||||
dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
|
||||
if (dev->inited && dev->startup)
|
||||
EnableDevice(dev);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/*
|
||||
* adapted from mieq.c to support extended events
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue