Exemple #1
0
        public override void ConvertandSendReport(DS4State state, int device)
        {
            Xbox360Buttons tempButtons = 0;

            unchecked
            {
                if (state.Share)
                {
                    tempButtons |= Xbox360Buttons.Back;
                }
                if (state.L3)
                {
                    tempButtons |= Xbox360Buttons.LeftThumb;
                }
                if (state.R3)
                {
                    tempButtons |= Xbox360Buttons.RightThumb;
                }
                if (state.Options)
                {
                    tempButtons |= Xbox360Buttons.Start;
                }

                if (state.DpadUp)
                {
                    tempButtons |= Xbox360Buttons.Up;
                }
                if (state.DpadRight)
                {
                    tempButtons |= Xbox360Buttons.Right;
                }
                if (state.DpadDown)
                {
                    tempButtons |= Xbox360Buttons.Down;
                }
                if (state.DpadLeft)
                {
                    tempButtons |= Xbox360Buttons.Left;
                }

                if (state.L1)
                {
                    tempButtons |= Xbox360Buttons.LeftShoulder;
                }
                if (state.R1)
                {
                    tempButtons |= Xbox360Buttons.RightShoulder;
                }

                if (state.Triangle)
                {
                    tempButtons |= Xbox360Buttons.Y;
                }
                if (state.Circle)
                {
                    tempButtons |= Xbox360Buttons.B;
                }
                if (state.Cross)
                {
                    tempButtons |= Xbox360Buttons.A;
                }
                if (state.Square)
                {
                    tempButtons |= Xbox360Buttons.X;
                }
                if (state.PS)
                {
                    tempButtons |= Xbox360Buttons.Guide;
                }
                report.SetButtonsFull(tempButtons);
            }

            report.LeftTrigger  = state.L2;
            report.RightTrigger = state.R2;

            SASteeringWheelEmulationAxisType steeringWheelMappedAxis = Global.GetSASteeringWheelEmulationAxis(device);

            switch (steeringWheelMappedAxis)
            {
            case SASteeringWheelEmulationAxisType.None:
                report.LeftThumbX  = AxisScale(state.LX, false);
                report.LeftThumbY  = AxisScale(state.LY, true);
                report.RightThumbX = AxisScale(state.RX, false);
                report.RightThumbY = AxisScale(state.RY, true);
                break;

            case SASteeringWheelEmulationAxisType.LX:
                report.LeftThumbX  = (short)state.SASteeringWheelEmulationUnit;
                report.LeftThumbY  = AxisScale(state.LY, true);
                report.RightThumbX = AxisScale(state.RX, false);
                report.RightThumbY = AxisScale(state.RY, true);
                break;

            case SASteeringWheelEmulationAxisType.LY:
                report.LeftThumbX  = AxisScale(state.LX, false);
                report.LeftThumbY  = (short)state.SASteeringWheelEmulationUnit;
                report.RightThumbX = AxisScale(state.RX, false);
                report.RightThumbY = AxisScale(state.RY, true);
                break;

            case SASteeringWheelEmulationAxisType.RX:
                report.LeftThumbX  = AxisScale(state.LX, false);
                report.LeftThumbY  = AxisScale(state.LY, true);
                report.RightThumbX = (short)state.SASteeringWheelEmulationUnit;
                report.RightThumbY = AxisScale(state.RY, true);
                break;

            case SASteeringWheelEmulationAxisType.RY:
                report.LeftThumbX  = AxisScale(state.LX, false);
                report.LeftThumbY  = AxisScale(state.LY, true);
                report.RightThumbX = AxisScale(state.RX, false);
                report.RightThumbY = (short)state.SASteeringWheelEmulationUnit;
                break;

            case SASteeringWheelEmulationAxisType.L2R2:
                report.LeftTrigger = report.RightTrigger = 0;
                if (state.SASteeringWheelEmulationUnit >= 0)
                {
                    report.LeftTrigger = (Byte)state.SASteeringWheelEmulationUnit;
                }
                else
                {
                    report.RightTrigger = (Byte)state.SASteeringWheelEmulationUnit;
                }
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1X:
            case SASteeringWheelEmulationAxisType.VJoy2X:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_X);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Y:
            case SASteeringWheelEmulationAxisType.VJoy2Y:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Y);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Z:
            case SASteeringWheelEmulationAxisType.VJoy2Z:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Z);
                goto case SASteeringWheelEmulationAxisType.None;

            default:
                // Should never come here but just in case use the NONE case as default handler....
                goto case SASteeringWheelEmulationAxisType.None;
            }

            cont.SendReport(report);
        }
Exemple #2
0
        public override void ConvertandSendReport(DS4State state, int device)
        {
            if (!connected)
            {
                return;
            }

            cont.ResetReport();
            ushort tempButtons = 0;
            DualShock4DPadDirection tempDPad = DualShock4DPadDirection.None;
            ushort tempSpecial = 0;

            unchecked
            {
                if (state.Share)
                {
                    tempButtons |= DualShock4Button.Share.Value;
                }
                if (state.L3)
                {
                    tempButtons |= DualShock4Button.ThumbLeft.Value;
                }
                if (state.R3)
                {
                    tempButtons |= DualShock4Button.ThumbRight.Value;
                }
                if (state.Options)
                {
                    tempButtons |= DualShock4Button.Options.Value;
                }

                if (state.DpadUp && state.DpadRight)
                {
                    tempDPad = DualShock4DPadDirection.Northeast;
                }
                else if (state.DpadUp && state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.Northwest;
                }
                else if (state.DpadUp)
                {
                    tempDPad = DualShock4DPadDirection.North;
                }
                else if (state.DpadRight && state.DpadDown)
                {
                    tempDPad = DualShock4DPadDirection.Southeast;
                }
                else if (state.DpadRight)
                {
                    tempDPad = DualShock4DPadDirection.East;
                }
                else if (state.DpadDown && state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.Southwest;
                }
                else if (state.DpadDown)
                {
                    tempDPad = DualShock4DPadDirection.South;
                }
                else if (state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.West;
                }

                /*if (state.DpadUp) tempDPad = (state.DpadRight) ? DualShock4DPadValues.Northeast : DualShock4DPadValues.North;
                 * if (state.DpadRight) tempDPad = (state.DpadDown) ? DualShock4DPadValues.Southeast : DualShock4DPadValues.East;
                 * if (state.DpadDown) tempDPad = (state.DpadLeft) ? DualShock4DPadValues.Southwest : DualShock4DPadValues.South;
                 * if (state.DpadLeft) tempDPad = (state.DpadUp) ? DualShock4DPadValues.Northwest : DualShock4DPadValues.West;
                 */

                if (state.L1)
                {
                    tempButtons |= DualShock4Button.ShoulderLeft.Value;
                }
                if (state.R1)
                {
                    tempButtons |= DualShock4Button.ShoulderRight.Value;
                }
                //if (state.L2Btn) tempButtons |= DualShock4Buttons.TriggerLeft;
                //if (state.R2Btn) tempButtons |= DualShock4Buttons.TriggerRight;
                if (state.L2 > 0)
                {
                    tempButtons |= DualShock4Button.TriggerLeft.Value;
                }
                if (state.R2 > 0)
                {
                    tempButtons |= DualShock4Button.TriggerRight.Value;
                }

                if (state.Triangle)
                {
                    tempButtons |= DualShock4Button.Triangle.Value;
                }
                if (state.Circle)
                {
                    tempButtons |= DualShock4Button.Circle.Value;
                }
                if (state.Cross)
                {
                    tempButtons |= DualShock4Button.Cross.Value;
                }
                if (state.Square)
                {
                    tempButtons |= DualShock4Button.Square.Value;
                }
                if (state.PS)
                {
                    tempSpecial |= DualShock4SpecialButton.Ps.Value;
                }
                if (state.TouchButton)
                {
                    tempSpecial |= DualShock4SpecialButton.Touchpad.Value;
                }
                cont.SetButtonsFull(tempButtons);
                cont.SetSpecialButtonsFull((byte)tempSpecial);
                cont.SetDPadDirection(tempDPad);
                //report.Buttons = (ushort)tempButtons;
                //report.SpecialButtons = (byte)tempSpecial;
            }

            cont.LeftTrigger  = state.L2;
            cont.RightTrigger = state.R2;

            SASteeringWheelEmulationAxisType steeringWheelMappedAxis = Global.GetSASteeringWheelEmulationAxis(device);

            switch (steeringWheelMappedAxis)
            {
            case SASteeringWheelEmulationAxisType.None:
                cont.LeftThumbX  = state.LX;
                cont.LeftThumbY  = state.LY;
                cont.RightThumbX = state.RX;
                cont.RightThumbY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.LX:
                cont.LeftThumbX  = (byte)state.SASteeringWheelEmulationUnit;
                cont.LeftThumbY  = state.LY;
                cont.RightThumbX = state.RX;
                cont.RightThumbY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.LY:
                cont.LeftThumbX  = state.LX;
                cont.LeftThumbY  = (byte)state.SASteeringWheelEmulationUnit;
                cont.RightThumbX = state.RX;
                cont.RightThumbY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.RX:
                cont.LeftThumbX  = state.LX;
                cont.LeftThumbY  = state.LY;
                cont.RightThumbX = (byte)state.SASteeringWheelEmulationUnit;
                cont.RightThumbY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.RY:
                cont.LeftThumbX  = state.LX;
                cont.LeftThumbY  = state.LY;
                cont.RightThumbX = state.RX;
                cont.RightThumbY = (byte)state.SASteeringWheelEmulationUnit;
                break;

            case SASteeringWheelEmulationAxisType.L2R2:
                cont.LeftTrigger = cont.RightTrigger = 0;
                if (state.SASteeringWheelEmulationUnit >= 0)
                {
                    cont.LeftTrigger = (Byte)state.SASteeringWheelEmulationUnit;
                }
                else
                {
                    cont.RightTrigger = (Byte)state.SASteeringWheelEmulationUnit;
                }
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1X:
            case SASteeringWheelEmulationAxisType.VJoy2X:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_X);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Y:
            case SASteeringWheelEmulationAxisType.VJoy2Y:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Y);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Z:
            case SASteeringWheelEmulationAxisType.VJoy2Z:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Z);
                goto case SASteeringWheelEmulationAxisType.None;

            default:
                // Should never come here but just in case use the NONE case as default handler....
                goto case SASteeringWheelEmulationAxisType.None;
            }

            cont.SubmitReport();
        }
        public override unsafe void ConvertandSendReport(DS4State state, int device)
        {
            if (!connected)
            {
                return;
            }

            ushort tempButtons = 0;
            DualShock4DPadDirection tempDPad = DualShock4DPadDirection.None;
            ushort tempSpecial = 0;

            unchecked
            {
                if (state.Share)
                {
                    tempButtons |= DualShock4Button.Share.Value;
                }
                if (state.L3)
                {
                    tempButtons |= DualShock4Button.ThumbLeft.Value;
                }
                if (state.R3)
                {
                    tempButtons |= DualShock4Button.ThumbRight.Value;
                }
                if (state.Options)
                {
                    tempButtons |= DualShock4Button.Options.Value;
                }

                if (state.DpadUp && state.DpadRight)
                {
                    tempDPad = DualShock4DPadDirection.Northeast;
                }
                else if (state.DpadUp && state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.Northwest;
                }
                else if (state.DpadUp)
                {
                    tempDPad = DualShock4DPadDirection.North;
                }
                else if (state.DpadRight && state.DpadDown)
                {
                    tempDPad = DualShock4DPadDirection.Southeast;
                }
                else if (state.DpadRight)
                {
                    tempDPad = DualShock4DPadDirection.East;
                }
                else if (state.DpadDown && state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.Southwest;
                }
                else if (state.DpadDown)
                {
                    tempDPad = DualShock4DPadDirection.South;
                }
                else if (state.DpadLeft)
                {
                    tempDPad = DualShock4DPadDirection.West;
                }

                /*if (state.DpadUp) tempDPad = (state.DpadRight) ? DualShock4DPadValues.Northeast : DualShock4DPadValues.North;
                 * if (state.DpadRight) tempDPad = (state.DpadDown) ? DualShock4DPadValues.Southeast : DualShock4DPadValues.East;
                 * if (state.DpadDown) tempDPad = (state.DpadLeft) ? DualShock4DPadValues.Southwest : DualShock4DPadValues.South;
                 * if (state.DpadLeft) tempDPad = (state.DpadUp) ? DualShock4DPadValues.Northwest : DualShock4DPadValues.West;
                 */

                if (state.L1)
                {
                    tempButtons |= DualShock4Button.ShoulderLeft.Value;
                }
                if (state.R1)
                {
                    tempButtons |= DualShock4Button.ShoulderRight.Value;
                }
                //if (state.L2Btn) tempButtons |= DualShock4Buttons.TriggerLeft;
                //if (state.R2Btn) tempButtons |= DualShock4Buttons.TriggerRight;
                if (state.L2 > 0)
                {
                    tempButtons |= DualShock4Button.TriggerLeft.Value;
                }
                if (state.R2 > 0)
                {
                    tempButtons |= DualShock4Button.TriggerRight.Value;
                }

                if (state.Triangle)
                {
                    tempButtons |= DualShock4Button.Triangle.Value;
                }
                if (state.Circle)
                {
                    tempButtons |= DualShock4Button.Circle.Value;
                }
                if (state.Cross)
                {
                    tempButtons |= DualShock4Button.Cross.Value;
                }
                if (state.Square)
                {
                    tempButtons |= DualShock4Button.Square.Value;
                }
                if (state.PS)
                {
                    tempSpecial |= DualShock4SpecialButton.Ps.Value;
                }
                if (state.OutputTouchButton)
                {
                    tempSpecial |= DualShock4SpecialButton.Touchpad.Value;
                }

                outDS4Report.wButtons = tempButtons;
                // Frame counter is high 6 bits. Low 2 bits is for extra buttons (PS, TP Click)
                outDS4Report.bSpecial  = (byte)(tempSpecial | (state.FrameCounter << 2));
                outDS4Report.wButtons |= tempDPad.Value;
            }

            outDS4Report.bTriggerL = state.L2;
            outDS4Report.bTriggerR = state.R2;

            SASteeringWheelEmulationAxisType steeringWheelMappedAxis = Global.GetSASteeringWheelEmulationAxis(device);

            switch (steeringWheelMappedAxis)
            {
            case SASteeringWheelEmulationAxisType.None:
                outDS4Report.bThumbLX = state.LX;
                outDS4Report.bThumbLY = state.LY;
                outDS4Report.bThumbRX = state.RX;
                outDS4Report.bThumbRY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.LX:
                outDS4Report.bThumbLX = (byte)state.SASteeringWheelEmulationUnit;
                outDS4Report.bThumbLY = state.LY;
                outDS4Report.bThumbRX = state.RX;
                outDS4Report.bThumbRY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.LY:
                outDS4Report.bThumbLX = state.LX;
                outDS4Report.bThumbLY = (byte)state.SASteeringWheelEmulationUnit;
                outDS4Report.bThumbRX = state.RX;
                outDS4Report.bThumbRY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.RX:
                outDS4Report.bThumbLX = state.LX;
                outDS4Report.bThumbLY = state.LY;
                outDS4Report.bThumbRX = (byte)state.SASteeringWheelEmulationUnit;
                outDS4Report.bThumbRY = state.RY;
                break;

            case SASteeringWheelEmulationAxisType.RY:
                outDS4Report.bThumbLX = state.LX;
                outDS4Report.bThumbLY = state.LY;
                outDS4Report.bThumbRX = state.RX;
                outDS4Report.bThumbRY = (byte)state.SASteeringWheelEmulationUnit;
                break;

            case SASteeringWheelEmulationAxisType.L2R2:
                outDS4Report.bTriggerL = outDS4Report.bTriggerR = 0;
                if (state.SASteeringWheelEmulationUnit >= 0)
                {
                    outDS4Report.bTriggerL = (Byte)state.SASteeringWheelEmulationUnit;
                }
                else
                {
                    outDS4Report.bTriggerR = (Byte)state.SASteeringWheelEmulationUnit;
                }
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1X:
            case SASteeringWheelEmulationAxisType.VJoy2X:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_X);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Y:
            case SASteeringWheelEmulationAxisType.VJoy2Y:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Y);
                goto case SASteeringWheelEmulationAxisType.None;

            case SASteeringWheelEmulationAxisType.VJoy1Z:
            case SASteeringWheelEmulationAxisType.VJoy2Z:
                DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Z);
                goto case SASteeringWheelEmulationAxisType.None;

            default:
                // Should never come here but just in case use the NONE case as default handler....
                goto case SASteeringWheelEmulationAxisType.None;
            }

            // Only worry about mapping 1 touch packet
            outDS4Report.bTouchPacketsN = 1;
            outDS4Report.sCurrentTouch.bPacketCounter    = state.TouchPacketCounter;
            outDS4Report.sCurrentTouch.bIsUpTrackingNum1 = state.TrackPadTouch0.RawTrackingNum;
            outDS4Report.sCurrentTouch.bTouchData1[0]    = (byte)(state.TrackPadTouch0.X & 0xFF);
            outDS4Report.sCurrentTouch.bTouchData1[1]    = (byte)((state.TrackPadTouch0.X >> 8) & 0x0F | (state.TrackPadTouch0.Y << 4) & 0xF0);
            outDS4Report.sCurrentTouch.bTouchData1[2]    = (byte)(state.TrackPadTouch0.Y >> 4);

            outDS4Report.sCurrentTouch.bIsUpTrackingNum2 = state.TrackPadTouch1.RawTrackingNum;
            outDS4Report.sCurrentTouch.bTouchData2[0]    = (byte)(state.TrackPadTouch1.X & 0xFF);
            outDS4Report.sCurrentTouch.bTouchData2[1]    = (byte)((state.TrackPadTouch1.X >> 8) & 0x0F | (state.TrackPadTouch1.Y << 4) & 0xF0);
            outDS4Report.sCurrentTouch.bTouchData2[2]    = (byte)(state.TrackPadTouch1.Y >> 4);

            // Flip some coordinates back to DS4 device coordinate system
            //outDS4Report.wGyroX = (short)-state.Motion.gyroYawFull;
            //outDS4Report.wGyroY = (short)state.Motion.gyroPitchFull;
            outDS4Report.wGyroX  = (short)state.Motion.gyroPitchFull;
            outDS4Report.wGyroY  = (short)-state.Motion.gyroYawFull;
            outDS4Report.wGyroZ  = (short)-state.Motion.gyroRollFull;
            outDS4Report.wAccelX = (short)-state.Motion.accelXFull;
            outDS4Report.wAccelY = (short)-state.Motion.accelYFull;
            outDS4Report.wAccelZ = (short)state.Motion.accelZFull;

            // USB DS4 v.1 battery level range is [0-11]
            outDS4Report.bBatteryLvlSpecial = (byte)(state.Battery / 11);

            outDS4Report.wTimestamp = state.ds4Timestamp;

            DS4OutDeviceExtras.CopyBytes(ref outDS4Report, rawOutReportEx);
            //Console.WriteLine("TEST: {0}, {1} {2}", outDS4Report.wGyroX, rawOutReportEx[12], rawOutReportEx[13]);
            //Console.WriteLine("OUTPUT: {0}", string.Join(", ", rawOutReportEx));
            cont.SubmitRawReport(rawOutReportEx);
        }
Exemple #4
0
        public void Parse(DS4State state, Byte[] Output, int device)
        {
            Output[0] = 0x1C;
            Output[4] = (Byte)(device + firstController);
            Output[9] = 0x14;

            for (int i = 10; i < 28; i++)
            {
                Output[i] = 0;
            }

            unchecked
            {
                if (state.Share)
                {
                    Output[10] |= (Byte)(1 << 5);              // Back
                }
                if (state.L3)
                {
                    Output[10] |= (Byte)(1 << 6);           // Left  Thumb
                }
                if (state.R3)
                {
                    Output[10] |= (Byte)(1 << 7);           // Right Thumb
                }
                if (state.Options)
                {
                    Output[10] |= (Byte)(1 << 4);                // Start
                }
                if (state.DpadUp)
                {
                    Output[10] |= (Byte)(1 << 0);               // Up
                }
                if (state.DpadRight)
                {
                    Output[10] |= (Byte)(1 << 3);                  // Down
                }
                if (state.DpadDown)
                {
                    Output[10] |= (Byte)(1 << 1);                 // Right
                }
                if (state.DpadLeft)
                {
                    Output[10] |= (Byte)(1 << 2);                 // Left
                }
                if (state.L1)
                {
                    Output[11] |= (Byte)(1 << 0);           // Left  Shoulder
                }
                if (state.R1)
                {
                    Output[11] |= (Byte)(1 << 1);           // Right Shoulder
                }
                if (state.Triangle)
                {
                    Output[11] |= (Byte)(1 << 7);                 // Y
                }
                if (state.Circle)
                {
                    Output[11] |= (Byte)(1 << 5);               // B
                }
                if (state.Cross)
                {
                    Output[11] |= (Byte)(1 << 4);              // A
                }
                if (state.Square)
                {
                    Output[11] |= (Byte)(1 << 6);               // X
                }
                if (state.PS)
                {
                    Output[11] |= (Byte)(1 << 2);           // Guide
                }
                SASteeringWheelEmulationAxisType steeringWheelMappedAxis = Global.GetSASteeringWheelEmulationAxis(device);
                Int32 ThumbLX;
                Int32 ThumbLY;
                Int32 ThumbRX;
                Int32 ThumbRY;

                Output[12] = state.L2; // Left Trigger
                Output[13] = state.R2; // Right Trigger

                switch (steeringWheelMappedAxis)
                {
                case SASteeringWheelEmulationAxisType.None:
                    ThumbLX = Scale(state.LX, false);
                    ThumbLY = Scale(state.LY, true);
                    ThumbRX = Scale(state.RX, false);
                    ThumbRY = Scale(state.RY, true);
                    break;

                case SASteeringWheelEmulationAxisType.LX:
                    ThumbLX = state.SASteeringWheelEmulationUnit;
                    ThumbLY = Scale(state.LY, true);
                    ThumbRX = Scale(state.RX, false);
                    ThumbRY = Scale(state.RY, true);
                    break;

                case SASteeringWheelEmulationAxisType.LY:
                    ThumbLX = Scale(state.LX, false);
                    ThumbLY = state.SASteeringWheelEmulationUnit;
                    ThumbRX = Scale(state.RX, false);
                    ThumbRY = Scale(state.RY, true);
                    break;

                case SASteeringWheelEmulationAxisType.RX:
                    ThumbLX = Scale(state.LX, false);
                    ThumbLY = Scale(state.LY, true);
                    ThumbRX = state.SASteeringWheelEmulationUnit;
                    ThumbRY = Scale(state.RY, true);
                    break;

                case SASteeringWheelEmulationAxisType.RY:
                    ThumbLX = Scale(state.LX, false);
                    ThumbLY = Scale(state.LY, true);
                    ThumbRX = Scale(state.RX, false);
                    ThumbRY = state.SASteeringWheelEmulationUnit;
                    break;

                case SASteeringWheelEmulationAxisType.L2R2:
                    Output[12] = Output[13] = 0;
                    if (state.SASteeringWheelEmulationUnit >= 0)
                    {
                        Output[12] = (Byte)state.SASteeringWheelEmulationUnit;
                    }
                    else
                    {
                        Output[13] = (Byte)state.SASteeringWheelEmulationUnit;
                    }
                    goto case SASteeringWheelEmulationAxisType.None;

                case SASteeringWheelEmulationAxisType.VJoy1X:
                case SASteeringWheelEmulationAxisType.VJoy2X:
                    DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_X);
                    goto case SASteeringWheelEmulationAxisType.None;

                case SASteeringWheelEmulationAxisType.VJoy1Y:
                case SASteeringWheelEmulationAxisType.VJoy2Y:
                    DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Y);
                    goto case SASteeringWheelEmulationAxisType.None;

                case SASteeringWheelEmulationAxisType.VJoy1Z:
                case SASteeringWheelEmulationAxisType.VJoy2Z:
                    DS4Windows.VJoyFeeder.vJoyFeeder.FeedAxisValue(state.SASteeringWheelEmulationUnit, ((((uint)steeringWheelMappedAxis) - ((uint)SASteeringWheelEmulationAxisType.VJoy1X)) / 3) + 1, DS4Windows.VJoyFeeder.HID_USAGES.HID_USAGE_Z);
                    goto case SASteeringWheelEmulationAxisType.None;

                default:
                    // Should never come here but just in case use the NONE case as default handler....
                    goto case SASteeringWheelEmulationAxisType.None;
                }

                Output[14] = (Byte)((ThumbLX >> 0) & 0xFF); // LX
                Output[15] = (Byte)((ThumbLX >> 8) & 0xFF);
                Output[16] = (Byte)((ThumbLY >> 0) & 0xFF); // LY
                Output[17] = (Byte)((ThumbLY >> 8) & 0xFF);
                Output[18] = (Byte)((ThumbRX >> 0) & 0xFF); // RX
                Output[19] = (Byte)((ThumbRX >> 8) & 0xFF);
                Output[20] = (Byte)((ThumbRY >> 0) & 0xFF); // RY
                Output[21] = (Byte)((ThumbRY >> 8) & 0xFF);
            }
        }