ButtonToggle() public method

public ButtonToggle ( uint joystickIndex, uint value, bool isPressed ) : void
joystickIndex uint
value uint
isPressed bool
return void
        public static void OutputMappingForJoyStick(byte[] response, JoystickController jController, uint controllerIndex,uint deadzone)
        {
            if (response[1] == 1 && response[3] == 240 && response[5] == 19)
            {
                if (response[8] == 0)
                {
                    jController.AxisSet(controllerIndex, 0, 8);
                }
                if (response[9] == 0)
                {
                    jController.AxisSet(controllerIndex, 0, 9);
                }
                if (response[11] < deadzone && response[13] < deadzone)
                {
                    jController.AxisSet(controllerIndex, 0, 11);
                    jController.AxisSet(controllerIndex, 0, 13);
                }
                if (response[15] < deadzone && response[17] < deadzone)
                {
                    jController.AxisSet(controllerIndex, 0, 15);
                    jController.AxisSet(controllerIndex, 0, 17);
                }
                //0 1 0 240 0 19 0 XX 0 0 32 12 92 0 44 6 163 247
                //a=16, b=32, x=64, y=128
                if (response[7] > 0)
                {
                    var b = (Bits)response[7];

                    string[] sArray = b.ToString().Replace(" ", string.Empty).Split(',');
                    foreach (string s in sArray)
                    {
                        jController.ButtonToggle(controllerIndex, jController.GetJoystickKeyValue(s, 1), true);
                    }
                }
                else // || response[4] == 0)
                {
                    var b = (Bits)255;
                    string[] sArray = b.ToString().Replace(" ", string.Empty).Split(',');
                    foreach (string s in sArray)
                    {
                        if (s != "NA")
                        {
                            jController.ButtonToggle(controllerIndex, jController.GetJoystickKeyValue(s, 1), false);
                        }
                    }
                }
                if (response[6] > 0)
                {
                    var b = (Bits2)response[6];

                    string[] sArray = b.ToString().Replace(" ", string.Empty).Split(',');
                    foreach (string s in sArray)
                    {
                        if (s.Contains("UP") || s.Contains("DOWN") || s.Contains("LEFT") || s.Contains("RIGHT"))
                        {
                            previousDPad.Enqueue(s);
                            if (previousDPad.Count > 2)
                            {
                                //Store a queue of dpad events as you can only press two directions on the dpad at the same time
                                //But an evant to release the dpad isn't send until all directions are released
                                string dequeudDPad = previousDPad.Dequeue();
                                jController.ButtonToggle(controllerIndex, jController.GetJoystickKeyValue(dequeudDPad, 2), false);
                            }
                        }
                        jController.ButtonToggle(controllerIndex, jController.GetJoystickKeyValue(s, 2), true);
                    }
                }
                else
                {
                    var b2 = (Bits2)255;
                    string[] sArray = b2.ToString().Replace(" ", string.Empty).Split(',');
                    foreach (string s in sArray)
                    {
                        if (s != "NA")
                        {
                            jController.ButtonToggle(controllerIndex, jController.GetJoystickKeyValue(s, 2), false);
                        }
                    }
                    previousDPad.Clear();
                }
                if (response[8] > 0)
                {
                    //Left Trigger
                    int v = response[8];
                    if (v < 0)
                    {
                        v = 0;
                    }
                    jController.AxisSet(controllerIndex, -response[8]/2, 8);
                }
                if (response[9] > 0)
                {
                    int v = response[9];
                    if (v > 0)
                    {
                        v = 0;
                    }
                    jController.AxisSet(controllerIndex, response[9]/2, 9);
                }
                if (response[11] > deadzone || response[13] > deadzone)
                {
                    int x = response[11];
                    if (x >= 128) //What why? Why does MS provide 4 points to position in 2d space? Why do the values jump at a certain point? Why... Why...
                    {
                        x = x - 255;
                    }
                    jController.AxisSet(controllerIndex, x, 11);
                    int y = response[13];
                    if (y >= 128) //What why? Why does MS provide 4 points to position in 2d space? Why do the values jump at a certain point? Why... Why...
                    {
                        y = y - 255; //Why is the y stick inverted?
                    }
                    jController.AxisSet(controllerIndex, -y, 13);
                }
                if (response[15] > deadzone || response[17] > deadzone)
                {
                    int x = response[15];
                    if (x >= 128) //What why? Why does MS provide 4 points to position in 2d space? Why do the values jump at a certain point? Why... Why...
                    {
                        x = x - 255;
                    }
                    jController.AxisSet(controllerIndex, -x, 15);
                    int y = response[17];
                    if (y >= 128) //What why? Why does MS provide 4 points to position in 2d space? Why do the values jump at a certain point? Why... Why...
                    {
                        y = y - 255; //Why is the y stick inverted?
                    }
                    jController.AxisSet(controllerIndex, -y, 17);
                }
            }
        }