Skip to content

Project setting for Joypad on unfocused Window#82965

Open
Chtau wants to merge 1 commit intogodotengine:masterfrom
Chtau:joypad-focus
Open

Project setting for Joypad on unfocused Window#82965
Chtau wants to merge 1 commit intogodotengine:masterfrom
Chtau:joypad-focus

Conversation

@Chtau
Copy link
Contributor

@Chtau Chtau commented Oct 7, 2023

Project setting to prevent handling from joypad input when the window is not focused.

Closes #16832

@Chtau Chtau requested review from a team as code owners October 7, 2023 13:35
@Chtau Chtau requested a review from a team as a code owner October 7, 2023 16:26
input when the window is not focused.
#include "core/input/default_controller_mappings.h"
#include "core/input/input_map.h"
#include "core/os/os.h"
#include "servers/display_server.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This was discussed in a PR-review meeting and Input should not depend on display_server.
An alternative approach would be to notify Input from the main loop about application focus changes.


bool Input::_config_ignore_joypad_on_unfocused_window() {
if (ignore_joypad_on_unfocused) {
if (!DisplayServer::get_singleton()->window_is_focused(DisplayServer::MAIN_WINDOW_ID)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach doesn't cover the case, that an application can have multiple OS-Windows. Perhaps a better approach would be to take application focus instead of window focus into consideration.

@Gatada
Copy link
Contributor

Gatada commented Oct 26, 2023

Adding this option if fine by me—as long as if I disable this option, and enable No Focus, the controller should keep working without the running project having focus. Which is what I prefer.

@MJacred
Copy link
Contributor

MJacred commented Apr 20, 2025

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.

Games receive joypad input even if the game window is not focused

6 participants