summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/kdrive/src/kinput.c139
-rw-r--r--hw/xfree86/common/xf86Config.c16
-rw-r--r--hw/xfree86/common/xf86Init.c29
-rw-r--r--hw/xfree86/common/xf86Option.c3
-rw-r--r--hw/xfree86/common/xf86Optionstr.h13
-rw-r--r--hw/xfree86/common/xf86Xinput.c5
-rw-r--r--hw/xfree86/doc/ddxDesign.xml4
-rw-r--r--hw/xfree86/parser/Flags.c5
-rw-r--r--hw/xfree86/parser/Layout.c2
9 files changed, 105 insertions, 111 deletions
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index c14dd8241..6a1ce49e0 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -49,6 +49,7 @@
#include "eventstr.h"
#include "xserver-properties.h"
#include "inpututils.h"
+#include "optionstr.h"
#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
@@ -344,7 +345,7 @@ KdEnableInput (void)
}
static KdKeyboardDriver *
-KdFindKeyboardDriver (char *name)
+KdFindKeyboardDriver (const char *name)
{
KdKeyboardDriver *ret;
@@ -361,7 +362,7 @@ KdFindKeyboardDriver (char *name)
}
static KdPointerDriver *
-KdFindPointerDriver (char *name)
+KdFindPointerDriver (const char *name)
{
KdPointerDriver *ret;
@@ -1040,33 +1041,39 @@ KdRemovePointer (KdPointerInfo *pi)
static Bool
KdGetOptions (InputOption **options, char *string)
{
- InputOption *newopt = NULL, **tmpo = NULL;
+ InputOption *newopt = NULL;
+ char *key = NULL,
+ *value = NULL;
int tam_key = 0;
- newopt = calloc(1, sizeof (InputOption));
- if (!newopt)
- return FALSE;
-
- for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
- ; /* Hello, I'm here */
- *tmpo = newopt;
-
if (strchr(string, '='))
{
tam_key = (strchr(string, '=') - string);
- newopt->key = (char *)malloc(tam_key);
- strncpy(newopt->key, string, tam_key);
- newopt->key[tam_key] = '\0';
- newopt->value = strdup(strchr(string, '=') + 1);
+ key = malloc(tam_key + 1);
+ if (!key)
+ goto out;
+
+ strncpy(key, string, tam_key);
+ key[tam_key] = '\0';
+ value = strdup(strchr(string, '=') + 1);
+ if (!value)
+ goto out;
}
else
{
- newopt->key = strdup(string);
- newopt->value = NULL;
+ key = strdup(string);
+ value = NULL;
}
- newopt->next = NULL;
- return TRUE;
+ newopt = input_option_new(*options, key, value);
+ if (newopt)
+ *options = newopt;
+
+out:
+ free(key);
+ free(value);
+
+ return (newopt != NULL);
}
static void
@@ -1074,23 +1081,26 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
{
InputOption *option = NULL;
- for (option = ki->options; option; option = option->next)
+ nt_list_for_each_entry(option, ki->options, list.next)
{
- 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 = strdup(option->value);
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcasecmp(key, "XkbRules") == 0)
+ ki->xkbRules = strdup(value);
+ else if (strcasecmp(key, "XkbModel") == 0)
+ ki->xkbModel = strdup(value);
+ else if (strcasecmp(key, "XkbLayout") == 0)
+ ki->xkbLayout = strdup(value);
+ else if (strcasecmp(key, "XkbVariant") == 0)
+ ki->xkbVariant = strdup(value);
+ else if (strcasecmp(key, "XkbOptions") == 0)
+ ki->xkbOptions = strdup(value);
+ else if (!strcasecmp (key, "device"))
+ ki->path = strdup(value);
else
ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
+ key, value);
}
}
@@ -1171,23 +1181,26 @@ KdParsePointerOptions (KdPointerInfo *pi)
{
InputOption *option = NULL;
- for (option = pi->options; option; option = option->next)
+ nt_list_for_each_entry(option, pi->options, list.next)
{
- if (!strcmp (option->key, "emulatemiddle"))
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (!strcmp (key, "emulatemiddle"))
pi->emulateMiddleButton = TRUE;
- else if (!strcmp (option->key, "noemulatemiddle"))
+ else if (!strcmp (key, "noemulatemiddle"))
pi->emulateMiddleButton = FALSE;
- else if (!strcmp (option->key, "transformcoord"))
+ else if (!strcmp (key, "transformcoord"))
pi->transformCoordinates = TRUE;
- else if (!strcmp (option->key, "rawcoord"))
+ else if (!strcmp (key, "rawcoord"))
pi->transformCoordinates = FALSE;
- else if (!strcasecmp (option->key, "device"))
- pi->path = strdup(option->value);
- else if (!strcasecmp (option->key, "protocol"))
- pi->protocol = strdup(option->value);
+ else if (!strcasecmp (key, "device"))
+ pi->path = strdup(value);
+ else if (!strcasecmp (key, "protocol"))
+ pi->protocol = strdup(value);
else
ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
+ key, value);
}
}
@@ -2216,14 +2229,17 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
KdPointerInfo *pi = NULL;
KdKeyboardInfo *ki = NULL;
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "type") == 0) {
- if (strcmp(option->value, "pointer") == 0) {
+ nt_list_for_each_entry(option, options, list.next) {
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcmp(key, "type") == 0) {
+ if (strcmp(value, "pointer") == 0) {
pi = KdNewPointer();
if (!pi)
return BadAlloc;
}
- else if (strcmp(option->value, "keyboard") == 0) {
+ else if (strcmp(value, "keyboard") == 0) {
ki = KdNewKeyboard();
if (!ki)
return BadAlloc;
@@ -2234,16 +2250,16 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
}
}
#ifdef CONFIG_HAL
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/hal") == 0)
+ else if (strcmp(key, "_source") == 0 &&
+ strcmp(value, "server/hal") == 0)
{
ErrorF("Ignoring device from HAL.\n");
return BadValue;
}
#endif
#ifdef CONFIG_UDEV
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/udev") == 0)
+ else if (strcmp(key, "_source") == 0 &&
+ strcmp(value, "server/udev") == 0)
{
ErrorF("Ignoring device from udev.\n");
return BadValue;
@@ -2258,16 +2274,19 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
/* FIXME: change this code below to use KdParseKbdOptions and
* KdParsePointerOptions */
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "device") == 0) {
- if (pi && option->value)
- pi->path = strdup(option->value);
- else if (ki && option->value)
- ki->path = strdup(option->value);
+ nt_list_for_each_entry(option, options, list.next) {
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcmp(key, "device") == 0) {
+ if (pi && value)
+ pi->path = strdup(value);
+ else if (ki && value)
+ ki->path = strdup(value);
}
- else if (strcmp(option->key, "driver") == 0) {
+ else if (strcmp(key, "driver") == 0) {
if (pi) {
- pi->driver = KdFindPointerDriver(option->value);
+ pi->driver = KdFindPointerDriver(value);
if (!pi->driver) {
ErrorF("couldn't find driver!\n");
KdFreePointer(pi);
@@ -2276,7 +2295,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
pi->options = options;
}
else if (ki) {
- ki->driver = KdFindKeyboardDriver(option->value);
+ ki->driver = KdFindKeyboardDriver(value);
if (!ki->driver) {
ErrorF("couldn't find driver!\n");
KdFreeKeyboard(ki);
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 5c46152b2..cb4be4210 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1194,8 +1194,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (Pointer)
foundPointer = configInput(Pointer, confInput, from);
if (foundPointer) {
- Pointer->options = xf86addNewOption(Pointer->options,
- xnfstrdup("CorePointer"), "on");
+ Pointer->options = xf86AddNewOption(Pointer->options,
+ "CorePointer", "on");
+ Pointer->options = xf86AddNewOption(Pointer->options,
+ "driver", confInput->inp_driver);
+ Pointer->options = xf86AddNewOption(Pointer->options,
+ "identifier", confInput->inp_identifier);
servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
}
}
@@ -1284,8 +1288,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (Keyboard)
foundKeyboard = configInput(Keyboard, confInput, from);
if (foundKeyboard) {
- Keyboard->options = xf86addNewOption(Keyboard->options,
- xnfstrdup("CoreKeyboard"), "on");
+ Keyboard->options = xf86AddNewOption(Keyboard->options,
+ "CoreKeyboard", "on");
+ Keyboard->options = xf86AddNewOption(Keyboard->options,
+ "driver", confInput->inp_driver);
+ Keyboard->options = xf86AddNewOption(Keyboard->options,
+ "identifier", confInput->inp_identifier);
servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
}
}
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 74e0bc220..a0fdf29ad 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -811,21 +811,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
NULL);
}
-static InputInfoPtr
-duplicateDevice(InputInfoPtr pInfo)
-{
- InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
- if (dup) {
- dup->name = strdup(pInfo->name);
- dup->driver = strdup(pInfo->driver);
- dup->options = xf86OptionListDuplicate(pInfo->options);
- /* type_name is a const string */
- dup->type_name = pInfo->type_name;
- dup->fd = -1;
- }
- return dup;
-}
-
/**
* Initialize all supported input devices present and referenced in the
* xorg.conf.
@@ -842,20 +827,8 @@ InitInput(int argc, char **argv)
/* Initialize all configured input devices */
for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
- InputInfoPtr dup;
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
- strcpy((*pInfo)->driver, "kbd");
- }
-
- /* Data passed into xf86NewInputDevice will be freed on shutdown.
- * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
- * xorg.conf input devices in the second generation
- */
- dup = duplicateDevice(*pInfo);
-
/* If one fails, the others will too */
- if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
+ if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc)
break;
}
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 73b6573f1..9c528782f 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -44,6 +44,7 @@
#include "xf86Xinput.h"
#include "xf86Optrec.h"
#include "xf86Parser.h"
+#include "optionstr.h"
static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
Bool markUsed);
@@ -298,7 +299,7 @@ xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
return LookupPercentOption(optlist, name, deflt, FALSE);
}
/*
- * addNewOption() has the required property of replacing the option value
+ * xf86AddNewOption() has the required property of replacing the option value
* if the option is already present.
*/
XF86OptionPtr
diff --git a/hw/xfree86/common/xf86Optionstr.h b/hw/xfree86/common/xf86Optionstr.h
index 8cc82d34c..fc9385617 100644
--- a/hw/xfree86/common/xf86Optionstr.h
+++ b/hw/xfree86/common/xf86Optionstr.h
@@ -24,16 +24,7 @@
#ifndef XF86OPTIONSTR_H
#define XF86OPTIONSTR_H
-
-/*
- * all records that need to be linked lists should contain a GenericList as
- * their first field.
- */
-typedef struct generic_list_rec
-{
- void *next;
-}
-GenericListRec, *GenericListPtr, *glp;
+#include "list.h"
/*
* All options are stored using this data type.
@@ -48,6 +39,6 @@ typedef struct _XF86OptionRec
}
XF86OptionRec;
-typedef struct _XF86OptionRec *XF86OptionPtr;
+typedef struct _InputOption *XF86OptionPtr;
#endif
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ea1f92761..425b35957 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -68,6 +68,7 @@
#include "exglobals.h"
#include "eventstr.h"
#include "inpututils.h"
+#include "optionstr.h"
#include <string.h> /* InputClassMatches */
#ifdef HAVE_FNMATCH_H
@@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
if (!pInfo)
return BadAlloc;
- nt_list_for_each_entry(option, options, next) {
+ nt_list_for_each_entry(option, options, list.next) {
if (strcasecmp(input_option_get_key(option), "driver") == 0) {
if (pInfo->driver) {
rval = BadRequest;
@@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
}
}
- nt_list_for_each_entry(option, options, next) {
+ nt_list_for_each_entry(option, options, list.next) {
/* Copy option key/value strings from the provided list */
pInfo->options = xf86AddNewOption(pInfo->options,
input_option_get_key(option),
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index a4baad557..0d5e952a2 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -189,7 +189,7 @@ following changes:
<varlistentry><term><emphasis>Keyboard</emphasis></term>
<listitem><literallayout>
&k.identifier; "Implicit Core Keyboard"
- &k.driver; "keyboard"
+ &k.driver; "kbd"
</literallayout></listitem></varlistentry>
<varlistentry><term><emphasis>Pointer</emphasis></term>
<listitem><literallayout>
@@ -206,7 +206,7 @@ following changes:
is no &k.serverlayout; section, if the <option>-screen</option> command
line options is used, or if the &k.serverlayout; section doesn't
reference any &k.inputdevice; sections. In this case, the first
- sections with drivers "keyboard" and "mouse" are used as the core
+ sections with drivers "kbd" and "mouse" are used as the core
keyboard and pointer respectively.
</para>
</sect2>
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 7a0794bb0..f0a61707b 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -63,6 +63,7 @@
#include "Configint.h"
#include <X11/Xfuncproto.h>
#include "Xprintf.h"
+#include "optionstr.h"
extern LexRec val;
@@ -203,7 +204,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
free(new->opt_val);
}
else
- new = calloc (1, sizeof (XF86OptionRec));
+ new = calloc (1, sizeof (*new));
new->opt_name = name;
new->opt_val = val;
new->opt_used = used;
@@ -284,7 +285,7 @@ xf86newOption(char *name, char *value)
{
XF86OptionPtr opt;
- opt = calloc(1, sizeof (XF86OptionRec));
+ opt = calloc(1, sizeof (*opt));
if (!opt)
return NULL;
diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index e1f770bc3..4487b0df6 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -63,7 +63,7 @@
#include "xf86tokens.h"
#include "Configint.h"
#include <string.h>
-
+#include "optionstr.h"
/* Needed for auto server layout */
extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);