From 9dd4de8fe1d085c4a39ff57ae6e37c0516f05daa Mon Sep 17 00:00:00 2001 From: Iliyas Jorio Date: Wed, 7 Feb 2024 23:32:44 +0100 Subject: [PATCH] Keyboard takes precedence over analog in keyboard player --- Source/System/SDLInput.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/System/SDLInput.c b/Source/System/SDLInput.c index e16d556..be84e10 100644 --- a/Source/System/SDLInput.c +++ b/Source/System/SDLInput.c @@ -484,6 +484,12 @@ static float GetAnalogValue(int needID, bool raw, int playerID) const Controller* controller = &gControllers[playerID]; + // Keyboard takes precedence when the key is pressed + if ((gNumLocalPlayers <= 1 || controller->fallbackToKeyboard) && gNeedStates[needID]) + { + return 1.0f; + } + if (controller->open && controller->needAnalogRaw[needID] != 0.0f) { float value = controller->needAnalogRaw[needID]; @@ -506,12 +512,6 @@ static float GetAnalogValue(int needID, bool raw, int playerID) return value; } - // Fallback to KB/M - if (gNumLocalPlayers <= 1 || controller->fallbackToKeyboard) - { - return gNeedStates[needID] ? 1.0f : 0.0f; - } - return 0; }