public XINPUT_GAMEPAD Parse()

in ScpControl/BusDevice.cs [158:289]


        public XINPUT_GAMEPAD Parse(ScpHidReport inputReport)
        {
            var xButton = X360Button.None;
            var output = new XINPUT_GAMEPAD();

            switch (inputReport.Model)
            {
                case DsModel.DS3:
                {
                    // select & start
                    if (inputReport[Ds3Button.Select].IsPressed) xButton |= X360Button.Back;
                    if (inputReport[Ds3Button.Start].IsPressed) xButton |= X360Button.Start;

                    // d-pad
                    if (inputReport[Ds3Button.Up].IsPressed) xButton |= X360Button.Up;
                    if (inputReport[Ds3Button.Right].IsPressed) xButton |= X360Button.Right;
                    if (inputReport[Ds3Button.Down].IsPressed) xButton |= X360Button.Down;
                    if (inputReport[Ds3Button.Left].IsPressed) xButton |= X360Button.Left;

                    // shoulders
                    if (inputReport[Ds3Button.L1].IsPressed) xButton |= X360Button.LB;
                    if (inputReport[Ds3Button.R1].IsPressed) xButton |= X360Button.RB;

                    // face buttons
                    if (inputReport[Ds3Button.Triangle].IsPressed) xButton |= X360Button.Y;
                    if (inputReport[Ds3Button.Circle].IsPressed) xButton |= X360Button.B;
                    if (inputReport[Ds3Button.Cross].IsPressed) xButton |= X360Button.A;
                    if (inputReport[Ds3Button.Square].IsPressed) xButton |= X360Button.X;

                    // PS/Guide
                    if (inputReport[Ds3Button.Ps].IsPressed) xButton |= X360Button.Guide;

                    // thumbs
                    if (inputReport[Ds3Button.L3].IsPressed) xButton |= X360Button.LS;
                    if (inputReport[Ds3Button.R3].IsPressed) xButton |= X360Button.RS;

                    // face buttons
                    output.wButtons = (ushort) xButton;

                    // trigger
                    output.bLeftTrigger = inputReport[Ds3Axis.L2].Value;
                    output.bRightTrigger = inputReport[Ds3Axis.R2].Value;

                    if (!DsMath.DeadZone(GlobalConfiguration.Instance.DeadZoneL, 
                        inputReport[Ds3Axis.Lx].Value,
                        inputReport[Ds3Axis.Ly].Value))
                        // Left Stick DeadZone
                    {
                        output.sThumbLX =
                            (short)
                                +DsMath.Scale(inputReport[Ds3Axis.Lx].Value, GlobalConfiguration.Instance.FlipLX);
                        output.sThumbLY =
                            (short)
                                -DsMath.Scale(inputReport[Ds3Axis.Ly].Value, GlobalConfiguration.Instance.FlipLY);
                    }

                    if (!DsMath.DeadZone(GlobalConfiguration.Instance.DeadZoneR,
                        inputReport[Ds3Axis.Rx].Value,
                        inputReport[Ds3Axis.Ry].Value))
                        // Right Stick DeadZone
                    {
                        output.sThumbRX =
                            (short)
                                +DsMath.Scale(inputReport[Ds3Axis.Rx].Value, GlobalConfiguration.Instance.FlipRX);
                        output.sThumbRY =
                            (short)
                                -DsMath.Scale(inputReport[Ds3Axis.Ry].Value, GlobalConfiguration.Instance.FlipRY);
                    }
                }
                    break;

                case DsModel.DS4:
                {
                    if (inputReport[Ds4Button.Share].IsPressed) xButton |= X360Button.Back;
                    if (inputReport[Ds4Button.Options].IsPressed) xButton |= X360Button.Start;

                    if (inputReport[Ds4Button.Up].IsPressed) xButton |= X360Button.Up;
                    if (inputReport[Ds4Button.Right].IsPressed) xButton |= X360Button.Right;
                    if (inputReport[Ds4Button.Down].IsPressed) xButton |= X360Button.Down;
                    if (inputReport[Ds4Button.Left].IsPressed) xButton |= X360Button.Left;

                    if (inputReport[Ds4Button.L1].IsPressed) xButton |= X360Button.LB;
                    if (inputReport[Ds4Button.R1].IsPressed) xButton |= X360Button.RB;

                    if (inputReport[Ds4Button.Triangle].IsPressed) xButton |= X360Button.Y;
                    if (inputReport[Ds4Button.Circle].IsPressed) xButton |= X360Button.B;
                    if (inputReport[Ds4Button.Cross].IsPressed) xButton |= X360Button.A;
                    if (inputReport[Ds4Button.Square].IsPressed) xButton |= X360Button.X;

                    if (inputReport[Ds4Button.Ps].IsPressed) xButton |= X360Button.Guide;

                    if (inputReport[Ds4Button.L3].IsPressed) xButton |= X360Button.LS;
                    if (inputReport[Ds4Button.R3].IsPressed) xButton |= X360Button.RS;

                    // face buttons
                    output.wButtons = (ushort) xButton;

                    // trigger
                    output.bLeftTrigger = inputReport[Ds4Axis.L2].Value;
                    output.bRightTrigger = inputReport[Ds4Axis.R2].Value;

                    if (!DsMath.DeadZone(GlobalConfiguration.Instance.DeadZoneL, 
                        inputReport[Ds4Axis.Lx].Value,
                        inputReport[Ds4Axis.Ly].Value))
                        // Left Stick DeadZone
                    {
                        output.sThumbLX =
                            (short)
                                +DsMath.Scale(inputReport[Ds4Axis.Lx].Value, GlobalConfiguration.Instance.FlipLX);
                        output.sThumbLY =
                            (short)
                                -DsMath.Scale(inputReport[Ds4Axis.Ly].Value, GlobalConfiguration.Instance.FlipLY);
                    }

                    if (!DsMath.DeadZone(GlobalConfiguration.Instance.DeadZoneR, 
                        inputReport[Ds4Axis.Rx].Value,
                        inputReport[Ds4Axis.Ry].Value))
                        // Right Stick DeadZone
                    {
                        output.sThumbRX =
                            (short)
                                +DsMath.Scale(inputReport[Ds4Axis.Rx].Value, GlobalConfiguration.Instance.FlipRX);
                        output.sThumbRY =
                            (short)
                                -DsMath.Scale(inputReport[Ds4Axis.Ry].Value, GlobalConfiguration.Instance.FlipRY);
                    }
                }
                    break;
            }

            return output;
        }