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

[3.x] Linux: Don't use udev for joypad hotloading when running in a sandbox #76962

Merged

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented May 11, 2023

udev doesn't work in sandboxes, notably the new Steam container runtime as found notably on the Steam Deck, and in Flatpak/Snap packages.

Like SDL does, when we detect such a containerized environment, we fall back to parsing /dev/input directly.
See smcv's comments in #76879 for details.

Fixes #76879.

3.x backport of #76961.

CC @tcoxon

I tested this one with Cassette Beasts on Steam Deck and it does seem to solve the issue.

Scenarios tested successfully:

  • Connect Xbox controller (bluetooth) while the game is closed. Run the game, Xbox controller is working. Disconnect it, game notifies that it lost connection. Reconnect the Xbox controller, and the game finds it back.
  • Same as above, but start with the controller disconnected when launching the game, and connecting the controller once the main menu is up. Also works fine.

It's not fully perfect as there's still the question of which of the two controllers (Xbox controller and Steam Deck builtin controller) the game decides to focus on when using both. Starting with the Xbox controller, disconnecting it, then using the Steam Deck controller will change which device the game expects to use, and then reconnecting the Xbox controller won't make it take precedence again, until changed manually in the Steam controller config. But this might be a game specific issue or a general Steam Deck quirk that may not be an engine bug.

@akien-mga akien-mga added bug platform:linuxbsd topic:input cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels May 11, 2023
@akien-mga akien-mga added this to the 3.6 milestone May 11, 2023
@akien-mga akien-mga requested a review from a team as a code owner May 11, 2023 18:17
@akien-mga akien-mga force-pushed the 3.x-linux-joypad-skip-udev-if-sandboxed branch from 5b1f516 to fc3b368 Compare May 11, 2023 18:19
@akien-mga akien-mga force-pushed the 3.x-linux-joypad-skip-udev-if-sandboxed branch from fc3b368 to aa1e32a Compare May 12, 2023 07:55
@akien-mga akien-mga changed the title Linux: Don't use udev for joypad hotloading when running in a sandbox [3.x] Linux: Don't use udev for joypad hotloading when running in a sandbox May 12, 2023
udev doesn't work in sandboxes, notably the new Steam container runtime
as found notably on the Steam Deck, and in Flatpak/Snap packages.

Like SDL does, when we detect such a containerized environment, we fall
back to parsing `/dev/input` directly.
See smcv's comments in godotengine#76879 for details.

Fixes godotengine#76879.

(cherry picked from commit 788cb74)
@akien-mga akien-mga force-pushed the 3.x-linux-joypad-skip-udev-if-sandboxed branch from aa1e32a to 8a23fa4 Compare May 12, 2023 09:30
@tcoxon
Copy link
Contributor

tcoxon commented May 12, 2023

Thanks a lot! I've given this a try on my end and it works great. 🎉

Starting with the Xbox controller, disconnecting it, then using the Steam Deck controller will change which device the game expects to use, and then reconnecting the Xbox controller won't make it take precedence again, until changed manually in the Steam controller config. But this might be a game specific issue or a general Steam Deck quirk that may not be an engine bug.

Cassette Beasts uses a bunch of weird heuristics to exclude the duplicate virtual controllers Steam creates. This sounds like a game-specific issue.

@akien-mga akien-mga merged commit 716fef7 into godotengine:3.x May 12, 2023
@akien-mga akien-mga deleted the 3.x-linux-joypad-skip-udev-if-sandboxed branch May 12, 2023 14:39
@akien-mga
Copy link
Member Author

Cherry-picked for 3.5.3.

@akien-mga akien-mga removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Aug 18, 2023
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.

2 participants