summaryrefslogtreecommitdiff
path: root/rcm-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-server.c')
-rw-r--r--rcm-server.c170
1 files changed, 2 insertions, 168 deletions
diff --git a/rcm-server.c b/rcm-server.c
index fb5eba9..26620fc 100644
--- a/rcm-server.c
+++ b/rcm-server.c
@@ -7,44 +7,10 @@
#include <string.h>
#include <systemd/sd-bus.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
#include "utils.h"
-
-struct keycode {
- char *name;
- char *value;
-};
-
-struct keymap {
- char *name;
- uint16_t rows;
- uint16_t cols;
- struct list_head list;
- struct keycode keycodes[];
-};
-
-struct device {
- char *name;
- char *path;
- char *driver_name;
- char *keymap_name;
- struct list_head list;
- struct list_head keymaps;
-};
-
-struct manager {
- sd_bus *bus;
- sd_event *event;
- struct udev *udev;
- struct udev_monitor *udev_mon;
- sd_event_source *udev_ev;
- struct list_head devices;
- unsigned num_devices;
-};
+#include "rcm-server.h"
+#include "rcm-server-keymap.h"
static int
method_echostring(sd_bus_message *m, void *userdata, sd_bus_error *error)
@@ -141,18 +107,6 @@ out:
return sd_bus_error_set_errno(error, r);
}
-static struct keymap *
-find_keymap_by_name(struct device *dev, const char *name)
-{
- struct keymap *keymap;
-
- list_for_each_entry(keymap, &dev->keymaps, list)
- if (!strcmp(keymap->name, name))
- return keymap;
-
- return NULL;
-}
-
static int
method_getkeymap(sd_bus_message *m, void *userdata, sd_bus_error *error)
{
@@ -295,99 +249,6 @@ remove_device(struct manager *mgr, struct udev_device *udev)
}
}
-static struct keymap *
-keymap_read(int dfd, const char *name)
-{
- int fd;
- struct keymap *keymap;
- unsigned i;
-
- if (dfd < 0 || !name)
- return NULL;
-
- fd = openat(dfd, name, O_RDONLY);
- if (fd < 0)
- return NULL;
-
- keymap = zmalloc(sizeof(*keymap) + (8 * 3) * sizeof(struct keycode));
- if (!keymap) {
- close(fd);
- return NULL;
- }
-
- keymap->name = strdup(name);
- if (!keymap->name) {
- close(fd);
- free(keymap);
- return NULL;
- }
-
- keymap->cols = 3;
- keymap->rows = 8;
-
- for (i = 0; i < (keymap->cols * keymap->rows); i++) {
- keymap->keycodes[i].name = "key-1-2";
- keymap->keycodes[i].value = "KEY_COFFEE";
- }
- /* FIXME: Actually read the keymap :) */
-
- close(fd);
- return keymap;
-}
-
-static int
-keymaps_load_dir(struct device *device, const char *path)
-{
- DIR *dir;
- int dfd;
- struct dirent *dent;
- struct keymap *keymap;
-
- dir = opendir(path);
- if (!dir)
- return -1;
-
- dfd = dirfd(dir);
- if (dfd < 0) {
- closedir(dir);
- return -1;
- }
-
- while ((dent = readdir(dir))) {
- switch (dent->d_type) {
- case DT_REG:
- case DT_LNK:
- case DT_UNKNOWN:
- keymap = keymap_read(dfd, dent->d_name);
- if (keymap)
- list_add(&keymap->list, &device->keymaps);
- break;
- default:
- break;
- }
- }
-
- if (closedir(dir) < 0)
- return -1;
-
- return 0;
-}
-
-static int
-keymaps_load(struct device *device)
-{
- char pdpath[strlen("./keymaps/per-device/") + strlen(device->name) + 1];
-
- sprintf(pdpath, "./keymaps/per-device/%s", device->name);
-
- printf("Loading per-device keymaps...\n");
- keymaps_load_dir(device, pdpath);
- printf("Loading default keymaps...\n");
- keymaps_load_dir(device, "./keymaps/default");
-
- return 0;
-}
-
static void
add_device(struct manager *mgr, struct udev_device *udev)
{
@@ -700,30 +561,3 @@ finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
-#if 0
-static gboolean
-on_irrx(RCIRDevice *object,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- GVariantBuilder builder;
- GVariant *ret;
-
- printf("In on_irrx\n");
- g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
- g_variant_builder_add(&builder, "{sv}", "name",
- g_variant_new_string("apan"));
- g_variant_builder_add(&builder, "{sv}", "foo",
- g_variant_new_string("bar"));
-
- ret = g_variant_builder_end (&builder);
-
- rcirdevice_complete_get_irrxparameters(object,
- invocation,
- ret);
-
- return true;
-}
-
-#endif
-