From 05b56eeb5c74aebe81de7550c41546d7d6f3fb0c Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Thu, 16 Mar 2006 13:09:19 +0000 Subject: Switch from my own globbing function to fnmatch. Detect keys numbered higher then buttons. Remove the (depreciated since long before xkb support was added to evdev) XkbKeymap option. --- src/evdev_brain.c | 41 ++++------------------------------------- src/evdev_key.c | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/evdev_brain.c b/src/evdev_brain.c index 04cc542..e3163c3 100644 --- a/src/evdev_brain.c +++ b/src/evdev_brain.c @@ -39,6 +39,7 @@ #include "evdev.h" #include +#include #ifndef SYSCALL #define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) @@ -49,40 +50,6 @@ static InputInfoPtr evdev_pInfo = NULL; static evdevDriverPtr evdev_drivers = NULL; static int evdev_seq; -static int -glob_match(const char *pattern, const char *matchp) -{ - int i, j = 0, ret = 0; - if (!(pattern && matchp)) - return (strlen(pattern) == strlen(matchp)); - - for (i = 0; matchp[i]; i++) { - if (pattern[j] == '\\') - j++; - else if (pattern[j] == '*') { - if (pattern[j + 1]) { - if (!glob_match(pattern+j+1,matchp+i)) - return 0; - } else - return 0; - continue; - } else if (pattern[j] == '?') { - j++; - continue; - } - - if ((ret = (pattern[j] - matchp[i]))) - return ret; - - j++; - } - if (!pattern[j] || ((pattern[j] == '*') && !pattern[j + 1])) - return 0; - else - return 1; -} - - int evdevGetFDForDevice (evdevDevicePtr device) { @@ -160,11 +127,11 @@ MatchAny (long *dev, long *match, int len) static Bool MatchDriver (evdevDriverPtr driver, evdevDevInfoPtr info) { - if (driver->name && glob_match(driver->name, info->name)) + if (driver->name && fnmatch(driver->name, info->name, 0)) return FALSE; - if (driver->phys && glob_match(driver->phys, info->phys)) + if (driver->phys && fnmatch(driver->phys, info->phys, 0)) return FALSE; - if (driver->device && glob_match(driver->device, info->dev)) + if (driver->device && fnmatch(driver->device, info->dev, 0)) return FALSE; if (driver->id.bustype && driver->id.bustype != info->id.bustype) diff --git a/src/evdev_key.c b/src/evdev_key.c index e9d4518..1073d62 100644 --- a/src/evdev_key.c +++ b/src/evdev_key.c @@ -365,6 +365,12 @@ EvdevKeyNew (InputInfoPtr pInfo) keys = 1; break; } + if (!keys) + for (i = KEY_OK; i <= KEY_MAX; i++) + if (TestBit (i, pEvdev->bits.key)) { + keys = 1; + break; + } if (!keys) return !Success; @@ -375,23 +381,17 @@ EvdevKeyNew (InputInfoPtr pInfo) pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED; - SetXkbOption (pInfo, "XkbKeymap", NULL, &state->key->xkbnames.keymap); - if (state->key->xkbnames.keymap) { - xf86Msg(X_CONFIG, "%s: XkbKeymap overrides all other XKB settings\n", - pInfo->name); - } else { - SetXkbOption (pInfo, "XkbRules", __XKBDEFRULES__, &state->key->xkb_rules); - SetXkbOption (pInfo, "XkbModel", "evdev", &state->key->xkb_model); - SetXkbOption (pInfo, "XkbLayout", "us", &state->key->xkb_layout); - SetXkbOption (pInfo, "XkbVariant", NULL, &state->key->xkb_variant); - SetXkbOption (pInfo, "XkbOptions", NULL, &state->key->xkb_options); - - SetXkbOption (pInfo, "XkbKeycodes", NULL, &state->key->xkbnames.keycodes); - SetXkbOption (pInfo, "XkbTypes", NULL, &state->key->xkbnames.types); - SetXkbOption (pInfo, "XkbCompat", NULL, &state->key->xkbnames.compat); - SetXkbOption (pInfo, "XkbSymbols", NULL, &state->key->xkbnames.symbols); - SetXkbOption (pInfo, "XkbGeometry", NULL, &state->key->xkbnames.geometry); - } + SetXkbOption (pInfo, "XkbRules", __XKBDEFRULES__, &state->key->xkb_rules); + SetXkbOption (pInfo, "XkbModel", "evdev", &state->key->xkb_model); + SetXkbOption (pInfo, "XkbLayout", "us", &state->key->xkb_layout); + SetXkbOption (pInfo, "XkbVariant", NULL, &state->key->xkb_variant); + SetXkbOption (pInfo, "XkbOptions", NULL, &state->key->xkb_options); + + SetXkbOption (pInfo, "XkbKeycodes", NULL, &state->key->xkbnames.keycodes); + SetXkbOption (pInfo, "XkbTypes", NULL, &state->key->xkbnames.types); + SetXkbOption (pInfo, "XkbCompat", NULL, &state->key->xkbnames.compat); + SetXkbOption (pInfo, "XkbSymbols", NULL, &state->key->xkbnames.symbols); + SetXkbOption (pInfo, "XkbGeometry", NULL, &state->key->xkbnames.geometry); return Success; } -- cgit v1.2.3