summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-07-19 11:41:16 -0400
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-07-21 15:19:50 -0400
commitc9a3d9baa81ceb940032ffe529d9eadf2d202ab2 (patch)
treed2d541d22c923d543318b333d7c456db9b89f344
parent02a95311568e24e1055ea52c7df8cb7aa3f38ad0 (diff)
xorg DDX: implement NewInputDeviceRequest
Implement NewInputDeviceRequest for Xorg, mainly written by Kristian Høgsberg. Move MatchInput to xf86Helper.c, as xf86LookupInputDriver.
-rw-r--r--hw/xfree86/common/xf86Helper.c13
-rw-r--r--hw/xfree86/common/xf86InPriv.h3
-rw-r--r--hw/xfree86/common/xf86Init.c17
-rw-r--r--hw/xfree86/common/xf86Xinput.c76
4 files changed, 93 insertions, 16 deletions
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index ebc460f30..05ac5709c 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -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)
{
diff --git a/hw/xfree86/common/xf86InPriv.h b/hw/xfree86/common/xf86InPriv.h
index a14e9e7bb..940e8ba1c 100644
--- a/hw/xfree86/common/xf86InPriv.h
+++ b/hw/xfree86/common/xf86InPriv.h
@@ -41,4 +41,7 @@ extern int xf86NumInputDrivers;
/* xf86Xinput.c */
void xf86ActivateDevice(InputInfoPtr pInfo);
+/* xf86Helper.c */
+InputDriverPtr xf86LookupInputDriver(const char *name);
+
#endif /* _xf86InPriv_h */
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 993918426..6defa9465 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -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;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a931a5d60..329dcba98 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -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
*