From ac13d05d8bcf212e3423f3100331ffe0fa1a433a Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 16 Jul 2015 11:29:19 +0200 Subject: Some cleanups to prepare for multiple keymaps --- RemoteControlManager.xml | 4 ---- keymaps/default/test2.layout | 48 ++++++++++++++++++++++++++++++++++++++++++++ rcm-client-main.c | 9 +++------ rcm-server-keymap.c | 21 ++++++++----------- rcm-server-main.c | 32 ++++++++--------------------- 5 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 keymaps/default/test2.layout diff --git a/RemoteControlManager.xml b/RemoteControlManager.xml index ac81962..1d5751d 100644 --- a/RemoteControlManager.xml +++ b/RemoteControlManager.xml @@ -2,10 +2,6 @@ - - - - diff --git a/keymaps/default/test2.layout b/keymaps/default/test2.layout new file mode 100644 index 0000000..c1ff8dc --- /dev/null +++ b/keymaps/default/test2.layout @@ -0,0 +1,48 @@ +[Description] +Name=Foobar 2000 +Description=Foobar TV/AVR Universal Remote + +[Keymap] +Map=nec:0xf00f0000:KEY_NUMERIC_0 +Map=nec:0xf00f0001:KEY_NUMERIC_1 +Map=nec:0xf00f0002:KEY_NUMERIC_2 +Map=nec:0xf00f0003:KEY_NUMERIC_3 +Map=nec:0xf00f0004:KEY_NUMERIC_4 +Map=nec:0xf00f0005:KEY_NUMERIC_5 +Map=nec:0xf00f0006:KEY_NUMERIC_6 +Map=nec:0xf00f0007:KEY_NUMERIC_7 +Map=nec:0xf00f0008:KEY_NUMERIC_8 +Map=nec:0xf00f0009:KEY_NUMERIC_9 +Map=nec:0xf00f0010:KEY_OK +Map=nec:0xf00f0011:KEY_UP +Map=nec:0xf00f0012:KEY_DOWN +Map=nec:0xf00f0013:KEY_LEFT +Map=nec:0xf00f0014:KEY_RIGHT + +[Layout] +Rows=8 +Cols=3 +Button=KEY_NUMERIC_1 +Button=KEY_NUMERIC_2 +Button=KEY_NUMERIC_3 +Button=KEY_NUMERIC_4 +Button=KEY_NUMERIC_5 +Button=KEY_NUMERIC_6 +Button=KEY_NUMERIC_7 +Button=KEY_NUMERIC_8 +Button=KEY_NUMERIC_9 +Button=Blank +Button=KEY_NUMERIC_0 +Button=Blank +Button=Blank +Button=Blank +Button=Blank +Button=Blank +Button=KEY_UP +Button=Blank +Button=KEY_LEFT +Button=KEY_OK +Button=KEY_RIGHT +Button=Blank +Button=KEY_DOWN +Button=Blank diff --git a/rcm-client-main.c b/rcm-client-main.c index 17979dd..f7a70c6 100644 --- a/rcm-client-main.c +++ b/rcm-client-main.c @@ -37,12 +37,9 @@ poke_objects() } RCDevice *object = RCDEVICE(interface); - gchar *reply = NULL; - rcdevice_call_echo_string_sync(object, "Roeven", &reply, NULL, NULL); - printf("Called object %s: %s\n", g_dbus_object_get_object_path (G_DBUS_OBJECT(l->data)), reply); - printf("Driver name is: %s\n", rcdevice_get_driver_name(object)); - printf("Keymap name is: %s\n", rcdevice_get_kernel_keymap_name(object)); - g_free(reply); + printf("DBus object %s\n", g_dbus_object_get_object_path(G_DBUS_OBJECT(l->data))); + printf("\tDriver name is: %s\n", rcdevice_get_driver_name(object)); + printf("\tKeymap name is: %s\n", rcdevice_get_kernel_keymap_name(object)); g_object_unref(interface); } diff --git a/rcm-server-keymap.c b/rcm-server-keymap.c index 8a4fa3e..3231ed2 100644 --- a/rcm-server-keymap.c +++ b/rcm-server-keymap.c @@ -207,9 +207,6 @@ keymap_parse(FILE *fp, char **line, size_t *buf_size, struct keymap *keymap, keymap->keycodes[keycode_count].protocol = strdup(protocol); keymap->keycodes[keycode_count].scancode = scancode; keymap->keycodes[keycode_count].keycode = strdup(keycode); - printf("\tMapping: protocol %s scancode 0x%08" PRIx64 " keycode %s\n", - protocol, scancode, keycode); - } keycode_count++; } else { @@ -341,12 +338,10 @@ keymap_read(int dfd, const char *name) return NULL; fd = -1; - printf("Parsing keymap %s\n", name); + printf("Parsing keymap %s...\n", name); r = keymap_parse(fp, &line, &buf_size, NULL, &rows, &cols, &keycode_count); - if (r < 0) { - fprintf(stderr, "Invalid keymap: %s\n", name); + if (r < 0) return NULL; - } keymap = zmalloc(sizeof(*keymap) + sizeof(struct keycode) * keycode_count); if (!keymap) @@ -360,11 +355,15 @@ keymap_read(int dfd, const char *name) r = keymap_parse(fp, &line, &buf_size, keymap, NULL, NULL, NULL); if (r < 0) { - fprintf(stderr, "Invalid keymap: %s\n", name); free(keymap->layout); free(keymap); return NULL; } + + printf("\tKeymap added\n"); + printf("\tDescription: %s\n", keymap->desc); + printf("\tName: %s\n", keymap->name); + printf("\tMappings: %u entries\n", keycode_count); printf("\tLayout: %u rows x %u cols = %u entries\n", rows, cols, rows * cols); return keymap; } @@ -394,12 +393,8 @@ keymaps_load_dir(struct device *device, const char *path) if (keymap) continue; keymap = keymap_read(dfd, dent->d_name); - if (keymap) { - printf("Keymap added (0x%p)\n", keymap); - printf("\tDescription: %s\n", keymap->desc); - printf("\tName: %s\n", keymap->name); + if (keymap) list_add(&keymap->list, &device->keymaps); - } break; default: break; diff --git a/rcm-server-main.c b/rcm-server-main.c index 283b685..4f4e9e1 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -12,21 +12,6 @@ #include "rcm-server-main.h" #include "rcm-server-keymap.h" -static int -method_echostring(sd_bus_message *m, void *userdata, sd_bus_error *error) -{ - const char *msg; - int r; - - r = sd_bus_message_read(m, "s", &msg); - if (r < 0) { - fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); - return sd_bus_error_set_errno(error, r); - } - - return sd_bus_reply_method_return(m, "s", msg); -} - static struct device * find_device_by_path(struct manager *mgr, const char *path) { @@ -187,7 +172,6 @@ static const sd_bus_vtable device_vtable[] = { SD_BUS_PROPERTY("DriverName", "s", property_get, 0, 0), SD_BUS_PROPERTY("KernelKeymapName", "s", property_get, 0, 0), SD_BUS_PROPERTY("HardwareType", "s", property_get, 0, 0), - SD_BUS_METHOD("EchoString", "s", "s", method_echostring, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("ListKeymaps", NULL, "as", method_listkeymaps, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetKeymap", "s", "qqaa{sv}", method_getkeymap, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_SIGNAL("KeyPressed", "s", 0), @@ -309,15 +293,15 @@ add_device(struct manager *mgr, struct udev_device *udev) } printf("Adding Device Object\n"); - printf(" Path : %s\n", udev_device_get_syspath(udev)); - printf(" Node : %s\n", udev_device_get_devnode(udev)); - printf(" Subsystem : %s\n", udev_device_get_subsystem(udev)); - printf(" Devtype : %s\n", udev_device_get_devtype(udev)); - printf(" Action : %s\n", udev_device_get_action(udev)); - printf(" Protocols : %s\n", + printf("\tPath : %s\n", udev_device_get_syspath(udev)); + printf("\tNode : %s\n", udev_device_get_devnode(udev)); + printf("\tSubsystem : %s\n", udev_device_get_subsystem(udev)); + printf("\tDevtype : %s\n", udev_device_get_devtype(udev)); + printf("\tAction : %s\n", udev_device_get_action(udev)); + printf("\tDriver : %s\n", device->driver_name); + printf("\tKernel map: %s\n", device->keymap_name); + printf("\tProtocols : %s\n", udev_device_get_sysattr_value(udev, "protocols")); - printf(" Uevent : %s\n", - udev_device_get_sysattr_value(udev, "uevent")); list_add(&device->list, &mgr->devices); mgr->num_devices++; -- cgit v1.2.3