mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 14:55:31 +00:00
Don't send the initial joystick axis event if the application is in the background
This commit is contained in:
parent
d31f90d9e1
commit
7681929cb4
|
@ -1344,7 +1344,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
|||
info->value = value;
|
||||
info->zero = value;
|
||||
info->has_initial_value = SDL_TRUE;
|
||||
} else if (value == info->value) {
|
||||
} else if (value == info->value && !info->sending_initial_value) {
|
||||
return 0;
|
||||
} else {
|
||||
info->has_second_value = SDL_TRUE;
|
||||
|
@ -1356,15 +1356,17 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
|||
return 0;
|
||||
}
|
||||
info->sent_initial_value = SDL_TRUE;
|
||||
info->value = ~value; /* Just so we pass the check above */
|
||||
info->sending_initial_value = SDL_TRUE;
|
||||
SDL_PrivateJoystickAxis(joystick, axis, info->initial_value);
|
||||
info->sending_initial_value = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* We ignore events if we don't have keyboard focus, except for centering
|
||||
* events.
|
||||
*/
|
||||
if (SDL_PrivateJoystickShouldIgnoreEvent()) {
|
||||
if ((value > info->zero && value >= info->value) ||
|
||||
if (info->sending_initial_value ||
|
||||
(value > info->zero && value >= info->value) ||
|
||||
(value < info->zero && value <= info->value)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef struct _SDL_JoystickAxisInfo
|
|||
SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */
|
||||
SDL_bool has_second_value; /* Whether we've seen a second value on the axis yet */
|
||||
SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */
|
||||
SDL_bool sending_initial_value; /* Whether we are sending the initial axis value */
|
||||
} SDL_JoystickAxisInfo;
|
||||
|
||||
typedef struct _SDL_JoystickTouchpadFingerInfo
|
||||
|
|
Loading…
Reference in a new issue