Advertisement Jump to content
Sign in to follow this  
Dunge

DirectInput Force Feedback... do nothing?

This topic is 4883 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

Anyone ever tryed using force feedback with directinput? I wrote my code using the DXSDK tutorial and checked ou other exemples. I am using a ConstantForce effect. All function return DI_OK even Start() but when I call Start() it just don't do anything. Still my gamepad is active and acquired (it work in-game for reading button and direction). Here is the mehod of interest:
bool InputDevice_Joystick::initEffect()
{
  DWORD      dwAxes[2] = {DIJOFS_X, DIJOFS_Y};
  LONG       lDirection[2] = {0, 0};
  DICONSTANTFORCE cf = { 0 };

  DIEFFECT   diEffect;        // general parameters

  diEffect.dwSize = sizeof(DIEFFECT); 
  diEffect.dwFlags = DIEFF_POLAR | DIEFF_OBJECTOFFSETS; 
  diEffect.dwDuration = (DWORD)(2 * DI_SECONDS);
  diEffect.dwSamplePeriod = 0;
  diEffect.dwGain = DI_FFNOMINALMAX;
  diEffect.dwTriggerButton = DIEB_NOTRIGGER;
  diEffect.dwTriggerRepeatInterval = 0;      
  diEffect.cAxes = 2; 
  diEffect.rgdwAxes = dwAxes; 
  diEffect.rglDirection = &lDirection[0]; 
  diEffect.lpEnvelope = NULL; 
  diEffect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
  diEffect.lpvTypeSpecificParams = &cf;

  if(FAILED(device->CreateEffect(GUID_ConstantForce, &diEffect, &effect, NULL)))
    return 0;
  else
    return 1;
}
oh and yeah I got a gamepad supporting force feedback. I tried using EnumEffects but it return GUID_ConstantForce so I guesss it's ok..

Share this post


Link to post
Share on other sites
Advertisement
You're not actually filling out "cf" with anything.

(it's supposed to have the magnitude -- set it to 10,000)

Also, you may need to set direction to something non-0.

Share this post


Link to post
Share on other sites
thx, I just found it by myself and was about to write "nevermind forgot to set cf.lMagnitude = DI_FFNOMINALMAX;"

direction is not supported by my gamepad I think and I don't really care which way it's shaking for my game.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!