From bde923a8584b8104ed999091b81bcd6c84d533ba Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 20 Aug 2015 00:23:27 +0200 Subject: Add raw event logging UI --- RemoteControlManager.xml | 3 ++ rcm-client-advanced.c | 37 ++++++++++++++++++++++ rcm-client-advanced.h | 2 ++ rcm-client-main.c | 6 ++++ rcm-client.ui | 81 ++++++++++++++++++++++++++++++++++++++++++++++-- rcm-server-evdev.c | 18 ++++++++--- rcm-server-main.c | 1 + 7 files changed, 142 insertions(+), 6 deletions(-) diff --git a/RemoteControlManager.xml b/RemoteControlManager.xml index 0462b7d..f1a5326 100644 --- a/RemoteControlManager.xml +++ b/RemoteControlManager.xml @@ -40,6 +40,9 @@ + + + diff --git a/rcm-client-advanced.c b/rcm-client-advanced.c index ca10331..0141c37 100644 --- a/rcm-client-advanced.c +++ b/rcm-client-advanced.c @@ -48,6 +48,30 @@ encode_nec(uint32_t scancode_raw) return r; } +void +advanced_receive_event(const gchar *event) +{ + GtkTextView *textview = GTK_TEXT_VIEW(get_object("advanced_receive_textview")); + GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview); + GtkTextIter iter; + + gtk_text_buffer_get_end_iter(buffer, &iter); + gtk_text_buffer_insert(buffer, &iter, event, -1); +} + +static void +advanced_receive_clear_cb(GtkButton *button, gpointer user_data) +{ + GtkTextView *textview = GTK_TEXT_VIEW(get_object("advanced_receive_textview")); + GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview); + GtkTextIter si, ei; + + gtk_text_buffer_get_start_iter(buffer, &si); + gtk_text_buffer_get_end_iter(buffer, &ei); + + gtk_text_buffer_delete(buffer, &si, &ei); +} + static void advanced_transmit_cb(GtkButton *button, gpointer user_data) { @@ -120,6 +144,18 @@ advanced_show_main_cb(GtkButton *button, gpointer user_data) gtk_stack_set_visible_child_name(stack, "advanced_main_page"); } +static void +advanced_show_receive_cb(GtkButton *button, gpointer user_data) +{ + RCDevice *object = user_data; + GtkStack *stack; + + stack = GTK_STACK(get_object("advanced_stack")); + gtk_stack_set_visible_child_name(stack, "advanced_receive_page"); + g_signal_replace_id("advanced_receive_clear", "clicked", G_CALLBACK(advanced_receive_clear_cb), object); + local_create_header_button("Return to advanced menu", "go-previous-symbolic", false, G_CALLBACK(advanced_show_main_cb), NULL); +} + static void advanced_show_transmit_cb(GtkButton *button, gpointer user_data) { @@ -311,6 +347,7 @@ advanced_init_ui(RCDevice *object) g_free(titlestr); g_signal_replace_id("advanced_main_transmit", "clicked", G_CALLBACK(advanced_show_transmit_cb), object); + g_signal_replace_id("advanced_main_receive", "clicked", G_CALLBACK(advanced_show_receive_cb), object); g_signal_replace_id("advanced_main_keymap", "clicked", G_CALLBACK(advanced_show_keymap_cb), object); gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(get_object("advanced_keymap_treecol_scancode")), diff --git a/rcm-client-advanced.h b/rcm-client-advanced.h index 81c1ebc..9c7edd6 100644 --- a/rcm-client-advanced.h +++ b/rcm-client-advanced.h @@ -1,3 +1,5 @@ +void advanced_receive_event(const gchar *event); + void advanced_init_ui(RCDevice *object); diff --git a/rcm-client-main.c b/rcm-client-main.c index e3dcd04..9d6c4e1 100644 --- a/rcm-client-main.c +++ b/rcm-client-main.c @@ -10,6 +10,7 @@ #include "rcm-client-main.h" #include "rcm-client-hardware-list.h" #include "rcm-client-receive.h" +#include "rcm-client-advanced.h" #define WINDOW_WIDTH 300 #define WINDOW_HEIGHT 300 @@ -77,6 +78,7 @@ on_signal(GDBusObjectManagerClient *manager, gchar *protocol; guint64 scancode; gchar *keycode; + gchar *event; g_print("Signal %s received for obj %s\n", signal_name, g_dbus_object_get_object_path(G_DBUS_OBJECT(object_proxy))); @@ -90,6 +92,10 @@ on_signal(GDBusObjectManagerClient *manager, rcng_client_receive_key_pressed(G_DBUS_OBJECT(object_proxy), protocol, scancode, keycode); g_free(protocol); g_free(keycode); + } else if (!strcmp(signal_name, "Event")) { + g_variant_get(parameters, "(s)", &event); + advanced_receive_event(event); + g_free(event); } } diff --git a/rcm-client.ui b/rcm-client.ui index 5619159..5aaabb0 100644 --- a/rcm-client.ui +++ b/rcm-client.ui @@ -76,7 +76,6 @@ True - False True True True @@ -84,7 +83,6 @@ True - False False 12 @@ -521,6 +519,85 @@ to keycode mappings 2 + + + True + False + 12 + 12 + + + True + False + start + 0 + 0 + dialog-information + 6 + + + 0 + 0 + + + + + True + False + <b><big>Receive Events</big></b> +Show raw events received from the kernel + True + 0 + + + 1 + 0 + + + + + True + True + True + True + in + + + True + False + True + False + True + + + + + 0 + 1 + 2 + + + + + Clear + True + True + True + end + + + 0 + 2 + 2 + + + + + advanced_receive_page + advanced_receive_page + 3 + + diff --git a/rcm-server-evdev.c b/rcm-server-evdev.c index 9444b7f..3b76482 100644 --- a/rcm-server-evdev.c +++ b/rcm-server-evdev.c @@ -220,14 +220,24 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata) } do { + char buf[100]; + r = libevdev_next_event(device->evdev_dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); if (r != LIBEVDEV_READ_STATUS_SUCCESS) continue; - printf("Event: %s %s %u (0x%08x)\n", - libevdev_event_type_get_name(ev.type), - libevdev_event_code_get_name(ev.type, ev.code), - ev.value, ev.value); + snprintf(buf, sizeof(buf), "Event: %s %s %u (0x%08x)\n", + libevdev_event_type_get_name(ev.type), + libevdev_event_code_get_name(ev.type, ev.code), + ev.value, ev.value); + + sd_bus_emit_signal(device->mgr->bus, + device->path, + "org.gnome.RemoteControlManager.Device", + "Event", + "s", buf); + + printf(buf); switch (ev.type) { case EV_KEY: diff --git a/rcm-server-main.c b/rcm-server-main.c index d4b41fe..596d81c 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -849,6 +849,7 @@ static const sd_bus_vtable device_vtable[] = { SD_BUS_METHOD("Transmit", "au", NULL, method_transmit, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_SIGNAL("KeyPressed", "sts", 0), SD_BUS_SIGNAL("KeyReleased", "s", 0), + SD_BUS_SIGNAL("Event", "s", 0), SD_BUS_VTABLE_END }; -- cgit v1.2.3