From bc29063bf4e2312133d91e211dfe9c86ee811489 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Tue, 30 Aug 2011 11:59:45 -0700 Subject: minui: events: refactor event acquisition Events are now delivered through a callback mechanism during a call to ev_dispatch(). This will allow us to extend the events code to handle other devices/fds, not just input. One such example is the ability to process uevents. During initialization, we provide an input callback to ev_init that gets called when a new event is encountered during dispatch. ev_get has been removed and replaced with ev_get_input() helper function that can be called from inside the callback to attempt to get an input event. The existing client of ev_get in recovery has been split up such that the input thread just calls ev_wait(); ev_dispatch(); and the input_callback handles individual events by using the ev_get_input() helper. Change-Id: I24d8e71bd1533876b4ab1ae751ba200fea43c049 Signed-off-by: Dima Zavin --- minui/minui.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index 2284a3374..5a4168c46 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -45,9 +45,20 @@ unsigned int gr_get_height(gr_surface surface); // see http://www.mjmwired.net/kernel/Documentation/input/ for info. struct input_event; -int ev_init(void); +typedef int (*ev_callback)(int fd, short revents, void *data); + +int ev_init(ev_callback input_cb, void *data); void ev_exit(void); -int ev_get(struct input_event *ev, unsigned dont_wait); + +/* timeout has the same semantics as for poll + * 0 : don't block + * < 0 : block forever + * > 0 : block for 'timeout' milliseconds + */ +int ev_wait(int timeout); + +int ev_get_input(int fd, short revents, struct input_event *ev); +void ev_dispatch(void); // Resources -- cgit v1.2.3