diff options
author | David Härdeman <david@hardeman.nu> | 2015-08-20 00:23:27 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2015-08-20 00:23:27 +0200 |
commit | bde923a8584b8104ed999091b81bcd6c84d533ba (patch) | |
tree | 028ac16441d21cd12598785551e3229110f88a0e | |
parent | 8d24f123abeb73cb2c1255d7b306e11ad7ba1c42 (diff) |
Add raw event logging UI
-rw-r--r-- | RemoteControlManager.xml | 3 | ||||
-rw-r--r-- | rcm-client-advanced.c | 37 | ||||
-rw-r--r-- | rcm-client-advanced.h | 2 | ||||
-rw-r--r-- | rcm-client-main.c | 6 | ||||
-rw-r--r-- | rcm-client.ui | 81 | ||||
-rw-r--r-- | rcm-server-evdev.c | 18 | ||||
-rw-r--r-- | 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 @@ <signal name='KeyReleased'> <arg type='s' name='keycode'/> </signal> + <signal name='Event'> + <arg type='s' name='description'/> + </signal> <property name='SysName' type='s' access='read'/> <property name='Description' type='s' access='read'/> <property name='DriverName' type='s' access='read'/> 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) { @@ -121,6 +145,18 @@ advanced_show_main_cb(GtkButton *button, gpointer user_data) } 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) { RCDevice *object = 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 @@ <child> <object class="GtkButton" id="advanced_main_receive"> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="hexpand">True</property> @@ -84,7 +83,6 @@ <child> <object class="GtkBox" id="advanced_main_receive_box"> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="can_focus">False</property> <property name="spacing">12</property> <child> @@ -521,6 +519,85 @@ to keycode mappings <property name="position">2</property> </packing> </child> + <child> + <object class="GtkGrid" id="advanced_receive_grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkImage" id="advanced_receive_icon"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="icon_name">dialog-information</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="advanced_receive_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes"><b><big>Receive Events</big></b> +Show raw events received from the kernel</property> + <property name="use_markup">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="advanced_receive_swin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="advanced_receive_textview"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="monospace">True</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="advanced_receive_clear"> + <property name="label" translatable="yes">Clear</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="halign">end</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> + </object> + <packing> + <property name="name">advanced_receive_page</property> + <property name="title" translatable="yes">advanced_receive_page</property> + <property name="position">3</property> + </packing> + </child> </object> </child> <child type="titlebar"> 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 }; |