#include <tizen-extension-server-protocol.h>
static void
-_devicemgr_generate_key(pepper_keyboard_t *keyboard, int keycode, int pressed)
+_devicemgr_generate_key(pepper_input_device_t *device, int keycode, int pressed)
{
pepper_input_event_t event;
struct timeval time;
event.key = keycode - 8;
event.state = pressed ? PEPPER_KEY_STATE_PRESSED : PEPPER_KEY_STATE_RELEASED;
- pepper_object_emit_event((pepper_object_t *)keyboard,
- PEPPER_EVENT_KEYBOARD_KEY, &event);
+ pepper_object_emit_event((pepper_object_t *)device,
+ PEPPER_EVENT_INPUT_DEVICE_KEYBOARD_KEY, &event);
}
PEPPER_API int
PEPPER_CHECK(devicemgr,
return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES,
"Invalid devicemgr structure.\n");
- PEPPER_CHECK(devicemgr->keyboard && devicemgr->keyboard->kbd,
+ PEPPER_CHECK(devicemgr->keyboard && devicemgr->keyboard->input_device,
return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES,
"Keyboard device is not initialized\n");
- _devicemgr_generate_key(devicemgr->keyboard->kbd, keycode, pressed);
+ _devicemgr_generate_key(devicemgr->keyboard->input_device, keycode, pressed);
return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
}
PEPPER_API void
-devicemgr_input_generator_keyboard_set(devicemgr_t *devicemgr, pepper_keyboard_t *keyboard)
+devicemgr_input_generator_keyboard_set(devicemgr_t *devicemgr, pepper_input_device_t *device)
{
PEPPER_CHECK(devicemgr, return, "Invalid devicemgr structure.\n");
PEPPER_CHECK(devicemgr->keyboard, return, "input generator is not initialized yet.\n");
- if (devicemgr->keyboard->kbd) return;
- devicemgr->keyboard->kbd = keyboard;
+ if (devicemgr->keyboard->input_device) return;
+ devicemgr->keyboard->input_device = device;
}
PEPPER_API void
-devicemgr_input_generator_keyboard_unset(devicemgr_t *devicemgr, pepper_keyboard_t *keyboard)
+devicemgr_input_generator_keyboard_unset(devicemgr_t *devicemgr, pepper_input_device_t *device)
{
PEPPER_CHECK(devicemgr, return, "Invalid devicemgr structure.\n");
- devicemgr->keyboard->kbd = NULL;
+ devicemgr->keyboard->input_device = NULL;
}
static pepper_bool_t
_devicemgr_input_generator_keyboard_create(devicemgr_t *devicemgr, const char *name)
{
- if (devicemgr->keyboard->kbd) return PEPPER_TRUE;
+ if (devicemgr->keyboard->input_device) return PEPPER_TRUE;
devicemgr->keyboard->input_device = pepper_input_device_create(devicemgr->compositor, WL_SEAT_CAPABILITY_KEYBOARD, NULL, NULL);
PEPPER_CHECK(devicemgr->keyboard->input_device, return PEPPER_FALSE, "Failed to create input device !\n");
PEPPER_API int devicemgr_input_generator_deinit(devicemgr_t *devicemgr);
PEPPER_API int devicemgr_input_generator_generate_key(devicemgr_t *devicemgr, int keycode, pepper_bool_t pressed);
-PEPPER_API void devicemgr_input_generator_keyboard_set(devicemgr_t *devicemgr, pepper_keyboard_t *keyboard);
-PEPPER_API void devicemgr_input_generator_keyboard_unset(devicemgr_t *devicemgr, pepper_keyboard_t *keyboard);
+PEPPER_API void devicemgr_input_generator_keyboard_set(devicemgr_t *devicemgr, pepper_input_device_t *device);
+PEPPER_API void devicemgr_input_generator_keyboard_unset(devicemgr_t *devicemgr, pepper_input_device_t *device);
#ifdef __cplusplus
}
pepper_list_t *keymap_list;
#endif
+ pepper_event_listener_t *listener_input_device_add;
+#ifdef _F_DEVICEMGR_XKB
pepper_event_listener_t *listener_seat_keyboard_add;
pepper_event_listener_t *listener_keyboard_keymap_update;
+#endif
pepper_list_t resources;
pepper_devicemgr->xkb_info = keyboard->xkb_info;
}
-#endif
static void
_pepper_devicemgr_handle_seat_keyboard_add(pepper_event_listener_t *listener, pepper_object_t *object, uint32_t id, void *info, void *data)
pepper_keyboard_t *keyboard = (pepper_keyboard_t *)info;
pepper_devicemgr_t *pepper_devicemgr = (pepper_devicemgr_t *)data;
- devicemgr_input_generator_keyboard_set(pepper_devicemgr->devicemgr, keyboard);
-#ifdef _F_DEVICEMGR_XKB
pepper_devicemgr->xkb_info = keyboard->xkb_info;
pepper_devicemgr->listener_keyboard_keymap_update =
pepper_object_add_event_listener((pepper_object_t *)keyboard,
PEPPER_EVENT_KEYBOARD_KEYMAP_UPDATE, 0,
_pepper_devicemgr_handle_keyboard_keymap_update, pepper_devicemgr);
+}
#endif
+
+static void
+_pepper_devicemgr_handle_input_device_add(pepper_event_listener_t *listener, pepper_object_t *object, uint32_t id, void *info, void *data)
+{
+ pepper_input_device_t *device = (pepper_input_device_t *)info;
+ pepper_devicemgr_t *pepper_devicemgr = (pepper_devicemgr_t *)data;
+
+ if (pepper_input_device_get_caps(device) & WL_SEAT_CAPABILITY_KEYBOARD)
+ devicemgr_input_generator_keyboard_set(pepper_devicemgr->devicemgr, device);
}
static void
pepper_devicemgr->compositor = compositor;
pepper_devicemgr->seat = seat;
+ pepper_devicemgr->listener_input_device_add = pepper_object_add_event_listener((pepper_object_t *)pepper_devicemgr->compositor,
+ PEPPER_EVENT_COMPOSITOR_INPUT_DEVICE_ADD,
+ 0, _pepper_devicemgr_handle_input_device_add, pepper_devicemgr);
+
+#ifdef _F_DEVICEMGR_XKB
pepper_devicemgr->listener_seat_keyboard_add = pepper_object_add_event_listener((pepper_object_t *)pepper_devicemgr->seat,
PEPPER_EVENT_SEAT_KEYBOARD_ADD,
0, _pepper_devicemgr_handle_seat_keyboard_add, pepper_devicemgr);
+#endif
pepper_list_init(&pepper_devicemgr->resources);