Exemplo n.º 1
0
            public static bool GetButtonDownHook(string buttonName, ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }

                if (buttonName == "Horizontal")
                {
                    if (GamepadWhisperer.GetButtonDown(state => state.DPad.Right) || GamepadWhisperer.GetButtonDown(state => state.DPad.Left))
                    {
                        __result = true;
                        return(false);
                    }
                }
                else if (buttonName == "Vertical")
                {
                    if (GamepadWhisperer.GetButtonDown(state => state.DPad.Up) || GamepadWhisperer.GetButtonDown(state => state.DPad.Down))
                    {
                        __result = true;
                        return(false);
                    }
                }
                return(true);
            }
Exemplo n.º 2
0
 public static void WindowNoneButtonCancel(ref KeyInput.Data __result)
 {
     if (_disabled)
     {
         return;
     }
     if (GamepadWhisperer.GetButtonDown(state => state.Buttons.Y) || GamepadWhisperer.GetButtonDown(state => state.Buttons.B))
     {
         __result.isKey = true;
     }
 }
Exemplo n.º 3
0
            public static void BackLogTextBack(ref KeyInput.Data __result)
            {
                if (_disabled)
                {
                    return;
                }

                if (GamepadWhisperer.RightStickDown() && WithinAngle(GamepadWhisperer.GetRightStickAngle(), 180))
                {
                    __result.isKey = true;
                }
            }
Exemplo n.º 4
0
            public static void BackLogButtonCancel(ref KeyInput.Data __result)
            {
                if (_disabled)
                {
                    return;
                }

                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.B) || GamepadWhisperer.GetButtonDown(state => state.Buttons.RightStick) && !CursorEmulator.EmulatingCursor())
                {
                    __result.isKey = true;
                }
            }
Exemplo n.º 5
0
            public static void TextNext(ref KeyInput.Data __result)
            {
                if (_disabled)
                {
                    return;
                }

                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.B))
                {
                    __result.isKey = true;
                }
            }
Exemplo n.º 6
0
 public static bool SkipButtonHook(ref bool __result)
 {
     if (_disabled)
     {
         return(true);
     }
     if (GamepadWhisperer.GetButton(state => state.Buttons.X))
     {
         __result = true;
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
            public static float?GetMovementAngle()
            {
                if (GamepadWhisperer.CurrentState.IsConnected)
                {
                    var stickPosition = GamepadWhisperer.GetLeftStickDpadCombined();
                    if (stickPosition.magnitude > 0.01f)
                    {
                        var absAngle = Vector2.Angle(Vector2.up, stickPosition);
                        return(stickPosition.x >= 0 ? absAngle : -absAngle);
                    }
                }

                return(null);
            }
Exemplo n.º 8
0
            public static bool isViewPlayerHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }
                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.RightStick) && !CursorEmulator.EmulatingCursor())
                {
                    __result = true;
                    return(false);
                }

                return(true);
            }
Exemplo n.º 9
0
            public static bool isCrouchHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }
                if (GamepadWhisperer.GetButton(state => state.Buttons.RightShoulder))
                {
                    __result = true;
                    return(false);
                }

                return(true);
            }
Exemplo n.º 10
0
            public static bool isViewTurnHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }
                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.LeftShoulder))
                {
                    __result = true;
                    return(false);
                }

                return(true);
            }
Exemplo n.º 11
0
            public static bool isCursorLockHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }
                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.B))
                {
                    __result = true;
                    return(false);
                }

                return(true);
            }
Exemplo n.º 12
0
            public static bool BackLogTextPageBackHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }

                if (GamepadWhisperer.RightStickDown() && WithinAngle(GamepadWhisperer.GetRightStickAngle(), -90))
                {
                    __result = true;
                    return(false);
                }

                return(true);
            }
Exemplo n.º 13
0
            public static bool isWalkHook(ref bool __result)
            {
                if (_disabled)
                {
                    return(true);
                }
                if (GamepadWhisperer.CurrentState.IsConnected)
                {
                    var movementAmount = GamepadWhisperer.GetLeftStickDpadCombined().magnitude;
                    if (movementAmount > 0.01f && movementAmount < 0.9f)
                    {
                        __result = true;
                        return(false);
                    }
                }

                return(true);
            }
Exemplo n.º 14
0
            public static void HSpriteUpdateHook(HSprite __instance)
            {
                if (_disabled)
                {
                    return;
                }

                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.X))
                {
                    __instance.flags.click = HFlag.ClickKind.motionchange;
                }

                if (GamepadWhisperer.GetButtonDown(state => state.Buttons.Y))
                {
                    __instance.flags.click = HFlag.ClickKind.modeChange;
                }

                if (GamepadWhisperer.GetButton(state => state.Buttons.LeftShoulder))
                {
                    __instance.flags.SpeedUpClick(-__instance.flags.rateWheelSpeedUp * Time.deltaTime * 6, 1f);

                    // Manual piston
                    if (GamepadWhisperer.GetButtonDown(state => state.Buttons.RightShoulder))
                    {
                        __instance.flags.click = HFlag.ClickKind.speedup;
                    }
                }
                else if (GamepadWhisperer.GetButton(state => state.Buttons.RightShoulder))
                {
                    __instance.flags.SpeedUpClick(__instance.flags.rateWheelSpeedUp * Time.deltaTime * 6, 1f);

                    // Manual piston
                    if (GamepadWhisperer.GetButtonDown(state => state.Buttons.LeftShoulder))
                    {
                        __instance.flags.click = HFlag.ClickKind.speedup;
                    }
                }
            }
Exemplo n.º 15
0
        public static void OnUpdate()
        {
            if (!Application.isFocused)
            {
                if (_enabled)
                {
                    LeftUp();
                    RightUp();
                }
                _enabled = false;
            }

            // Deadzone for trigger presses
            var rPressed = _previousR ? GamepadWhisperer.CurrentState.Triggers.Right > 0.1f : GamepadWhisperer.CurrentState.Triggers.Right > 0.4f;
            var lPressed = _previousL ? GamepadWhisperer.CurrentState.Triggers.Left > 0.1f : GamepadWhisperer.CurrentState.Triggers.Left > 0.4f;

            var bothPressed = rPressed && lPressed;

            if (bothPressed != _previousBoth)
            {
                _previousBoth = bothPressed;
                if (bothPressed)
                {
                    _enabled = !_enabled;

                    GamepadSupportPlugin.Logger.Log(LogLevel.Message, "Cursor mode " + (_enabled ? "ON (LTrig and RTrig for mouse buttons)" : "OFF"));

                    // Fix stuck keys
                    if (!_enabled)
                    {
                        LeftUp();
                        RightUp();
                    }
                }
            }

            if (EmulatingCursor())
            {
                var rightStick = GamepadWhisperer.GetRightStick();
                if (rightStick.magnitude > 0)
                {
                    var expStick = new Vector2(rightStick.x * Mathf.Abs(rightStick.x), rightStick.y * Mathf.Abs(rightStick.y));
                    var amount   = expStick * Time.deltaTime * 700;
                    MoveCursor(amount);
                }

                if (rPressed && !_previousR)
                {
                    LeftDown();
                }
                else if (!rPressed && _previousR)
                {
                    LeftUp();
                }

                if (lPressed && !_previousL)
                {
                    RightDown();
                }
                else if (!lPressed && _previousL)
                {
                    RightUp();
                }

                var scrollAmount = Mathf.RoundToInt(GamepadWhisperer.CurrentState.ThumbSticks.Left.Y * Native.WHEEL_DELTA * Time.deltaTime);
                if (scrollAmount != 0)
                {
                    Native.mouse_event(Native.MOUSEEVENTF_WHEEL, 0, 0, scrollAmount, 0);
                }
            }

            _previousR = rPressed;
            _previousL = lPressed;
        }
Exemplo n.º 16
0
            public static bool UpdateHook(ShortcutKey __instance)
            {
                if (_disabled)
                {
                    return(true);
                }

                if (GamepadWhisperer.CurrentState.IsConnected)
                {
                    foreach (var proc in __instance.procList)
                    {
                        if (proc.enabled)
                        {
                            if (_hotkeyBindings.TryGetValue(proc.keyCode, out var func) && GamepadWhisperer.GetButtonDown(func))
                            {
                                proc.call.Invoke();
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }