#include <libds/keyboard.h>
#include <libds/seat.h>
#include <libds-tizen/keyrouter.h>
+#include <libds-tizen/input_devicemgr.h>
#include <xkbcommon/xkbcommon.h>
#include "headless_server.h"
+#define KEYNAME_XF86_VOLUME_RAISE "XF86VolumeRaise"
+#define KEYNAME_XF86_VOLUME_LOWER "XF86VolumeLower"
+#define KEYNAME_XF86_LIGHT_ON "XF86LightOn"
+#define KEYNAME_XF86_LIGHT_OFF "XF86LightOff"
+
+#define KEYCODE_XF86_VOLUME_RAISE 455
+#define KEYCODE_XF86_VOLUME_LOWER 456
+#define KEYCODE_XF86_LIGHT_ON 457
+#define KEYCODE_XF86_LIGHT_OFF 458
+
typedef struct headless_input headless_input_t;
typedef struct headless_keyboard headless_keyboard_t;
struct ds_backend *backend;
struct ds_seat *seat;
struct ds_tizen_keyrouter *keyrouter;
+ struct ds_tizen_input_devicemgr *devicemgr;
struct wl_listener new_input;
struct wl_listener focus_change;
static void keyboard_destroy(headless_keyboard_t *keyboard);
static void keyboard_handle_destroy(struct wl_listener *listener, void *data);
static void keyboard_handle_key(struct wl_listener *listener, void *data);
+static void devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr);
headless_input_t *
headless_input_create(headless_server_t *server)
goto err_seat;
}
+ input->devicemgr = ds_tizen_input_devicemgr_create(
+ input->backend, input->seat);
+ if (!input->devicemgr) {
+ ds_err("Could not create ds_tizen_input_devicemgr");
+ goto err_input_devicemgr;
+ }
+
+ devicemgr_set_keymap(input->devicemgr);
+
input->new_input.notify = handle_new_input;
ds_backend_add_new_input_listener(input->backend, &input->new_input);
return input;
+err_input_devicemgr:
err_seat:
err_keyrouter:
ds_backend_destroy(input->backend);
input->top_view ? input->top_view->surface : NULL,
ev->time_msec, ev->keycode, ev->state);
}
+
+static void
+devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode)
+{
+ struct ds_tizen_input_devicemgr_keymap_data *data;
+
+ data = calloc(1, sizeof *data);
+ if (!data) {
+ ds_err("Failed to alloc memory");
+ return;
+ }
+
+ data->name = strdup(name);
+ data->keycode = keycode;
+
+ wl_list_insert(list, &data->link);
+}
+
+static void
+devicemgr_remove_keymap_data(struct wl_list *list, int keycode)
+{
+ struct ds_tizen_input_devicemgr_keymap_data *data, *tmp;
+
+ wl_list_for_each_safe(data, tmp, list, link) {
+ if (data->keycode == keycode) {
+ wl_list_remove(&data->link);
+ free(data->name);
+ free(data);
+ }
+ }
+}
+
+static void
+devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr)
+{
+ struct wl_list keymap_list;
+ bool res;
+
+ wl_list_init(&keymap_list);
+
+ devicemgr_add_keymap_data(&keymap_list, KEYNAME_XF86_VOLUME_RAISE, KEYCODE_XF86_VOLUME_RAISE);
+ devicemgr_add_keymap_data(&keymap_list, KEYNAME_XF86_VOLUME_LOWER, KEYCODE_XF86_VOLUME_LOWER);
+ devicemgr_add_keymap_data(&keymap_list, KEYNAME_XF86_LIGHT_ON, KEYCODE_XF86_LIGHT_ON);
+ devicemgr_add_keymap_data(&keymap_list, KEYNAME_XF86_LIGHT_OFF, KEYCODE_XF86_LIGHT_OFF);
+
+ res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list);
+ if (!res)
+ ds_inf("Failed to set keymap");
+
+ devicemgr_remove_keymap_data(&keymap_list, KEYCODE_XF86_VOLUME_RAISE);
+ devicemgr_remove_keymap_data(&keymap_list, KEYCODE_XF86_VOLUME_LOWER);
+ devicemgr_remove_keymap_data(&keymap_list, KEYCODE_XF86_LIGHT_ON);
+ devicemgr_remove_keymap_data(&keymap_list, KEYCODE_XF86_LIGHT_OFF);
+}
+
#else
#include <pepper-evdev.h>
#include <pepper-input-backend.h>