Пример #1
0
    void Update()
    {
        // pressing 1, 2 activate buttons in debug mode
        if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha1)) {
            buttonState = ButtonState.LeftPressed;
            leftMat.color = leftPressed;
            rightMat.color = rightUnpressed;
            leftAnimator.SetTrigger(Animator.StringToHash("Push"));
            Debug.Log("Pressed left button");
        } else if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha2)) {
            buttonState = ButtonState.RightPressed;
            leftMat.color = leftUnpressed;
            rightMat.color = rightPressed;
            rightAnimator.SetTrigger(Animator.StringToHash("Push"));
            Debug.Log("Pressed right button");
        }

        if (Activated && buttonState == ButtonState.LeftPressed) {
            leftMat.color = leftPressed;
            rightMat.color = rightUnpressed;
        } else if (Activated && buttonState == ButtonState.RightPressed) {
            leftMat.color = leftUnpressed;
            rightMat.color = rightPressed;
        }
    }
Пример #2
0
 static InputManager()
 {
     keySet = new HashSet<Keys>();
     leftClick = Mouse.GetState().LeftButton;
     rightClick = Mouse.GetState().RightButton;
     mouseLastState = Mouse.GetState();
 }
 protected void StateChangedMethod(ButtonState prevState, ButtonState currState)
 {
     var backButtonTex = Resources.Load<Texture2D>(String.Format(@"Buttons/{0}", gameObject.GetComponent<SpriteRenderer>().sprite.texture.name.Replace(prevState.ToString(), currState.ToString())));
     if (!backButtonTex) return;
     gameObject.GetComponent<SpriteRenderer>().sprite = Sprite.Create(backButtonTex,
         new Rect(0, 0, backButtonTex.width, backButtonTex.height), new Vector2(0, 0));
 }
        public HalfPadState(ControlSide side, PlayerIndex controllerIndex)
        {
            GamePadState gamePadState = GamePad.GetState(controllerIndex);
            if (side == ControlSide.left)
            {
                stick1 = new Stick(gamePadState.ThumbSticks.Left);
                stick2 = new Stick(gamePadState.DPad.Up,
                                   gamePadState.DPad.Down,
                                   gamePadState.DPad.Left,
                                   gamePadState.DPad.Right);

                Btn1 = gamePadState.Buttons.LeftShoulder;
                Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
                Btn2AsTrigger = gamePadState.Triggers.Left;
                Btn3 = gamePadState.Buttons.LeftStick;

                BtnStart = gamePadState.Buttons.Back;
            }
            else //if (side == ControlSide.right)
            {
                stick1 = new Stick(gamePadState.ThumbSticks.Right);
                stick2 = new Stick(gamePadState.Buttons.Y,
                                   gamePadState.Buttons.A,
                                   gamePadState.Buttons.X,
                                   gamePadState.Buttons.B);

                Btn1 = gamePadState.Buttons.RightShoulder;
                Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
                Btn2AsTrigger = gamePadState.Triggers.Right;
                Btn3 = gamePadState.Buttons.RightStick;

                BtnStart = gamePadState.Buttons.Start;
            }
        }
Пример #5
0
 /*public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
                   ButtonState A_1, ButtonState X_2, ButtonState B_3, ButtonState Y_4,
                   ButtonState Dpad_UpArrow, ButtonState Dpad_DownArrow, ButtonState Dpad_RightArrow, ButtonState Dpad_LeftArrow,
                   ButtonState Select_TAB, ButtonState Start_ESC,
                   ButtonState LeftBumper_Q, ButtonState RightBumper_E,
                   ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
                   float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
 {
     this.LeftStick_WASD = LeftStick_WASD;
     this.RightStick_Mouse = RightStick_Mouse;
     this.A_1 = A_1;
     this.X_2 = X_2;
     this.B_3 = B_3;
     this.Y_4 = Y_4;
     this.Dpad_UpArrow = Dpad_UpArrow;
     this.Dpad_DownArrow = Dpad_DownArrow;
     this.Dpad_RightArrow = Dpad_RightArrow;
     this.Dpad_LeftArrow = Dpad_LeftArrow;
     this.Select_TAB = Select_TAB;
     this.Start_ESC = Start_ESC;
     this.LeftBumper_Q = LeftBumper_Q;
     this.RightBumper_E = RightBumper_E;
     this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
     this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
     this.LeftTriggerAnalog = LeftTriggerAnalog;
     this.RightTriggerAnalog = RightTriggerAnalog;
 }*/
 //keyboard/mouse
 public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
                   ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
                   bool A_1, bool X_2, bool B_3, bool Y_4,
                   bool Dpad_UpArrow, bool Dpad_DownArrow, bool Dpad_RightArrow, bool Dpad_LeftArrow,
                   bool Select_TAB, bool Start_ESC,
                   bool LeftBumper_Q, bool RightBumper_E,
                   float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
 {
     this.LeftStick_WASD = LeftStick_WASD;
     this.RightStick_Mouse = RightStick_Mouse;
     this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
     this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
     this.A_1 = A_1 ? ButtonState.Pressed : ButtonState.Released;
     this.X_2 = X_2 ? ButtonState.Pressed : ButtonState.Released;
     this.B_3 = B_3 ? ButtonState.Pressed : ButtonState.Released;
     this.Y_4 = Y_4 ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_UpArrow = Dpad_UpArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_DownArrow = Dpad_DownArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_RightArrow = Dpad_RightArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Dpad_LeftArrow = Dpad_LeftArrow ? ButtonState.Pressed : ButtonState.Released;
     this.Select_TAB = Select_TAB ? ButtonState.Pressed : ButtonState.Released;
     this.Start_ESC = Start_ESC ? ButtonState.Pressed : ButtonState.Released;
     this.LeftBumper_Q = LeftBumper_Q ? ButtonState.Pressed : ButtonState.Released;
     this.RightBumper_E = RightBumper_E ? ButtonState.Pressed : ButtonState.Released;
     this.LeftTriggerAnalog = LeftTriggerAnalog;
     this.RightTriggerAnalog = RightTriggerAnalog;
 }
Пример #6
0
        public void Update()
        {
            if (ft)
            {
                ft = false;
                return;
            }
            state = Mouse.GetState();
            if (mousePos.X != state.X || mousePos.Y != state.Y)
                moved = true;
            else
                moved = false;
            mousePos.X = state.X;
            mousePos.Y = state.Y;

            d_mouse = new Vector2(state.X - lastState.X, state.Y - lastState.Y);

            scrollWheelDelta = scrollWheelValue - state.ScrollWheelValue;
            scrollWheelValue = state.ScrollWheelValue;

            lmbState = state.LeftButton;
            rmbState = state.RightButton;
            isJustPressed = isJustReleased = false;
            if (lmblastState == ButtonState.Pressed && lmbState == ButtonState.Released)
                isJustReleased = true;
            else if (lmblastState == ButtonState.Released && lmbState == ButtonState.Pressed)
                isJustPressed = true;

            lastState = state;
        }
Пример #7
0
 public FlickGesture()
 {
     AngleThreshold = 0.35f;
     DistanceThreshold = 0.05f;
     _previousState = ButtonState.Up;
     _pointData = new List<PointF>();
 }
 internal static RadioButtonState ConvertFromButtonState(ButtonState state, bool isHot)
 {
     if ((state & ButtonState.Checked) == ButtonState.Checked)
     {
         if ((state & ButtonState.Pushed) == ButtonState.Pushed)
         {
             return RadioButtonState.CheckedPressed;
         }
         if ((state & ButtonState.Inactive) == ButtonState.Inactive)
         {
             return RadioButtonState.CheckedDisabled;
         }
         if (isHot)
         {
             return RadioButtonState.CheckedHot;
         }
         return RadioButtonState.CheckedNormal;
     }
     if ((state & ButtonState.Pushed) == ButtonState.Pushed)
     {
         return RadioButtonState.UncheckedPressed;
     }
     if ((state & ButtonState.Inactive) == ButtonState.Inactive)
     {
         return RadioButtonState.UncheckedDisabled;
     }
     if (isHot)
     {
         return RadioButtonState.UncheckedHot;
     }
     return RadioButtonState.UncheckedNormal;
 }
Пример #9
0
        public virtual void Update(Microsoft.Xna.Framework.Vector2 position)
        {
            position = Screen.RelationToPosition(position-offset);
            var pos = Mouse.GetState();
            if (pos.X > position.X && pos.X < position.X + Width
                &&
                pos.Y > position.Y && pos.Y < position.Y + Height)
            {
                if (focus != this)
                {
                    if (MouseEnter != null)
                        MouseEnter(this, new EventArgs());
                }
                focus = this;

                if (pos.LeftButton == ButtonState.Pressed
                    && msButState != pos.LeftButton)
                {
                    if (MouseClick != null)
                        MouseClick(this, new EventArgs());
                }
                msButState = pos.LeftButton;
            }
            else
            {
                if (focus == this)
                {
                    focus = null;
                    if (MouseLeave != null)
                        MouseLeave(this, new EventArgs());
                }
            }
        }
 protected void OnMouseUpAsButton()
 {
     if (_State == ButtonState.Disabled) return;
     _State = ButtonState.Over;
     if(MethodOnClick != null)
         MethodOnClick.DynamicInvoke();
 }
Пример #11
0
        /// <summary>
        ///  This class performs an important function.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            mouseState = Mouse.GetState();
            buttonState = mouseState.LeftButton;

            if (Contains(mouseState.X, mouseState.Y))
            {
                foreach (AnswerWidget tmp in AnswerListWidget)
                {
                    if (tmp.Contains(mouseState.X, mouseState.Y))
                    {
                        this.Scale = new Vector2(2, 1);
                        this.TintColor = Color.Red;
                        if ((buttonState == ButtonState.Pressed))
                        {
                            //Engine.Instance.ResolutionManager.ScreenSize = new Vector2(Width, Height);
                        }
                        else
                        {
                            this.Scale = new Vector2(1, 1);
                            this.TintColor = Color.Yellow;
                        }
                    }
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ErrorDialog"/> class.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="buttons">The buttons.</param>
        public ErrorDialog(string title, string message, Exception exception, ButtonState buttons)
            : this()
        {
            ErrorTitle = title;
            ErrorMessage = message;
            ErrorException = exception;

            switch (buttons)
            {
                case ButtonState.CloseContinue:
                    btnContinue.Visible = true;
                    btnClose.Visible = true;
                    btnOk.Visible = false;
                    btnCancel.Visible = false;
                    break;
                case ButtonState.OkCancel:
                    btnContinue.Visible = false;
                    btnClose.Visible = false;
                    btnOk.Visible = true;
                    btnCancel.Visible = true;
                    break;
                case ButtonState.OkOnly:
                    btnContinue.Visible = false;
                    btnClose.Visible = false;
                    btnOk.Visible = true;
                    btnCancel.Visible = false;
                    break;
            }
        }
Пример #13
0
		public ButtonCell()
		{
			title = "Button";
			buttonType = ButtonType.MomentaryLight;
			bezelStyle = BezelStyle.Rounded;
			buttonState = ButtonState.Unchecked;
		}
Пример #14
0
 public MouseEventArgs(float _x, float _y, int _button, ButtonState _buttonState)
 {
     x = _x;
     y = _y;
     button = _button;
     buttonState = _buttonState;
 }
Пример #15
0
		//render using new style
		protected override void DrawSelectionFrame(PaintEventArgs e, Rectangle rct, ButtonState state)
		{
			if (state == ButtonState.Checked ||
			    state == ButtonState.Pushed) {
				e.Graphics.PixelOffsetMode = PixelOffsetMode.None;
				e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
				rct.Width--;
				rct.Height--;
				using (GraphicsPath pth = CreateRoundedRect(2, rct)) {
					using (LinearGradientBrush brs = new LinearGradientBrush(
						new Point(0, rct.Bottom), new Point(0, rct.Y),
						Color.Black, Color.White)) {
						ColorBlend colorblnd = new ColorBlend();
						colorblnd.Positions = new float[]
						                      	{
						                      		0F, 0.5F, 0.50F, 1F
						                      	};
						colorblnd.Colors = new Color[]
						                   	{
						                   		Color.FromArgb(255, 236, 181),
						                   		Color.FromArgb(255, 236, 181),
						                   		Color.FromArgb(255, 243, 207),
						                   		Color.FromArgb(255, 252, 242)
						                   	};
						//
						brs.InterpolationColors = colorblnd;
						e.Graphics.FillPath(brs, pth);
					}
					using (Pen pn = new Pen(Color.FromArgb(229, 195, 101)))
						e.Graphics.DrawPath(pn, pth);
				}
			}
		}
Пример #16
0
        /// <summary>
        /// Update method that will trigger click events as needed
        /// </summary>
        /// <param name="state"></param>
        public void Update(ButtonState state)
        {
            if (state == ButtonState.Pressed && previousState != ButtonState.Pressed)
            {
                if (Pressed != null)
                {
                    Pressed(this);
                }
            }
            else if (state == ButtonState.Released && previousState == ButtonState.Pressed)
            {
                // For now, define a click as a release. In the future, maybe
                // have click be more restrictive or even driven by components
                // rather than a generic input handler
                if (Clicked != null)
                {
                    Clicked(this);
                }

                if (Released != null)
                {
                    Released(this);
                }
            }

            previousState = state;
        }
        internal void ThreadButtonState()
        {
            int LastSearchTime = Config.ButtonStateUpdateInterval;
            while (true)
            {
                if (Form.NTRConnection.HardwarePID != null)
                {
                    SearchCriteria Criteria = new SearchCriteria();
                    Criteria.ProcessID = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Form.NTRConnection.HardwarePID), 0);
                    Criteria.DataType = DataTypeExact.Bytes1;
                    Criteria.StartAddress = BUTTON_STATES_START;
                    Criteria.Length = BUTTON_STATES_SIZE;
                    Criteria.SearchType = SearchTypeBase.Unknown;
                    Criteria.SearchValue = new byte[] { 0 };
                    Criteria.Size = 1;
                    Criteria.HideSearch = true;
                    Form.NTRConnection.SearchCriteria.Add(Criteria);

                    Form.NTRConnection.SendReadMemoryPacket(Criteria);

                    ButtonState = (ButtonState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Button][0];
                    ShoulderState = (ShoulderState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Shoulder][0];
                    StickState = (StickState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Stick][0];
                    StickHoriz = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Horiz][0];
                    StickVert = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Vert][0];

                    LastSearchTime = Math.Max(LastSearchTime, (int)Criteria.Duration);

                    Form.NTRConnection.SetCurrentOperationText2 = ButtonState.ToString() + "|" + ShoulderState.ToString() + "|" + StickState.ToString() + "|" + StickHoriz + "|" + StickVert + "|" + LastSearchTime;
                }

                Thread.Sleep(LastSearchTime * 2);
            }
        }
 public bool IsClicked()
 {
     MouseState tmp = Mouse.GetState();
         bool b = ButtonState.Released == tmp.LeftButton && leftButtonState == ButtonState.Pressed;
         leftButtonState = tmp.LeftButton;
         return b && tmp.X >= X && tmp.X <= X + Texture.Width && tmp.Y >= Y && tmp.Y <= Y + Texture.Height;
 }
Пример #19
0
		public GamePadDPad (
         ButtonState upValue,
         ButtonState downValue,
         ButtonState leftValue,
         ButtonState rightValue )
		{
		}
 public void UpdateInput(object sender, MouseInputEventArgs e)
 {
     if (MouseMode != e.Mode)
         e.Mode = MouseMode;
     X -= e.X;
     Y -= e.Y;
     WheelDelta += e.WheelDelta;
     if (e.ButtonFlags == MouseButtonFlags.LeftDown)
         LeftButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.LeftUp)
         LeftButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.RightDown)
         RightButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.RightUp)
         RightButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.MiddleDown)
         MiddleButton = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.MiddleUp)
         MiddleButton = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.Button4Down)
         Button4 = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.Button4Up)
         Button4 = ButtonState.Released;
     if (e.ButtonFlags == MouseButtonFlags.Button5Down)
         Button5 = ButtonState.Pressed;
     if (e.ButtonFlags == MouseButtonFlags.Button5Up)
         Button5 = ButtonState.Released;
 }
Пример #21
0
        public override void Update(GameTime gameTime)
        {
            if (!Visible) return;
            Text = Width + " x " + Height;
            mouseState = Mouse.GetState();
            buttonState = mouseState.LeftButton;

            base.Update(gameTime);
            if (Contains(mouseState.X, mouseState.Y) )
            {
                this.Scale = new Vector2(2, 1);
                this.TintColor = Color.Red;
                if ((buttonState == ButtonState.Pressed) )
                {
                    Engine.Instance.ResolutionManager.ScreenSize = new Vector2(Width, Height);
                    //Engine.Instance.ResolutionManager.FullScreen = !Engine.Instance.ResolutionManager.FullScreen;
                }

            }
            else
            {
                this.Scale = new Vector2(1, 1);
                this.TintColor = Color.Yellow;
            }
        }
Пример #22
0
 public void Update(ButtonState up, ButtonState down, ButtonState left, ButtonState right)
 {
     this.Up = up == ButtonState.Pressed;
     this.Down = down == ButtonState.Pressed;
     this.Left = left == ButtonState.Pressed;
     this.Right = right == ButtonState.Pressed;
 }
Пример #23
0
 public Slider(Rectangle sliderBar, Rectangle buttonPosition, Rectangle bounds, string texturePath)
 {
     this.sliderBar = sliderBar;
     this.bounds = bounds;
     this.buttonPosition = buttonPosition;
     this.texturePath = texturePath;
     PreviousButtonState = ButtonState.Released;
 }
Пример #24
0
 public void Initialize()
 {
     c = ButtonState.Released;
     z = ButtonState.Released;
     joyAngle = 0;
     joyMagnitude = 0;
     connected = false;
 }
Пример #25
0
		internal MouseState(int x, int y)
		{
			_x = x;
			_y = y;
			_leftButton = ButtonState.Released;
			_middleButton = ButtonState.Released;
			_rightButton = ButtonState.Released;
		}
Пример #26
0
 public Button(ContentManager content, string asset, Vector2 position, float radius)
     : base(content, asset)
 {
     _pos = position;
        _scale = radius;
        _buttonstate = ButtonState.IDLE;
        _data = 0;
 }
Пример #27
0
 public GamePadDPad(ButtonState upValue, ButtonState downValue, ButtonState leftValue, ButtonState rightValue)
     : this()
 {
     Up = upValue;
     Down = downValue;
     Left = leftValue;
     Right = rightValue;
 }
Пример #28
0
 public GamePadDPad(ButtonState upValue, ButtonState downValue, ButtonState leftValue, ButtonState rightValue)
 {
   this = new GamePadDPad();
   this.Up = upValue;
   this.Down = downValue;
   this.Left = leftValue;
   this.Right = rightValue;
 }
Пример #29
0
 public GameButton(SpriteManager.ESprite s, Vector2 pos, PlayerControl.HandlerAction act)
     : base(App.Game)
 {
     btnState = ButtonState.Released;
     handler = act;
     type = s;
     coord = new Rectangle((int)pos.X, (int)pos.Y, (int)Constants.Measures.buttonSize, (int)Constants.Measures.buttonSize);
 }
 public MouseButtonCondition(string name, MouseButton mouseButton, Operator inputOperator,
     ButtonState buttonState)
 {
     Name = name;
     MouseButton = mouseButton;
     Operator = inputOperator;
     ButtonState = buttonState;
 }
Пример #31
0
 public static void DrawMixedCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state)
 {
     DrawMixedCheckBox(graphics, new Rectangle(x, y, width, height), state);
 }
Пример #32
0
 public static void DrawScrollButton(Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state)
 {
     ThemeEngine.Current.CPDrawScrollButton(graphics, rectangle, button, state);
 }
Пример #33
0
        private void UpdateButtons(MouseEventArgs e, bool up = false)
        {
            if (DesignMode)
            {
                return;
            }
            var  oldState = _buttonState;
            bool showMin  = MinimizeBox && ControlBox;
            bool showMax  = MaximizeBox && ControlBox;

            if (e.Button == MouseButtons.Left && !up)
            {
                if (showMin && !showMax && _maxButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MinDown;
                }
                else if (showMin && showMax && _minButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MinDown;
                }
                else if (showMax && _maxButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MaxDown;
                }
                else if (ControlBox && _xButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.XDown;
                }
                else
                {
                    _buttonState = ButtonState.None;
                }
            }
            else
            {
                if (showMin && !showMax && _maxButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MinOver;

                    if (oldState == ButtonState.MinDown && up)
                    {
                        WindowState = FormWindowState.Minimized;
                    }
                }
                else if (showMin && showMax && _minButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MinOver;

                    if (oldState == ButtonState.MinDown && up)
                    {
                        WindowState = FormWindowState.Minimized;
                    }
                }
                else if (MaximizeBox && ControlBox && _maxButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.MaxOver;

                    if (oldState == ButtonState.MaxDown && up)
                    {
                        MaximizeWindow();
                    }
                }
                else if (ControlBox && _xButtonBounds.Contains(e.Location))
                {
                    _buttonState = ButtonState.XDown;

                    if (oldState == ButtonState.XDown && up)
                    {
                        Close();
                    }
                }
                else
                {
                    _buttonState = ButtonState.None;
                }
            }

            if (oldState != _buttonState)
            {
                Invalidate();
            }
        }
Пример #34
0
 public void setState(int state)
 {
     currentState = (ButtonState)state;
     resetColor();
 }
Пример #35
0
 private static bool GetControllerValue(int buttonIndex, ButtonState state)
 {
     return(GenericUtility.ConcatBool(GetControllerValues(buttonIndex, state)));
 }
Пример #36
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     state = ButtonState.Pushed;
     base.OnMouseDown(e);
 }
Пример #37
0
 /// <summary>
 /// Allow some external component to set button state (for current frame only).
 /// </summary>
 /// <param name="index">Index.</param>
 /// <param name="state">State.</param>
 abstract public void ForceButtonState(int index, ButtonState state);
Пример #38
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.m_leftStickButton, gamepad));

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

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                return(false);
            }
        }
Пример #39
0
        private bool IsButtonPressedOrReleased(XInput.Button button, ButtonState prevButtonState, ButtonState buttonState)
        {
            switch (button)
            {
            case XInput.Button.A:
                return(prevState.Buttons.A == prevButtonState && state.Buttons.A == buttonState);

            case XInput.Button.B:
                return(prevState.Buttons.B == prevButtonState && state.Buttons.B == buttonState);

            case XInput.Button.Back:
                return(prevState.Buttons.Back == prevButtonState && state.Buttons.Back == buttonState);

            case XInput.Button.Guide:
                return(prevState.Buttons.Guide == prevButtonState && state.Buttons.Guide == buttonState);

            case XInput.Button.LeftShoulder:
                return(prevState.Buttons.LeftShoulder == prevButtonState && state.Buttons.LeftShoulder == buttonState);

            case XInput.Button.LeftStick:
                return(prevState.Buttons.LeftStick == prevButtonState && state.Buttons.LeftStick == buttonState);

            case XInput.Button.RightShoulder:
                return(prevState.Buttons.RightShoulder == prevButtonState && state.Buttons.RightShoulder == buttonState);

            case XInput.Button.RightStick:
                return(prevState.Buttons.RightStick == prevButtonState && state.Buttons.RightStick == buttonState);

            case XInput.Button.Start:
                return(prevState.Buttons.Start == prevButtonState && state.Buttons.Start == buttonState);

            case XInput.Button.X:
                return(prevState.Buttons.X == prevButtonState && state.Buttons.X == buttonState);

            case XInput.Button.Y:
                return(prevState.Buttons.Y == prevButtonState && state.Buttons.Y == buttonState);

            case XInput.Button.DPadUp:
                return(prevState.DPad.Up == prevButtonState && state.DPad.Up == buttonState);

            case XInput.Button.DPadDown:
                return(prevState.DPad.Down == prevButtonState && state.DPad.Down == buttonState);

            case XInput.Button.DPadLeft:
                return(prevState.DPad.Left == prevButtonState && state.DPad.Left == buttonState);

            case XInput.Button.DPadRight:
                return(prevState.DPad.Right == prevButtonState && state.DPad.Right == buttonState);

            default:
                return(false);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Stat">Input TagAccess Data</param>
 public OnButtonClickEventArgs(ButtonState Stat, bool Enable)
 {
     state  = Stat;
     enable = Enable;
 }
Пример #41
0
 public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state)
 {
     DrawCaptionButton(graphics, new Rectangle(x, y, width, height), button, state);
 }
Пример #42
0
 public GamePadDPad(ButtonState upValue, ButtonState downValue, ButtonState leftValue, ButtonState rightValue)
 {
     this       = new GamePadDPad();
     this.Up    = upValue;
     this.Down  = downValue;
     this.Left  = leftValue;
     this.Right = rightValue;
 }
Пример #43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     state = ButtonState.Normal;
     base.OnMouseUp(e);
 }
Пример #44
0
        public void CtorWithHorizontalScroll(int x, int y, int scrollWheel, ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2, int horizontalScrollWheel)
        {
#if !XNA
            var state = new MouseState(x, y, scrollWheel, leftButton, middleButton, rightButton, xButton1, xButton2, horizontalScrollWheel);
#else
            var state = new MouseState(x, y, scrollWheel, leftButton, middleButton, rightButton, xButton1, xButton2);
#endif

            Assert.AreEqual(state.X, x);
            Assert.AreEqual(state.Y, y);
#if !XNA
            Assert.AreEqual(state.Position, new Point(x, y));
#endif
            Assert.AreEqual(state.ScrollWheelValue, scrollWheel);
            Assert.AreEqual(state.LeftButton, leftButton);
            Assert.AreEqual(state.MiddleButton, middleButton);
            Assert.AreEqual(state.RightButton, rightButton);
            Assert.AreEqual(state.XButton1, xButton1);
            Assert.AreEqual(state.XButton2, xButton2);
#if !XNA
            Assert.AreEqual(state.HorizontalScrollWheelValue, horizontalScrollWheel);
#endif
        }
Пример #45
0
        private void UpdateState(ButtonState newState)
        {
            if (!Enabled)
            {
                if (checkedValue)
                {
                    Quad.Texture = this.textureDisabledOn;
                }
                else
                {
                    Quad.Texture = this.textureDissabledOff;
                }
            }
            else
            {
                switch (newState)
                {
                case ButtonState.Hover:
                    if (buttonState == ButtonState.PressedHover)
                    {
                        checkedValue = !checkedValue;
                        if (this.Changed != null)
                        {
                            this.Changed();
                        }
                    }
                    if (checkedValue)
                    {
                        Quad.Texture = this.textureHoverOn;
                    }
                    else
                    {
                        Quad.Texture = this.textureHoverOff;
                    }
                    break;

                case ButtonState.PressedHover:
                    if (checkedValue)
                    {
                        Quad.Texture = this.textureHoverOff;
                    }
                    else
                    {
                        Quad.Texture = this.textureHoverOn;
                    }
                    break;

                case ButtonState.Pressed:
                    if (checkedValue)
                    {
                        Quad.Texture = this.textureHoverOn;
                    }
                    else
                    {
                        Quad.Texture = this.textureHoverOff;
                    }
                    break;

                case ButtonState.Normal:
                    if (checkedValue)
                    {
                        Quad.Texture = this.textureOn;
                    }
                    else
                    {
                        Quad.Texture = this.textureOff;
                    }
                    break;
                }
            }
            this.buttonState = newState;
        }
Пример #46
0
        public void SetGet(int x, int y, int scrollWheel, ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2, int horizontalScrollWheel)
        {
            var state = new MouseState
            {
                X = x,
                Y = y,
                ScrollWheelValue           = scrollWheel,
                LeftButton                 = leftButton,
                MiddleButton               = middleButton,
                RightButton                = rightButton,
                XButton1                   = xButton1,
                XButton2                   = xButton2,
                HorizontalScrollWheelValue = horizontalScrollWheel
            };

            Assert.AreEqual(state.X, x);
            Assert.AreEqual(state.Y, y);
            Assert.AreEqual(state.ScrollWheelValue, scrollWheel);
            Assert.AreEqual(state.LeftButton, leftButton);
            Assert.AreEqual(state.MiddleButton, middleButton);
            Assert.AreEqual(state.RightButton, rightButton);
            Assert.AreEqual(state.XButton1, xButton1);
            Assert.AreEqual(state.XButton2, xButton2);
            Assert.AreEqual(state.HorizontalScrollWheelValue, horizontalScrollWheel);

            var state2 = new MouseState(x, y, scrollWheel, leftButton, middleButton, rightButton, xButton1, xButton2, horizontalScrollWheel);

            Assert.AreEqual(state, state2);
            Assert.AreEqual(state.GetHashCode(), state2.GetHashCode());
        }
Пример #47
0
 public override void OnPointerUp(PointerEventData data)
 {
     state = ButtonState.UP;
 }
Пример #48
0
        private bool checkButtonsState(eInputButtons i_Buttons, ButtonState i_ButtonState, bool i_IsOneEnough)
        {
            const bool v_CheckChanged = true;

            return(checkButtonsState(i_Buttons, i_ButtonState, i_IsOneEnough, !v_CheckChanged));
        }
Пример #49
0
 public override void OnPointerDown(PointerEventData data)
 {
     state = ButtonState.DOWN;
 }
Пример #50
0
    protected void CalculateState(Keys k, out ButtonState state)
    {
        bool        keyDown   = currentKeyboardState.IsKeyDown(k);
        ButtonState prevState = previousKeyStates[k];

        switch (prevState)
        {
        case (ButtonState.Down):
        {
            if (keyDown)
            {
                state = ButtonState.Down;
            }
            else
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Released}");
                state = ButtonState.Released;
            }
        }
        break;

        case (ButtonState.Pressed):
        {
            if (keyDown)
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Down}");
                state = ButtonState.Down;
            }
            else
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Released}");
                state = ButtonState.Released;
            }
        }
        break;

        case (ButtonState.Released):
        {
            if (keyDown)
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Pressed}");
                state = ButtonState.Pressed;
            }
            else
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Up}");
                state = ButtonState.Up;
            }
        }
        break;

        case (ButtonState.Up):
        {
            if (keyDown)
            {
                LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Pressed}");
                state = ButtonState.Pressed;
            }
            else
            {
                state = ButtonState.Up;
            }
        }
        break;

        default:
        {
            LogManager.LogVerbose($"Key {k} state changed from {prevState} to {ButtonState.Up}");
            state = ButtonState.Up;
        }
        break;
        }
    }
Пример #51
0
 private void UpdateButtonState(ButtonState newButtonState, int rowIndex)
 {
     Debug.Assert(this.DataGridView != null);
     this.ButtonStatePrivate = newButtonState;
     this.DataGridView.InvalidateCell(this.ColumnIndex, rowIndex);
 }
Пример #52
0
 public static void DrawRadioButton(Graphics graphics, Rectangle rectangle, ButtonState state)
 {
     ThemeEngine.Current.CPDrawRadioButton(graphics, rectangle, state);
 }
Пример #53
0
        private void DrawButton(Graphics e, mcButtonState state, mcHeaderButtons button, Rectangle rect)
        {
            Bitmap image = null;
            int    x     = 0;
            int    y     = 0;
            int    corr  = 0;

            if (Application.RenderWithVisualStyles)
            {
                VisualStyleElement element = VisualStyleElement.Button.PushButton.Normal;

                if (m_calendar.Enabled)
                {
                    if (state == mcButtonState.Hot)
                    {
                        element = VisualStyleElement.Button.PushButton.Hot;
                    }
                    else if (state == mcButtonState.Inactive)
                    {
                        element = VisualStyleElement.Button.PushButton.Disabled;
                    }
                    else if (state == mcButtonState.Pushed)
                    {
                        element = VisualStyleElement.Button.PushButton.Pressed;
                    }
                }
                else
                {
                    element = VisualStyleElement.Button.PushButton.Disabled;
                }

                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e, rect);
                switch (button)
                {
                case mcHeaderButtons.PreviousMonth:
                {
                    image = m_prevMonthVs;
                    x     = rect.Left + 5;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.PreviousYear:
                {
                    image = m_prevYearVs;
                    x     = rect.Left + 4;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.NextMonth:
                {
                    image = m_nextMonthVs;
                    x     = rect.Right - 13;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.NextYear:
                {
                    image = m_nextYearVs;
                    x     = rect.Right - 16;
                    y     = rect.Top + 5;
                    break;
                }
                }

                if ((m_calendar.Enabled) && (state != mcButtonState.Inactive))
                {
                    e.DrawImageUnscaled(image, new Point(x, y));
                }
                else
                {
                    ControlPaint.DrawImageDisabled(e, image, x, y, Color.Transparent);
                }
            }
            else
            {
                ButtonState btnState = ButtonState.Normal;
                if (m_calendar.Enabled)
                {
                    if (state == mcButtonState.Hot)
                    {
                        btnState = ButtonState.Normal;
                    }
                    else if (state == mcButtonState.Inactive)
                    {
                        btnState = ButtonState.Inactive;
                    }
                    else if (state == mcButtonState.Pushed)
                    {
                        btnState = ButtonState.Pushed;
                    }
                }
                else
                {
                    btnState = ButtonState.Inactive;
                }

                switch (button)
                {
                case mcHeaderButtons.PreviousMonth:
                {
                    ControlPaint.DrawScrollButton(e, rect, ScrollButton.Left, btnState);
                    break;
                }

                case mcHeaderButtons.NextMonth:
                {
                    ControlPaint.DrawScrollButton(e, rect, ScrollButton.Right, btnState);
                    break;
                }

                case mcHeaderButtons.NextYear:
                {
                    ControlPaint.DrawButton(e, rect, btnState);
                    if (state == mcButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if ((m_calendar.Enabled) && (m_nextYearBtnState != mcButtonState.Inactive))
                    {
                        e.DrawImage(m_nextYear, new Point(rect.Left + 3, rect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_nextYearDisabled, new Point(rect.Left + 3, rect.Top + 2 + corr));
                    }

                    break;
                }

                case mcHeaderButtons.PreviousYear:
                {
                    ControlPaint.DrawButton(e, rect, btnState);
                    if (state == mcButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if ((m_calendar.Enabled) && (m_prevYearBtnState != mcButtonState.Inactive))
                    {
                        e.DrawImage(m_prevYear, new Point(rect.Left, rect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_prevYearDisabled, new Point(rect.Left, rect.Top + 2 + corr));
                    }

                    break;
                }
                }
            }
        }
Пример #54
0
 public static void DrawScrollButton(Graphics graphics, int x, int y, int width, int height, ScrollButton button, ButtonState state)
 {
     ThemeEngine.Current.CPDrawScrollButton(graphics, new Rectangle(x, y, width, height), button, state);
 }
 private void EnableButton(ButtonState state, bool en)
 {
     RaiseEvent <OnButtonClickEventArgs>(OnButtonEnable, this, new OnButtonClickEventArgs(state, en));
 }
Пример #56
0
 public static void DrawRadioButton(Graphics graphics, int x, int y, int width, int height, ButtonState state)
 {
     DrawRadioButton(graphics, new Rectangle(x, y, width, height), state);
 }
Пример #57
0
 public GamePadButtons(ButtonState start, ButtonState back, ButtonState leftStick, ButtonState rightStick,
                       ButtonState leftShoulder, ButtonState rightShoulder, ButtonState guide,
                       ButtonState a, ButtonState b, ButtonState x, ButtonState y)
 {
     this.start         = start;
     this.back          = back;
     this.leftStick     = leftStick;
     this.rightStick    = rightStick;
     this.leftShoulder  = leftShoulder;
     this.rightShoulder = rightShoulder;
     this.guide         = guide;
     this.a             = a;
     this.b             = b;
     this.x             = x;
     this.y             = y;
 }
 /// <summary>
 /// Does the X movement.
 /// </summary>
 override protected void MoveInX(float horizontalAxis, int horizontalAxisDigital, ButtonState runButton)
 {
     if (initialJumpDirection == 1)
     {
         character.SetVelocityX(airSpeed);
         character.Translate(airSpeed * TimeManager.FrameTime, 0, true);
     }
     else if (initialJumpDirection == -1)
     {
         character.SetVelocityX(-airSpeed);
         character.Translate(-airSpeed * TimeManager.FrameTime, 0, true);
     }
     else
     {
         character.SetVelocityX(0);
     }
 }
Пример #59
0
        /// <summary>
        /// Function to retrieve the pointing device data.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        /// <param name="doubleClick">TRUE if the event is from a double click, FALSE if not.</param>
        /// <param name="state">The state for the button event.</param>
        private void GetMouseData(MouseEventArgs e, bool doubleClick, ButtonState state)
        {
            if ((BoundControl == null) || (BoundControl.Disposing))
            {
                return;
            }

            OnPointingDeviceWheelMove(e.Delta);

            // Get button data.
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                if (state == ButtonState.Down)
                {
                    OnPointingDeviceDown(PointingDeviceButtons.Left);
                }

                if ((state == ButtonState.Up) || (doubleClick))
                {
                    OnPointingDeviceUp(PointingDeviceButtons.Left, e.Clicks);
                }
            }

            if ((e.Button & MouseButtons.Right) == MouseButtons.Right)
            {
                if (state == ButtonState.Down)
                {
                    OnPointingDeviceDown(PointingDeviceButtons.Right);
                }

                if ((state == ButtonState.Up) || (doubleClick))
                {
                    OnPointingDeviceUp(PointingDeviceButtons.Right, e.Clicks);
                }
            }

            if ((e.Button & MouseButtons.Middle) == MouseButtons.Middle)
            {
                if (state == ButtonState.Down)
                {
                    OnPointingDeviceDown(PointingDeviceButtons.Middle);
                }

                if ((state == ButtonState.Up) || (doubleClick))
                {
                    OnPointingDeviceUp(PointingDeviceButtons.Middle, e.Clicks);
                }
            }
            if ((e.Button & MouseButtons.XButton1) == MouseButtons.XButton1)
            {
                if (state == ButtonState.Down)
                {
                    OnPointingDeviceDown(PointingDeviceButtons.Button4);
                }

                if ((state == ButtonState.Up) || (doubleClick))
                {
                    OnPointingDeviceUp(PointingDeviceButtons.Button4, e.Clicks);
                }
            }
            if ((e.Button & MouseButtons.XButton2) == MouseButtons.XButton2)
            {
                if (state == ButtonState.Down)
                {
                    OnPointingDeviceDown(PointingDeviceButtons.Button5);
                }

                if ((state == ButtonState.Up) || (doubleClick))
                {
                    OnPointingDeviceUp(PointingDeviceButtons.Button5, e.Clicks);
                }
            }

            OnPointingDeviceMove(e.Location, true);
        }
Пример #60
0
 public static void DrawMixedCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state)
 {
     ThemeEngine.Current.CPDrawMixedCheckBox(graphics, rectangle, state);
 }