Move the joystick deadzone processing until after all the mapping.

This commit is contained in:
Henrik Rydgård 2021-07-08 23:49:14 +02:00
parent c3c7eef6af
commit 7eaa687140
2 changed files with 18 additions and 48 deletions

View File

@ -155,10 +155,23 @@ static void SetPSPAxis(char axis, float value, int stick) {
default:
break;
}
if (axis == 'X')
__CtrlSetAnalogX(value, stick);
else if (axis == 'Y')
__CtrlSetAnalogY(value, stick);
// TODO: Can we move the rest of this logic into ControlMapping too?
static float history[2][2] = {};
int axisId = axis == 'X' ? 0 : 1;
history[stick][axisId] = value;
float x = history[stick][0];
float y = history[stick][1];
// It's a bit non-ideal to run through this twice, once for each axis, but...
ConvertAnalogStick(x, y);
__CtrlSetAnalogX(x, stick);
__CtrlSetAnalogY(y, stick);
}
EmuScreen::EmuScreen(const Path &filename)

View File

@ -1327,38 +1327,6 @@ bool NativeKey(const KeyInput &key) {
return retval;
}
static bool AnalogStickAxis(const AxisInput &axis) {
static float history[JOYSTICK_AXIS_MAX+1] = { 0.0f };
history[axis.axisId] = axis.value;
AxisInput axisA = axis;
AxisInput axisB = axis;
switch (axis.axisId) {
case JOYSTICK_AXIS_X:
case JOYSTICK_AXIS_Y:
axisA.axisId = JOYSTICK_AXIS_X;
axisB.axisId = JOYSTICK_AXIS_Y;
axisA.value = history[JOYSTICK_AXIS_X];
axisB.value = history[JOYSTICK_AXIS_Y];
break;
case JOYSTICK_AXIS_Z:
case JOYSTICK_AXIS_RZ:
axisA.axisId = JOYSTICK_AXIS_Z;
axisB.axisId = JOYSTICK_AXIS_RZ;
axisA.value = history[JOYSTICK_AXIS_Z];
axisB.value = history[JOYSTICK_AXIS_RZ];
break;
default:
break;
}
ConvertAnalogStick(axisA.value, axisB.value);
bool retA = screenManager->axis(axisA);
bool retB = screenManager->axis(axisB);
return retA && retB;
}
bool NativeAxis(const AxisInput &axis) {
if (!screenManager) {
// Too early.
@ -1367,16 +1335,6 @@ bool NativeAxis(const AxisInput &axis) {
using namespace TiltEventProcessor;
switch (axis.axisId) {
case JOYSTICK_AXIS_X:
case JOYSTICK_AXIS_Y:
case JOYSTICK_AXIS_Z:
case JOYSTICK_AXIS_RZ:
return AnalogStickAxis(axis);
default:
break;
}
// only handle tilt events if tilt is enabled.
if (g_Config.iTiltInputType == TILT_NULL) {
// if tilt events are disabled, then run it through the usual way.
@ -1388,8 +1346,7 @@ bool NativeAxis(const AxisInput &axis) {
}
// create the base coordinate tilt system from the calibration data.
// This is static for no particular reason, can be un-static'ed
static Tilt baseTilt;
Tilt baseTilt;
baseTilt.x_ = g_Config.fTiltBaseX;
baseTilt.y_ = g_Config.fTiltBaseY;