diff options
author | Julien Cristau <jcristau@debian.org> | 2009-09-27 14:45:47 +0200 |
---|---|---|
committer | Julien Cristau <jcristau@debian.org> | 2009-12-30 19:05:44 +0000 |
commit | 435f27667f84269768efecde34de4af2b2d43376 (patch) | |
tree | 308b00d27cd065fb19d8aec663e0b7cf0b0e54e3 /config/config.c | |
parent | b8b12e41c453c3bf94b11e7a18934d3b6e1869bf (diff) |
config: add libudev input-hotplug backend
Add a backend using libudev for input hotplug, and disable the hal and
dbus backends if this one is enabled.
XKB configuration happens using xkb{rules,model,layout,variant,options}
properties (case-insensitive) on the device. We fill in InputAttributes
to allow configuration through InputClass in Xorg.
Requires udev 148 for the input_id helper and ID_INPUT* properties.
Signed-off-by: Julien Cristau <jcristau@debian.org>
Acked-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'config/config.c')
-rw-r--r-- | config/config.c | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/config/config.c b/config/config.c index b01329339..7bf5e4179 100644 --- a/config/config.c +++ b/config/config.c @@ -28,13 +28,17 @@ #endif #include "os.h" +#include "inputstr.h" #include "hotplug.h" #include "config-backends.h" void config_init(void) { -#if defined(CONFIG_DBUS_API) || defined(CONFIG_HAL) +#ifdef CONFIG_UDEV + if (!config_udev_init()) + ErrorF("[config] failed to initialise udev\n"); +#elif defined(CONFIG_NEED_DBUS) if (config_dbus_core_init()) { # ifdef CONFIG_DBUS_API if (!config_dbus_init()) @@ -54,7 +58,9 @@ config_init(void) void config_fini(void) { -#if defined(CONFIG_DBUS_API) || defined(CONFIG_HAL) +#if defined(CONFIG_UDEV) + config_udev_fini(); +#elif defined(CONFIG_NEED_DBUS) # ifdef CONFIG_HAL config_hal_fini(); # endif @@ -64,3 +70,70 @@ config_fini(void) config_dbus_core_fini(); #endif } + +static void +remove_device(const char *backend, DeviceIntPtr dev) +{ + /* this only gets called for devices that have already been added */ + LogMessage(X_INFO, "config/%s: removing device %s\n", backend, dev->name); + + /* Call PIE here so we don't try to dereference a device that's + * already been removed. */ + OsBlockSignals(); + ProcessInputEvents(); + DeleteInputDeviceRequest(dev); + OsReleaseSignals(); +} + +void +remove_devices(const char *backend, const char *config_info) +{ + DeviceIntPtr dev, next; + + for (dev = inputInfo.devices; dev; dev = next) { + next = dev->next; + if (dev->config_info && strcmp(dev->config_info, config_info) == 0) + remove_device(backend, dev); + } + for (dev = inputInfo.off_devices; dev; dev = next) { + next = dev->next; + if (dev->config_info && strcmp(dev->config_info, config_info) == 0) + remove_device(backend, dev); + } +} + +BOOL +device_is_duplicate(const char *config_info) +{ + DeviceIntPtr dev; + + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (dev->config_info && (strcmp(dev->config_info, config_info) == 0)) + return TRUE; + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + { + if (dev->config_info && (strcmp(dev->config_info, config_info) == 0)) + return TRUE; + } + + return FALSE; +} + +void +add_option(InputOption **options, const char *key, const char *value) +{ + if (!value || *value == '\0') + return; + + for (; *options; options = &(*options)->next) + ; + *options = xcalloc(sizeof(**options), 1); + if (!*options) /* Yeesh. */ + return; + (*options)->key = xstrdup(key); + (*options)->value = xstrdup(value); + (*options)->next = NULL; +} |