This topic is now archived and is closed to further replies.


Force feedback in gamepads

Recommended Posts

I have a problem creating a constant force effect to my gamepad. This is the code I use :

DIEFFECT effect;
constant.lMagnitude = 10000;

ZeroMemory(&effect, sizeof(DIEFFECT));

DWORD      dwAxes = DIJOFS_Z;
LONG       lDirection = 0;

effect.dwSize = sizeof(DIEFFECT);
effect.dwDuration = 2*DI_SECONDS;

effect.dwSamplePeriod = 0;
effect.dwGain = 10000;
effect.dwTriggerButton = DIEB_NOTRIGGER;
effect.dwTriggerRepeatInterval = 0;      
effect.cAxes = 1; 
effect.rgdwAxes = &dwAxes; 
effect.rglDirection = &lDirection; 
effect.lpEnvelope = NULL; 
effect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
effect.lpvTypeSpecificParams = &constant;
effect.dwStartDelay = 0;

// create effect
HRESULT hr = _joystick->CreateEffect(GUID_ConstantForce,
			             &_effect, // var. to store effect
After the CreateEffect call the hr is equal to DIERR_INVALI DPARAM. Since gamepads just have vibration motors, how do you know which axis and direction to set ?

Share this post

Link to post
Share on other sites
Not sure exactly, but it might be easier to just use the Force Editor and load those files. DirectInput will automatically adapt forces to work with the device.

Share this post

Link to post
Share on other sites