Good Place. Good Things. Good Time.

SharpDX Error ‘The Parameter is Incorrect’, how to debug from dx?

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.

Search more articles here: SharpDX Error 'The Parameter is Incorrect', how to debug from dx?

Read original article here: SharpDX Error 'The Parameter is Incorrect', how to debug from dx?



Disclaimers and Denial of responsibility..!

Denial of responsibility! TheTopMag.com is an automatic aggregator of all media around the world. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – jamesonline999@gmail.com . The content will be deleted within 72 hours.
You might also like
Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.