DirectInput force feedback error RRS feed

  • Question

  • Hi,

        I am working on joystick wheel force feedback DirectInput. I am using following code. But it gives error: "Value does not fall within the expected range."

    Please help me to resolve the problem or suggest me any sdk force feedback.

      DeviceList xDeviceList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); 
                DeviceInstance someDeviceInstance; 
                foreach (DeviceInstance deviceInstance in xDeviceList) 
                    someDeviceInstance = deviceInstance; 
                Device someDevice = new Device(someDeviceInstance.InstanceGuid); 
                someDevice.SetCooperativeLevel(this.Handle, CooperativeLevelFlags.Exclusive | CooperativeLevelFlags.Background); 
                int[] axis = new int[0]; 
                foreach (DeviceObjectInstance doi in someDevice.Objects) 
                    if((doi.Flags & (int)ObjectInstanceFlags.Actuator) != 0) 
                        axis = new int[axis.Length + 1]; 
                        axis[axis.Length - 1] = doi.Offset; 
                Effect effect = new Effect(); 
                effect.SetDirection(new int[axis.Length]); 
                effect.SetAxes(new int[axis.Length]); 
                effect.ConditionStruct = new Condition[axis.Length]; 
                effect.Flags = EffectFlags.Cartesian | EffectFlags.ObjectOffsets; 
                effect.Duration = int.MaxValue; 
                effect.SamplePeriod = 0; 
                effect.Gain = 10000; 
                effect.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger; 
                effect.TriggerRepeatInterval = 0; 
                effect.UsesEnvelope = false; 
                effect.EffectType = Microsoft.DirectX.DirectInput.EffectType.ConstantForce; 
                effect.StartDelay = 0; 
                effect.Constant = new Microsoft.DirectX.DirectInput.ConstantForce(); 
                effect.Constant.Magnitude = -5000; 
                EffectObject effectObject = null; 
                foreach (EffectInformation ei in someDevice.GetEffects(EffectType.ConstantForce)) 
                    effectObject = new EffectObject(ei.EffectGuid, effect, someDevice); 
                effectObject.SetParameters(effect, EffectParameterFlags.Start ); 

    • Moved by Mattew Wu Friday, February 3, 2017 4:21 AM not p\
    Thursday, February 2, 2017 1:35 PM


All replies

  • Hi Zeal Baa,

    This forum is used to discuss the question regarding publishing and certification process, I will move your thread so that it may appear in a more appropriate category.

    Thanks for your understanding.

    Best regards,

    Mattew Wu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Edited by Mattew Wu Friday, February 3, 2017 4:20 AM
    Friday, February 3, 2017 2:32 AM
  • I'd try asking over here.



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Friday, February 3, 2017 4:37 AM