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

Check for focus before reading joypad input. #16276

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zoltanvb
Copy link
Contributor

Description

The udev and sdl joypad drivers were reading input in all cases. Now state is not monitored if window has no focus, connect / disconnect events are still processed.

Related Issues

Fixes #16261

The udev and sdl joypad drivers were reading input in all cases.
Now state is not changed if window has no focus, connect / disconnect
events are still processed.
@LibretroAdmin
Copy link
Contributor

LibretroAdmin commented Feb 23, 2024

Is this how the other input drivers work as well? We wouldn't want to introduce something specific to certain input driver implementations in a non-unified way. Also I think it's the wrong approach to do this 'video_driver_has_focus()' call inside the input driver implementation, should be done higher-level.

Also in addition to it being a generic option that should work across the board for all input drivers, I feel this should remain entirely optional and tied behind a setting instead of forced, there might be usecases where we still want input for a non-focused window, this is in fact a handy feature when you want to still be able to play a game in an unfocused window with your gamepad.

@hizzlekizzle
Copy link
Contributor

some people specifically request input detection in the background. it's a nasty surprise if you're not wanting, that, though, and end up wreaking havoc.

I'm loathe to add more options unnecessarily, but it might be worthwhile here.

@sonninnos
Copy link
Collaborator

In general I feel that Windows drivers do it correctly, which is: keyboard is ignored when app is not in focus, and controllers never.

@zoltanvb
Copy link
Contributor Author

Udev keyboard/mouse does something similar already, but not much else.
Hm, it may be better to unify it, putting it behind an option may solve my concerns for a general solution - I wonder if video context driver focus (which is understood as keyboard focus on desktop) matches the user's perception of focus on all platforms.

@zoltanvb zoltanvb marked this pull request as draft February 23, 2024 21:56
@LibretroAdmin
Copy link
Contributor

LibretroAdmin commented Mar 19, 2024

Ye I feel this should be behind a setting with the following options (you can decide on the names of each option)

0 - receives both keyboard and controller input when out of focus
1 - keyboard ignored when app is not in focus, but controller input still received
2 - keyboard and controller input ignored when app is not in focus

1 should be the default setting value.

@zoltanvb
Copy link
Contributor Author

I'm fine with the approach (though option 0 will always be a bit misleading, as the possibility of getting keyboard input when out of focus is very much platform/driver dependent). I'm just wary of doing it centrally in input_driver.c, which is probably the 3rd most complex piece in whole RA I have visited so far, so it may take a while. I can close the PR until that time, if preferred.

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

Successfully merging this pull request may close these issues.

Input always active
4 participants