From e13fa63dc0cc49dc75c9d6b5750c2e7327eaaad8 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Tue, 27 Jan 2015 11:30:03 -0600 Subject: Move input handling into the main thread This also makes the hardwarekeyboard.cpp file that I created for the Asus Transformer tablets with a keyboard dock the default hardware keyboard handler. USB keyboards should work properly now if present for keyboard input. Change-Id: I724606e91ffe2a55265a9d1cb1ec714de244d38b --- minuitwrp/events.c | 48 ++++++++++++++++++++++-------------------------- minuitwrp/minui.h | 2 +- 2 files changed, 23 insertions(+), 27 deletions(-) (limited to 'minuitwrp') diff --git a/minuitwrp/events.c b/minuitwrp/events.c index f02edd34f..98b3a34ee 100644 --- a/minuitwrp/events.c +++ b/minuitwrp/events.c @@ -719,44 +719,40 @@ static int vk_modify(struct ev *e, struct input_event *ev) return 0; } -int ev_get(struct input_event *ev, unsigned dont_wait) +int ev_get(struct input_event *ev) { int r; unsigned n; struct timeval curr; - do { - gettimeofday(&curr, NULL); - if(curr.tv_sec - lastInputStat.tv_sec >= 2) + gettimeofday(&curr, NULL); + if(curr.tv_sec - lastInputStat.tv_sec >= 2) + { + struct stat st; + stat("/dev/input", &st); + if (st.st_mtime > lastInputMTime) { - struct stat st; - stat("/dev/input", &st); - if (st.st_mtime > lastInputMTime) - { - LOGI("Reloading input devices\n"); - ev_exit(); - ev_init(); - lastInputMTime = st.st_mtime; - } - lastInputStat = curr; + printf("Reloading input devices\n"); + ev_exit(); + ev_init(); + lastInputMTime = st.st_mtime; } + lastInputStat = curr; + } - r = poll(ev_fds, ev_count, 0); + r = poll(ev_fds, ev_count, 0); - if(r > 0) { - for(n = 0; n < ev_count; n++) { - if(ev_fds[n].revents & POLLIN) { - r = read(ev_fds[n].fd, ev, sizeof(*ev)); - if(r == sizeof(*ev)) { - if (!vk_modify(&evs[n], ev)) - return 0; - } + if(r > 0) { + for(n = 0; n < ev_count; n++) { + if(ev_fds[n].revents & POLLIN) { + r = read(ev_fds[n].fd, ev, sizeof(*ev)); + if(r == sizeof(*ev)) { + if (!vk_modify(&evs[n], ev)) + return 0; } } } - - usleep(1000); - } while(dont_wait == 0); + } return -1; } diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h index cb9f8a385..abebc1450 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/minui.h @@ -75,7 +75,7 @@ struct input_event; int ev_init(void); void ev_exit(void); -int ev_get(struct input_event *ev, unsigned dont_wait); +int ev_get(struct input_event *ev); int ev_has_mouse(void); // Resources -- cgit v1.2.3