summaryrefslogtreecommitdiff
path: root/hw/kdrive/src/kinput.c
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-08-23 18:19:17 -0700
committerIan Romanick <idr@us.ibm.com>2007-08-23 18:19:17 -0700
commit8b6b40b7271acd81a9548f502c18f46f3b640640 (patch)
tree1462cb63501a8bdd8845d7c62e038b6a86b78fd5 /hw/kdrive/src/kinput.c
parentab7a6d860d4a275a810a64b1ba7b13726ed10575 (diff)
parent3305d17195e3a0a5555300555bd7703312fa489f (diff)
Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into pci-reworkpci-rework
Conflicts: hw/xfree86/common/xf86.h hw/xfree86/common/xf86Init.c hw/xfree86/common/xf86pciBus.c hw/xfree86/int10/generic.c hw/xfree86/int10/helper_exec.c hw/xfree86/loader/xf86sym.c hw/xfree86/os-support/bus/Pci.c hw/xfree86/os-support/bus/Pci.h hw/xfree86/os-support/bus/linuxPci.c hw/xfree86/os-support/linux/int10/linux.c
Diffstat (limited to 'hw/kdrive/src/kinput.c')
-rw-r--r--hw/kdrive/src/kinput.c190
1 files changed, 150 insertions, 40 deletions
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 7edcc5106..6c247c185 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1,6 +1,4 @@
/*
- * Id: kinput.c,v 1.1 1999/11/02 03:54:46 keithp Exp $
- *
* Copyright © 1999 Keith Packard
* Copyright © 2006 Nokia Corporation
*
@@ -22,7 +20,6 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $RCSId: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.30 2002/11/13 16:37:39 keithp Exp $ */
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
@@ -740,6 +737,9 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
DevicePtr pDev = (DevicePtr)pDevice;
KdKeyboardInfo *ki;
Atom xiclass;
+#ifdef XKB
+ XkbComponentNamesRec names;
+#endif
if (!pDev)
return BadImplementation;
@@ -788,13 +788,13 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
KdInitModMap(ki);
KdInitAutoRepeats(ki);
-#ifndef XKB
+#ifdef XKB
if (!noXkbExtension) {
memset(&names, 0, sizeof(XkbComponentNamesRec));
- if (XkbInitialMap)
- names.keymap = XkbInitialMap;
- XkbSetRulesDflts ("base", "pc105", "us", NULL, NULL);
+ XkbSetRulesDflts (ki->xkbRules, ki->xkbModel, ki->xkbLayout,
+ ki->xkbVariant, ki->xkbOptions);
+
ret = XkbInitKeyboardDeviceStruct (pDevice,
&names,
&ki->keySyms,
@@ -963,6 +963,13 @@ KdNewKeyboard (void)
ki->bellDuration = 200;
ki->next = NULL;
ki->options = NULL;
+#ifdef XKB
+ ki->xkbRules = KdSaveString("base");
+ ki->xkbModel = KdSaveString("pc105");
+ ki->xkbLayout = KdSaveString("us");
+ ki->xkbVariant = NULL;
+ ki->xkbOptions = NULL;
+#endif
return ki;
}
@@ -1098,11 +1105,78 @@ KdRemovePointer (KdPointerInfo *pi)
KdFreePointer(pi);
}
+/*
+ * You can call your kdriver server with something like:
+ * $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
+ * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
+ */
+static Bool
+KdGetOptions (InputOption **options, char *string)
+{
+ InputOption *newopt = NULL, **tmpo = NULL;
+ int tam_key = 0;
+
+ newopt = (InputOption *) xalloc(sizeof (InputOption));
+ if (!newopt)
+ return FALSE;
+
+ bzero(newopt, sizeof (InputOption));
+
+ for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
+ ; /* Hello, I'm here */
+ *tmpo = newopt;
+
+ if (strchr(string, '='))
+ {
+ tam_key = (strchr(string, '=') - string);
+ newopt->key = (char *)xalloc(tam_key);
+ strncpy(newopt->key, string, tam_key);
+ newopt->key[tam_key] = '\0';
+ newopt->value = xstrdup(strchr(string, '=') + 1);
+ }
+ else
+ {
+ newopt->key = xstrdup(string);
+ newopt->value = NULL;
+ }
+ newopt->next = NULL;
+
+ return TRUE;
+}
+
+static void
+KdParseKbdOptions (KdKeyboardInfo *ki)
+{
+ InputOption *option = NULL;
+
+ for (option = ki->options; option; option = option->next)
+ {
+#ifdef XKB
+ if (strcasecmp(option->key, "XkbRules") == 0)
+ ki->xkbRules = option->value;
+ else if (strcasecmp(option->key, "XkbModel") == 0)
+ ki->xkbModel = option->value;
+ else if (strcasecmp(option->key, "XkbLayout") == 0)
+ ki->xkbLayout = option->value;
+ else if (strcasecmp(option->key, "XkbVariant") == 0)
+ ki->xkbVariant = option->value;
+ else if (strcasecmp(option->key, "XkbOptions") == 0)
+ ki->xkbOptions = option->value;
+ else if (!strcasecmp (option->key, "device"))
+ ki->path = KdSaveString(option->value);
+ else
+#endif
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
KdKeyboardInfo *
KdParseKeyboard (char *arg)
{
char save[1024];
char delim;
+ InputOption *options = NULL;
KdKeyboardInfo *ki = NULL;
ki = KdNewKeyboard();
@@ -1145,18 +1219,63 @@ KdParseKeyboard (char *arg)
else
ki->driverPrivate = xstrdup(save);
- /* FIXME actually implement options */
+ if (delim != ',')
+ {
+ return ki;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ if (!KdGetOptions(&options, save))
+ {
+ KdFreeKeyboard(ki);
+ return NULL;
+ }
+ }
+
+ if (options)
+ {
+ ki->options = options;
+ KdParseKbdOptions(ki);
+ }
return ki;
}
+static void
+KdParsePointerOptions (KdPointerInfo *pi)
+{
+ InputOption *option = NULL;
+
+ for (option = pi->options; option; option = option->next)
+ {
+ if (!strcmp (option->key, "emulatemiddle"))
+ pi->emulateMiddleButton = TRUE;
+ else if (!strcmp (option->key, "noemulatemiddle"))
+ pi->emulateMiddleButton = FALSE;
+ else if (!strcmp (option->key, "transformcoord"))
+ pi->transformCoordinates = TRUE;
+ else if (!strcmp (option->key, "rawcoord"))
+ pi->transformCoordinates = FALSE;
+ else if (!strcasecmp (option->key, "device"))
+ pi->path = KdSaveString(option->value);
+ else
+ ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
KdPointerInfo *
KdParsePointer (char *arg)
{
char save[1024];
char delim;
KdPointerInfo *pi = NULL;
- InputOption *options = NULL, *newopt = NULL, **tmpo = NULL;
+ InputOption *options = NULL;
int i = 0;
pi = KdNewPointer();
@@ -1216,45 +1335,21 @@ KdParsePointer (char *arg)
s++;
}
}
- else if (!strcmp (save, "emulatemiddle"))
- pi->emulateMiddleButton = TRUE;
- else if (!strcmp (save, "noemulatemiddle"))
- pi->emulateMiddleButton = FALSE;
- else if (!strcmp (save, "transformcoord"))
- pi->transformCoordinates = TRUE;
- else if (!strcmp (save, "rawcoord"))
- pi->transformCoordinates = FALSE;
else
{
- newopt = (InputOption *) xalloc(sizeof (InputOption));
- if (!newopt)
+ if (!KdGetOptions(&options, save))
{
KdFreePointer(pi);
return NULL;
}
- bzero(newopt, sizeof (InputOption));
-
- for (tmpo = &options; *tmpo; tmpo = &(*tmpo)->next)
- *tmpo = newopt;
-
- if (strchr(arg, '='))
- {
- i = (strchr(arg, '=') - arg);
- newopt->key = (char *)xalloc(i+1);
- strncpy(newopt->key, arg, i+1);
- newopt->value = xstrdup(strchr(arg, '=') + 1);
- }
- else
- {
- newopt->key = xstrdup(save);
- newopt->value = NULL;
- }
- newopt->next = NULL;
}
}
if (options)
+ {
pi->options = options;
+ KdParsePointerOptions(pi);
+ }
return pi;
}
@@ -2296,6 +2391,7 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
return Success;
case DEVICE_CORE:
+ case DEVICE_ENABLE:
return Success;
default:
@@ -2319,13 +2415,11 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
pi = KdNewPointer();
if (!pi)
return BadAlloc;
- pi->options = options;
}
else if (strcmp(option->value, "keyboard") == 0) {
ki = KdNewKeyboard();
if (!ki)
return BadAlloc;
- ki->options = options;
}
else {
ErrorF("unrecognised device type!\n");
@@ -2334,8 +2428,21 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
}
}
+ if (!ki && !pi) {
+ ErrorF("unrecognised device identifier!\n");
+ return BadValue;
+ }
+
+ /* FIXME: change this code below to use KdParseKbdOptions and
+ * KdParsePointerOptions */
for (option = options; option; option = option->next) {
- if (strcmp(option->key, "driver") == 0) {
+ if (strcmp(option->key, "device") == 0) {
+ if (pi && option->value)
+ pi->path = KdSaveString(option->value);
+ else if (ki && option->value)
+ ki->path = KdSaveString(option->value);
+ }
+ else if (strcmp(option->key, "driver") == 0) {
if (pi) {
pi->driver = KdFindPointerDriver(option->value);
if (!pi->driver) {
@@ -2343,6 +2450,7 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
KdFreePointer(pi);
return BadValue;
}
+ pi->options = options;
}
else if (ki) {
ki->driver = KdFindKeyboardDriver(option->value);
@@ -2351,6 +2459,7 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
KdFreeKeyboard(ki);
return BadValue;
}
+ ki->options = options;
}
}
}
@@ -2384,4 +2493,5 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
void
DeleteInputDeviceRequest(DeviceIntPtr pDev)
{
+ RemoveDevice(pDev);
}