forked from enlightenment/efl
elput: Start code to process events from libinput
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
parent
f832d2019c
commit
bd0d4ba60f
|
@ -24,10 +24,41 @@ const struct libinput_interface _input_interface =
|
|||
_cb_close_restricted,
|
||||
};
|
||||
|
||||
static int
|
||||
_udev_process_event(struct libinput_event *event)
|
||||
{
|
||||
Elput_Manager *em;
|
||||
struct libinput *lib;
|
||||
struct libinput_device *dev;
|
||||
int ret = 1;
|
||||
|
||||
lib = libinput_event_get_context(event);
|
||||
dev = libinput_event_get_device(event);
|
||||
em = libinput_get_user_data(lib);
|
||||
|
||||
switch (libinput_event_get_type(event))
|
||||
{
|
||||
case LIBINPUT_EVENT_DEVICE_ADDED:
|
||||
DBG("Input Device Added: %s", libinput_device_get_name(dev));
|
||||
/* TODO: add device */
|
||||
break;
|
||||
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
||||
DBG("Input Device Removed: %s", libinput_device_get_name(dev));
|
||||
/* TODO: remove device */
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
_process_event(struct libinput_event *event)
|
||||
{
|
||||
/* TODO */
|
||||
if (_udev_process_event(event)) return;
|
||||
/* TODO: evdev processing */
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -42,9 +73,26 @@ _process_events(Elput_Input *ei)
|
|||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cb_input_dispatch(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
|
||||
{
|
||||
Elput_Input *ei;
|
||||
|
||||
ei = data;
|
||||
|
||||
if (libinput_dispatch(ei->lib) != 0)
|
||||
WRN("libinput failed to dispatch events");
|
||||
|
||||
_process_events(ei);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
elput_input_init(Elput_Manager *manager, const char *seat)
|
||||
{
|
||||
int fd;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE);
|
||||
|
||||
memset(&manager->input, 0, sizeof(Elput_Input));
|
||||
|
@ -65,10 +113,20 @@ elput_input_init(Elput_Manager *manager, const char *seat)
|
|||
|
||||
_process_events(&manager->input);
|
||||
|
||||
/* TODO */
|
||||
fd = libinput_get_fd(manager->input.lib);
|
||||
|
||||
manager->input.hdlr =
|
||||
ecore_main_fd_handler_add(fd, ECORE_FD_READ, _cb_input_dispatch,
|
||||
&manager->input, NULL, NULL);
|
||||
if (!manager->input.hdlr)
|
||||
{
|
||||
ERR("Could not create input fd handler");
|
||||
goto hdlr_err;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
|
||||
hdlr_err:
|
||||
seat_err:
|
||||
libinput_unref(manager->input.lib);
|
||||
udev_err:
|
||||
|
@ -81,6 +139,8 @@ elput_input_shutdown(Elput_Manager *manager)
|
|||
EINA_SAFETY_ON_NULL_RETURN(manager);
|
||||
EINA_SAFETY_ON_NULL_RETURN(&manager->input);
|
||||
|
||||
if (manager->input.hdlr) ecore_main_fd_handler_del(manager->input.hdlr);
|
||||
|
||||
/* TODO */
|
||||
|
||||
libinput_unref(manager->input.lib);
|
||||
|
|
Loading…
Reference in New Issue