Example #1
0
        static uint XInputGetDSoundAudioDeviceGuids_Hooked(int dwUserIndex, out Guid pDSoundRenderGuid, out Guid pDSoundCaptureGuid)
        {
            pDSoundRenderGuid  = new Guid();
            pDSoundCaptureGuid = new Guid();

            try
            {
                ControllerReader myController = ControllerReader.Instance;

                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }
                //TODO
                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputGetDSoundAudioDeviceGuids");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Example #2
0
        static uint XInputGetBatteryInformation_Hooked(int dwUserIndex, int devType, out BatteryInformation pBatteryInformation)
        {
            pBatteryInformation = new BatteryInformation();
            try
            {
                ControllerReader myController = ControllerReader.Instance;

                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                pBatteryInformation.BatteryType  = BatteryType.Wired;
                pBatteryInformation.BatteryLevel = BatteryLevel.Full;

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputGetBatteryInformation");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Example #3
0
        static uint XInputGetKeystroke_Hooked(int dwUserIndex, int dwReserved, out Keystroke pKeystroke)
        {
            pKeystroke = new Keystroke();
            try
            {
                ControllerReader myController = ControllerReader.Instance;
                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                //TODO

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputGetKeystroke");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_EMPTY);
        }
Example #4
0
        static uint XInputSetState_Hooked(int dwUserIndex, ref Vibration pVibration)
        {
            try
            {
                ControllerReader myController = ControllerReader.Instance;

                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                int leftVal  = ThreadController.iround(((float)pVibration.LeftMotorSpeed / 65535) * 255);
                int rightVal = ThreadController.iround(((float)pVibration.RightMotorSpeed / 65535) * 255);
                myController.controllers[dwUserIndex].Vibrate(0, 0, leftVal, rightVal, dwUserIndex);

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputSetState dwUserIndex = " + dwUserIndex);
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Example #5
0
        static uint XInputGetCapabilities_Hooked(int dwUserIndex, DeviceQueryType dwFlags, out Capabilities pCapabilities)
        {
            pCapabilities = new Capabilities();
            try
            {
                if (dwFlags > DeviceQueryType.Gamepad)
                {
                    return(ERROR_BAD_ARGUMENTS);
                }

                ControllerReader myController = ControllerReader.Instance;
                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                pCapabilities.Flags   = CapabilityFlags.VoiceSupported;
                pCapabilities.Type    = DeviceType.Gamepad;
                pCapabilities.SubType = DeviceSubType.Gamepad;

                pCapabilities.Gamepad.Buttons = GamepadButtonFlags.A | GamepadButtonFlags.B | GamepadButtonFlags.Back | GamepadButtonFlags.DPadDown
                                                | GamepadButtonFlags.DPadLeft | GamepadButtonFlags.DPadRight | GamepadButtonFlags.DPadUp | GamepadButtonFlags.LeftShoulder | GamepadButtonFlags.LeftThumb
                                                | GamepadButtonFlags.RightShoulder | GamepadButtonFlags.RightThumb | GamepadButtonFlags.Start | GamepadButtonFlags.X | GamepadButtonFlags.Y;

                pCapabilities.Gamepad.LeftTrigger  = 0xFF;
                pCapabilities.Gamepad.RightTrigger = 0xFF;

                pCapabilities.Gamepad.LeftThumbX  = short.MaxValue;
                pCapabilities.Gamepad.LeftThumbY  = short.MaxValue;
                pCapabilities.Gamepad.RightThumbX = short.MaxValue;
                pCapabilities.Gamepad.RightThumbY = short.MaxValue;

                pCapabilities.Vibration.LeftMotorSpeed  = 0xFF;
                pCapabilities.Vibration.RightMotorSpeed = 0xFF;

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputGetCapabilities");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Example #6
0
        static void Main(string[] args)
        {
            ControllerReader myController = ControllerReader.Instance;
            int x = 0;

            while (x < 5)
            {
                Thread.Sleep(1000);
                ++x;
            }
            myController.CloseController();

            XboxOneController.State lol = new XboxOneController.State();
            lol.PacketNumber = 1;
        }
Example #7
0
        public PactSchemaService(PactOptions options)
        {
            this._options     = options;
            this._jsonOptions = new JsonSerializerOptions
            {
                Converters           = { new UnionConverterFactory() },
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                IgnoreNullValues     = true
            };
            var typeProvider        = this._options.TypeProvider ?? new TypeProvider();
            var typeChecker         = new TypeChecker(typeProvider);
            var distinctTypeQueue   = new DistinctTypeQueue();
            var typeReferenceReader = new TypeReferenceReader(typeChecker, distinctTypeQueue);
            var distinctTypeReader  = new DistinctTypeReader(typeChecker, typeReferenceReader);
            var methodReader        = new MethodReader(typeChecker, typeReferenceReader);
            var controllerReader    = new ControllerReader(methodReader);

            this._schemaReader = new SchemaReader(distinctTypeQueue, distinctTypeReader, controllerReader, typeProvider);
        }
Example #8
0
        static uint XInputGetState_Hooked(int dwUserIndex, out State pState)
        {
            pState = new State();
            try
            {
                ControllerReader myController = ControllerReader.Instance;

                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                pState.Gamepad.LeftTrigger  = myController.controllers[dwUserIndex].state.leftTrigger;
                pState.Gamepad.RightTrigger = myController.controllers[dwUserIndex].state.rightTrigger;
                pState.Gamepad.LeftThumbX   = myController.controllers[dwUserIndex].state.thumbLX;
                pState.Gamepad.LeftThumbY   = myController.controllers[dwUserIndex].state.thumbLY;
                pState.Gamepad.RightThumbX  = myController.controllers[dwUserIndex].state.thumbRX;
                pState.Gamepad.RightThumbY  = myController.controllers[dwUserIndex].state.thumbRY;

                pState.Gamepad.Buttons = 0;

                if (myController.controllers[dwUserIndex].state.view != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.Back;
                }
                if (myController.controllers[dwUserIndex].state.leftThumb != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.LeftThumb;
                }
                if (myController.controllers[dwUserIndex].state.rightThumb != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.RightThumb;
                }
                if (myController.controllers[dwUserIndex].state.menu != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.Start;
                }

                if (myController.controllers[dwUserIndex].state.up != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.DPadUp;
                }
                if (myController.controllers[dwUserIndex].state.right != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.DPadRight;
                }
                if (myController.controllers[dwUserIndex].state.down != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.DPadDown;
                }
                if (myController.controllers[dwUserIndex].state.left != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.DPadLeft;
                }

                if (myController.controllers[dwUserIndex].state.leftShoulder != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.LeftShoulder;
                }
                if (myController.controllers[dwUserIndex].state.rightShoulder != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.RightShoulder;
                }

                if (myController.controllers[dwUserIndex].state.yButton != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.Y;
                }
                if (myController.controllers[dwUserIndex].state.bButton != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.B;
                }
                if (myController.controllers[dwUserIndex].state.aButton != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.A;
                }
                if (myController.controllers[dwUserIndex].state.xButton != 0)
                {
                    pState.Gamepad.Buttons |= SharpDX.XInput.GamepadButtonFlags.X;
                }

                pState.PacketNumber = myController.controllers[dwUserIndex].tickCount;

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputGetState");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }