DIEFFECT effect;
DICONSTANTFORCE constant;
constant.lMagnitude = 10000;
ZeroMemory(&effect, sizeof(DIEFFECT));
DWORD dwAxes = DIJOFS_Z;
LONG lDirection = 0;
effect.dwSize = sizeof(DIEFFECT);
effect.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
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,
&_effect, // var. to store effect
NULL);
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 ?
Force feedback in gamepads
I have a problem creating a constant force effect to my gamepad.
This is the code I use :
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement