1
\$\begingroup\$

I have written some code to handle a DX device. When the code is finished and makes it's call to DX the DX engine is complaining. What I'm looking to understand is how one goes about debugging on the DX end or at most what parameter passed is trowing an error.

For reference this is my code. This is not the complete class but gives an idea of the code I'm attempting. Happy to share more if needed.

public void doFFBAPI(Joystick joystick)
        {
            var allEffects = joystick.GetEffects( EffectType.All );

            foreach (var ei in allEffects)  
            {
                if (Convert.ToString((int)ei.Type & 7, 2) == "101")
                {
                    EffectParameters ep = new EffectParameters();
                    int xAxisOffset = 0, yAxisOffset = 0;
                    int nextOffset = 0;
                    foreach (DeviceObjectInstance d in joystick.GetObjects())
                    {
                        if (d.ObjectType.Equals(DeviceObjectTypeFlags.ForceFeedbackActuator))
                        {
                            if (nextOffset == 0)
                                xAxisOffset = d.Offset;
                            else
                                yAxisOffset = d.Offset;
                            nextOffset++;
                        }
                    }

                    int[] offsets = new int[2];
                    offsets[0] = xAxisOffset;
                    offsets[1] = yAxisOffset;
                    int[] coords = { 0, 0 };

                    ep.Flags = EffectFlags.Cartesian | EffectFlags.ObjectOffsets;
                    ep.Directions= new int[1]{0};//MaxValue
                    ep.Gain = 10000;
                    ep.Duration = int.MaxValue;
                    ep.SetAxes(offsets, coords);
                    ep.SamplePeriod = joystick.Capabilities.ForceFeedbackSamplePeriod;
                    ep.TriggerButton = -1;
                    ep.TriggerRepeatInterval = int.MaxValue;
                    ep.Envelope = new Envelope();
                    ep.Axes = new int[1] { 0 };
                    ep.StartDelay = 0;
                    CustomForce CF = new CustomForce();
                    CF.ChannelCount = 2;
                    CF.SampleCount = 12;
                    CF.SamplePeriod = 1000; 
                    int[]  forces;
                    forces = new int[24];
                    forces[0] = 79;
                    forces[1] = 0;
                    forces[2] = 0;
                    forces[3] = 0;
                    forces[4] = 0;
                    forces[5] = 0;
                    forces[6] = 0;
                    forces[7] = 0;
                    forces[8] = 0;
                    forces[9] = 0;
                    forces[10] = 0;
                    forces[11] = 0;
                    forces[12] = 0;
                    forces[13] = 0;
                    forces[14] = 0;
                    forces[15] = 0;
                    forces[16] = 0;
                    forces[17] = 0;
                    forces[18] = 0;
                    forces[19] = 0;
                    forces[20] = 0;
                    forces[21] = 0;
                    forces[22] = 0;
                    forces[23] = 0;
                    CF.ForceData = forces;
                    ep.Parameters = CF;

                    Effect e = new Effect(joystick, ei.Guid, ep);//<-- trows the DX error. 
                    effect = e;
                    e.Start();
                }
            }
        }

Here is the error

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.

I marked the section of code where the error occurs. I recall doing some debugging in IE once where I could attach a processes, can that be done with some DX dll of sorts? There must be a way to get more detailed info here. I tried contacting sharpDX but they don't seem to frequent the forums much.

\$\endgroup\$
1
  • \$\begingroup\$ I'm getting the exact same error, did you managed to solve? \$\endgroup\$ Commented Apr 8, 2020 at 23:39

1 Answer 1

1
\$\begingroup\$

I was having the exact same error on the same line, and I managed to solve by completing all the properties of the EffectParameters object.

Mine was the ep.TriggerButton, that I changed from 0 to -1.

I know that you already have this property set on yours, but maybe some other property that have wrong value/not set.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .