aboutsummaryrefslogtreecommitdiff
path: root/src/evdev.c
diff options
context:
space:
mode:
authorZephaniah E. Hull <warp@agamemnon.b5>2007-06-05 23:12:58 -0400
committerZephaniah E. Hull <warp@agamemnon.b5>2007-06-05 23:12:58 -0400
commit294355842ba9fb3cb3bbd7bfd60c9ca3ce704475 (patch)
tree243c982bb7f88578246e8c50715220a30199ab8b /src/evdev.c
parentDisable and remove the device when a read error occurs. (diff)
downloadxf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.tar.gz
xf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.tar.bz2
xf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.zip
Alright, this is a really big commit that breaks stuff.
evdev.h: Switch to flags in the abs and rel structs. Add the axes struct, and defines. Rework the abs and rel structs, moving stuff to the axes struct and moving everything to the new mapping handling. Add the structs and function declarations for the new tokenization stuff, parsing stuff, and mapping stuff. evdev.c: Add EvdevTokenize, and the evdev_map_parsers list. evdev_axes.c: Basicly a full rewrite, big, messy. We now use a completely different mapping setup for axes, and mapping to buttons is currently missing. However we now handle ABS_CALIB and ABS_AREA, including rotation in both rel and abs modes. evdev_btn.c: Disable lots of code and break things horribly, we compile but we don't work very well. Fixing this is next on my todo list.
Diffstat (limited to 'src/evdev.c')
-rw-r--r--src/evdev.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 7e8b633..3b91e53 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -103,6 +103,104 @@ evdevGetBits (int fd, evdevBitsPtr bits)
return TRUE;
}
+/*
+ * Evdev option handling stuff.
+ *
+ * We should probably move this all off to it's own file, but for now it lives
+ * hereish.
+ */
+
+evdev_map_parsers_t evdev_map_parsers[] = {
+ {
+ .name = "RelAxis",
+ .func = EvdevParseMapToRelAxis,
+ },
+ {
+ .name = "AbsAxis",
+ .func = EvdevParseMapToAbsAxis,
+ },
+ {
+ .name = NULL,
+ .func = NULL,
+ }
+};
+
+evdev_option_token_t *
+EvdevTokenize (const char *option, const char *tokens, const char *first)
+{
+ evdev_option_token_t *head = NULL, *token = NULL, *prev = NULL;
+ const char *ctmp;
+ char *tmp = NULL;
+ int len;
+
+ if (!first) {
+ first = strchr (option, tokens[0]);
+ }
+
+ while (1) {
+ if (first)
+ len = first - option;
+ else {
+ len = strlen(option);
+ if (!len)
+ break;
+ }
+
+ if (!len) {
+ option++;
+ first = strchr (option, tokens[0]);
+ continue;
+ }
+
+ token = calloc (1, sizeof(evdev_option_token_t));
+ if (!head)
+ head = token;
+ if (prev)
+ prev->next = token;
+
+ prev = token;
+
+ tmp = calloc(1, len + 1);
+ strncpy (tmp, option, len);
+
+ if (tokens[1]) {
+ ctmp = strchr (tmp, tokens[1]);
+ if (ctmp) {
+ token->is_chain = 1;
+ token->u.chain = EvdevTokenize (tmp, tokens + 1, ctmp);
+ } else
+ token->u.str = tmp;
+ } else
+ token->u.str = tmp;
+
+ if (!first)
+ break;
+
+ option = first + 1;
+ first = strchr (option, tokens[0]);
+ }
+
+ return head;
+}
+
+void
+EvdevFreeTokens (evdev_option_token_t *token)
+{
+ evdev_option_token_t *next;
+
+ while (token) {
+ if (token->is_chain)
+ EvdevFreeTokens (token->u.chain);
+ else
+ free (token->u.str);
+ next = token->next;
+ free (token);
+ token = next;
+ }
+}
+
+
+
static void
EvdevReadInput(InputInfoPtr pInfo)
{