Example #1
0
        private void MapButtonValue(XNAInput.ButtonState previousXnaButton, XNAInput.ButtonState xnaButton, MappingButtons button)
        {
            // Mapping
            bool isDown = false;
            bool isPressed = false;
            bool isReleased = false;

            if (xnaButton == XNAInput.ButtonState.Pressed)
            {
                isDown = true;

                if (previousXnaButton == XNAInput.ButtonState.Released)
                {
                    isPressed = true;
                }
            }
            else if (xnaButton == XNAInput.ButtonState.Released)
            {
                if (previousXnaButton == XNAInput.ButtonState.Pressed)
                {
                    isReleased = true;
                }
            }

            SetMappingValue(button, isDown, isPressed, isReleased);
        }
		private void UpdateNormalButtons(XnaInput.GamePadState state)
		{
			UpdateButton(state.Buttons.A, GamePadButton.A);
			UpdateButton(state.Buttons.B, GamePadButton.B);
			UpdateButton(state.Buttons.X, GamePadButton.X);
			UpdateButton(state.Buttons.Y, GamePadButton.Y);
			UpdateButton(state.Buttons.Back, GamePadButton.Back);
			UpdateButton(state.Buttons.Start, GamePadButton.Start);
			UpdateButton(state.Buttons.BigButton, GamePadButton.BigButton);
		}
		private void UpdateDPadButtons(XnaInput.GamePadState state)
		{
			UpdateButton(state.DPad.Down, GamePadButton.Down);
			UpdateButton(state.DPad.Up, GamePadButton.Up);
			UpdateButton(state.DPad.Left, GamePadButton.Left);
			UpdateButton(state.DPad.Right, GamePadButton.Right);
		}
		private void UpdateStickAndShoulderButtons(XnaInput.GamePadState state)
		{
			UpdateButton(state.Buttons.LeftShoulder, GamePadButton.LeftShoulder);
			UpdateButton(state.Buttons.LeftStick, GamePadButton.LeftStick);
			UpdateButton(state.Buttons.RightShoulder, GamePadButton.RightShoulder);
			UpdateButton(state.Buttons.RightStick, GamePadButton.RightStick);
		}
		private void UpdateAllButtons(XnaInput.GamePadState state)
		{
			UpdateNormalButtons(state);
			UpdateStickAndShoulderButtons(state);
			UpdateDPadButtons(state);
		}
		private void UpdateButton(XnaInput.ButtonState newState, GamePadButton button)
		{
			var buttonIndex = (int)button;
			states[buttonIndex] =
				states[buttonIndex].UpdateOnNativePressing(newState == XnaInput.ButtonState.Pressed);
		}
Example #7
0
 private void UpdateValuesFromState(XnaInput.GamePadState state)
 {
     leftThumbStick.X = state.ThumbSticks.Left.X;
     leftThumbStick.Y = state.ThumbSticks.Left.Y;
     rightThumbStick.X = state.ThumbSticks.Right.X;
     rightThumbStick.Y = state.ThumbSticks.Right.Y;
     leftTrigger = state.Triggers.Left;
     rightTrigger = state.Triggers.Right;
     UpdateAllButtons(state);
 }
Example #8
0
 static void UpdateVectorOther(xnainput.KeyboardState newstate)
 {
     int horizontal = 0;
     if (newstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.L)) horizontal++;
     if (newstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.J)) horizontal--;
     int vertical = 0;
     if (newstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I)) vertical++;
     if (newstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.K)) vertical--;
     V_other.X = (float)horizontal;
     V_other.Y = (float)-vertical;//2DでY軸が下向きのためそれの補正
     if (V_other.LengthSquared() != 0)
         V_other = Vector2.Normalize(V_other);
 }