diff options
| author | Jules Blok <jules.blok@gmail.com> | 2014-02-09 16:59:47 +0900 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2014-02-09 17:04:05 +0900 |
| commit | 2063eddfa33167e7b29985c88362de95722830d2 (patch) | |
| tree | b870a87983e5f4e6f79aefc59243b252d990c2f4 /Source/Core/InputCommon/ControllerInterface | |
| parent | 992b91c082365c7f8faaee4d717556a947dbcca8 (diff) | |
ForceFeedback: Fixed scoping bug
Previous code relied on a destroyed variable to still be valid.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp index 744df7fc4a..04f2bb505f 100644 --- a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp @@ -70,10 +70,11 @@ bool ForceFeedbackDevice::InitForceFeedback(const LPDIRECTINPUTDEVICE8 device, i eff.rgdwAxes = rgdwAxes; eff.rglDirection = rglDirection; - // DIPERIODIC is the largest, so we'll use that - DIPERIODIC ff; - eff.lpvTypeSpecificParams = &ff; - memset(&ff, 0, sizeof(ff)); + // initialize parameters + DICONSTANTFORCE diCF = { -10000 }; + diCF.lMagnitude = DI_FFNOMINALMAX; + DIRAMPFORCE diRF = { 0 }; + DIPERIODIC diPE = { 0 }; // doesn't seem needed //DIENVELOPE env; @@ -85,18 +86,19 @@ bool ForceFeedbackDevice::InitForceFeedback(const LPDIRECTINPUTDEVICE8 device, i { if (f.guid == GUID_ConstantForce) { - DICONSTANTFORCE diCF = {-10000}; - diCF.lMagnitude = DI_FFNOMINALMAX; eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); eff.lpvTypeSpecificParams = &diCF; } else if (f.guid == GUID_RampForce) { eff.cbTypeSpecificParams = sizeof(DIRAMPFORCE); + eff.lpvTypeSpecificParams = &diRF; } else { + // all other forces need periodic parameters eff.cbTypeSpecificParams = sizeof(DIPERIODIC); + eff.lpvTypeSpecificParams = &diPE; } LPDIRECTINPUTEFFECT pEffect; |
