diff options
Diffstat (limited to 'rcm-client-main.c')
-rw-r--r-- | rcm-client-main.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rcm-client-main.c b/rcm-client-main.c index c12f046..17979dd 100644 --- a/rcm-client-main.c +++ b/rcm-client-main.c @@ -8,6 +8,7 @@ #include "generated.h" #include "rcm-client-main.h" #include "rcm-client-hardware-list.h" +#include "rcm-client-receive.h" #define WINDOW_WIDTH 300 #define WINDOW_HEIGHT 300 @@ -67,6 +68,33 @@ on_object_removed(GDBusObjectManager *manager, } static void +on_signal(GDBusObjectManagerClient *manager, + GDBusObjectProxy *object_proxy, + GDBusProxy *interface_proxy, + gchar *sender_name, + gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + bool pressed; + gchar *keycode; + + g_print("Signal %s received for obj %s\n", signal_name, + g_dbus_object_get_object_path(G_DBUS_OBJECT(object_proxy))); + + if (!strcmp(signal_name, "KeyReleased")) + pressed = false; + else if (!strcmp(signal_name, "KeyPressed")) + pressed = true; + else + return; + + g_variant_get(parameters, "(s)", &keycode); + rcng_client_receive_keypress(G_DBUS_OBJECT(object_proxy), keycode, pressed); + g_free(keycode); +} + +static void on_owner_change(GDBusObjectManager *manager, gpointer user_data) { g_print("Owner changed, now: %s\n", g_dbus_object_manager_client_get_name_owner(G_DBUS_OBJECT_MANAGER_CLIENT(manager))); @@ -99,6 +127,7 @@ manager_ready_cb(GObject *source, GAsyncResult *res, gpointer user_data) g_signal_connect(mgr, "object-added", G_CALLBACK(on_object_added), NULL); g_signal_connect(mgr, "object-removed", G_CALLBACK(on_object_removed), NULL); + g_signal_connect(mgr, "interface-proxy-signal", G_CALLBACK(on_signal), NULL); g_signal_connect(mgr, "notify::name-owner", G_CALLBACK(on_owner_change), NULL); on_owner_change(mgr, NULL); |