Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

DirectInput Force Feedback... do nothing?

Started by Dunge Sep 10, 2005 at 4:27 PM 1 replies 2.8k views
Original Post
Dunge
Dunge
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..
hplus0603
hplus0603
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.
enum Bool { True, False, FileNotFound };
Dunge
Dunge
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.