Add project setting to ignore joypad events if the app is unfocused#115119
Add project setting to ignore joypad events if the app is unfocused#115119Nintorch wants to merge 1 commit intogodotengine:masterfrom
Conversation
90b3c48 to
8e5f2ce
Compare
Calinou
left a comment
There was a problem hiding this comment.
Tested locally on Linux/X11, it mostly works as expected.
Some feedback:
- Clicking the window border in game embedding doesn't count as focusing the application, while it should. You need to click on the viewport instead.
- When the window loses focus, stick movement will sometimes still be registered, leading to a "ghost input". This is more common if you are actively moving the stick at the time the window loses focus.
gamepad_unfocused.mp4
|
Thank you for your review, Calinou! I will try to fix these issues later when I can! |
8e5f2ce to
5cfe066
Compare
I tried to fix these issues, they seem to be fixed now on my local branch( https://github.com/Nintorch/godot/actions/runs/21173143271 ). Tested on Windows 11. There's another issue that when I switch from the viewport to the embedder window (the window that embeds the game process), inputs get reset, but if I press them again they work. Not sure if I should fix this issue here or in a separate PR, because it's already reported in a separate issue: #115110 |
5cfe066 to
1bd7b5a
Compare
|
I decided to also fix #115110 in this PR as well :) |
1bd7b5a to
fdc8543
Compare
fdc8543 to
a785d16
Compare
Calinou
left a comment
There was a problem hiding this comment.
Works great now 🙂
gamepad_no_focus.mp4
The only remaining issue is that buttons pressed beforehand will not be seen as pressed by Godot once the window gains focus. For axes, this will sometimes happen (due to the value changing very often), but it's less likely to happen if you are fully holding a trigger (common with digital triggers) or a stick in a cardinal direction. That said, this issue is commonly found in other programs that disallow background input, so it's not critical and can be resolved in a future PR.
|
Thank you for your review, Calinou! I will try to add a property for this feature soon! |
a785d16 to
8e3228b
Compare
Co-Authored-By: Christoph Taucher <4498502+chtau@users.noreply.github.com>
8e3228b to
07a1484
Compare
| GLOBAL_DEF("collada/use_ambient", false); | ||
|
|
||
| // Input settings | ||
| GLOBAL_DEF("input_devices/config/ignore_joypad_on_unfocused_application", false); |
There was a problem hiding this comment.
The double negative ("ignore" -- "unfocused") makes it harder to understand the meaning of the setting. I would recommend a name such as accept_joypad_inputs_when_application_unfocused with the default value true.
There was a problem hiding this comment.
I tend to disagree, as the action the user would take here is specifically to ignore joypad events on unfocused apps. That's a double negative indeed, but "unfocused app" to me is a well-defined object, so not really a negation per se, if that makes sense. And a setting like "accept" that defaults to true doesn't seem expected to me, if I want to diverge from default behavior, I would expect to enable an option that disables that behavior (so indeed it's enabling a negative option).
But my native language (French) has no issue with double negatives so I may be biased. To me the original setting sounds much clearer than the one you propose, but maybe others would think differently.
There was a problem hiding this comment.
Personally, I'm not sure this is a double negative (even though my native language is not English either), I've always thought double negatives are grammar errors and they can be seen in sentences like "I didn't see nothing", "I ain't got no time for that", "But I ain't stupid neither" (Left 4 Dead 2 reference :D), see also https://professorscottsenglish.com/english-grammar/common-grammar-mistakes/double-negatives/why-double-negatives-are-grammatically-incorrect-sometimes/ (I'm not sure how reputable this website is, though)
So basically joypad events should be read when the application is focused, and ignored if it's unfocused.
There was a problem hiding this comment.
It would be double negation if it was "a non-unfocused" for example
| GLOBAL_DEF("collada/use_ambient", false); | ||
|
|
||
| // Input settings | ||
| GLOBAL_DEF("input_devices/config/ignore_joypad_on_unfocused_application", false); |
There was a problem hiding this comment.
| GLOBAL_DEF("input_devices/config/ignore_joypad_on_unfocused_application", false); | |
| GLOBAL_DEF("input_devices/joypads/ignore_joypad_on_unfocused_application", false); |
Supersedes #82965
Closes #16832
Also fixes #115110
This PR is based on #82965 and this PR addresses the problems pointed out in the reviews of the original PR, particularly that the
Inputclass shouldn't depend onDisplayServerand the PR should also handle multiple windows.This PR adds a project setting that allows the joypad events to be ignored if the application (or any of its windows) is unfocused.
2026-01-19.12-40-30.mp4
2026-01-19.12-55-34.mp4
TODO: