From: Sung-Jin Park Date: Tue, 14 Mar 2017 04:54:44 +0000 (+0900) Subject: evdev: implement _evdev_keyboard_event_fd_read() to read/process key event(s) from... X-Git-Tag: accepted/tizen/common/20170322.154125~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ac77458ac3341400f8c0785ed555a95c06e0dd6;p=platform%2Fcore%2Fuifw%2Fpepper.git evdev: implement _evdev_keyboard_event_fd_read() to read/process key event(s) from kernel Change-Id: I29bce2f5d59d989a4ed21e12b084b2cddce7edfe Signed-off-by: Sung-Jin Park --- diff --git a/src/lib/evdev/evdev.c b/src/lib/evdev/evdev.c index 719c086..3ad1b50 100644 --- a/src/lib/evdev/evdev.c +++ b/src/lib/evdev/evdev.c @@ -25,15 +25,61 @@ #include #include #include +#include +#include +#include #include #include #include +#ifdef EVENT_MAX +#undef EVENT_MAX +#endif +#define EVENT_MAX 32 + +static void +_evdev_keyboard_event_process(struct input_event *ev, evdev_device_info_t *device_info) +{ + switch (ev->type) + { + case EV_KEY: + /* TODO : add an event into the event queue */ + break; + + case EV_SYN: + /* TODO : flush events from the event queue */ + break; + + default: + break; + } +} + static int -_evdev_keyboard_event_fd_read(int fd, unsigned int mask, void *data) +_evdev_keyboard_event_fd_read(int fd, uint32_t mask, void *data) { - /* FIXME : read events from given fd and create pepper key event(s) */ + uint32_t i; + int nread; + struct input_event ev[EVENT_MAX]; + evdev_device_info_t *device_info = (evdev_device_info_t *)data; + + PEPPER_CHECK(mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR), + return 0, + "[%s] With the given fd, there is an error or it's been hung-up.\n", + __FUNCTION__); + + if (!(mask & WL_EVENT_READABLE)) + return 0; + + nread = read(fd, &ev, sizeof(ev)); + PEPPER_CHECK(nread>=0, return 0, "[%s] Failed on reading given fd. (error : %s, fd:%d)\n", + __FUNCTION__, strerror(errno), fd); + + for (i = 0 ; i < (nread / sizeof(ev[0])); i++) + { + _evdev_keyboard_event_process(&ev[i], device_info); + } return 0; } @@ -42,7 +88,7 @@ static int _evdev_keyboard_device_open(pepper_evdev_t *evdev, const char *path) { int fd; - unsigned int event_mask; + uint32_t event_mask; evdev_device_info_t *device_info = NULL; pepper_input_device_t *device = NULL;