summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-09-02 23:24:43 +0200
committerDima Zavin <dima@android.com>2011-09-02 23:55:20 +0200
commit88e0899617229db57ae2c616fddcf40543c8e392 (patch)
tree8f1677d6631613eeab1f2fdb98f4433290a13c10
parentminui: events: add ability to poll on non-input fds (diff)
downloadandroid_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar.gz
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar.bz2
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar.lz
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar.xz
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.tar.zst
android_bootable_recovery-88e0899617229db57ae2c616fddcf40543c8e392.zip
Diffstat (limited to '')
-rw-r--r--minui/events.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/minui/events.c b/minui/events.c
index 8458b2d39..c533a482a 100644
--- a/minui/events.c
+++ b/minui/events.c
@@ -27,6 +27,8 @@
#define MAX_DEVICES 16
#define MAX_MISC_FDS 16
+#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
+
struct fd_info {
ev_callback cb;
void *data;
@@ -48,11 +50,26 @@ int ev_init(ev_callback input_cb, void *data)
dir = opendir("/dev/input");
if(dir != 0) {
while((de = readdir(dir))) {
+ uint8_t ev_bits[(EV_MAX + 1) / 8];
+
// fprintf(stderr,"/dev/input/%s\n", de->d_name);
if(strncmp(de->d_name,"event",5)) continue;
fd = openat(dirfd(dir), de->d_name, O_RDONLY);
if(fd < 0) continue;
+ /* read the evbits of the input device */
+ if (ioctl(fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) < 0) {
+ close(fd);
+ continue;
+ }
+
+ /* TODO: add ability to specify event masks. For now, just assume
+ * that only EV_KEY and EV_REL event types are ever needed. */
+ if (!test_bit(EV_KEY, ev_bits) && !test_bit(EV_REL, ev_bits)) {
+ close(fd);
+ continue;
+ }
+
ev_fds[ev_count].fd = fd;
ev_fds[ev_count].events = POLLIN;
ev_fdinfo[ev_count].cb = input_cb;