Beispiel #1
0
        public XInputState GetControllerState(uint controllerId)
        {
            var result   = new XInputState();
            var opResult = XInputInvoker.XInputGetState(controllerId, ref result);

            switch (opResult)
            {
            case XInputOpResult.Success:
                return(result);

            case XInputOpResult.Error_DeviceNotConnected:
                throw new TurboXInputException(TurboXInputExceptionCode.DeviceNotConnected);

            default:
                throw new TurboXInputException(TurboXInputExceptionCode.UnexpectedError, "Error Code: " + opResult.ToString());
            }
        }
Beispiel #2
0
        public IEnumerable <uint> GetControllers()
        {
            var result = new List <uint>();

            for (uint i = 0; i < MaxScannedPlayer; i++)
            {
                var cab   = new XInputCapabilities();
                var avail = XInputInvoker.XInputGetCapabilities(i, XInputGetCapabilitiesFlag.XINPUT_FLAG_GAMEPAD, ref cab);

                if (avail == XInputOpResult.Success)
                {
                    result.Add(i);
                }
            }

            return(result);
        }