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

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jun 19, 2024

On my setup, my DualSense is finally at controller ID 0 as the ASRock LED Controller is no longer registered and takes up ID 0 as a result. The DualSense's trackpad is also no longer seen as a separate (non-functional) controller.

Tested both with udev=yes and udev=no, including hotplugging. Thanks to @geekley for providing the list of banned words (to which I added led) 🙂

Testing project: https://github.com/godotengine/godot-demo-projects/tree/master/misc/joypads

@geekley
Copy link

geekley commented Jun 19, 2024

Thanks for the PR and the ping @Calinou !
Just for clarity, this PR is a bit different from the scripts as it considers only space (U+0020) as word separator:

for (const String &word : name.to_lower().split(" ")) {

Whereas the GDScript codes consider more characters as word separators.
Any ASCII non-letters in the current gist:

static func is_ascii_non_letter(c: String) -> bool:
	return c.unicode_at(0) < 128 and not (c >= 'a' and c <= 'z' or c >= 'A' and c <= 'Z')

\b word boundary in the previous RegEx version:

static var pattern := RegEx.create_from_string('\\b(?i:(?:touch|track|click)pad|mouse|pen)\\b')

I'm not saying this method is better, I'm just pointing out the difference, since some cases would be handled differently.
E.g.: okWord-bannedWord, okWord_bannedWord, okWord2bannedWord, okWord\tbannedWord, etc.

I don't have an opinion on whether it's safer to consider what is a "word" more strictly or more broadly, because this is only theoretical, I didn't encounter these cases in practice; and also didn't do any sort of test or research on device names (though I consider this list and this repo's files to be good sources if anyone wants some sort of reference).

While on one hand these other word separators should be pretty safe assumptions, on the other, from #59412 (comment):

We'd rather have false positives than false negatives.

Still, even with fewer separators, maybe it's worth adding at least _ and \t as alternatives to space, just in case?
Regarding - (minus / hyphen), I have no idea. Maybe it's safer to not consider it a separator, as there are small words like "pen" and "led" that could be part of a larger word, like a brand name.

@AThousandShips AThousandShips added this to the 4.3 milestone Jun 19, 2024
@Calinou
Copy link
Member Author

Calinou commented Jun 20, 2024

Still, even with fewer separators, maybe it's worth adding at least _ and \t as alternatives to space, just in case?

I've never seen a controller name contain _ or \t personally.

@geekley
Copy link

geekley commented Jun 20, 2024

Yeah, I though so too after I took a look at the lists of names I linked. Though these only list actual controllers, not other devices like mouse, etc. it's probably safe to use just space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Laptop touchpads are seen as gamepads
3 participants