public void AssignFrom(DeviceState st, bool controlsOnly)
        {
            LeftStick  = st.LeftStick;
            RightStick = st.RightStick;
            Triggers   = st.Triggers;
            DPad       = st.DPad;
            DPadNum    = st.DPadNum;

            A               = st.A;
            B               = st.B;
            X               = st.X;
            Y               = st.Y;
            leftShoulder    = st.leftShoulder;
            rightShoulder   = st.rightShoulder;
            leftTrigger     = st.leftTrigger;
            rightTrigger    = st.rightTrigger;
            start           = st.start;
            back            = st.back;
            logo            = st.logo;
            leftStickClick  = st.leftStickClick;
            rightStickClick = st.rightStickClick;
            BigPad          = st.BigPad;

            if (!controlsOnly)
            {
                gamepadType = st.gamepadType;
                updateCount = st.updateCount;

                //DeviceId = st.DeviceId;
                //Device = st.Device;
            }
        }
        public void SetDPadNum(EGamepadType type, int dpadNum)
        {
            DPadNum = dpadNum;

            switch (type)
            {
            case EGamepadType.PS4DS4_BT:
                DPad = dirNumToVec(ref DPadNum, 0, 8);
                break;

            case EGamepadType.X360_USB:
                DPad = dirNumToVec(ref DPadNum, 1, 0);
                break;

            case EGamepadType.EIGP20_BT:
                DPad = dirNumToVec(ref DPadNum, -2, 0);
                break;

            case EGamepadType.XBONES_BT:
                DPad = dirNumToVec(ref DPadNum, 1, 0);
                break;

            default:
                break;
            }
        }
        private void OnDeviceOpened(IAsyncOperation <HidDevice> action, AsyncStatus status)
        {
            if (status == AsyncStatus.Completed)
            {
                HidDevice Device = action.GetResults();
                if (Device != null)
                {
                    Device.InputReportReceived += Device_InputReportReceived;
                    Device.GetInputReportAsync();

                    // Get the gamepad type from the vendor and product id
                    gamepadType = GetGamepadType(Device.VendorId, Device.ProductId);

                    // Try to get numeric controls.  This is broken I think

                    /*IReadOnlyList<HidNumericControlDescription> cs = Device.GetNumericControlDescriptions(HidReportType.Input, 0, 0);
                     * for (int i = 0; i < cs.Count; ++i)
                     * {
                     *      Debug.WriteLine("up: " + cs[i].UsagePage + " uid: " + cs[i].UsageId);
                     * }*/
                }
                else
                {
                    //Debug.WriteLine("Failed, why");
                    //var status1 = Windows.Devices.Enumeration.DeviceAccessInformation.CreateFromId(DeviceId);
                    //var c = status1.CurrentStatus;
                }
            }
        }
Exemple #4
0
        public static int[] GetNumericControls(EGamepadType type)
        {
            switch (type)
            {
            case EGamepadType.PS4DS4_BT:
                return(new int[] { 48, 49, 50, 51, 52, 53, 57 });

            case EGamepadType.X360_USB:
                return(new int[] { 48, 49, 50, 51, 52, 57 });

            case EGamepadType.EIGP20_BT:
                return(new int[] { 48, 49, 51, 52, 57 });

            default:
                break;
            }
            return(new int[0]);
        }