Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trackpads and graphics tablets being recognized as controllers on Linux/*BSD #93352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions platform/linuxbsd/joypad_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions platform/linuxbsd/joypad_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ class JoypadLinux {

Vector<String> attached_devices;

// List of lowercase words that will prevent the controller from being recognized if its name matches.
// This is done to prevent trackpads, graphics tablets and motherboard LED controllers from being
// recognized as controllers (and taking up controller ID slots as a result).
// Only whole words are matched within the controller name string. The match is case-insensitive.
const Vector<String> banned_words = {
"touchpad", // Matches e.g. "SynPS/2 Synaptics TouchPad", "Sony Interactive Entertainment DualSense Wireless Controller Touchpad"
"trackpad",
"clickpad",
"mouse", // Matches e.g. "Mouse passthrough"
"pen", // Matches e.g. "Wacom One by Wacom S Pen"
"finger", // Matches e.g. "Wacom HID 495F Finger"
"led", // Matches e.g. "ASRock LED Controller"
};

static void monitor_joypads_thread_func(void *p_user);
void monitor_joypads_thread_run();

Expand Down
Loading