Ejemplo n.º 1
0
        public bool this[GamepadButton button]
        {
            get
            {
                switch (button)
                {
                    case GamepadButton.A:				return this.state.Buttons.A == ButtonState.Pressed;
                    case GamepadButton.B:				return this.state.Buttons.B == ButtonState.Pressed;
                    case GamepadButton.X:				return this.state.Buttons.X == ButtonState.Pressed;
                    case GamepadButton.Y:				return this.state.Buttons.Y == ButtonState.Pressed;

                    case GamepadButton.DPadLeft:		return this.state.DPad.Left == ButtonState.Pressed;
                    case GamepadButton.DPadRight:		return this.state.DPad.Right == ButtonState.Pressed;
                    case GamepadButton.DPadUp:			return this.state.DPad.Up == ButtonState.Pressed;
                    case GamepadButton.DPadDown:		return this.state.DPad.Down == ButtonState.Pressed;

                    case GamepadButton.LeftShoulder:	return this.state.Buttons.LeftShoulder == ButtonState.Pressed;
                    case GamepadButton.LeftStick:		return this.state.Buttons.LeftStick == ButtonState.Pressed;
                    case GamepadButton.RightShoulder:	return this.state.Buttons.RightShoulder == ButtonState.Pressed;
                    case GamepadButton.RightStick:		return this.state.Buttons.RightStick == ButtonState.Pressed;

                    case GamepadButton.BigButton:		return this.state.Buttons.BigButton == ButtonState.Pressed;
                    case GamepadButton.Back:			return this.state.Buttons.Back == ButtonState.Pressed;
                    case GamepadButton.Start:			return this.state.Buttons.Start == ButtonState.Pressed;

                    default: return false;
                }
            }
        }
Ejemplo n.º 2
0
        public static bool GetButtonValue(GamepadButton button)
        {
            switch (button)
            {
                case GamepadButton.A:              return Input.GetKey(KeyCode.JoystickButton0);
                case GamepadButton.B:              return Input.GetKey(KeyCode.JoystickButton1);
                case GamepadButton.X:              return Input.GetKey(KeyCode.JoystickButton2);
                case GamepadButton.Y:              return Input.GetKey(KeyCode.JoystickButton3);
                case GamepadButton.RShoulder:      return Input.GetKey(KeyCode.JoystickButton5);
                case GamepadButton.LShoulder:      return Input.GetKey(KeyCode.JoystickButton4);
                case GamepadButton.Back:           return Input.GetKey(KeyCode.JoystickButton6);
                case GamepadButton.Start:          return Input.GetKey(KeyCode.JoystickButton7);
                case GamepadButton.LStick:         return Input.GetKey(KeyCode.JoystickButton8);
                case GamepadButton.RStick:         return Input.GetKey(KeyCode.JoystickButton9);

                case GamepadButton.LTrigger:       return Input.GetAxis("TriggersL") > TRIGGER_THRESHOLD;
                case GamepadButton.RTrigger:       return Input.GetAxis("TriggersR") > TRIGGER_THRESHOLD;

                case GamepadButton.DpadLeft:       return OverThreshold(GamepadAxis.DpadX, -MAIN_THRESHOLD);
                case GamepadButton.DpadRight:      return OverThreshold(GamepadAxis.DpadX, MAIN_THRESHOLD);
                case GamepadButton.DpadUp:         return OverThreshold(GamepadAxis.DpadY, MAIN_THRESHOLD);
                case GamepadButton.DpadDown:       return OverThreshold(GamepadAxis.DpadY, -MAIN_THRESHOLD);

                case GamepadButton.LStickLeft:     return OverThreshold(GamepadAxis.LStickX, -MAIN_THRESHOLD);
                case GamepadButton.LStickRight:    return OverThreshold(GamepadAxis.LStickX, MAIN_THRESHOLD);
                case GamepadButton.LStickUp:       return OverThreshold(GamepadAxis.LStickY, MAIN_THRESHOLD);
                case GamepadButton.LStickDown:     return OverThreshold(GamepadAxis.LStickY, -MAIN_THRESHOLD);

                case GamepadButton.RStickLeft:     return OverThreshold(GamepadAxis.RStickX, -MAIN_THRESHOLD);
                case GamepadButton.RStickRight:    return OverThreshold(GamepadAxis.RStickX, MAIN_THRESHOLD);
                case GamepadButton.RStickUp:       return OverThreshold(GamepadAxis.RStickY, MAIN_THRESHOLD);
                case GamepadButton.RStickDown:     return OverThreshold(GamepadAxis.RStickY, -MAIN_THRESHOLD);
            }
            return false;
        }
Ejemplo n.º 3
0
        public string GetName(GamepadButton button)
        {
            switch (button)
            {
                case GamepadButton.A:               return "A";
                case GamepadButton.B:               return "B";
                case GamepadButton.X:               return "X";
                case GamepadButton.Y:               return "Y";
                case GamepadButton.RShoulder:       return "R Bumper";
                case GamepadButton.LShoulder:       return "L Bumper";
                case GamepadButton.Back:            return "Back";
                case GamepadButton.Start:           return "Start";
                case GamepadButton.LStick:          return "L Stick";
                case GamepadButton.RStick:          return "R Stick";

                case GamepadButton.LTrigger:        return "L Trigger";
                case GamepadButton.RTrigger:        return "R Trigger";
                case GamepadButton.DpadUp:          return "Dpad Up";
                case GamepadButton.DpadDown:        return "Dpad Down";
                case GamepadButton.DpadLeft:        return "Dpad Left";
                case GamepadButton.DpadRight:       return "Dpad Right";
                case GamepadButton.LStickUp:        return "L Stick Up";
                case GamepadButton.LStickDown:      return "L Stick Down";
                case GamepadButton.LStickLeft:      return "L Stick Left";
                case GamepadButton.LStickRight:     return "L Stick Right";
                case GamepadButton.RStickUp:        return "R Stick Up";
                case GamepadButton.RStickDown:      return "R Stick Down";
                case GamepadButton.RStickLeft:      return "R Stick Left";
                case GamepadButton.RStickRight:     return "R Stick Right";
            }
            return "None";
        }
Ejemplo n.º 4
0
	public string GetButtonName (GamepadButton button)
	{
		for (int i = 0; i < buttonNames.Count; i++)
		{
			if (buttonNames [i].button == button)
				return buttonNames [i].name;
		}

		return button.ToString ();
	}
Ejemplo n.º 5
0
        public static void SetKey(GamepadButton button, Key key)
        {
            var binding = CurrentKeybinds.First(bind => bind.BindType == button);
            binding.Key = key;

            SaveBindings();
            BindingsChanged?.Invoke(null, EventArgs.Empty);

            Properties.Settings.Default.BindingsModified = DateTime.Now;
            BindWriter.WriteBinds();
        }
Ejemplo n.º 6
0
        public float HowLongHasButtonBeenHeldDown(GamepadButton button, bool countIfUpThisFrame)
        {
            if (_buttonsDown.ContainsKey(button))
            {
                return(_buttonsDown[button]);
            }

            if (countIfUpThisFrame && _buttonsUpThisFrame.ContainsKey(button))
            {
                return(_buttonsUpThisFrame[button]);
            }

            return(0.0f);
        }
Ejemplo n.º 7
0
        private string GetWoWStringName(GamepadButton button)
        {
            var bindKey = _bindings.FirstOrDefault(bind => bind.BindType == button)?.Key;
            var bindVal = WowKeysDictionary.FirstOrDefault(bind => bind.Key == bindKey);

            if (bindVal.Key == Key.None)
            {
                return(bindKey.ToString().ToUpper());
            }
            else
            {
                return(WowKeysDictionary[bindVal.Key]);
            }
        }
Ejemplo n.º 8
0
        public GamepadState WithButton(GamepadButton button, bool value = true)
        {
            var bit = (uint)1 << (int)button;

            if (value)
            {
                buttons |= bit;
            }
            else
            {
                buttons &= ~bit;
            }
            return(this);
        }
Ejemplo n.º 9
0
        private GamepadButtonRaw GetGamepadButtonRawMapping(GamepadButton button)
        {
            var result = GamepadButtonRaw.None;

            switch (button)
            {
            case GamepadButton.A:
                result = GamepadButtonRaw.Button_1;
                break;

            case GamepadButton.B:
                result = GamepadButtonRaw.Button_2;
                break;

            case GamepadButton.X:
                result = GamepadButtonRaw.Button_3;
                break;

            case GamepadButton.Y:
                result = GamepadButtonRaw.Button_4;
                break;

            case GamepadButton.L:
                result = GamepadButtonRaw.Button_5;
                break;

            case GamepadButton.R:
                result = GamepadButtonRaw.Button_6;
                break;

            case GamepadButton.Select:
                result = GamepadButtonRaw.Button_7;
                break;

            case GamepadButton.Start:
                result = GamepadButtonRaw.Button_8;
                break;

            case GamepadButton.L_Stick:
                result = GamepadButtonRaw.Button_10;
                break;

            case GamepadButton.R_Stick:
                result = GamepadButtonRaw.Button_11;
                break;
            }

            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Set the specific buttons to be pressed or unpressed.
        /// </summary>
        /// <param name="button">A gamepad button.</param>
        /// <param name="value">Whether to set <paramref name="button"/> to be pressed or not pressed in
        /// <see cref="buttons"/>.</param>
        /// <returns>GamepadState with a modified <see cref="buttons"/> mask.</returns>
        public GamepadState WithButton(GamepadButton button, bool value = true)
        {
            Debug.Assert((int)button < 32, $"Expected button < 32, so we fit into the 32 bit wide bitmask");
            var bit = 1U << (int)button;

            if (value)
            {
                buttons |= bit;
            }
            else
            {
                buttons &= ~bit;
            }
            return(this);
        }
Ejemplo n.º 11
0
        private void ButtonUp(GamepadButton button)
        {
            float timeDown = 0.0f;

            if (_buttonsDown.ContainsKey(button))
            {
                timeDown = _buttonsDown[button];
                _buttonsDown.Remove(button);
            }

            if (!_buttonsUpThisFrame.ContainsKey(button))
            {
                _buttonsUpThisFrame.Add(button, timeDown);
            }
        }
Ejemplo n.º 12
0
        private void PressGamepadButtonAndVerifyOffsetAndFocus(GamepadButton gamepadButton, string expectedFocusedItemName, double expectedHorizontalOffset, double expectedVerticalOffset)
        {
            var  focusChangedWaiter = new FocusAcquiredWaiter();
            bool waitForFocusChange = UIObject.Focused.Name != expectedFocusedItemName;

            GamepadHelper.PressButton(null, gamepadButton);

            if (waitForFocusChange)
            {
                focusChangedWaiter.Wait(TimeSpan.FromSeconds(2));
            }

            WaitForScrollViewerOffsets(expectedHorizontalOffset, expectedVerticalOffset);
            Verify.AreEqual(expectedFocusedItemName, UIObject.Focused.Name, "Verify focused element");
        }
Ejemplo n.º 13
0
    /// <summary>
    /// button est le button presser dans le cas d'un flags 1'
    /// Flags = 1 un button, 0 une direction
    /// dir est le vecteur directeur dans le cas d'un flag 0'
    /// </summary>
    /// <param name="button"></param>
    /// <param name="flag"></param>
    /// <param name="dir"></param>
    public void AddCombo(GamepadButton button, int flag, Vector2 dir)
    {
        if (flag == 0 && dir == Vector2.zero)
        {
            lastAxis = Utils.ComboInput.Carre;
            return;
        }

        foreach (InputData inputData in inputs)
        {
            if (inputData.flags == flag)
            {
                switch (flag)
                {
                case 0:
                    if (inputData.xInputZone.x < dir.x && inputData.xInputZone.y > dir.x &&
                        inputData.yInputZone.x < dir.y && inputData.yInputZone.y > dir.y)
                    {
                        if (inputData.input != lastAxis)
                        {
                            currentCombo.Add(inputData.input);
                            lastAxis     = inputData.input;
                            currentDelay = Time.time + maxDelayBetweenTwoInputs;
                        }
                    }
                    break;

                case 1:
                    if (inputData.button == button)
                    {
                        currentCombo.Add(inputData.input);
                        currentDelay = Time.time + maxDelayBetweenTwoInputs;
                    }
                    break;

                default:
                    Debug.LogError("Mauvais flag pour " + button + " " + dir);
                    break;
                }
            }
        }

        if (currentCombo.Count > lastCount)
        {
            ComboManager(currentCombo);
            lastCount = currentCombo.Count;
        }
    }
Ejemplo n.º 14
0
        public void Copy(InputBinding source)
        {
            m_positive = source.m_positive;
            m_negative = source.m_negative;

            m_deadZone    = source.m_deadZone;
            m_gravity     = source.m_gravity;
            m_sensitivity = source.m_sensitivity;
            m_snap        = source.m_snap;
            m_invert      = source.m_invert;
            m_type        = source.m_type;

            mouseAxis       = source.mouseAxis;
            m_gamepadAxis   = source.m_gamepadAxis;
            m_gamepadButton = source.m_gamepadButton;
        }
Ejemplo n.º 15
0
 internal static KeyCode GetGamepadKeyCode(GamepadButton @enum)
 {
     return(@enum switch
     {
         GamepadButton.ButtonSouth => KeyCode.JoystickButton0,
         GamepadButton.ButtonEast => KeyCode.JoystickButton1,
         GamepadButton.ButtonWest => KeyCode.JoystickButton2,
         GamepadButton.ButtonNorth => KeyCode.JoystickButton3,
         GamepadButton.LeftShoulder => KeyCode.JoystickButton4,
         GamepadButton.RightShoulder => KeyCode.JoystickButton5,
         GamepadButton.SelectButton => KeyCode.JoystickButton6,
         GamepadButton.StartButton => KeyCode.JoystickButton7,
         GamepadButton.LeftStickButton => KeyCode.JoystickButton8,
         GamepadButton.RightStickButton => KeyCode.JoystickButton9,
         _ => KeyCode.None
     });
Ejemplo n.º 16
0
        private async void OnShowKeybindDialog(GamepadButton button)
        {
            _keybindButton = button;

            var buttonName = ControllerManager.GetButtonName(button);

            KeyDown += OnKeyDown;
            _keybindDialogController =
                await
                this.ShowProgressAsync($"Rebind {buttonName}",
                                       $"Press a button on your keyboard. Some special keys may not be recognized by the WoW client.",
                                       true);

            _keybindDialogController.Canceled += KeybindDialogControllerOnCanceled;
            _keybindDialogController.Closed   += KeybindDialogControllerOnClosed;
        }
Ejemplo n.º 17
0
 public void Copy(InputBinding source)
 {
     m_positive      = source.m_positive;
     m_negative      = source.m_negative;
     m_deadZone      = source.m_deadZone;
     m_gravity       = source.m_gravity;
     m_sensitivity   = source.m_sensitivity;
     m_snap          = source.m_snap;
     m_invert        = source.m_invert;
     m_type          = source.m_type;
     m_axis          = source.m_axis;
     m_joystick      = source.m_joystick;
     m_gamepadAxis   = source.m_gamepadAxis;
     m_gamepadButton = source.m_gamepadButton;
     m_gamepadIndex  = source.m_gamepadIndex;
 }
Ejemplo n.º 18
0
        private static bool ProcessButton(GamepadButton button, bool state)
        {
            if (_keyStates[(int)button] != state)
            {
                if (state)
                {
                    WoWInput.SendKeyDown(BindManager.GetKey(button));
                }
                else
                {
                    WoWInput.SendKeyUp(BindManager.GetKey(button));
                }

                _keyStates[(int)button] = state;
            }
            return(state);
        }
Ejemplo n.º 19
0
 private static void ProcessPlayerAoe(GamepadButton button, bool state)
 {
     if (!_keyStates[(int)button])
     {
         if (button == Settings.Default.MemoryAoeConfirm)
         {
             WoWInput.SendMouseClick(MouseButton.Left);
             return;
         }
         if (button == Settings.Default.MemoryAoeCancel)
         {
             WoWInput.SendMouseClick(MouseButton.Right);
             return;
         }
     }
     ProcessInput(button, state);
 }
Ejemplo n.º 20
0
        public bool GetButtonUp(GamepadButton button, int gamepad)
        {
            if (m_gamepadProfile == null)
            {
                return(false);
            }

            switch (button)
            {
            case GamepadButton.LeftStick: return(GetButtonUp(m_gamepadProfile.LeftStickButton, gamepad));

            case GamepadButton.RightStick: return(GetButtonUp(m_gamepadProfile.RightStickButton, gamepad));

            case GamepadButton.LeftBumper: return(GetButtonUp(m_gamepadProfile.LeftBumperButton, gamepad));

            case GamepadButton.RightBumper: return(GetButtonUp(m_gamepadProfile.RightBumperButton, gamepad));

            case GamepadButton.Back: return(GetButtonUp(m_gamepadProfile.BackButton, gamepad));

            case GamepadButton.Start: return(GetButtonUp(m_gamepadProfile.StartButton, gamepad));

            case GamepadButton.ActionBottom: return(GetButtonUp(m_gamepadProfile.ActionBottomButton, gamepad));

            case GamepadButton.ActionRight: return(GetButtonUp(m_gamepadProfile.ActionRightButton, gamepad));

            case GamepadButton.ActionLeft: return(GetButtonUp(m_gamepadProfile.ActionLeftButton, gamepad));

            case GamepadButton.ActionTop: return(GetButtonUp(m_gamepadProfile.ActionTopButton, gamepad));

            case GamepadButton.DPadUp:
                return(m_gamepadProfile.DPadType == GamepadDPadType.Button ? GetButtonUp(m_gamepadProfile.DPadUpButton, gamepad) : m_dpadState[gamepad].Up == ButtonState.JustReleased);

            case GamepadButton.DPadDown:
                return(m_gamepadProfile.DPadType == GamepadDPadType.Button ? GetButtonUp(m_gamepadProfile.DPadDownButton, gamepad) : m_dpadState[gamepad].Down == ButtonState.JustReleased);

            case GamepadButton.DPadLeft:
                return(m_gamepadProfile.DPadType == GamepadDPadType.Button ? GetButtonUp(m_gamepadProfile.DPadLeftButton, gamepad) : m_dpadState[gamepad].Left == ButtonState.JustReleased);

            case GamepadButton.DPadRight:
                return(m_gamepadProfile.DPadType == GamepadDPadType.Button ? GetButtonUp(m_gamepadProfile.DPadRightButton, gamepad) : m_dpadState[gamepad].Right == ButtonState.JustReleased);

            default:
                return(false);
            }
        }
Ejemplo n.º 21
0
        private string GetTextureName(GamepadButton button)
        {
            switch (button)
            {
            case GamepadButton.ShoulderLeft:
                return("CP_TL1");

            case GamepadButton.ShoulderRight:
                return("CP_TR1");

            case GamepadButton.TriggerLeft:
                return("CP_TL2");

            case GamepadButton.TriggerRight:
                return("CP_TR2");
            }
            return(string.Empty);
        }
Ejemplo n.º 22
0
        public static string GetPrompt(this GamepadButton button, GamepadType type)
        {
            if (button == GamepadButton.None)
            {
                return("?");
            }

            var imagePath = button.GetPromptImagePath(type);

            if (imagePath != null)
            {
                return('[' + imagePath + ']');
            }
            else
            {
                return(button.ToString().ToProperSpaced());
            }
        }
Ejemplo n.º 23
0
        static bool ButtonQuery(GamepadButton button, int gamepad, System.Func <int, int, bool> callback, ButtonState dpadButtonStateCheck)
        {
            GenericGamepadProfile profile;

            if (!GamepadAvailable(gamepad, out profile))
            {
                return(false);
            }

            switch (button)
            {
            case GamepadButton.LeftStick:       return(callback(profile.LeftStickButton, gamepad));

            case GamepadButton.RightStick:      return(callback(profile.RightStickButton, gamepad));

            case GamepadButton.LeftBumper:      return(callback(profile.LeftBumperButton, gamepad));

            case GamepadButton.RightBumper:     return(callback(profile.RightBumperButton, gamepad));

            case GamepadButton.Back:            return(callback(profile.BackButton, gamepad));

            case GamepadButton.Start:           return(callback(profile.StartButton, gamepad));

            case GamepadButton.ActionBottom:    return(callback(profile.ActionBottomButton, gamepad));

            case GamepadButton.ActionRight:     return(callback(profile.ActionRightButton, gamepad));

            case GamepadButton.ActionLeft:      return(callback(profile.ActionLeftButton, gamepad));

            case GamepadButton.ActionTop:       return(callback(profile.ActionTopButton, gamepad));

            case GamepadButton.DPadUp:          return(profile.DPadType == GamepadDPadType.Button ? callback(profile.DPadUpButton, gamepad) : m_dpadState[gamepad].Up == dpadButtonStateCheck);

            case GamepadButton.DPadDown:        return(profile.DPadType == GamepadDPadType.Button ? callback(profile.DPadDownButton, gamepad) : m_dpadState[gamepad].Down == dpadButtonStateCheck);

            case GamepadButton.DPadLeft:        return(profile.DPadType == GamepadDPadType.Button ? callback(profile.DPadLeftButton, gamepad) : m_dpadState[gamepad].Left == dpadButtonStateCheck);

            case GamepadButton.DPadRight:       return(profile.DPadType == GamepadDPadType.Button ? callback(profile.DPadRightButton, gamepad) : m_dpadState[gamepad].Right == dpadButtonStateCheck);

            default:
                return(false);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Retrieve a gamepad button by its <see cref="GamepadButton"/> enumeration
        /// constant.
        /// </summary>
        /// <param name="button">Button to retrieve.</param>
        /// <exception cref="InvalidEnumArgumentException"><paramref name="button"/> is not a valid gamepad
        /// button value.</exception>
        public ButtonControl this[GamepadButton button]
        {
            get
            {
                switch (button)
                {
                case GamepadButton.North: return(buttonNorth);

                case GamepadButton.South: return(buttonSouth);

                case GamepadButton.East: return(buttonEast);

                case GamepadButton.West: return(buttonWest);

                case GamepadButton.Start: return(startButton);

                case GamepadButton.Select: return(selectButton);

                case GamepadButton.LeftShoulder: return(leftShoulder);

                case GamepadButton.RightShoulder: return(rightShoulder);

                case GamepadButton.LeftTrigger: return(leftTrigger);

                case GamepadButton.RightTrigger: return(rightTrigger);

                case GamepadButton.LeftStick: return(leftStickButton);

                case GamepadButton.RightStick: return(rightStickButton);

                case GamepadButton.DpadUp: return(dpad.up);

                case GamepadButton.DpadDown: return(dpad.down);

                case GamepadButton.DpadLeft: return(dpad.left);

                case GamepadButton.DpadRight: return(dpad.right);

                default:
                    throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(GamepadButton));
                }
            }
        }
Ejemplo n.º 25
0
 public EventData(EventType t)
 {
     type          = t;
     key           = KeyConstant.Unknown;
     scancode      = Scancode.Unknow;
     joystick      = null;
     direction     = JoystickHat.Centered;
     gamepadButton = GamepadButton.A;
     gamepadAxis   = GamepadAxis.LeftX;
     text          = null;
     flag          = false;
     fx            = 0;
     fy            = 0;
     fz            = 0;
     fw            = 0;
     fp            = 0;
     idx           = 0;
     idy           = 0;
     lid           = 0;
 }
Ejemplo n.º 26
0
        public GamepadThumbsticks(Vector2 left, Vector2 right, GamepadDeadZoneMode deadZoneMode)
        {
            Left  = left;
            Right = right;

            DirectionalState = 0;

            ApplyDeadZone(deadZoneMode);

            if (deadZoneMode == GamepadDeadZoneMode.Circular)
            {
                ApplyCircularClamp();
            }
            else
            {
                ApplySquareClamp();
            }

            SetDirectionalState(Left, Right);
        }
Ejemplo n.º 27
0
        bool ScanJoystickButton()
        {
            int gamepadButtons = 14;

            for (int i = 0; i < gamepadButtons; i++)
            {
                GamepadButton button = (GamepadButton)i;
                for (int x = 0; x < InputBinding.MAX_JOYSTICKS; x++)
                {
                    if (InputManager.Gamepad.GetButtonDown(button, x))
                    {
                        if (m_scanHandler(ScanResult.GamepadButtonResult(button)))
                        {
                            return(EndScan());
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 28
0
        public WebGLGamepadState WithButton(GamepadButton button, float value = 1)
        {
            int index;

            switch (button)
            {
            case GamepadButton.South: index = 0; break;

            case GamepadButton.East: index = 1; break;

            case GamepadButton.West: index = 2; break;

            case GamepadButton.North: index = 3; break;

            case GamepadButton.LeftShoulder: index = 4; break;

            case GamepadButton.RightShoulder: index = 5; break;

            case GamepadButton.Select: index = 8; break;

            case GamepadButton.Start: index = 9; break;

            case GamepadButton.LeftStick: index = 10; break;

            case GamepadButton.RightStick: index = 11; break;

            case GamepadButton.DpadUp: index = 12; break;

            case GamepadButton.DpadDown: index = 13; break;

            case GamepadButton.DpadLeft: index = 14; break;

            case GamepadButton.DpadRight: index = 15; break;

            default:
                throw new InvalidEnumArgumentException("button");
            }

            SetValue(kNumAxes + index, value);
            return(this);
        }
Ejemplo n.º 29
0
        private static void ProcessInput(GamepadButton button, bool state)
        {
            // Do left/right mouse buttons
            if (button == GamepadButton.LeftStick)
            {
                if (state)
                {
                    WoWInput.SendMouseDown(MouseButton.Left);
                }
                else
                {
                    WoWInput.SendMouseUp(MouseButton.Left);
                }
            }
            else if (button == GamepadButton.RightStick)
            {
                if (state)
                {
                    WoWInput.SendMouseDown(MouseButton.Right);
                }
                else
                {
                    WoWInput.SendMouseUp(MouseButton.Right);
                }
            }

            // Do other buttons
            if (_keyStates[(int)button] != state)
            {
                if (state)
                {
                    WoWInput.SendKeyDown(BindManager.GetKey(button));
                }
                else
                {
                    WoWInput.SendKeyUp(BindManager.GetKey(button));
                }
            }

            _keyStates[(int)button] = state;
        }
Ejemplo n.º 30
0
 public static Key GetKey(GamepadButton button)
 {
     try
     {
         if (Properties.Settings.Default.CustomBindings)
         {
             return(CurrentKeybinds.First(
                        bind => bind.BindType == button).Key);
         }
         else
         {
             return
                 (Defaults.KeybindStyles.GetDefault(Properties.Settings.Default.ModifierStyle).First(
                      bind => bind.BindType == button).Key);
         }
     }
     catch
     {
         return(Key.None);
     }
 }
        static bool ScanJoystickButton(int numJoysticks)
        {
            int gamepadButtons = 14;

            for (int i = 0; i < gamepadButtons; i++)
            {
                GamepadButton button = (GamepadButton)i;
                // for (int x = 0; x < InputBinding.MAX_JOYSTICKS; x++) {
                for (int x = 0; x < numJoysticks; x++)
                {
                    if (GamepadHandler.GetButtonDown(button, x))
                    {
                        if (scanHandler(ScanResult.GamepadButtonResult(button)))
                        {
                            return(EndScan());
                        }
                    }
                }
            }
            return(false);
        }
    public static KKeyCode GetGamepadKeyCode(int gamepad_number, GamepadButton button)
    {
        switch (gamepad_number)
        {
        case 0:
            return((KKeyCode)(button + 350));

        case 1:
            return((KKeyCode)(button + 370));

        case 2:
            return((KKeyCode)(button + 390));

        case 3:
            return((KKeyCode)(button + 410));

        default:
            DebugUtil.Assert(false);
            return(KKeyCode.None);
        }
    }
Ejemplo n.º 33
0
        public void Copy(InputBinding source)
        {
            m_positive = source.m_positive;
            m_negative = source.m_negative;

            m_deadZone               = source.m_deadZone;
            m_gravity                = source.m_gravity;
            m_sensitivity            = source.m_sensitivity;
            m_snap                   = source.m_snap;
            m_invert                 = source.m_invert;
            useNegativeAxisForButton = source.useNegativeAxisForButton;
            m_type                   = source.m_type;

            rebindable          = source.rebindable;
            sensitivityEditable = source.sensitivityEditable;
            invertEditable      = source.invertEditable;

            mouseAxis       = source.mouseAxis;
            m_gamepadAxis   = source.m_gamepadAxis;
            m_gamepadButton = source.m_gamepadButton;
        }
Ejemplo n.º 34
0
 public static Key GetKey(GamepadButton button)
 {
     try
     {
         if (Properties.Settings.Default.CustomBindings)
         {
             return CurrentKeybinds.First(
                 bind => bind.BindType == button).Key;
         }
         else
         {
             return
                 Defaults.KeybindStyles.GetDefault(Properties.Settings.Default.ModifierStyle).First(
                     bind => bind.BindType == button).Key;
         }
     }
     catch
     {
         return Key.None;
     }
 }
Ejemplo n.º 35
0
        private void SetDirectionalState(Vector2 left, Vector2 right)
        {
            DirectionalState = 0;

            if (left.X < -LeftThumbDeadZone)
            {
                DirectionalState |= GamepadButton.LeftThumbstickLeft;
            }
            else if (left.X > LeftThumbDeadZone)
            {
                DirectionalState |= GamepadButton.LeftThumbstickRight;
            }

            if (left.Y < -LeftThumbDeadZone)
            {
                DirectionalState |= GamepadButton.LeftThumbstickUp;
            }
            else if (left.Y > LeftThumbDeadZone)
            {
                DirectionalState |= GamepadButton.LeftThumbstickDown;
            }

            if (right.X < -RightThumbDeadZone)
            {
                DirectionalState |= GamepadButton.RightThumbstickLeft;
            }
            else if (right.X > RightThumbDeadZone)
            {
                DirectionalState |= GamepadButton.RightThumbstickRight;
            }

            if (right.Y < -RightThumbDeadZone)
            {
                DirectionalState |= GamepadButton.RightThumbstickUp;
            }
            else if (right.Y > RightThumbDeadZone)
            {
                DirectionalState |= GamepadButton.RightThumbstickDown;
            }
        }
Ejemplo n.º 36
0
        public bool this[GamepadButton button]
        {
            get
            {
                switch (button)
                {
                case GamepadButton.A: return(this.state.Buttons.A == ButtonState.Pressed);

                case GamepadButton.B: return(this.state.Buttons.B == ButtonState.Pressed);

                case GamepadButton.X: return(this.state.Buttons.X == ButtonState.Pressed);

                case GamepadButton.Y: return(this.state.Buttons.Y == ButtonState.Pressed);

                case GamepadButton.DPadLeft: return(this.state.DPad.Left == ButtonState.Pressed);

                case GamepadButton.DPadRight: return(this.state.DPad.Right == ButtonState.Pressed);

                case GamepadButton.DPadUp: return(this.state.DPad.Up == ButtonState.Pressed);

                case GamepadButton.DPadDown: return(this.state.DPad.Down == ButtonState.Pressed);

                case GamepadButton.LeftShoulder: return(this.state.Buttons.LeftShoulder == ButtonState.Pressed);

                case GamepadButton.LeftStick: return(this.state.Buttons.LeftStick == ButtonState.Pressed);

                case GamepadButton.RightShoulder: return(this.state.Buttons.RightShoulder == ButtonState.Pressed);

                case GamepadButton.RightStick: return(this.state.Buttons.RightStick == ButtonState.Pressed);

                case GamepadButton.BigButton: return(this.state.Buttons.BigButton == ButtonState.Pressed);

                case GamepadButton.Back: return(this.state.Buttons.Back == ButtonState.Pressed);

                case GamepadButton.Start: return(this.state.Buttons.Start == ButtonState.Pressed);

                default: return(false);
                }
            }
        }
Ejemplo n.º 37
0
	public bool GetButton (GamepadButton buttonType)
	{
		
		switch (buttonType)
		{
		case GamepadButton.Action1:
			return GetInputBool (UnGamepadConfig.InputTarget.Action1);
		case GamepadButton.Action2:
			return GetInputBool (UnGamepadConfig.InputTarget.Action2);
		case GamepadButton.Action3:
			return GetInputBool (UnGamepadConfig.InputTarget.Action3);
		case GamepadButton.Action4:
			return GetInputBool (UnGamepadConfig.InputTarget.Action4);
		case GamepadButton.Menu:
			return GetInputBool (UnGamepadConfig.InputTarget.Menu);
		case GamepadButton.Start:
			return GetInputBool (UnGamepadConfig.InputTarget.Start);
		case GamepadButton.Back:
			return GetInputBool (UnGamepadConfig.InputTarget.Back);
		case GamepadButton.DpadDown:
			return GetInputBool (UnGamepadConfig.InputTarget.DpadDown);
		case GamepadButton.DpadLeft:
			return GetInputBool (UnGamepadConfig.InputTarget.DpadLeft);
		case GamepadButton.DpadRight:
			return GetInputBool (UnGamepadConfig.InputTarget.DpadRight);
		case GamepadButton.DpadUp:
			return GetInputBool (UnGamepadConfig.InputTarget.DpadUp);
		case GamepadButton.LeftBumper:
			return GetInputBool (UnGamepadConfig.InputTarget.LeftBumper);
		case GamepadButton.RightBumper:
			return GetInputBool (UnGamepadConfig.InputTarget.RightBumper);
		case GamepadButton.LeftStickButton:
			return GetInputBool (UnGamepadConfig.InputTarget.LeftStickButton);
		case GamepadButton.RightStickButton:
			return GetInputBool (UnGamepadConfig.InputTarget.RightStickButton);
		}
		
		throw new UnityException ();
	}
Ejemplo n.º 38
0
        private static void ActiveController_ButtonStateChanged(GamepadButton button, bool state)
        {
            if (Settings.Default.EnableMemoryReading)
            {
                // Process input if player is at character select
                if (Settings.Default.MemoryOverrideMenu && WoWReader.IsAttached && !WoWReader.GameState)
                {
                    ProcessCharacterMenu(button, state);
                    return;
                }

                // Process input if player is casting targeted AoE
                if (WoWReader.GameState && Settings.Default.MemoryOverrideAoeCast &&
                    WoWReader.AoeState)
                {
                    ProcessPlayerAoe(button, state);
                    return;
                }
            }

            // Process input
            ProcessInput(button, state);
        }
Ejemplo n.º 39
0
 public static BitmapImage GetButtonIcon(GamepadButton button)
 {
     switch (Properties.Settings.Default.ButtonStyle)
     {
         case 0:
             if (ActiveController != null)
             {
                 switch (ActiveController.Type)
                 {
                     case GamepadType.PlayStation:
                         return DS4Data.GetButtonImage(button);
                     case GamepadType.Xbox:
                         return XboxData.GetButtonImage(button);
                 }
             }
             goto default;
         case 1:
             return DS4Data.GetButtonImage(button);
         case 2:
             return XboxData.GetButtonImage(button);
         default:
             return XboxData.GetButtonImage(button);
     }
 }
Ejemplo n.º 40
0
 private static void ActiveControllerOnButtonStateChanged(GamepadButton button, bool state)
 {
     ControllerButtonStateChanged?.Invoke(button, state);
 }
Ejemplo n.º 41
0
 public JoystickButtonAxis(GamepadButton positive, GamepadButton negative, float multiplier)
 {
     m_positive = positive;
     m_negative = negative;
     m_multiplier = multiplier;
 }
	public override bool GetButtonDown (GamepadButton buttonType)
	{
		return currentState.GetButton (buttonType) && !lastState.GetButton (buttonType);
	}
Ejemplo n.º 43
0
 private string GetTextureName(GamepadButton button)
 {
     switch (button)
     {
         case GamepadButton.ShoulderLeft:
             return "CP_TL1";
         case GamepadButton.ShoulderRight:
             return "CP_TR1";
         case GamepadButton.TriggerLeft:
             return "CP_TL2";
         case GamepadButton.TriggerRight:
             return "CP_TR2";
     }
     return string.Empty;
 }
Ejemplo n.º 44
0
        private static void ProcessCharacterMenu(GamepadButton button, bool state)
        {
            switch (button)
            {
                case GamepadButton.LFaceUp:
                    if (state && !_keyStates[(int) button])
                        WoWInput.SendKeyDown(Key.Up);
                    if (!state && _keyStates[(int) button])
                        WoWInput.SendKeyUp(Key.Up);
                    break;
                case GamepadButton.LFaceDown:
                    if (state && !_keyStates[(int) button])
                        WoWInput.SendKeyDown(Key.Down);
                    if (!state && _keyStates[(int) button])
                        WoWInput.SendKeyUp(Key.Down);
                    break;
                case GamepadButton.RFaceDown:
                    if (state && !_keyStates[(int) button])
                        WoWInput.SendKeyDown(Key.Enter);
                    if (!state && _keyStates[(int) button])
                        WoWInput.SendKeyUp(Key.Enter);
                    break;
                case GamepadButton.CenterMiddle:
                    if (state && !_keyStates[(int) button])
                        WoWInput.SendKeyDown(Key.Escape);
                    if (!state && _keyStates[(int) button])
                        WoWInput.SendKeyUp(Key.Escape);
                    break;
            }

            // Do left/right mouse buttons
            if (button == GamepadButton.LeftStick)
            {
                if (state)
                    WoWInput.SendMouseDown(MouseButton.Left);
                else
                    WoWInput.SendMouseUp(MouseButton.Left);
            }
            else if (button == GamepadButton.RightStick)
            {
                if (state)
                    WoWInput.SendMouseDown(MouseButton.Right);
                else
                    WoWInput.SendMouseUp(MouseButton.Right);
            }

            _keyStates[(int) button] = state;
        }
Ejemplo n.º 45
0
        private static void ProcessInput(GamepadButton button, bool state)
        {
            // Do left/right mouse buttons
            if (button == GamepadButton.LeftStick)
            {
                if (state)
                    WoWInput.SendMouseDown(MouseButton.Left);
                else
                    WoWInput.SendMouseUp(MouseButton.Left);
            }
            else if (button == GamepadButton.RightStick)
            {
                if (state)
                    WoWInput.SendMouseDown(MouseButton.Right);
                else
                    WoWInput.SendMouseUp(MouseButton.Right);
            }

            // Do other buttons
            if (_keyStates[(int) button] != state)
            {
                if (state)
                {
                    WoWInput.SendKeyDown(BindManager.GetKey(button));
                }
                else
                {
                    WoWInput.SendKeyUp(BindManager.GetKey(button));
                }
            }

            _keyStates[(int) button] = state;
        }
Ejemplo n.º 46
0
		public GamepadButtonEventArgs(GamepadInput inputChannel, GamepadButton button, bool pressed) : base(inputChannel)
		{
			this.button = button;
			this.pressed = pressed;
		}
Ejemplo n.º 47
0
 /// <summary>
 /// Called when a gamepad button is pressed or released.
 /// </summary>
 /// <param name="button">The gamepad button.</param>
 public virtual void OnGamepadButton(GamepadButton button) { }
Ejemplo n.º 48
0
 public bool GetButtonState(GamepadButton button)
 {
     return _buttonStates[(int) button];
 }
Ejemplo n.º 49
0
 private void SendButtonEvent(GamepadButton button, bool state)
 {
     _buttonStates[(int) button] = state;
     ButtonStateChanged?.Invoke(button, state);
 }
Ejemplo n.º 50
0
		/// <summary>
		/// [GET] Returns whether the specified gamepad button is currently pressed.
		/// </summary>
		/// <param name="button"></param>
		/// <returns></returns>
		public bool this[GamepadButton button]
		{
			get { return this.currentState.ButtonPressed[(int)button]; }
		}
	public override bool GetButtonUp (GamepadButton buttonType)
	{
		return !currentState.GetButton (buttonType) && lastState.GetButton (buttonType);
	}
Ejemplo n.º 52
0
 public JoystickButton(GamepadButton button)
 {
     m_button = button;
 }
Ejemplo n.º 53
0
 private static void ProcessPlayerAoe(GamepadButton button, bool state)
 {
     if (!_keyStates[(int) button])
     {
         if (button == Settings.Default.MemoryAoeConfirm)
         {
             WoWInput.SendMouseClick(MouseButton.Left);
             return;
         }
         if (button == Settings.Default.MemoryAoeCancel)
         {
             WoWInput.SendMouseClick(MouseButton.Right);
             return;
         }
     }
     ProcessInput(button, state);
 }
Ejemplo n.º 54
0
 private float GetButtonValue(GamepadButton button)
 {
     return JoystickButton.GetButtonValue(button) ? 1 : 0;
 }
Ejemplo n.º 55
0
	public abstract bool GetButtonUp (GamepadButton buttonType);	
Ejemplo n.º 56
0
 public static BitmapImage GetButtonImage(GamepadButton button)
 {
     return ButtonImages[button];
 }
Ejemplo n.º 57
0
 private string GetWoWStringName(GamepadButton button)
 {
     var bindKey = _bindings.FirstOrDefault(bind => bind.BindType == button)?.Key;
     var bindVal = WowKeysDictionary.FirstOrDefault(bind => bind.Key == bindKey);
     if (bindVal.Key == Key.None)
     {
         return bindKey.ToString().ToUpper();
     }
     else
     {
         return WowKeysDictionary[bindVal.Key];
     }
 }
Ejemplo n.º 58
0
 public static string GetButtonName(GamepadButton button)
 {
     return ButtonNames[button];
 }
Ejemplo n.º 59
0
		/// <summary>
		/// Returns whether the specified button was released this frame.
		/// </summary>
		/// <param name="button"></param>
		/// <returns></returns>
		public bool ButtonReleased(GamepadButton button)
		{
			return !this.currentState.ButtonPressed[(int)button] && this.lastState.ButtonPressed[(int)button];
		}
Ejemplo n.º 60
0
		/// <summary>
		/// Returns whether the specified button was hit this frame.
		/// </summary>
		/// <param name="button"></param>
		/// <returns></returns>
		public bool ButtonHit(GamepadButton button)
		{
			return this.currentState.ButtonPressed[(int)button] && !this.lastState.ButtonPressed[(int)button];
		}