Example #1
0
 public void OnButtonPressed(ButtonCode code)
 {
     if (code == ButtonCode.Back)
     {
         SceneManager.LoadScene("the_last_one");
     }
 }
Example #2
0
    public bool GetButton(ButtonCode keyCode)
    {
        string latestData = thisCommand;

        switch (keyCode)
        {
        case ButtonCode.KeyFoward:
            return(latestData == "F");

        case ButtonCode.KeyRight:
            return(latestData == "R");

        case ButtonCode.KeyBack:
            return(latestData == "B");

        case ButtonCode.KeyLeft:
            return(latestData == "L");

        case ButtonCode.KeyExit:
            return(latestData == "ESC");

        case ButtonCode.KeyComboOne:
            return(latestData == "C1");

        case ButtonCode.KeyComboTwo:
            return(latestData == "C2");

        case ButtonCode.KeyComboThree:
            return(latestData == "C3");

        default:
            return(false);
        }
    }
Example #3
0
    public bool GetButton(ButtonCode keyCode)
    {
        switch (keyCode)
        {
        case ButtonCode.KeyFoward:
            return(forwardPressed.GetState(hand));

        case ButtonCode.KeyRight:
            return(rightPressed.GetState(hand));

        case ButtonCode.KeyBack:
            return(backPressed.GetState(hand));

        case ButtonCode.KeyLeft:
            return(leftPressed.GetState(hand));

        case ButtonCode.KeyExit:
            return(false);

        case ButtonCode.KeyComboOne:
            return(false);

        case ButtonCode.KeyComboTwo:
            return(false);

        case ButtonCode.KeyComboThree:
            return(false);

        default:
            throw new ArgumentException("Unknown keyCode" + keyCode);
        }
    }
Example #4
0
 public void OnButtonPressed(ButtonCode code)
 {
     if (code == ButtonCode.A && playerGrab.isGrabbingHair != true)
     {
         Jump();
     }
 }
Example #5
0
 private static IEnumerable <IEvent> CreateChildren(ButtonCode Button)
 {
     return(new IEvent[] {
         new ButtonDown(Button),
         new ButtonUp(Button),
     });
 }
 // Add a button mapping to the specified action
 public void AddButtonMapping(ActionCode action, ButtonCode button)
 {
     if (ButtonMaps[action].Add(button))
     {
         TestFromActionCode(action).AddTest(ButtonMap[button]);
     }
 }
Example #7
0
        /// <summary>
        /// Triggered by runtime when a button is pressed.
        /// </summary>
        /// <param name="code">Code of the pressed button.</param>
        /// <param name="deviceIdx">Device the event originated from.</param>
        /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
        private static void Internal_TriggerButtonDown(ButtonCode code, int deviceIdx, bool isUsed)
        {
            ButtonEvent ev = new ButtonEvent(code, deviceIdx, isUsed);

            if (OnButtonDown != null)
                OnButtonDown(ev);
        }
 // Remove a button mapping from the specified action
 public void RemoveButtonMapping(ActionCode action, ButtonCode button)
 {
     if (ButtonMaps[action].Remove(button))
     {
         TestFromActionCode(action).RemoveTest(ButtonMap[button]);
     }
 }
Example #9
0
        public override bool GetButtonDown(ButtonCode code, bool usePreceding = false)
        {
            if (!ActionEnabled)
            {
                return(false);
            }
            if (code == ButtonCode.MouseLeft)
            {
                bool res = (jumpBuff.Count >= 1);
                if (res)
                {
                    jumpBuff.Dequeue();
                    if (usePreceding)
                    {
                        return(true);
                    }
                    else
                    {
                        return(Input.GetMouseButtonDown((int)code));
                    }
                }
                return(false);
            }

            return(Input.GetMouseButtonDown((int)code));
        }
Example #10
0
        private Button AddButton(ButtonCode code)
        {
            var b = new Button(code, Driver);

            buttons[code] = b;
            return(b);
        }
        public static MouseFlag ToMouseButtonUpFlags(this ButtonCode This)
        {
            var ret = default(MouseFlag);

            switch (This)
            {
            case ButtonCode.Left:
                ret = MouseFlag.LeftUp;
                break;

            case ButtonCode.Right:
                ret = MouseFlag.RightUp;
                break;

            case ButtonCode.Middle:
                ret = MouseFlag.MiddleUp;
                break;

            case ButtonCode.XButton1:
                ret = MouseFlag.XUp;
                break;

            case ButtonCode.XButton2:
                ret = MouseFlag.XUp;
                break;

            default:
                throw new InvalidCastException($@"Unable to convert {This} to a valid 'Up' state.  Valid inputs are: {ButtonCode.Left}, {ButtonCode.Right}, {ButtonCode.Middle}, {ButtonCode.XButton1}, and {ButtonCode.XButton2}.");
            }

            return(ret);
        }
Example #12
0
 public bool GetButtonDown(ButtonCode keyCode)
 {
     if (!changed)
     {
         return(false);
     }
     return(GetButton(keyCode));
 }
    private void AlternateMaxTwo()
    {
        ButtonCode button1 = altButton[0], button2 = altButton[1];

        altButton = new ButtonCode[2];
        altButton.SetValue(button1, 0);
        altButton.SetValue(button2, 1);
    }
        public void KeyMapper_MapMouseKey_ProperlyMapped(ButtonCode input, UserInputKey result)
        {
            IKeyMapper keyMapper = CreateKeyMapper();

            UserInputKey mappedKey = keyMapper.MapToUserInputKey(input);

            Assert.Equal(mappedKey, result);
        }
Example #15
0
 public override bool GetButton(ButtonCode code)
 {
     if (!ActionEnabled)
     {
         return(false);
     }
     return(Input.GetMouseButton((int)code));
 }
Example #16
0
 private static IEnumerable <IEvent> CreateChildren(ButtonCode Button)
 {
     yield return(new RawInput(new MOUSEINPUT()
     {
         Flags = Button.ToMouseButtonDownFlags(),
         MouseData = (uint)Button.ToMouseButtonData(),
     }));
 }
        public void GetCommand_Success(string data, ButtonCode expectedCode, int expectedMenuMessageId, string expectedParameter = null)
        {
            var buttonCommand = _commandFactory.GetCommand(data);

            Assert.NotNull(buttonCommand);
            Assert.Equal(buttonCommand.Button, expectedCode);
            Assert.Equal(buttonCommand.MenuMessageId, expectedMenuMessageId);
            Assert.Equal(buttonCommand.Parameter, expectedParameter);
        }
Example #18
0
        /// <summary>
        /// Triggered by runtime when a button is pressed.
        /// </summary>
        /// <param name="code">Code of the pressed button.</param>
        /// <param name="deviceIdx">Device the event originated from.</param>
        private static void Internal_TriggerButtonDown(ButtonCode code, int deviceIdx)
        {
            ButtonEvent ev = new ButtonEvent(code, deviceIdx);

            if (OnButtonDown != null)
            {
                OnButtonDown(ev);
            }
        }
Example #19
0
        public static bool GetButtonStatus(ButtonCode buttonCode)
        {
            if (button[(int)buttonCode].buttonCode == buttonCode)
            {
                return(button[(int)buttonCode].pointer);
            }

            return(false);
        }
Example #20
0
 public static IObservable <Unit> GetButtonUpObservable(ButtonCode button, Player gamePadId = Player.Player1)
 {
     return
         (Observable.EveryUpdate()
          .Where(_ => Input.GetButtonUp(gamePadId.ToString() + " " + ButtonCodeToInputSignal(button)))
          .AsUnitObservable()
          .Publish()
          .RefCount());
 }
Example #21
0
        /// <summary>
        /// Triggered by runtime when a button is released.
        /// </summary>
        /// <param name="code">Code of the released button.</param>
        /// <param name="deviceIdx">Device the event originated from.</param>
        /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
        private static void Internal_TriggerButtonUp(ButtonCode code, int deviceIdx, bool isUsed)
        {
            ButtonEvent ev = new ButtonEvent(code, deviceIdx, isUsed);

            if (OnButtonUp != null)
            {
                OnButtonUp(ev);
            }
        }
Example #22
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MouseInput" /> class.
        /// </summary>
        /// <param name="Button">One of the MouseButtons values indicating which mouse button was pressed.</param>
        /// <param name="clicks">The number of times a mouse button was pressed.</param>
        /// <param name="point">The x and y coordinate of a mouse click, in pixels.</param>
        /// <param name="scrolldelta">A signed count of the number of detents the wheel has rotated.</param>
        /// <param name="timestamp">The system tick count when the event occurred.</param>
        /// <param name="isMouseButtonDown">True if event signals mouse button down.</param>
        /// <param name="isMouseButtonUp">True if event signals mouse button up.</param>
        public MouseInput(ButtonCode Button, POINT point, int scrolldelta, ButtonStatus status)
        {
            this.Button = Button;
            this.X      = point.X;
            this.Y      = point.Y;

            this.ScrollOffset = scrolldelta;
            this.ButtonStatus = status;
        }
Example #23
0
 /// <summary>
 /// Creates a new menu item attribute with a shortcut. Pressing the shortcut key or selecting the item in the menu
 /// will trigger the menu item callback.
 /// </summary>
 /// <param name="path">Path that determines where in the menu to add the element. All path elements must be
 ///                    separated by /, e.g. "View/Toolbars/Find"</param>
 /// <param name="shortcutModifier">Optional shortcut modifier that needs to be pressed along with the shortcut
 ///                                button in order to trigger the shortcut.</param>
 /// <param name="shortcutKey">Shortcut key that will trigger the shortcut.</param>
 /// <param name="priority">Priority determines the position of the menu item relative to its siblings.
 ///                        Higher priority means it will be placed earlier in the menu.</param>
 /// <param name="separator">Determines should a separator be inserted just before this element.</param>
 /// <param name="contextCallback">Name of a method that returns a boolean determining whether the menu item callback
 ///                               is allowed to trigger. This is useful if menu items are only valid in specific
 ///                               situations (e.g. a scene object must be selected). The method must be static,
 ///                               return a boolean value, accept no parameters and be in the same class as
 ///                               the method this attribute is attached to.</param>
 public MenuItem(string path, ButtonModifier shortcutModifier, ButtonCode shortcutKey, int priority = 0,
                 bool separator = false, string contextCallback = null)
 {
     this.path            = path;
     this.shortcut        = new ShortcutKey(shortcutModifier, shortcutKey);
     this.priority        = priority;
     this.separator       = separator;
     this.contextCallback = contextCallback;
 }
Example #24
0
        private static IEnumerable <IEvent> CreateChildren(ButtonCode Button, int Offset)
        {
            var Flags = Button.ToMouseWheel();

            yield return(new RawInput(new MOUSEINPUT()
            {
                Flags = Flags,
                MouseData = (uint)Offset
            }));
        }
        public InlineKeyboardButtonMenuBuilder AddBackButton(ButtonCode buttonCode, int menuMessageId)
        {
            if (buttonCode != ButtonCode.None)
            {
                var data = new MenuButtonData(buttonCode, menuMessageId).ToString();
                _menu.Add(FormatOneButtonInline("<<<<", data));
            }

            return(this);
        }
Example #26
0
    public bool GetButtonState(int a_Index, ButtonCode a_Button)
    {
        if (m_PlayerIndices.Count <= a_Index)
        {
            return(false);
        }

        switch (a_Button)
        {
        case ButtonCode.A:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.A == ButtonState.Pressed);

        case ButtonCode.B:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.B == ButtonState.Pressed);

        case ButtonCode.X:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.X == ButtonState.Pressed);

        case ButtonCode.Y:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.Y == ButtonState.Pressed);

        case ButtonCode.DpadUp:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).DPad.Up == ButtonState.Pressed);

        case ButtonCode.DpadDown:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).DPad.Down == ButtonState.Pressed);

        case ButtonCode.DpadLeft:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).DPad.Left == ButtonState.Pressed);

        case ButtonCode.DpadRight:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).DPad.Right == ButtonState.Pressed);

        case ButtonCode.Start:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.Start == ButtonState.Pressed);

        case ButtonCode.Back:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.Back == ButtonState.Pressed);

        case ButtonCode.LBumper:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.LeftShoulder == ButtonState.Pressed);

        case ButtonCode.RBumper:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.RightShoulder == ButtonState.Pressed);

        case ButtonCode.LStick:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.LeftStick == ButtonState.Pressed);

        case ButtonCode.RStick:
            return(GamePad.GetState(m_PlayerIndices[a_Index]).Buttons.RightStick == ButtonState.Pressed);

        default:
            return(false);
        }
    }
Example #27
0
 public void SetDebugButtonActive(ButtonCode bcode, bool setting)
 {
     if (setting)
     {
         debugButtons[(int)bcode].image.sprite = activeImages[(int)bcode];
     }
     else
     {
         debugButtons[(int)bcode].image.sprite = inactiveImages[(int)bcode];
     }
     debugButtons[(int)bcode].interactable = setting;
 }
Example #28
0
 private void UpdateButton(string optionText, ButtonCode buttonCode, bool isCorrectOption = false)
 {
     if (buttonCode == _buttonCode)
     {
         _optionBackgroundImage.texture = _optionDefaultBackground;
         _chooseIconImage.texture       = _defaultOptionIcon;
         _optionText.SetText(optionText);
         isTrueOption = isCorrectOption;
     }
     else
     {
         return;
     }
 }
        public static uint ToMouseButtonData(this ButtonCode This)
        {
            var ret = default(uint);

            if (This == ButtonCode.XButton1)
            {
                ret = 1;
            }
            else if (This == ButtonCode.XButton2)
            {
                ret = 2;
            }

            return(ret);
        }
Example #30
0
 // Use this for initialization
 void Start()
 {
     if (!xinputStarted)
     {
         xinputStarted = true;
         InitGamepads();
         ButtonCode.init();
     }
     for (int k = 0; k < 4; k++)
     {
         connected[k] = CheckGamepadConnected(k);
         if (connected[k])
         {
             gamepadsConnected++;
         }
     }
 }
Example #31
0
        private void PrintOutReplyMarkup(LangCode langCode, ButtonCode topButtonCode, InlineKeyboardMarkup replyMarkup)
        {
            var text        = _localizer.GetButtonText(langCode, topButtonCode);
            var textBuilder = new StringBuilder().AppendLine(text);

            foreach (var row in replyMarkup.InlineKeyboard)
            {
                var rowText = new StringBuilder();
                foreach (var column in row)
                {
                    rowText.Append($"{column.Text} ({column.CallbackData})\t");
                }

                textBuilder.AppendLine(rowText.ToString());
            }

            _botResponse.Response(textBuilder.ToString());
        }
Example #32
0
 /// <summary>
 /// Creates a new button input event. For runtime use only.
 /// </summary>
 /// <param name="buttonCode">Button code this event is referring to.</param>
 /// <param name="deviceIdx">Index of the device that the event originated from.</param>
 /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
 internal ButtonEvent(ButtonCode buttonCode, int deviceIdx, bool isUsed)
 {
     this.buttonCode = buttonCode;
     this.deviceIdx = deviceIdx;
     this.isUsed = isUsed;
 }
Example #33
0
        /// <summary>
        /// Triggered by runtime when a button is released.
        /// </summary>
        /// <param name="code">Code of the released button.</param>
        /// <param name="deviceIdx">Device the event originated from.</param>
        private static void Internal_TriggerButtonUp(ButtonCode code, int deviceIdx)
        {
            ButtonEvent ev = new ButtonEvent(code, deviceIdx);

            if (OnButtonUp != null)
                OnButtonUp(ev);
        }
Example #34
0
 private static extern bool Internal_IsButtonUp(ButtonCode keyCode, int deviceIdx);
Example #35
0
 /// <summary>
 /// Query if the provided button is currently being released (only true for one frame).
 /// </summary>
 /// <param name="code">Code of the button to query.</param>
 /// <param name="deviceIdx">Device to query the button on (0 - primary).</param>
 /// <returns>True if the button is being released.</returns>
 public static bool IsButtonUp(ButtonCode code, int deviceIdx = 0)
 {
     return Internal_IsButtonUp(code, deviceIdx);
 }
Example #36
0
 /// <summary>
 /// Creates a new button input event. For runtime use only.
 /// </summary>
 /// <param name="buttonCode">Button code this event is referring to.</param>
 /// <param name="deviceIdx">Index of the device that the event originated from.</param>
 internal ButtonEvent(ButtonCode buttonCode, int deviceIdx)
 {
     this.buttonCode = buttonCode;
     this.deviceIdx = deviceIdx;
 }
Example #37
0
 private static extern void Internal_RegisterButton(IntPtr thisPtr, String name, ButtonCode buttonCode,
     ButtonModifier modifiers, bool repeatable);
Example #38
0
 /// <summary>
 /// Registers a new virtual button.
 /// </summary>
 /// <param name="name">Unique name used to access the virtual button.</param>
 /// <param name="buttonCode">Physical button the virtual button is triggered by.</param>
 /// <param name="modifiers">Modifiers required to be pressed with the physical button to trigger the virtual button.
 ///                         </param>
 /// <param name="repeatable">If true, the virtual button events will be sent continually while the physical button 
 ///                          is being held.</param>
 public void RegisterButton(String name, ButtonCode buttonCode, 
     ButtonModifier modifiers = ButtonModifier.None, bool repeatable = false)
 {
     Internal_RegisterButton(mCachedPtr, name, buttonCode, modifiers, repeatable);
 }
Example #39
0
 /// <summary>
 /// Creates a new shortcut key.
 /// </summary>
 /// <param name="modifier">Optional modifier that is required to be pressed along with the shortcut button.</param>
 /// <param name="key">Shortcut button that triggers the shortcut.</param>
 public ShortcutKey(ButtonModifier modifier, ButtonCode key)
 {
     this.modifier = modifier;
     this.key = key;
 }
Example #40
0
 public EmulatorButtonEvent(PhoneEvent.Types.KeyEvent proto)
 {
     code = (ButtonCode) proto.Code;
       down = proto.Action == 0;
 }