From 2063eddfa33167e7b29985c88362de95722830d2 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 9 Feb 2014 16:59:47 +0900 Subject: [PATCH] ForceFeedback: Fixed scoping bug Previous code relied on a destroyed variable to still be valid. --- .../ForceFeedback/ForceFeedbackDevice.cpp | 14 ++++++++------ 1 file 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;