Move the internal screen rotation compensation to after value mapping.

This commit is contained in:
Henrik Rydgård 2021-07-09 10:52:48 +02:00
parent cd8cfcfcd7
commit fac4c2a90b

View File

@ -137,25 +137,6 @@ static void __EmuScreenVblank()
// TODO: This should be a callback too, so we don't actually call the __Ctrl functions
// from settings screens, etc.
static void SetPSPAxis(char axis, float value, int stick) {
switch (g_Config.iInternalScreenRotation) {
case ROTATION_LOCKED_HORIZONTAL:
// Standard rotation.
break;
case ROTATION_LOCKED_HORIZONTAL180:
value = -value;
break;
case ROTATION_LOCKED_VERTICAL:
value = axis == 'Y' ? value : -value;
axis = (axis == 'X') ? 'Y' : 'X';
break;
case ROTATION_LOCKED_VERTICAL180:
value = axis == 'Y' ? -value : value;
axis = (axis == 'X') ? 'Y' : 'X';
break;
default:
break;
}
// TODO: Can we move the rest of this logic into ControlMapping too?
static float history[2][2] = {};
@ -170,6 +151,32 @@ static void SetPSPAxis(char axis, float value, int stick) {
// It's a bit non-ideal to run through this twice, once for each axis, but...
ConvertAnalogStick(x, y);
switch (g_Config.iInternalScreenRotation) {
case ROTATION_LOCKED_HORIZONTAL:
// Standard rotation. No change.
break;
case ROTATION_LOCKED_HORIZONTAL180:
x = -x;
y = -y;
break;
case ROTATION_LOCKED_VERTICAL:
{
float new_y = -x;
x = y;
y = new_y;
break;
}
case ROTATION_LOCKED_VERTICAL180:
{
float new_y = y = x;
x = -y;
y = new_y;
break;
}
default:
break;
}
__CtrlSetAnalogXY(stick, x, y);
}