Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//using Microsoft.DirectX
//using Microsoft.DirectX.DirectInput
DeviceList dList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
DeviceInstance dInstance;
foreach (DeviceInstance deviceInstance in dList)
{

dInstance = deviceInstance;
break;
}
//Initializing Device "12btns / 2anlg vibration Joystick "
EffectObject eo = null;
Effect eff = new Effect();
Device dev = new Device(dInstance.InstanceGuid);
dev.SetCooperativeLevel(this, CooperativeLevelFlags.Exclusive | CooperativeLevelFlags.Background);
int[] axis = new int[0];
foreach (DeviceObjectInstance devoi in dev.Objects)
{
if((devoi.Flags & (int)ObjectInstanceFlags.Force) != 0)
{
axis = new int[axis.Length + 1];
axis[axis.Length - 1] = devoi.Offset;
}
}

dev.Acquire();


eff.SetDirection(new int[axis.Length]);
//int the next step when trying "new int[axis.Lenght]" causes
//"Value does not fall within the expected range" error
//maybe its a bug in DirectX Inner Constructor Code.
//Directx.Dll Version :5.04.00.2904 - DirectInput.Dll version 9.15.779.0000
eff.SetAxes(new int[1]);

//other properties.
eff.TriggerButton = (int)Button.NoTrigger;
eff.Duration = 25000;
eff.Gain = 10000;
eff.Flags = EffectFlags.Spherical | EffectFlags.ObjectOffsets;
eff.Duration = int.MaxValue;
eff.SamplePeriod = 0;


eff.TriggerRepeatInterval = (int)DI.Infinite;
eff.UsesEnvelope = true;
eff.EffectType = EffectType.ConstantForce;
eff.StartDelay = 0;
eff.Constant.Magnitude = 10000;



//Guid For Constant Force Effect From Registry :HKLM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick\OEM\VID_0079&PID_0006\...
eo = new EffectObject(new Guid("{13541C20-8E33-11D0-9AD0-00A0C9A06E35}"),eff,dev);

//starting Effect (1 iteration)
//both Motors.
eo.Start(1);

//now I need to send Force Effect to specified Motor(distinguish between left & right);
// like the one in GameControllers.ControlPanel.Vibration Test
//exemple : [RightForce|leftForce|BothForce]
//changing [SetAxes|SetDirection] Parameters Below Didn't work;
//neither editing registry Values for OEM
// ForceFeedBack effects didn't work too;

What I have tried:

hanging [SetAxes|SetDirection] Parameters
editing registry Values for OEM ForceFeedBack effects
Nothing Worked at all
Posted
Comments
[no name] 8-Mar-19 15:33pm    
How can you have a "for each" with an unconditional "break" in the middle?

Use .First...() if that's what you want.
Member 14073125 13-Mar-19 8:05am    
it's a twin gamepad . i need to Get only the first device
i need that in some dxdiag project

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900