Include xkb in doctor 64/258064/2
authordyamy-lee <dyamy.lee@samsung.com>
Thu, 6 May 2021 09:47:36 +0000 (18:47 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Mon, 10 May 2021 05:33:26 +0000 (14:33 +0900)
For using xkb keymap, create xkb and set keyboard.

Change-Id: Ica04ce57971f272376784f603f1dc89e22afe12f

src/bin/doctor/doctor.c

index 1a7b60a..f36d9c1 100644 (file)
@@ -5,8 +5,10 @@
 #include <stdlib.h>
 #include <tbm_bufmgr.h>
 #include <pepper-devicemgr.h>
+#include <pepper-xkb.h>
 
 /* basic pepper objects */
+pepper_xkb_t *xkb = NULL;
 pepper_seat_t *seat = NULL;
 pepper_evdev_t *evdev = NULL;
 pepper_keyrouter_t *keyrouter = NULL;
@@ -104,6 +106,20 @@ _handle_touch_event(pepper_event_listener_t *listener, pepper_object_t *object,
        }
 }
 
+static void
+_handle_keyboard_key(pepper_event_listener_t *listener, pepper_object_t *object, uint32_t id, void *info, void *data)
+{
+       pepper_input_event_t *event;
+
+       PEPPER_CHECK(id == PEPPER_EVENT_KEYBOARD_KEY, return, "%d event will not be handled.\n", id);
+       PEPPER_CHECK(data, return, "Invalid data.\n");
+
+       event = (pepper_input_event_t *)info;
+       PEPPER_TRACE("[%s] keycode:%d, state=%d\n", __FUNCTION__, event->key, event->state);
+
+       pepper_keyrouter_event_handler(listener, object, id, info, keyrouter);
+}
+
 /* seat keyboard add event handler */
 static void
 _handle_seat_keyboard_add(pepper_event_listener_t *listener, pepper_object_t *object, uint32_t id, void *info, void *data)
@@ -112,13 +128,13 @@ _handle_seat_keyboard_add(pepper_event_listener_t *listener, pepper_object_t *ob
 
        PEPPER_TRACE("[%s] keyboard added\n", __FUNCTION__);
 
-       pepper_keyboard_set_keymap_info(keyboard, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, -1, 0);
+       pepper_xkb_keyboard_set_keymap(xkb, keyboard, NULL);
 
        listener_keyboard_event = pepper_object_add_event_listener((pepper_object_t *)keyboard,
                                                                PEPPER_EVENT_KEYBOARD_KEY,
                                                                0,
-                                                               pepper_keyrouter_event_handler,
-                                                               (void *)keyrouter);
+                                                               _handle_keyboard_key,
+                                                               keyboard);
 }
 
 /* seat pointer add event handler */
@@ -263,6 +279,10 @@ int main(int argc, char *argv[])
        res = tbm_bufmgr_bind_native_display(bufmgr, (void *)pepper_compositor_get_display(compositor));
        PEPPER_CHECK(res, goto shutdown_on_failure, "Failed to bind native display with tbm buffer manager !\n");
 
+       /* create pepper xkb */
+       xkb = pepper_xkb_create();
+       PEPPER_CHECK(xkb, goto shutdown_on_failure, "Failed to create pepper_xkb !\n");
+
        /* register event listeners */
        listener_seat_add = pepper_object_add_event_listener((pepper_object_t *)compositor,
                                                PEPPER_EVENT_COMPOSITOR_SEAT_ADD,
@@ -377,6 +397,11 @@ shutdown:
        }
 
        /* TODO : clean up any other objects if needed */
+       if(xkb)
+       {
+               pepper_xkb_destroy(xkb);
+               xkb = NULL;
+       }
 
        /* destroy keyrouter */
        if (keyrouter)