summaryrefslogtreecommitdiffstats
path: root/minuitwrp/events.c
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2014-02-20 21:43:28 +0100
committerVojtech Bocek <vbocek@gmail.com>2014-02-20 21:44:32 +0100
commit971d318d342513e5d863433ed2dcbdebe8d3c977 (patch)
tree01b215f329c5112c0613d0d6905cc84a10a42142 /minuitwrp/events.c
parentMerge "Improve ORS scanning of storage locations" into android-4.4 (diff)
downloadandroid_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar.gz
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar.bz2
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar.lz
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar.xz
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.tar.zst
android_bootable_recovery-971d318d342513e5d863433ed2dcbdebe8d3c977.zip
Diffstat (limited to 'minuitwrp/events.c')
-rw-r--r--minuitwrp/events.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/minuitwrp/events.c b/minuitwrp/events.c
index 94942ba7b..f07fc14b4 100644
--- a/minuitwrp/events.c
+++ b/minuitwrp/events.c
@@ -250,6 +250,9 @@ static int vk_init(struct ev *e)
#define OFF(x) ((x)%BITS_PER_LONG)
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
+
+// Check for EV_REL (REL_X and REL_Y) and, because touchscreens can have those too,
+// check also for EV_KEY (BTN_LEFT and BTN_RIGHT)
static void check_mouse(int fd)
{
if(has_mouse)
@@ -259,12 +262,18 @@ static void check_mouse(int fd)
memset(bit, 0, sizeof(bit));
ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]);
- if(!test_bit(EV_REL, bit[0]))
+ if(!test_bit(EV_REL, bit[0]) || !test_bit(EV_KEY, bit[0]))
return;
ioctl(fd, EVIOCGBIT(EV_REL, KEY_MAX), bit[EV_REL]);
- if(test_bit(REL_X, bit[EV_REL]) && test_bit(REL_Y, bit[EV_REL]))
- has_mouse = 1;
+ if(!test_bit(REL_X, bit[EV_REL]) || !test_bit(REL_Y, bit[EV_REL]))
+ return;
+
+ ioctl(fd, EVIOCGBIT(EV_KEY, KEY_MAX), bit[EV_KEY]);
+ if(!test_bit(BTN_LEFT, bit[EV_KEY]) || !test_bit(BTN_RIGHT, bit[EV_KEY]))
+ return;
+
+ has_mouse = 1;
}
int ev_has_mouse(void)