mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-28 00:33:34 +01:00
Merge __CtrlSetAnalogX/Y into one function. Always called together.
This commit is contained in:
1 parent
7eaa687140
commit
cd8cfcfcd7
7 files changed
+33
-43
No files matched your search
@@ -254,8 +254,7 @@ void WebSocketInputState::AnalogSend(DebuggerRequest &req) {
|
||||
if (!AnalogValue(req, &x, "x") || !AnalogValue(req, &y, "y"))
|
||||
return;
|
||||
|
||||
__CtrlSetAnalogX(x, stick == "left" ? CTRL_STICK_LEFT : CTRL_STICK_RIGHT);
|
||||
__CtrlSetAnalogY(y, stick == "left" ? CTRL_STICK_LEFT : CTRL_STICK_RIGHT);
|
||||
__CtrlSetAnalogXY(stick == "left" ? CTRL_STICK_LEFT : CTRL_STICK_RIGHT, x, y);
|
||||
|
||||
req.Respond();
|
||||
}
|
||||
+6
-10
@@ -188,18 +188,14 @@ void __CtrlButtonUp(u32 buttonBit)
|
||||
ctrlCurrent.buttons &= ~buttonBit;
|
||||
}
|
||||
|
||||
void __CtrlSetAnalogX(float x, int stick)
|
||||
void __CtrlSetAnalogXY(int stick, float x, float y)
|
||||
{
|
||||
u8 scaled = clamp_u8((int)ceilf(x * 127.5f + 127.5f));
|
||||
u8 scaledX = clamp_u8((int)ceilf(x * 127.5f + 127.5f));
|
||||
// TODO: We might have too many negations of Y...
|
||||
u8 scaledY = clamp_u8((int)ceilf(-y * 127.5f + 127.5f));
|
||||
std::lock_guard<std::mutex> guard(ctrlMutex);
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_X] = scaled;
|
||||
}
|
||||
|
||||
void __CtrlSetAnalogY(float y, int stick)
|
||||
{
|
||||
u8 scaled = clamp_u8((int)ceilf(-y * 127.5f + 127.5f));
|
||||
std::lock_guard<std::mutex> guard(ctrlMutex);
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = scaled;
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_X] = scaledX;
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = scaledY;
|
||||
}
|
||||
|
||||
void __CtrlSetRapidFire(bool state)
|
||||
|
||||
+2
-3
@@ -72,10 +72,9 @@ void __CtrlButtonDown(u32 buttonBit);
|
||||
void __CtrlButtonUp(u32 buttonBit);
|
||||
|
||||
// Call this to set the position of an analog stick, ideally when it changes.
|
||||
// Position value should be from -1 to 1, inclusive, in a square (no need to force to a circle.)
|
||||
// X and Y values should be from -1 to 1, inclusive, in a square (no need to force to a circle.)
|
||||
// No deadzone filtering is done (but note that this applies to the actual PSP as well.)
|
||||
void __CtrlSetAnalogX(float value, int stick = CTRL_STICK_LEFT);
|
||||
void __CtrlSetAnalogY(float value, int stick = CTRL_STICK_LEFT);
|
||||
void __CtrlSetAnalogXY(int stick, float x, float y);
|
||||
|
||||
// Call this to enable rapid-fire. This will cause buttons other than arrows to alternate.
|
||||
void __CtrlSetRapidFire(bool state);
|
||||
|
||||
Reference in new issue
Block a user