Make input whitelist and blacklist work for mouse devices too

Includes some minor code clean up. Also we are now outputting the
name of the first mouse device that we encounter to make it easier
to identify which device(s) may need to be blacklisted.

Change-Id: I515baf92967390edd224728f3a7092239138e6b8
This commit is contained in:
Ethan Yonker
2016-08-10 12:30:10 -05:00
committed by Dees Troy
parent ad05c6dce4
commit 64dbd0df84
+6 -4
View File
@@ -176,7 +176,7 @@ static int vk_init(struct ev *e)
}
#else
#ifndef TW_INPUT_BLACKLIST
// Blacklist these "input" devices
// Blacklist these "input" devices, use TW_INPUT_BLACKLIST := "accelerometer\x0atest1\x0atest2" using the \x0a as a separator between input devices
if (strcmp(e->deviceName, "bma250") == 0 || strcmp(e->deviceName, "bma150") == 0)
{
printf("blacklisting %s input device\n", e->deviceName);
@@ -277,7 +277,7 @@ static int vk_init(struct ev *e)
// 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)
static void check_mouse(int fd, const char* deviceName)
{
if(has_mouse)
return;
@@ -297,6 +297,7 @@ static void check_mouse(int fd)
if(!test_bit(BTN_LEFT, bit[EV_KEY]) || !test_bit(BTN_RIGHT, bit[EV_KEY]))
return;
printf("Found mouse '%s'\n", deviceName);
has_mouse = 1;
}
@@ -326,9 +327,10 @@ int ev_init(void)
evs[ev_count].fd = &ev_fds[ev_count];
/* Load virtualkeys if there are any */
vk_init(&evs[ev_count]);
vk_init(&evs[ev_count]);
check_mouse(fd);
if (!evs[ev_count].ignored)
check_mouse(fd, evs[ev_count].deviceName);
ev_count++;
if(ev_count == MAX_DEVICES) break;