summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Brulebois <kibi@debian.org>2011-02-15 13:06:58 +0000
committerCyril Brulebois <kibi@debian.org>2011-02-15 13:06:58 +0000
commit4cffbf9c5820f440abefad4c98cbaf2a41a6eac2 (patch)
tree0e09840a2fdbba87a77dd17766f3eac817de16a0
parentda29effec2fe505f7a318cae0854b33ecd3ac5cd (diff)
Try and get inputbk started.inputbk
-rw-r--r--config/config-backends.h6
-rw-r--r--config/config.c10
-rw-r--r--config/inputbk.c270
-rw-r--r--include/dix-config.h.in3
4 files changed, 281 insertions, 8 deletions
diff --git a/config/config-backends.h b/config/config-backends.h
index 0a2a22af0..ed4dd59e8 100644
--- a/config/config-backends.h
+++ b/config/config-backends.h
@@ -32,9 +32,9 @@ void remove_devices(const char *backend, const char *config_info);
BOOL device_is_duplicate(const char *config_info);
void add_option(InputOption **options, const char *key, const char *value);
-#ifdef CONFIG_UDEV
-int config_udev_init(void);
-void config_udev_fini(void);
+#ifdef CONFIG_INPUTBK
+int config_inputbk_init(void);
+void config_inputbk_fini(void);
#else
# ifdef CONFIG_NEED_DBUS
diff --git a/config/config.c b/config/config.c
index 7bf5e4179..167f90803 100644
--- a/config/config.c
+++ b/config/config.c
@@ -35,9 +35,9 @@
void
config_init(void)
{
-#ifdef CONFIG_UDEV
- if (!config_udev_init())
- ErrorF("[config] failed to initialise udev\n");
+#ifdef CONFIG_INPUTBK
+ if (!config_inputbk_init())
+ ErrorF("[config] failed to initialise inputbk\n");
#elif defined(CONFIG_NEED_DBUS)
if (config_dbus_core_init()) {
# ifdef CONFIG_DBUS_API
@@ -58,8 +58,8 @@ config_init(void)
void
config_fini(void)
{
-#if defined(CONFIG_UDEV)
- config_udev_fini();
+#if defined(CONFIG_INPUTBK)
+ config_inputbk_fini();
#elif defined(CONFIG_NEED_DBUS)
# ifdef CONFIG_HAL
config_hal_fini();
diff --git a/config/inputbk.c b/config/inputbk.c
new file mode 100644
index 000000000..576837fe6
--- /dev/null
+++ b/config/inputbk.c
@@ -0,0 +1,270 @@
+/*
+ * Copyright © 2009 Julien Cristau
+ * Copyright © 2011 Cyril Brulebois
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Julien Cristau <jcristau@debian.org>
+ * Cyril Brulebois <kibi@debian.org>
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <ctype.h>
+
+#include "input.h"
+#include "inputstr.h"
+#include "hotplug.h"
+#include "config-backends.h"
+#include "os.h"
+
+#define UDEV_XKB_PROP_KEY "xkb"
+
+#define LOG_PROPERTY(path, prop, val) \
+ LogMessageVerb(X_INFO, 10, \
+ "config/inputbk: getting property %s on %s " \
+ "returned \"%s\"\n", \
+ (prop), (path), (val) ? (val) : "(null)")
+#define LOG_SYSATTR(path, attr, val) \
+ LogMessageVerb(X_INFO, 10, \
+ "config/inputbk: getting attribute %s on %s " \
+ "returned \"%s\"\n", \
+ (attr), (path), (val) ? (val) : "(null)")
+
+
+static void
+device_added(void)
+{
+#if 0
+ const char *path, *name = NULL;
+ char *config_info = NULL;
+ const char *syspath;
+ const char *tags_prop;
+ const char *key, *value, *tmp;
+#endif
+ InputOption *options = NULL, *tmpo;
+ InputAttributes attrs = {};
+ DeviceIntPtr dev = NULL;
+
+
+ const char path[] = "/dev/ums0";
+ //const char prod[] = "Product";
+ //const char vend[] = "Vendor";
+ const char name[] = "My Device Name";
+ char *config_info = strdup("inputbk/ums0");
+ int rc;
+#if 0
+ struct udev_list_entry *set, *entry;
+ struct udev_device *parent;
+ int rc;
+
+ path = udev_device_get_devnode(udev_device);
+
+ syspath = udev_device_get_syspath(udev_device);
+
+ if (!path || !syspath)
+ return;
+
+ if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
+ LogMessageVerb(X_INFO, 10,
+ "config/udev: ignoring device %s without "
+ "property ID_INPUT set\n",
+ path);
+ return;
+ }
+#endif
+
+ options = calloc(sizeof(*options), 1);
+ if (!options)
+ return;
+
+ options->key = strdup("_source");
+ options->value = strdup("server/inputbk");
+ if (!options->key || !options->value)
+ goto unwind;
+
+
+ //LOG_SYSATTR(path, "name", name);
+ //LOG_PROPERTY(path, "NAME", name);
+ //attrs.pnp_id = strdup("my pnp id");
+ //LOG_SYSATTR(path, "pnp_id", attrs.pnp_id);
+ //attrs.usb_id = strdup("my usb id");
+ //LOG_PROPERTY(path, "PRODUCT", product);
+ attrs.product = strdup(name);
+
+ add_option(&options, "name", name);
+ add_option(&options, "path", path);
+ add_option(&options, "device", path);
+ attrs.device = strdup(path);
+
+ //LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
+ attrs.tags = NULL;
+ attrs.flags |= ATTR_POINTER;
+
+
+ LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n",
+ name, path);
+ rc = NewInputDeviceRequest18(options, &attrs, &dev);
+ if (rc != Success)
+ goto unwind;
+
+ for (; dev; dev = dev->next) {
+ free(dev->config_info);
+ dev->config_info = strdup(config_info);
+ }
+
+ unwind:
+ free(config_info);
+ while (!dev && (tmpo = options)) {
+ options = tmpo->next;
+ free(tmpo->key);
+ free(tmpo->value);
+ free(tmpo);
+ }
+
+// free(attrs.usb_id);
+ if (attrs.tags) {
+ char **tag = attrs.tags;
+ while (*tag) {
+ free(*tag);
+ tag++;
+ }
+ free(attrs.tags);
+ }
+
+ return;
+}
+
+#if 0
+static void
+device_removed()
+{
+ char *value;
+ const char *syspath = udev_device_get_syspath(device);
+
+ value = Xprintf("udev:%s", syspath);
+ if (!value)
+ return;
+
+ remove_devices("udev", value);
+
+ free(value);
+}
+#endif
+
+#if 0
+static void
+wakeup_handler(pointer data, int err, pointer read_mask)
+{
+ int udev_fd = udev_monitor_get_fd(udev_monitor);
+ struct udev_device *udev_device;
+ const char *action;
+
+ if (err < 0)
+ return;
+
+ if (FD_ISSET(udev_fd, (fd_set *)read_mask)) {
+ udev_device = udev_monitor_receive_device(udev_monitor);
+ if (!udev_device)
+ return;
+ action = udev_device_get_action(udev_device);
+ if (action) {
+ if (!strcmp(action, "add"))
+ device_added(udev_device);
+ else if (!strcmp(action, "remove"))
+ device_removed(udev_device);
+ }
+ udev_device_unref(udev_device);
+ }
+}
+#endif
+
+#if 0
+static void
+block_handler(pointer data, struct timeval **tv, pointer read_mask)
+{
+}
+#endif
+
+int
+config_inputbk_init(void)
+{
+#if 0
+ struct udev *udev;
+ struct udev_enumerate *enumerate;
+ struct udev_list_entry *devices, *device;
+
+ udev = udev_new();
+ if (!udev)
+ return 0;
+ udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
+ if (!udev_monitor)
+ return 0;
+
+ if (udev_monitor_enable_receiving(udev_monitor)) {
+ ErrorF("config/udev: failed to bind the udev monitor\n");
+ return 0;
+ }
+
+ enumerate = udev_enumerate_new(udev);
+ if (!enumerate)
+ return 0;
+ udev_enumerate_scan_devices(enumerate);
+ devices = udev_enumerate_get_list_entry(enumerate);
+ udev_list_entry_foreach(device, devices) {
+ const char *syspath = udev_list_entry_get_name(device);
+ struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath);
+ device_added(udev_device);
+ udev_device_unref(udev_device);
+ }
+ udev_enumerate_unref(enumerate);
+#endif
+
+ // Dummy addition
+ device_added();
+
+#if 0
+ RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
+ AddGeneralSocket(udev_monitor_get_fd(udev_monitor));
+#endif
+
+ return 1;
+}
+
+void
+config_inputbk_fini(void)
+{
+#if 0
+ struct udev *udev;
+
+ if (!udev_monitor)
+ return;
+
+ udev = udev_monitor_get_udev(udev_monitor);
+
+ RemoveGeneralSocket(udev_monitor_get_fd(udev_monitor));
+ RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
+ udev_monitor_unref(udev_monitor);
+ udev_monitor = NULL;
+ udev_unref(udev);
+#endif
+}
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 944a0061f..f7c99ef92 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -396,6 +396,9 @@
/* Use libudev for input hotplug */
#undef CONFIG_UDEV
+/* Use inputbk for input hotplug */
+#undef CONFIG_INPUTBK
+
/* Use D-Bus for input hotplug */
#undef CONFIG_NEED_DBUS