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

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.

@Calinou Calinou force-pushed the linuxbsd-controller-no-trackpad-graphics-tablet branch from 298b136 to 724cdff Compare July 5, 2024 22:26
@Calinou
Copy link
Member Author

Calinou commented Jul 5, 2024

I've added keyboard to the list of banned words following deathkiller/jazz2-native#56. Quoting Jazz² Resurrection 2.7.0's release notes:

  • Blacklisted every gamepad containing Keyboard and Mouse in name, because it's usually wrongly detected as gamepad on Linux

Note that analog keyboards (such as the Wooting two HE I have) are smart enough about this; none of them should have keyboard in their controller name.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give it a spin. I checked cat core/input/gamecontrollerdb.txt | cut -d',' -f2 for occurrences of these words and none of them seems included, so that should be fine.

I'm slightly concerned some controllers out there might have names like "PlayStation controller with touchpad" because in theory touchpad support is part of the SDL mapping, but since there's none in the list so far I guess it's fine.

@akien-mga akien-mga merged commit 49a6171 into godotengine:master Jul 9, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@Calinou Calinou deleted the linuxbsd-controller-no-trackpad-graphics-tablet branch July 9, 2024 18:22
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
4 participants