api: check for window focus when accepting input (#317)

## Link to GitHub Issue, if one exists
Fixes #139 

## Description of change
Add an option for detecting window focus when accepting input.

The new default will be to have the following:
 * naive bindings will check for window focus
* rawinput binds are not affected, will continue to be accepted
regardless of focus

Other options (always / never choices) can be picked by the user to
tweak the behavior if needed.

Clean up usage of `0xff` constant to represent invalid naive vkey.

## Testing
Still in progress, especially in regards to performance.

On a i7-9700 system, 10000 calls to `superexit::has_focus()` takes
250-350 microseconds, so this should not be a big deal at all.
This commit is contained in:
bicarus-dev
2025-05-07 13:22:29 -07:00
committed by GitHub
parent 6e7bf99af8
commit 26ea8a1b92
8 changed files with 75 additions and 9 deletions
+2
View File
@@ -28,6 +28,8 @@ namespace rawinput {
int TOUCHSCREEN_RANGE_X = 0;
int TOUCHSCREEN_RANGE_Y = 0;
bool DUMP_HID_DEVICES_TO_LOG = false;
bool NAIVE_REQUIRE_FOCUS = true;
bool RAWINPUT_REQUIRE_FOCUS = false;
// set this to something slightly longer than 16.67ms (60Hz) so that I/O can pick it up
// this may need to be adjusted for each game in the future if there is a game that polls less