From 7503cf959bdee7e1ddbcf672704a6d81a9b5b7a8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 19 Apr 2014 21:43:27 -0700 Subject: [PATCH] Saturate analog positions in case outside [-1, 1]. Reported by Mio, some configuration was giving 1.0000001, which wrapped. This is not a hot area so let's just saturate to force it to the right range. --- Core/HLE/sceCtrl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index 2a9e778ed4..b57a8e002e 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include "Globals.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/MIPS/MIPS.h" @@ -181,13 +182,15 @@ void __CtrlButtonUp(u32 buttonBit) void __CtrlSetAnalogX(float x, int stick) { std::lock_guard guard(ctrlMutex); - ctrlCurrent.analog[stick][CTRL_ANALOG_X] = (u8)ceilf(x * 127.5f + 127.5f); + int scaled = (int)ceilf(x * 127.5f + 127.5f); + ctrlCurrent.analog[stick][CTRL_ANALOG_X] = clamp_u8(scaled); } void __CtrlSetAnalogY(float y, int stick) { std::lock_guard guard(ctrlMutex); - ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = (u8)ceilf(-y * 127.5f + 127.5f); + int scaled = (int)ceilf(-y * 127.5f + 127.5f); + ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = clamp_u8(scaled); } void __CtrlSetRapidFire(bool state)