Skip to content

Commit

Permalink
fix: check for only eventX
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Nov 20, 2023
1 parent b82ee10 commit ed632a2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/src/main/cpp/evdev_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ std::vector<string> ListInputDevices() {

struct dirent *entry;
while ((entry = readdir(directory))) {
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
if (entry->d_name[0] == 'e') // is eventX
filenames.push_back(input_directory + "/" + entry->d_name);
}
}
return filenames;
}
Expand All @@ -51,22 +50,22 @@ std::vector<int> scanTouchpadDevices() {
}

if(!HasSpecificAbs(device_fd, ABS_X) || !HasSpecificAbs(device_fd, ABS_Y)) {
printf("%s does not have ABS_X or ABS_Y events\n", dev_name);
printf("%s: Not a touch device\n", dev_name);
printf("%s: ABS_X or ABS_Y events not found\n", dev_name);
printf("Not a touch device\n");
close(device_fd);
continue;
}

if (!HasInputProp(device_fd, INPUT_PROP_POINTER)) {
printf("%s does not have INPUT_PROP_POINTER\n", dev_name);
printf("%s: Not a touchpad device\n", dev_name);
printf("%s: INPUT_PROP_POINTER not set\n", dev_name);
printf("Not a touchpad device\n");
close(device_fd);
continue;
}


// Check for virtual devices
if (x_virtual_tablet == dev_name || x_virtual_mouse == dev_name) {
if (strcmp(x_virtual_tablet, dev_name) == 0 || strcmp(x_virtual_mouse, dev_name) == 0) {
printf("skipping %s\n", dev_name);
close(device_fd);
continue;
Expand All @@ -76,7 +75,7 @@ std::vector<int> scanTouchpadDevices() {
return touchpadDeviceFds;
}

printf(" adding touchpad device...\n", evdev.c_str());
printf("I: Add touchpad device: %s %s\n", dev_name, evdev.c_str());
ioctl(device_fd, EVIOCGRAB, (void *)1);

touchpadDeviceFds.push_back(device_fd);
Expand Down

0 comments on commit ed632a2

Please sign in to comment.