From c663e6d568a1bcb096df3ff072f1b9306980ab73 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 9 Jan 2023 09:05:40 -0800
Subject: [PATCH] Revert "Always allow controller events for virtual joysticks
regardless of focus state"
This reverts commit d94f2a9ee56abcbe84a95da91eb3a3319cb4d022.
Rather than changing behavior, we'll set SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS in the joystick tests
---
src/joystick/SDL_joystick.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 2c30b23abfa1..5b1c6a2c05c3 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1314,18 +1314,13 @@ void SDL_QuitJoysticks(void)
SDL_UnlockJoysticks();
}
-static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent(SDL_Joystick *joystick)
+static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
{
if (SDL_joystick_allows_background_events) {
return SDL_FALSE;
}
if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) {
- if (SDL_IsJoystickVIRTUAL(joystick->guid)) {
- /* Always allow events for virtual controllers, they're not affected by focus */
- return SDL_FALSE;
- }
-
/* We have windows but we don't have focus, ignore the event. */
return SDL_TRUE;
}
@@ -1525,7 +1520,7 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S
/* We ignore events if we don't have keyboard focus, except for centering
* events.
*/
- if (SDL_PrivateJoystickShouldIgnoreEvent(joystick)) {
+ if (SDL_PrivateJoystickShouldIgnoreEvent()) {
if (info->sending_initial_value ||
(value > info->zero && value >= info->value) ||
(value < info->zero && value <= info->value)) {
@@ -1569,7 +1564,7 @@ int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uin
/* We ignore events if we don't have keyboard focus, except for centering
* events.
*/
- if (SDL_PrivateJoystickShouldIgnoreEvent(joystick)) {
+ if (SDL_PrivateJoystickShouldIgnoreEvent()) {
if (value != SDL_HAT_CENTERED) {
return 0;
}
@@ -1627,7 +1622,7 @@ int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butto
/* We ignore events if we don't have keyboard focus, except for button
* release. */
- if (SDL_PrivateJoystickShouldIgnoreEvent(joystick)) {
+ if (SDL_PrivateJoystickShouldIgnoreEvent()) {
if (state == SDL_PRESSED) {
return 0;
}
@@ -2927,7 +2922,7 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch
}
/* We ignore events if we don't have keyboard focus, except for touch release */
- if (SDL_PrivateJoystickShouldIgnoreEvent(joystick)) {
+ if (SDL_PrivateJoystickShouldIgnoreEvent()) {
if (event_type != SDL_GAMEPADTOUCHPADUP) {
return 0;
}
@@ -2966,7 +2961,7 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT
SDL_AssertJoysticksLocked();
/* We ignore events if we don't have keyboard focus */
- if (SDL_PrivateJoystickShouldIgnoreEvent(joystick)) {
+ if (SDL_PrivateJoystickShouldIgnoreEvent()) {
return 0;
}