From 4d0b99ef12003ff9f1960ae8028b53eaf268baab Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Thu, 6 Feb 2020 06:21:22 -0800 Subject: [PATCH] Mac: Prevent centering analog stick from affecting hat values --- macosx/mac-joypad.mm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/macosx/mac-joypad.mm b/macosx/mac-joypad.mm index 3c308f6b..140e452d 100755 --- a/macosx/mac-joypad.mm +++ b/macosx/mac-joypad.mm @@ -194,14 +194,26 @@ void gamepadAction(void *inContext, IOReturn inResult, void *inSender, IOHIDValu if (buttonCodeByJoypadInput.find(inputStruct) != buttonCodeByJoypadInput.end()) { pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[inputStruct]] = true; - pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + + if ( buttonCodeByJoypadInput.find(oppositeInputStruct) != buttonCodeByJoypadInput.end() ) + { + pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + } + } else { oppositeInputStruct.value = info.min; - pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + if ( buttonCodeByJoypadInput.find(oppositeInputStruct) != buttonCodeByJoypadInput.end() ) + { + pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + } oppositeInputStruct.value = info.max; - pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + + if ( buttonCodeByJoypadInput.find(oppositeInputStruct) != buttonCodeByJoypadInput.end() ) + { + pressedGamepadButtons[playerNum][buttonCodeByJoypadInput[oppositeInputStruct]] = false; + } } } else if (info.usage == kHIDUsage_GD_Hatswitch)