Jump to content
  • Advertisement


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


Force feedback in gamepads

This topic is 5603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!