#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
+#include <tizen-extension-client-protocol.h>
struct wl_display *display = NULL;
struct wl_registry *registry = NULL;
struct wl_seat *seat = NULL;
struct wl_keyboard *keyboard = NULL;
+struct tizen_keyrouter *tz_keyrouter = NULL;
struct xkb_context *xkb_context;
struct xkb_keymap *keymap;
+typedef struct tizen_keyrouter_notify tizen_keyrouter_notify_t;
+struct tizen_keyrouter_notify
+{
+ unsigned int keycode;
+ unsigned int mode;
+ unsigned int error;
+};
+
unsigned int has_keymap = 0;
unsigned int set_keymap = 0;
static void keyboard_modifiers(void *, struct wl_keyboard *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
static void keyboard_repeat_setup(void *, struct wl_keyboard *, int32_t, int32_t);
+// tizen_keyrouter listener
+static void keygrab_notify(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, uint32_t key, uint32_t mode, uint32_t error);
+static void keygrab_notify_list(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, struct wl_array *notify_result);
+static void getgrab_notify_list(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, struct wl_array *notify_result);
+static void set_register_none_key(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, uint32_t mode);
+static void keyregister_notify(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t status);
+static void set_input_config(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t status);
+static void key_cancel(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t key);
+
static const struct wl_registry_listener registry_listener = {
handle_global,
handle_global_remove,
keyboard_repeat_setup,
};
+static const struct tizen_keyrouter_listener keyrouter_listener = {
+ keygrab_notify,
+ keygrab_notify_list,
+ getgrab_notify_list,
+ set_register_none_key,
+ keyregister_notify,
+ set_input_config,
+ key_cancel,
+};
+
static void
handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version)
{
seat = wl_registry_bind(registry, id, &wl_seat_interface, 4);
wl_seat_add_listener(seat, &seat_listener, NULL);
}
+ else if (!strcmp("tizen_keyrouter", interface))
+ {
+ tz_keyrouter = wl_registry_bind(registry, id, &tizen_keyrouter_interface, 1);
+ tizen_keyrouter_add_listener(tz_keyrouter, &keyrouter_listener, NULL);
+ }
}
static void
(void) delay;
}
+static void
+keygrab_notify(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, uint32_t key, uint32_t mode, uint32_t error)
+{
+ LOGD("key : %d, mode : %d, error : %d\n", key, mode, error);
+}
+
+static void
+keygrab_notify_list(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, struct wl_array *notify_result)
+{
+ tizen_keyrouter_notify_t *tz_keyrouter_notify;
+ struct wl_array array;
+
+ wl_array_init(&array);
+ wl_array_copy(&array, notify_result);
+
+ wl_array_for_each(tz_keyrouter_notify, &array)
+ {
+ LOGD("... keygrab result ! (keycode : %d, mode : %d, error : %d)\n",
+ tz_keyrouter_notify->keycode, tz_keyrouter_notify->mode, tz_keyrouter_notify->error);
+ }
+
+ wl_array_release(&array);
+}
+
+static void getgrab_notify_list(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, struct wl_array *notify_result)
+{
+ (void) tizen_keyrouter;
+ (void) surface;
+ (void) notify_result;
+}
+
+static void set_register_none_key(void *data, struct tizen_keyrouter *tizen_keyrouter, struct wl_surface *surface, uint32_t mode)
+{
+ (void) tizen_keyrouter;
+ (void) surface;
+ (void) mode;
+}
+
+static void keyregister_notify(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t status)
+{
+ (void) tizen_keyrouter;
+ (void) status;
+}
+
+static void set_input_config(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t status)
+{
+ (void) tizen_keyrouter;
+ (void) status;
+}
+
+static void key_cancel(void *data, struct tizen_keyrouter *tizen_keyrouter, uint32_t key)
+{
+ (void) tizen_keyrouter;
+ (void) key;
+}
+
int xkb_init(void)
{
xkb_context = xkb_context_new(0);
void _wl_shutdown(void)
{
+ tizen_keyrouter_destroy(tz_keyrouter);
wl_keyboard_release(keyboard);
wl_seat_destroy(seat);
wl_display_disconnect(display);