Ejemplo n.º 1
0
 static uint GetRawInputData_hook(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (uiCommand == RID_HEADER)
             {
                 This.Queue.Push("GetRawInputData RID_HEADER");
             }
             else if (uiCommand == RID_INPUT)
             {
                 This.Queue.Push("GetRawInputData RID_INPUT");
             }
             else
             {
                 This.Queue.Push("GetRawInputData " + uiCommand);
             }
         }
     }
     catch
     {
     }
     return(GetRawInputData(hRawInput, uiCommand, pData, ref pcbSize, cbSizeHeader));
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        static uint XInputEnable_Hooked(bool enable)
        {
            try
            {
                Vibration resetVibration = new Vibration();

                for (int x = 0; x < 4; ++x)
                {
                    XInputSetState_Hooked(x, ref resetVibration);
                }

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputEnable");
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 static int HidP_GetUsages_hook(HIDP_REPORT_TYPE ReportType, short UsagePage, short LinkCollection, [In, Out] HIDP_DATA[] UsageList, ref int UsageLength, IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] byte[] Report, int ReportLength)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("HidP_GetUsages");
             }
         }
     }
     catch
     {
     }
     return(HidP_GetUsages(ReportType, UsagePage, LinkCollection, UsageList, ref UsageLength, PreparsedData, Report, ReportLength));
 }
Ejemplo n.º 9
0
 static int HidP_GetValueCaps_hook(HIDP_REPORT_TYPE reportType, [In, Out] HidValueCaps[] valueCaps, ref ushort valueCapsLength, IntPtr preparsedData)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("HidP_GetValueCaps");
             }
         }
     }
     catch
     {
     }
     return(HidP_GetValueCaps(reportType, valueCaps, ref valueCapsLength, preparsedData));
 }
Ejemplo n.º 10
0
 static bool HidP_GetCaps_hook(IntPtr lpData, out HidCaps oCaps)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("HidP_GetCaps");
             }
         }
     }
     catch
     {
     }
     return(HidP_GetCaps(lpData, out oCaps));
 }
Ejemplo n.º 11
0
 static bool RegisterRawInputDevices_hook(RAWINPUTDEVICE[] pRawInputDevices, uint uiNumDevices, int cbSize)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("RegisterRawInputDevices");
             }
         }
     }
     catch
     {
     }
     return(RegisterRawInputDevices(pRawInputDevices, uiNumDevices, cbSize));
 }
Ejemplo n.º 12
0
 static uint GetRawInputDeviceList_hook([Out] RAWINPUTDEVICELIST[] pRawInputDeviceList, ref uint puiNumDevices, uint cbSize)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("GetRawInputDeviceInfo");
             }
         }
     }
     catch
     {
     }
     return(GetRawInputDeviceList(pRawInputDeviceList, ref puiNumDevices, cbSize));
 }
 static uint GetRawInputDeviceInfo_hook(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("GetRawInputDeviceInfo");
             }
         }
     }
     catch
     {
     }
     return(GetRawInputDeviceInfo(hDevice, uiCommand, pData, ref pcbSize));
 }
Ejemplo n.º 14
0
 static uint XInputGetStateEx_Hooked(int playerIndex, out State pState)
 {
     try
     {
         XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;
         //TODO
         lock (This.Queue)
         {
             if (This.Queue.Count < 1000)
             {
                 This.Queue.Push("XInputGetStateEx");
             }
         }
     }
     catch
     {
     }
     return(XInputGetStateEx(playerIndex, out pState));
 }
Ejemplo n.º 15
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);
        }