SharpDX help with exmaples.

Started by
0 comments, last by ulao 8 years, 3 months ago

Looks like SharpDX is still around. I was able to do much basic stuff on my own with it but I need some help. Are there no forums left for shrapDX? I'm trying something simple like created a new force effect but I can not find a single code example on the matter.

Normally you do something like this with managed code.


e = new Effect();
                    e.SetDirection( new int[Axis.Length] );
                    e.SetAxes( new int[1] ); 
                    e.EffectType = Type;
                    e.ConditionStruct = new Condition[Axis.Length];
                    e.Duration = INFINITE;
                    e.Gain = 10000;
                    e.Constant = new ConstantForce();
                    e.Constant.Magnitude = Magnitude;
                    e.SamplePeriod = 0;
                    e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
                    e.TriggerRepeatInterval = (int)DI.Infinite;
                    e.Flags = Flags;
                    e.UsesEnvelope = false;

                    // Create the effect, using the passed in guid.
                    eo = new EffectObject( ei.EffectGuid, e, Dev );

but I can not even create the effect with SharpDX as its expecting one of two constructors. I'm not even able to find a doc that has the right classes for SharpDX 3. Does anyone have a simple constant force example I could sample from?

Advertisement

Well I learned much on my own here. But I get ;

An unhandled exception of type 'SharpDX.SharpDXException' occurred in SharpDX.dll
Additional information: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

on the marked line below. My guess is I didn't get the data correct. Its quite difficult with no example.

EffectParameters ep = new EffectParameters();
foreach (var ei in allEffects)
{
Console.WriteLine("Effect available {0}", ei.Name);

if (ei.Type.HasFlag( EffectType.ConstantForce ))
{
ep.Flags = EffectFlags.Cartesian | EffectFlags.ObjectOffsets;
ep.Directions= new int[1]{0};//MaxValue
ep.Gain = 10000;
ep.Duration = int.MaxValue;
ep.SetAxes (new int[1],new int[1]);
ep.SamplePeriod =0;
//ep.TriggerButton=
// ep.TriggerRepeatInterval = int.MaxValue;
Effect e = new Effect(joystick, ei.Guid, ep); <-- error
e.Start();
}
}

This topic is closed to new replies.

Advertisement