c166a82a5f9457e621cfa18a563937eb92c93998
[platform/core/system/deviced.git] / plugins / iot-headless / input / input-dbus.c
1 #include <libsyscommon/libgdbus.h>
2 #include <linux/input.h>
3 #include <libinput.h>
4
5 #include "shared/common.h"
6 #include "input-handler.h"
7
8 static GVariant *dbus_emulate_key(GDBusConnection *conn,
9         const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
10         GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
11 {
12         int keycode, keyvalue;
13
14         g_variant_get(param, "(ii)", &keycode, &keyvalue);
15
16         input_handler_process_key(keycode, keyvalue);
17
18         return gdbus_new_g_variant_tuple();
19 }
20
21 static const dbus_method_s dbus_methods[] = {
22         { "EmulateKey",    "ii",    NULL, dbus_emulate_key },
23 };
24
25 static const dbus_interface_u dbus_interface = {
26         .oh = NULL,
27         .name = DEVICED_INTERFACE_INPUT,
28         .methods = dbus_methods,
29         .nr_methods = ARRAY_SIZE(dbus_methods),
30 };
31
32 void init_input_dbus(void)
33 {
34         gdbus_add_object(NULL, DEVICED_PATH_INPUT, &dbus_interface);
35 }