iio search test

This commit is contained in:
Denis 2023-12-08 18:40:58 +01:00
parent e074645c21
commit c7a78c60a5
No known key found for this signature in database
GPG key ID: DD9B63F805CF5C03
5 changed files with 242 additions and 99 deletions

View file

@ -13,10 +13,16 @@ static int open_fds[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static bool ev_matches(struct libevdev *dev, const uinput_filters_t* const filters) {
static bool ev_matches(
const uinput_filters_t* const in_filters,
struct libevdev *in_evdev
) {
if (in_evdev == NULL) {
return NULL;
}
const char* name = libevdev_get_name(dev);
if ((name != NULL) && (strcmp(name, filters->name) != 0)) {
const char* name = libevdev_get_name(in_evdev);
if ((name != NULL) && (strcmp(name, in_filters->name) != 0)) {
return false;
}
@ -119,7 +125,7 @@ int dev_evdev_open(
}
// try to open the device
if (!ev_matches(*out_evdev, in_filters)) {
if (!ev_matches(in_filters, *out_evdev)) {
libevdev_free(*out_evdev);
open_fds[open_sysfs_idx] = -1;
close(fd);