Added keyboard support for Wayland EGL
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com> SVN revision: 79515
This commit is contained in:
parent
7eab217299
commit
d27dc525eb
|
@ -21,3 +21,7 @@
|
||||||
2012-11-01 Eduardo Lima (Etrunko)
|
2012-11-01 Eduardo Lima (Etrunko)
|
||||||
|
|
||||||
* Added basic support for wayland engines
|
* Added basic support for wayland engines
|
||||||
|
|
||||||
|
2012-11-16 Eduardo Lima (Etrunko)
|
||||||
|
|
||||||
|
* Keyboard Support for Wayland EGL
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <linux/input.h>
|
||||||
|
|
||||||
#include <Evas_Engine_Wayland_Egl.h>
|
#include <Evas_Engine_Wayland_Egl.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-egl.h>
|
#include <wayland-egl.h>
|
||||||
|
@ -39,6 +41,28 @@ static const struct wl_shell_surface_listener _shell_surface_listener =
|
||||||
NULL, /* popup_done */
|
NULL, /* popup_done */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Seat (input) handler */
|
||||||
|
static void _seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
|
||||||
|
static const struct wl_seat_listener _seat_listener =
|
||||||
|
{
|
||||||
|
_seat_handle_capabilities,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Keyboard handler */
|
||||||
|
static void _keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
|
||||||
|
static void _keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
|
||||||
|
static void _keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
|
||||||
|
static void _keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
|
||||||
|
static void _keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
|
||||||
|
static const struct wl_keyboard_listener _keyboard_listener =
|
||||||
|
{
|
||||||
|
_keyboard_handle_keymap, /* keymap */
|
||||||
|
_keyboard_handle_enter, /* enter */
|
||||||
|
_keyboard_handle_leave, /* leave */
|
||||||
|
_keyboard_handle_key,
|
||||||
|
_keyboard_handle_modifiers, /* modifiers */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* API
|
* API
|
||||||
*/
|
*/
|
||||||
|
@ -84,8 +108,7 @@ engine_wayland_egl_args(const char *engine __UNUSED__, int width __UNUSED__, int
|
||||||
void
|
void
|
||||||
engine_wayland_egl_loop(void)
|
engine_wayland_egl_loop(void)
|
||||||
{
|
{
|
||||||
assert(wl_display_dispatch_pending(wl.display) != -1);
|
assert(wl_display_dispatch(wl.display) != -1);
|
||||||
wl_display_flush(wl.display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -113,6 +136,12 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
|
||||||
{
|
{
|
||||||
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(interface, "wl_seat"))
|
||||||
|
{
|
||||||
|
struct wl_seat *seat;
|
||||||
|
seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
|
||||||
|
wl_seat_add_listener(seat, &_seat_listener, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -120,3 +149,87 @@ _shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell
|
||||||
{
|
{
|
||||||
wl_shell_surface_pong(shell_surface, serial);
|
wl_shell_surface_pong(shell_surface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps)
|
||||||
|
{
|
||||||
|
static struct wl_keyboard *kbd = NULL;
|
||||||
|
|
||||||
|
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !kbd)
|
||||||
|
{
|
||||||
|
kbd = wl_seat_get_keyboard(seat);
|
||||||
|
wl_keyboard_add_listener(kbd, &_keyboard_listener, NULL);
|
||||||
|
}
|
||||||
|
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && kbd)
|
||||||
|
{
|
||||||
|
wl_keyboard_destroy(kbd);
|
||||||
|
kbd = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_keyboard_handle_enter(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__, struct wl_array *keys __UNUSED__)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_keyboard_handle_key(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t time __UNUSED__, uint32_t key, uint32_t state)
|
||||||
|
{
|
||||||
|
const char *key_str;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case KEY_LEFT:
|
||||||
|
key_str = "Left";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_RIGHT:
|
||||||
|
key_str = "Right";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_ENTER:
|
||||||
|
case KEY_KPENTER:
|
||||||
|
key_str = "Return";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_ESC:
|
||||||
|
key_str = "Escape";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
key_str = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key_str)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case WL_KEYBOARD_KEY_STATE_RELEASED:
|
||||||
|
evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WL_KEYBOARD_KEY_STATE_PRESSED:
|
||||||
|
evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_keyboard_handle_modifiers(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t mods_depressed __UNUSED__, uint32_t mods_latched __UNUSED__, uint32_t mods_locked __UNUSED__, uint32_t group __UNUSED__)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue