diff options
Diffstat (limited to 'platform/linuxbsd/joypad_linux.cpp')
-rw-r--r-- | platform/linuxbsd/joypad_linux.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 827c567785..49f2690e61 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -50,7 +50,7 @@ #define LONG_BITS (sizeof(long) * 8) #define test_bit(nr, addr) (((1UL << ((nr) % LONG_BITS)) & ((addr)[(nr) / LONG_BITS])) != 0) -#define NBITS(x) ((((x)-1) / LONG_BITS) + 1) +#define NBITS(x) ((((x) - 1) / LONG_BITS) + 1) #ifdef UDEV_ENABLED static const char *ignore_str = "/dev/input/js"; @@ -175,7 +175,7 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) { if (devnode) { String devnode_str = devnode; - if (devnode_str.find(ignore_str) == -1) { + if (!devnode_str.contains(ignore_str)) { open_joypad(devnode); } } @@ -214,7 +214,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) { const char *devnode = udev_device_get_devnode(dev); if (devnode) { String devnode_str = devnode; - if (devnode_str.find(ignore_str) == -1) { + if (!devnode_str.contains(ignore_str)) { if (action == "add") { open_joypad(devnode); } else if (String(action) == "remove") { @@ -225,7 +225,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) { udev_device_unref(dev); } } - usleep(50000); + OS::get_singleton()->delay_usec(50'000); } udev_monitor_unref(mon); } @@ -244,13 +244,13 @@ void JoypadLinux::monitor_joypads() { continue; } sprintf(fname, "/dev/input/%.*s", 16, current->d_name); - if (attached_devices.find(fname) == -1) { + if (!attached_devices.has(fname)) { open_joypad(fname); } } } closedir(input_directory); - usleep(1000000); // 1s + OS::get_singleton()->delay_usec(1'000'000); } } @@ -374,6 +374,12 @@ void JoypadLinux::open_joypad(const char *p_path) { name = namebuf; } + for (const String &word : name.to_lower().split(" ")) { + if (banned_words.has(word)) { + return; + } + } + if (ioctl(fd, EVIOCGID, &inpid) < 0) { close(fd); return; @@ -508,7 +514,7 @@ void JoypadLinux::joypad_events_thread_run() { } } if (no_events) { - usleep(10000); // 10ms + OS::get_singleton()->delay_usec(10'000); } } } |