USB: Early return from FF test in case of failure

This commit is contained in:
jackun 2020-12-24 21:53:06 +02:00
parent b8406a5b95
commit 9534b2af1d
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3
2 changed files with 7 additions and 8 deletions

View File

@ -1003,10 +1003,10 @@ namespace usb_pad
}
//set left/right ffb torque
void SetConstantForce(int port, LONG magnitude)
HRESULT SetConstantForce(int port, LONG magnitude)
{
if (!FFB[port])
return;
if (!FFB[port] || !g_pEffectConstant[port])
return DIERR_NOTINITIALIZED;
if (INVERTFORCES[port])
cfw.lMagnitude = -magnitude;
@ -1016,8 +1016,7 @@ namespace usb_pad
if (FFMULTI[port][0] > 0)
cfw.lMagnitude *= 1 + FFMULTI[port][0];
if (g_pEffectConstant[port])
g_pEffectConstant[port]->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START);
return g_pEffectConstant[port]->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START);
}
void TestForce(int port)
@ -1030,7 +1029,8 @@ namespace usb_pad
// Gain value may have changed, so update it for the constant force effect
UpdateFFBSettings(port, dev);
SetConstantForce(port, DI_FFNOMINALMAX / 3);
if (FAILED(SetConstantForce(port, DI_FFNOMINALMAX / 3)))
return;
Sleep(500);
SetConstantForce(port, -DI_FFNOMINALMAX / 3);
Sleep(1000);

View File

@ -202,9 +202,8 @@ namespace usb_pad
void FreeDirectInput();
void PollDevices();
float ReadAxis(const InputMapped& im);
float ReadAxis(int port, ControlID axisid);
float ReadAxis(int port, int axisid);
float FilterControl(float input, LONG linear, LONG offset, LONG dead);
bool KeyDown(DWORD KeyID);
void TestForce(int port);
LONG GetAxisValueFromOffset(int axis, const DIJOYSTATE2& j);
bool GetControl(int port, int id);