////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnGamePadPress(GamePadEventArgs e)
        {
            base.OnGamePadPress(e);

              if (e.Button == GamePadActions.Right)
              {
            ItemIndex += 1;
            e.Handled = true;
              }
              if (e.Button == GamePadActions.Left)
              {
            ItemIndex -= 1;
            e.Handled = true;
              }

              if (ItemIndex > Items.Count - 1) ItemIndex = 0;
              if (ItemIndex < 0) ItemIndex = Items.Count - 1;

              if (e.Button == GamePadActions.Down && Items[ItemIndex].Items.Count > 0)
              {
            e.Handled = true;
            OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));
              }
        }
		////////////////////////////////////////////////////////////////////////////     

		////////////////////////////////////////////////////////////////////////////     
		void Input_GamePadDown(object sender, GamePadEventArgs e)
		{
			if (this.Contains(Manager.FocusedControl, true))
			{
				if (e.Button == (GamePadActions as TabControlGamePadActions).NextTab)
				{
					e.Handled = true;
					SelectedIndex += 1;
				}
				else if (e.Button == (GamePadActions as TabControlGamePadActions).PrevTab)
				{
					e.Handled = true;
					SelectedIndex -= 1;
				}
			}
		}
Beispiel #3
0
    ////////////////////////////////////////////////////////////////////////////           

    ////////////////////////////////////////////////////////////////////////////
    void btnSlider_GamePadPress(object sender, GamePadEventArgs e)
    {
      if (e.Button == GamePadActions.Left || e.Button == GamePadActions.Down) Value -= stepSize;
      if (e.Button == GamePadActions.Right || e.Button == GamePadActions.Up) Value += stepSize;
    }
 ////////////////////////////////////////////////////////////////////////////     
 ////////////////////////////////////////////////////////////////////////////
 protected override void OnGamePadDown(GamePadEventArgs e)
 {
     if (!e.Handled)
       {
     if (e.Button == GamePadActions.Click || e.Button == GamePadActions.Press || e.Button == GamePadActions.Down)
     {
       e.Handled = true;
       btnDown_Click(this, new MouseEventArgs());
     }
       }
       base.OnGamePadDown(e);
 }
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 void Input_GamePadDown(object sender, GamePadEventArgs e)
 {
     if (Visible && (Manager.FocusedControl != null && Manager.FocusedControl.Root == this))
       {
     if (e.Button == (GamePadActions as WindowGamePadActions).Accept)
     {
       Close(ModalResult.Ok);
     }
     else if (e.Button == (GamePadActions as WindowGamePadActions).Cancel)
     {
       Close(ModalResult.Cancel);
     }
       }
 }
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 protected override void OnGamePadDown(GamePadEventArgs e)
 {
     base.OnGamePadDown(e);
 }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnGamePadPress(GamePadEventArgs e)
        {
            if (e.Button == GamePadActions.Up)
              {
            e.Handled = true;
            ShiftIndex(true);
              }
              else if (e.Button == GamePadActions.Down)
              {
            e.Handled = true;
            ShiftIndex(false);
              }

              base.OnGamePadPress(e);
        }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        private void UpdateGamePad(PlayerIndex playerIndex, GamePadState state, GameTime gameTime)
        {
            GamePadEventArgs e = new GamePadEventArgs(playerIndex);

              //if (state.ThumbSticks.Left != gamePadState.ThumbSticks.Left ||
              //    state.ThumbSticks.Right != gamePadState.ThumbSticks.Right ||
              //    state.Triggers.Left != gamePadState.Triggers.Left ||
              //    state.Triggers.Right != gamePadState.Triggers.Right)
              //{
              //  BuildGamePadEvent(state, GamePadButton.None, ref e);
              //  if (GamePadMove != null) GamePadMove.Invoke(this, e);
              //}

              foreach (InputGamePadButton btn in gamePadButtons)
              {
              ButtonState bs; ;

            if (btn.Button == GamePadButton.None) continue;
            //else if (btn.Button == GamePadButton.A) bs = state.Buttons.A;
            //else if (btn.Button == GamePadButton.B) bs = state.Buttons.B;
            //else if (btn.Button == GamePadButton.Back) bs = state.Buttons.Back;
            //else if (btn.Button == GamePadButton.Down) bs = state.DPad.Down;
            //else if (btn.Button == GamePadButton.Left) bs = state.DPad.Left;
            //else if (btn.Button == GamePadButton.Right) bs = state.DPad.Right;
            //else if (btn.Button == GamePadButton.Start) bs = state.Buttons.Start;
            //else if (btn.Button == GamePadButton.Up) bs = state.DPad.Up;
            //else if (btn.Button == GamePadButton.X) bs = state.Buttons.X;
            //else if (btn.Button == GamePadButton.Y) bs = state.Buttons.Y;
            //else if (btn.Button == GamePadButton.BigButton) bs = state.Buttons.BigButton;
            //else if (btn.Button == GamePadButton.LeftShoulder) bs = state.Buttons.LeftShoulder;
            //else if (btn.Button == GamePadButton.RightShoulder) bs = state.Buttons.RightShoulder;
            //else if (btn.Button == GamePadButton.LeftStick) bs = state.Buttons.LeftStick;
            //else if (btn.Button == GamePadButton.RightStick) bs = state.Buttons.RightStick;
            else bs = GetVectorState(btn.Button, state);

            bool pressed = bs.Pressed;
            if (pressed)
            {
              double ms = gameTime.ElapsedGameTime.TotalMilliseconds;
              if (pressed) btn.Countdown -= ms;
            }

            if ((pressed) && (!btn.Pressed))
            {
              btn.Pressed = true;
              BuildGamePadEvent(state, btn.Button, ref e);

              if (GamePadDown != null) GamePadDown.Invoke(this, e);
              if (GamePadPress != null) GamePadPress.Invoke(this, e);
            }
            else if ((!pressed) && (btn.Pressed))
            {
              btn.Pressed = false;
              btn.Countdown = RepeatDelay;
              BuildGamePadEvent(state, btn.Button, ref e);

              if (GamePadUp != null) GamePadUp.Invoke(this, e);
            }
            else if (btn.Pressed && btn.Countdown < 0)
            {
              e.Button = btn.Button;
              btn.Countdown = RepeatRate;
              BuildGamePadEvent(state, btn.Button, ref e);

              if (GamePadPress != null) GamePadPress.Invoke(this, e);
            }
              }
              gamePadState = state;
        }
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 private void BuildGamePadEvent(GamePadState state, GamePadButton button, ref GamePadEventArgs e)
 {
     e.State = state;
       e.Button = button;
       //e.Vectors.LeftStick = new Vector2(state.ThumbSticks.Left.X, state.ThumbSticks.Left.Y);
       //e.Vectors.RightStick = new Vector2(state.ThumbSticks.Right.X, state.ThumbSticks.Right.Y);
       //e.Vectors.LeftTrigger = state.Triggers.Left;
       //e.Vectors.RightTrigger = state.Triggers.Right;
 }
Beispiel #10
0
        /// <summary>
        /// Handles gamepad input for the tab control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Input_GamePadDown(object sender, GamePadEventArgs e)
        {
            // Tab control has focus?
            if (this.Contains(Manager.FocusedControl, true))
            {
                // Switch to the next tab page on RightTrigger presses.
                if (e.Button == (GamePadActions as TabControlGamePadActions).NextTab)
                {
                    e.Handled = true;
                    SelectedIndex += 1;
                }

                // Switch to the previous tab page on LeftTrigger presses.
                else if (e.Button == (GamePadActions as TabControlGamePadActions).PrevTab)
                {
                    e.Handled = true;
                    SelectedIndex -= 1;
                }
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnGamePadPress(GamePadEventArgs e)
        {
            if (e.Button == GamePadActions.Down)
            {
                e.Handled = true;
                itemIndex += sbVert.StepSize / 10;
            }
            else if (e.Button == GamePadActions.Up)
            {
                e.Handled = true;
                itemIndex -= sbVert.StepSize / 10;
            }

            if (itemIndex < 0) itemIndex = 0;
            else if (itemIndex >= Items.Count) itemIndex = Items.Count - 1;

            ItemIndex = itemIndex;
            base.OnGamePadPress(e);
        }
Beispiel #12
0
 /// <summary>
 /// Handles gamepad left/right button presses for the track bar control.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void btnSlider_GamePadPress(object sender, GamePadEventArgs e)
 {
     // Step up/down the track bar's value as needed.
     if (e.Button == GamePadActions.Left || e.Button == GamePadActions.Down) Value -= stepSize;
     if (e.Button == GamePadActions.Right || e.Button == GamePadActions.Up) Value += stepSize;
 }