public override bool PollJoystick(int port, float[] joyx, float[] joyy, float[] joyz, bool[] buttons) { if (port != 0) { return(false); } GamePadData gd = GamePad.GetData(port); joyx[0] = gd.AnalogLeftX; joyy[0] = -gd.AnalogLeftY; joyx[1] = gd.AnalogRightX; joyy[1] = -gd.AnalogRightY; GamePadButtons down = gd.ButtonsDown; buttons[0] = (down & GamePadButtons.Cross) != 0; buttons[1] = (down & GamePadButtons.Circle) != 0; buttons[2] = (down & GamePadButtons.Square) != 0; buttons[3] = (down & GamePadButtons.Triangle) != 0; buttons[4] = (down & GamePadButtons.L) != 0; buttons[5] = (down & GamePadButtons.R) != 0; buttons[6] = (down & GamePadButtons.Back) != 0; buttons[7] = (down & GamePadButtons.Start) != 0; buttons[8] = (down & GamePadButtons.Left) != 0; buttons[9] = (down & GamePadButtons.Up) != 0; buttons[10] = (down & GamePadButtons.Right) != 0; buttons[11] = (down & GamePadButtons.Down) != 0; return(true); }
//>> For getting input << private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) { ButtonState stateToReturn = ButtonState.Pressed; switch (xciBtn) { case XboxButton.A: stateToReturn = xiButtons.A; break; case XboxButton.B: stateToReturn = xiButtons.B; break; case XboxButton.X: stateToReturn = xiButtons.X; break; case XboxButton.Y: stateToReturn = xiButtons.Y; break; case XboxButton.Start: stateToReturn = xiButtons.Start; break; case XboxButton.Back: stateToReturn = xiButtons.Back; break; case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; } return(stateToReturn); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary> /// 前回の状態と現在の状態より、ボタン入力があったかどうかを取得します。 /// </summary> /// /// <param name="now">現在のキー入力状態。</param> /// <param name="prev">前回のキー入力状態。</param> /// <returns>ボタン入力があった場合、<c>true</c>。</returns> protected override bool isInput(GamePadState now, GamePadState prev) { bool result = now.IsConnected && prev.IsConnected; if (result) { GamePadButtons btns = now.Buttons; GamePadDPad dpad = now.DPad; GamePadThumbSticks nStks = now.ThumbSticks; GamePadThumbSticks pStks = prev.ThumbSticks; // TODO : トリガ忘れてね? result = btns != prev.Buttons && ( btns.A == ButtonState.Pressed || btns.B == ButtonState.Pressed || btns.Back == ButtonState.Pressed || btns.BigButton == ButtonState.Pressed || btns.LeftShoulder == ButtonState.Pressed || btns.LeftStick == ButtonState.Pressed || btns.RightShoulder == ButtonState.Pressed || btns.RightStick == ButtonState.Pressed || btns.Start == ButtonState.Pressed || btns.X == ButtonState.Pressed || btns.Y == ButtonState.Pressed) || dpad != prev.DPad && ( dpad.Up == ButtonState.Pressed || dpad.Down == ButtonState.Pressed || dpad.Left == ButtonState.Pressed || dpad.Right == ButtonState.Pressed) || nStks != pStks && ( (nStks.Left.Length() >= threshold && pStks.Left.Length() < threshold) || (nStks.Right.Length() >= threshold && pStks.Right.Length() < threshold)); } return(result); }
private ButtonState GetButtonState(int btnIndex) { GamePadButtons b = this.state.Buttons; switch (this.buttonNames[btnIndex]) { case ButtonTypes.A: return(b.A); case ButtonTypes.B: return(b.B); case ButtonTypes.BACK: return(b.Back); case ButtonTypes.BIG_BUTTON: return(b.BigButton); case ButtonTypes.LEFT_SHOULDER: return(b.LeftShoulder); case ButtonTypes.LEFT_STICK: return(b.LeftStick); case ButtonTypes.RIGHT_SHOULDER: return(b.RightShoulder); case ButtonTypes.RIGHT_STICK: return(b.RightStick); case ButtonTypes.START: return(b.Start); case ButtonTypes.X: return(b.X); case ButtonTypes.Y: return(b.Y); default: throw new System.NotImplementedException(); } }
private bool InputGetButtonState(GamePadButtons buttons, GmpdButton btn) { switch (btn) { case (GmpdButton.A): return(ButtonStateToBool(buttons.A)); break; case (GmpdButton.B): return(ButtonStateToBool(buttons.B)); break; case (GmpdButton.X): return(ButtonStateToBool(buttons.X)); break; case (GmpdButton.Y): return(ButtonStateToBool(buttons.Y)); break; case (GmpdButton.Start): return(ButtonStateToBool(buttons.Start)); break; case (GmpdButton.Back): return(ButtonStateToBool(buttons.Back)); break; case (GmpdButton.LBumper): return(ButtonStateToBool(buttons.LeftShoulder)); break; case (GmpdButton.RBumper): return(ButtonStateToBool(buttons.RightShoulder)); break; case (GmpdButton.LStick): return(ButtonStateToBool(buttons.LeftStick)); break; case (GmpdButton.RStick): return(ButtonStateToBool(buttons.RightStick)); break; } return(false); }
public static void Update() { for (int player = 0; player < States.Length; player++) { GamePadState stateX = GamePad.GetState((PlayerIndex)player); DInputState stateD = States[player]; stateD.connected = stateX.IsConnected; if (!stateD.connected) { continue; } // TODO: Finalize DInput mappings GamePadThumbSticks sticks = stateX.ThumbSticks; stateD.leftX = sticks.Left.X; stateD.leftY = sticks.Left.Y; stateD.leftZ = 0f; // ??? stateD.rightX = sticks.Right.X; stateD.rightY = sticks.Right.Y; stateD.rightZ = 0f; // ??? GamePadTriggers triggers = stateX.Triggers; stateD.slider1 = stateX.Triggers.Left; stateD.slider2 = stateX.Triggers.Right; GamePadDPad dpad = stateX.DPad; stateD.left = dpad.Left == ButtonState.Pressed; stateD.right = dpad.Right == ButtonState.Pressed; stateD.up = dpad.Up == ButtonState.Pressed; stateD.down = dpad.Down == ButtonState.Pressed; GamePadButtons buttonsX = stateX.Buttons; List <bool> buttonsD = stateD.buttons ?? new List <bool>(); for (int i = buttonsD.Count; i < 13; i++) { buttonsD.Add(false); } while (buttonsD.Count > 13) { buttonsD.RemoveAt(0); } buttonsD[0] = buttonsX.X == ButtonState.Pressed; buttonsD[1] = buttonsX.A == ButtonState.Pressed; buttonsD[2] = buttonsX.B == ButtonState.Pressed; buttonsD[3] = buttonsX.Y == ButtonState.Pressed; buttonsD[4] = buttonsX.LeftShoulder == ButtonState.Pressed; buttonsD[5] = buttonsX.RightShoulder == ButtonState.Pressed; buttonsD[6] = triggers.Left >= 0.999f; buttonsD[7] = triggers.Right >= 0.999f; buttonsD[8] = buttonsX.Back == ButtonState.Pressed; buttonsD[9] = buttonsX.Start == ButtonState.Pressed; buttonsD[10] = buttonsX.BigButton == ButtonState.Pressed; // ??? buttonsD[11] = buttonsX.LeftStick == ButtonState.Pressed; buttonsD[12] = buttonsX.RightStick == ButtonState.Pressed; stateD.buttons = buttonsD; } }
public static bool GamePadUp(PlayerIndex index, GamePadButtons button) { switch (button) { case GamePadButtons.A: return(currentGamePadState[(int)index].IsButtonUp(Buttons.A)); case GamePadButtons.B: return(currentGamePadState[(int)index].IsButtonUp(Buttons.B)); case GamePadButtons.X: return(currentGamePadState[(int)index].IsButtonUp(Buttons.X)); case GamePadButtons.Y: return(currentGamePadState[(int)index].IsButtonUp(Buttons.Y)); case GamePadButtons.DPadUp: return(currentGamePadState[(int)index].IsButtonUp(Buttons.DPadUp)); case GamePadButtons.DPadLeft: return(currentGamePadState[(int)index].IsButtonUp(Buttons.DPadLeft)); case GamePadButtons.DPadDown: return(currentGamePadState[(int)index].IsButtonUp(Buttons.DPadDown)); case GamePadButtons.DPadRight: return(currentGamePadState[(int)index].IsButtonUp(Buttons.DPadRight)); case GamePadButtons.Start: return(currentGamePadState[(int)index].IsButtonUp(Buttons.Start)); case GamePadButtons.Back: return(currentGamePadState[(int)index].IsButtonUp(Buttons.Back)); case GamePadButtons.Big: return(currentGamePadState[(int)index].IsButtonUp(Buttons.BigButton)); case GamePadButtons.RTrigger: return(currentGamePadState[(int)index].Triggers.Right <= deadZone[(int)index]); case GamePadButtons.RShoulder: return(currentGamePadState[(int)index].IsButtonUp(Buttons.RightShoulder)); case GamePadButtons.RStick: return(currentGamePadState[(int)index].IsButtonUp(Buttons.RightStick)); case GamePadButtons.LTrigger: return(currentGamePadState[(int)index].Triggers.Left <= deadZone[(int)index]); case GamePadButtons.LShoulder: return(currentGamePadState[(int)index].IsButtonUp(Buttons.LeftShoulder)); case GamePadButtons.LStick: return(currentGamePadState[(int)index].IsButtonUp(Buttons.LeftStick)); default: return(false); } }
static InputExtensions() { oldKeyState = newKeyState = Keyboard.GetState(); var padState = GamePad.GetState(PlayerIndex.One); oldDPadState = newDPadState = padState.DPad; oldButtonState = newButtonState = padState.Buttons; }
internal GamePadButtons(params Buttons[] buttons) { this = new GamePadButtons(); foreach (Buttons buttons1 in buttons) { this.buttons |= buttons1; } }
private void Init(GamePadButtons button) { _isFirstPressed = false; _isPrevPressed = false; _isHeld = false; _isFirstReleased = false; _isPrevReleased = true; _button = button; }
public bool AnyButtonPressed() { if (CurrentInput.Active) { GamePadButtons untouchedButtons = new GamePadButtons(); return(CurrentInput.BaseGamepadState.Buttons != untouchedButtons && PrevInput.BaseGamepadState.Buttons == untouchedButtons); } return(false); }
/// <summary> /// Creates a default orthographic camera and lets it respond as if /// the game pad's buttons were in the specified state /// </summary> /// <param name="buttons">State of the game pad's buttons</param> /// <returns>The camera after it has responded to the provided controls</returns> private Camera handleControlsOnDefaultCamera(GamePadButtons buttons) { return(handleControlsOnDefaultCamera( new KeyboardState(), new GamePadState( new GamePadThumbSticks(), new GamePadTriggers(), buttons, new GamePadDPad() ) )); }
/// private メソッド ///--------------------------------------------------------------------------- /// パッドの入力情報を格納 private void setInputState(ref InputGamePadState inputState, GamePadButtons gamePadButtons) { inputState = 0; /// 方向キー入力 if ((gamePadButtons & GamePadButtons.Up) != 0) { inputState |= InputGamePadState.Up; } if ((gamePadButtons & GamePadButtons.Down) != 0) { inputState |= InputGamePadState.Down; } if ((gamePadButtons & GamePadButtons.Left) != 0) { inputState |= InputGamePadState.Left; } if ((gamePadButtons & GamePadButtons.Right) != 0) { inputState |= InputGamePadState.Right; } /// ボタン入力 if ((gamePadButtons & GamePadButtons.Square) != 0) { inputState |= InputGamePadState.Square; } if ((gamePadButtons & GamePadButtons.Triangle) != 0) { inputState |= InputGamePadState.Triangle; } if ((gamePadButtons & GamePadButtons.Circle) != 0) { inputState |= InputGamePadState.Circle; } if ((gamePadButtons & GamePadButtons.Cross) != 0) { inputState |= InputGamePadState.Cross; } if ((gamePadButtons & GamePadButtons.Start) != 0) { inputState |= InputGamePadState.Start; } if ((gamePadButtons & GamePadButtons.Select) != 0) { inputState |= InputGamePadState.Select; } if ((gamePadButtons & GamePadButtons.L) != 0) { inputState |= InputGamePadState.L; } if ((gamePadButtons & GamePadButtons.R) != 0) { inputState |= InputGamePadState.R; } }
/// <summary> /// 指定したボタンが押下したままdt秒経過しているかどうかを返す /// </summary> public static bool IsHoldKey(GamePadButtons button, float dt) { if (!_holdDic.ContainsKey(button)) { return false; } return _holdDic[button] > dt; }
internal GamePadState(bool isConnected, RawState rawState, GamePadDeadZone deadZone) { this.isConnected = isConnected; if (!isConnected) { rawState.dwPacketNumber = 0; rawState.Gamepad.dwButtons = 0; rawState.Gamepad.bLeftTrigger = 0; rawState.Gamepad.bRightTrigger = 0; rawState.Gamepad.sThumbLX = 0; rawState.Gamepad.sThumbLY = 0; rawState.Gamepad.sThumbRX = 0; rawState.Gamepad.sThumbRY = 0; } packetNumber = rawState.dwPacketNumber; buttons = new GamePadButtons( (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.Start) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.Back) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.LeftThumb) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.RightThumb) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.LeftShoulder) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.RightShoulder) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.Guide) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.A) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.B) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.X) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.Y) != 0 ? ButtonState.Pressed : ButtonState.Released ); dPad = new GamePadDPad( (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.DPadUp) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.DPadDown) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.DPadLeft) != 0 ? ButtonState.Pressed : ButtonState.Released, (rawState.Gamepad.dwButtons & (uint)ButtonsConstants.DPadRight) != 0 ? ButtonState.Pressed : ButtonState.Released ); switch (deadZone) { case GamePadDeadZone.IndependentAxes: rawState.Gamepad.sThumbLX = ThumbStickDeadZoneIndependantAxes(rawState.Gamepad.sThumbLX, (short)Imports.Constants.LeftStickDeadZone); rawState.Gamepad.sThumbLY = ThumbStickDeadZoneIndependantAxes(rawState.Gamepad.sThumbLY, (short)Imports.Constants.LeftStickDeadZone); rawState.Gamepad.sThumbRX = ThumbStickDeadZoneIndependantAxes(rawState.Gamepad.sThumbRX, (short)Imports.Constants.RightStickDeadZone); rawState.Gamepad.sThumbRY = ThumbStickDeadZoneIndependantAxes(rawState.Gamepad.sThumbRY, (short)Imports.Constants.RightStickDeadZone); break; } thumbSticks = new GamePadThumbSticks( new GamePadThumbSticks.StickValue( rawState.Gamepad.sThumbLX < 0 ? rawState.Gamepad.sThumbLX / 32768.0f : rawState.Gamepad.sThumbLX / 32767.0f, rawState.Gamepad.sThumbLY < 0 ? rawState.Gamepad.sThumbLY / 32768.0f : rawState.Gamepad.sThumbLY / 32767.0f), new GamePadThumbSticks.StickValue( rawState.Gamepad.sThumbRX < 0 ? rawState.Gamepad.sThumbRX / 32768.0f : rawState.Gamepad.sThumbRX / 32767.0f, rawState.Gamepad.sThumbRY < 0 ? rawState.Gamepad.sThumbRY / 32768.0f : rawState.Gamepad.sThumbRY / 32767.0f) ); triggers = new GamePadTriggers(rawState.Gamepad.bLeftTrigger / 255.0f, rawState.Gamepad.bRightTrigger / 255.0f); }
public void ProcessPausedUpdate() { DetectConnectedState(); if (gamePadConnected) { GamePadState state = GamePad.GetState(PlayerIndex.One); GamePadStickDirection leftStickDirection = DetectStickDirection(state.ThumbSticks.Left, GamePadStickType.Left); GamePadButtons button = DetectButton(state); } }
/// <summary> /// Initializes a new instance of the <see cref="T:Microsoft.Xna.Framework.Input.GamePadState"/> struct /// using the specified GamePadThumbSticks, GamePadTriggers, GamePadButtons, and GamePadDPad. /// </summary> /// <param name="thumbSticks">Initial thumbstick state.</param> /// <param name="triggers">Initial trigger state..</param> /// <param name="buttons">Initial button state.</param> /// <param name="dPad">Initial directional pad state.</param> public GamePadState(GamePadThumbSticks thumbSticks, GamePadTriggers triggers, GamePadButtons buttons, GamePadDPad dPad) : this() { ThumbSticks = thumbSticks; Triggers = triggers; Buttons = buttons; DPad = dPad; IsConnected = true; PlatformConstruct(); }
void RaiseButtonChangedEvent(GamePadButtons button, ButtonState newState) { if (ButtonStateChanged != null) { ButtonStateChanged(this, new ButtonStateChangedEventArgs() { Button = button, ButtonState = newState }); } }
public static bool DelayedButton(GamePadButtons k, ButtonTrigger trigger = ButtonTrigger.OnPress) { var ret = Button(k, trigger); if (ret) { ResetInputLimit(); } return(ret); }
/// <summary> /// Generates a GamePadState based on the touch input provided (as applied to the on screen controls) and the gamepad state /// </summary> public GamePadState GetState(TouchCollection touchState, GamePadState gpState) { //Work out what buttons are pressed based on the touchState Buttons buttonsPressed = 0; foreach (var touch in touchState) { if (touch.State == TouchLocationState.Moved || touch.State == TouchLocationState.Pressed) { //Scale the touch position to be in _baseScreenSize coordinates Vector2 pos = touch.Position; Vector2.Transform(ref pos, ref globalTransformation, out pos); if (pos.X < 128) { buttonsPressed |= Buttons.DPadLeft; } else if (pos.X < 256) { buttonsPressed |= Buttons.DPadRight; } else if (pos.X >= baseScreenSize.X - 128) { buttonsPressed |= Buttons.A; } } } //Combine the buttons of the real gamepad var gpButtons = gpState.Buttons; buttonsPressed |= (gpButtons.A == ButtonState.Pressed ? Buttons.A : 0); buttonsPressed |= (gpButtons.B == ButtonState.Pressed ? Buttons.B : 0); buttonsPressed |= (gpButtons.X == ButtonState.Pressed ? Buttons.X : 0); buttonsPressed |= (gpButtons.Y == ButtonState.Pressed ? Buttons.Y : 0); buttonsPressed |= (gpButtons.Start == ButtonState.Pressed ? Buttons.Start : 0); buttonsPressed |= (gpButtons.Back == ButtonState.Pressed ? Buttons.Back : 0); buttonsPressed |= gpState.IsButtonDown(Buttons.DPadDown) ? Buttons.DPadDown : 0; buttonsPressed |= gpState.IsButtonDown(Buttons.DPadLeft) ? Buttons.DPadLeft : 0; buttonsPressed |= gpState.IsButtonDown(Buttons.DPadRight) ? Buttons.DPadRight : 0; buttonsPressed |= gpState.IsButtonDown(Buttons.DPadUp) ? Buttons.DPadUp : 0; buttonsPressed |= (gpButtons.BigButton == ButtonState.Pressed ? Buttons.BigButton : 0); buttonsPressed |= (gpButtons.LeftShoulder == ButtonState.Pressed ? Buttons.LeftShoulder : 0); buttonsPressed |= (gpButtons.RightShoulder == ButtonState.Pressed ? Buttons.RightShoulder : 0); buttonsPressed |= (gpButtons.LeftStick == ButtonState.Pressed ? Buttons.LeftStick : 0); buttonsPressed |= (gpButtons.RightStick == ButtonState.Pressed ? Buttons.RightStick : 0); var buttons = new GamePadButtons(buttonsPressed); return(new GamePadState(gpState.ThumbSticks, gpState.Triggers, buttons, gpState.DPad)); }
protected void Update(GamePadButtons buttons, Vector2 leftStick, Vector2 rightStick, float leftTrigger, float rightTrigger) { previousButtons = currentButtons; currentButtons = buttons; this.leftStick = leftStick; this.rightStick = rightStick; this.leftTrigger = leftTrigger; this.rightTrigger = rightTrigger; }
public static void Update() { oldKeyState = newKeyState; newKeyState = Keyboard.GetState(); var padState = GamePad.GetState(PlayerIndex.One); oldDPadState = newDPadState; newDPadState = padState.DPad; oldButtonState = newButtonState; newButtonState = padState.Buttons; }
public void resetPosition(float posX, float posY, int goodStep) { positionX = posX; positionY = posY; bestStep = goodStep; charge_time_top = 0.0f; charge_time_bottom = 0.0f; state = CharacterState.None; button_counter = 0; pre_buttons = GamePad.GetData (0).Buttons; }
/// <summary> /// Initializes a new instance of the GamePadState class using the specified /// GamePadThumbSticks, GamePadTriggers, GamePadButtons, and GamePadDPad. /// </summary> /// <param name="thumbSticks">Initial thumbstick state.</param> /// <param name="triggers">Initial trigger state.</param> /// <param name="buttons">Initial button state.</param> /// <param name="dPad">Initial directional pad state.</param> public GamePadState( GamePadThumbSticks thumbSticks, GamePadTriggers triggers, GamePadButtons buttons ) : this() { ThumbSticks = thumbSticks; Triggers = triggers; Buttons = buttons; IsConnected = true; PacketNumber = 0; }
private static float Translate_Trigger(GamePadButtons k, GamePadState _state) { switch (k) { case GamePadButtons.Left_Trigger: return(_state.Triggers.Left > deadzone_r ? _state.Triggers.Left : 0f); case GamePadButtons.Right_Trigger: return(_state.Triggers.Right > deadzone_r ? _state.Triggers.Right : 0f); } return(0f); }
/// <summary> /// Check if the GamePadKey value specified is pressed. /// </summary> private static bool IsGamePadButtonPressed(GamePadButtons gamePadKey) { switch (gamePadKey) { case GamePadButtons.Start: return(IsGamePadStartPressed()); case GamePadButtons.Back: return(IsGamePadBackPressed()); case GamePadButtons.A: return(IsGamePadAPressed()); case GamePadButtons.B: return(IsGamePadBPressed()); case GamePadButtons.X: return(IsGamePadXPressed()); case GamePadButtons.Y: return(IsGamePadYPressed()); case GamePadButtons.LeftShoulder: return(IsGamePadLeftShoulderPressed()); case GamePadButtons.RightShoulder: return(IsGamePadRightShoulderPressed()); case GamePadButtons.LeftTrigger: return(IsGamePadLeftTriggerPressed()); case GamePadButtons.RightTrigger: return(IsGamePadRightTriggerPressed()); case GamePadButtons.Up: return(IsGamePadDPadUpPressed() || IsGamePadLeftStickUpPressed()); case GamePadButtons.Down: return(IsGamePadDPadDownPressed() || IsGamePadLeftStickDownPressed()); case GamePadButtons.Left: return(IsGamePadDPadLeftPressed() || IsGamePadLeftStickLeftPressed()); case GamePadButtons.Right: return(IsGamePadDPadRightPressed() || IsGamePadLeftStickRightPressed()); } return(false); }
public static bool IsGamePadButtonTriggered(GamePadButtons gamePadKey) { switch (gamePadKey) { case GamePadButtons.Start: return(IsGamePadStartTriggered()); case GamePadButtons.Back: return(IsGamePadBackTriggered()); case GamePadButtons.A: return(IsGamePadATriggered()); case GamePadButtons.B: return(IsGamePadBTriggered()); case GamePadButtons.X: return(IsGamePadXTriggered()); case GamePadButtons.Y: return(IsGamePadYTriggered()); case GamePadButtons.LeftShoulder: return(IsGamePadLeftShoulderTriggered()); case GamePadButtons.RightShoulder: return(IsGamePadRightShoulderTriggered()); case GamePadButtons.LeftTrigger: return(IsGamePadLeftTriggerTriggered()); case GamePadButtons.RightTrigger: return(IsGamePadRightTriggerTriggered()); case GamePadButtons.Up: return(IsGamePadDPadUpTriggered() || IsGamePadLeftStickUpTriggered()); case GamePadButtons.Down: return(IsGamePadDPadDownTriggered() || IsGamePadLeftStickDownTriggered()); case GamePadButtons.Left: return(IsGamePadDPadLeftTriggered() || IsGamePadLeftStickLeftTriggered()); case GamePadButtons.Right: return(IsGamePadDPadRightTriggered() || IsGamePadLeftStickRightTriggered()); } return(false); }
public GamepadStateWeighted(GamePadState state_, float stickDZ_ = 0.1f) { StickDZ = stickDZ_; _gamepadState = state_; Triggers = state_.Triggers; ThumbSticks = state_.ThumbSticks; Buttons = state_.Buttons; DPad = state_.DPad; IsConnected = state_.IsConnected; PacketNumber = state_.PacketNumber; }
public static Buttons AsButtons(this GamePadButtons buttons) { Buttons original = new Buttons(); if (buttons.A == ButtonState.Pressed) { original = original | Buttons.A; } if (buttons.B == ButtonState.Pressed) { original = original | Buttons.B; } if (buttons.Back == ButtonState.Pressed) { original = original | Buttons.Back; } if (buttons.BigButton == ButtonState.Pressed) { original = original | Buttons.BigButton; } if (buttons.LeftShoulder == ButtonState.Pressed) { original = original | Buttons.LeftShoulder; } if (buttons.LeftStick == ButtonState.Pressed) { original = original | Buttons.LeftStick; } if (buttons.RightShoulder == ButtonState.Pressed) { original = original | Buttons.RightShoulder; } if (buttons.RightStick == ButtonState.Pressed) { original = original | Buttons.RightStick; } if (buttons.Start == ButtonState.Pressed) { original = original | Buttons.Start; } if (buttons.X == ButtonState.Pressed) { original = original | Buttons.X; } if (buttons.Y == ButtonState.Pressed) { original = original | Buttons.Y; } return(original); }
/// <summary> /// Initializes a new instance of the GamePadState class with the specified stick, /// trigger, and button values. /// </summary> /// <param name="leftThumbStick"> /// Left stick value. Each axis is clamped between 1.0 and 1.0. /// </param> /// <param name="rightThumbStick"> /// Right stick value. Each axis is clamped between 1.0 and 1.0. /// </param> /// <param name="leftTrigger"> /// Left trigger value. This value is clamped between 0.0 and 1.0. /// </param> /// <param name="rightTrigger"> /// Right trigger value. This value is clamped between 0.0 and 1.0. /// </param> /// <param name="buttons"> /// Array or parameter list of Buttons to initialize as pressed. /// </param> public GamePadState( Vector2 leftThumbStick, Vector2 rightThumbStick, float leftTrigger, float rightTrigger, params Buttons[] buttons ) : this( new GamePadThumbSticks(leftThumbStick, rightThumbStick), new GamePadTriggers(leftTrigger, rightTrigger), GamePadButtons.FromButtonArray(buttons), GamePadDPad.FromButtonArray(buttons) ) { }
private bool Press(GamePadButtons k, GamePadState _state) { ButtonState bs = Translate_Button(k, _state); float ts = Translate_Trigger(k, _state); Vector2 ss = Translate_Stick(k, _state); if ((ss != Vector2.Zero) || (ts != 0f) || (bs == ButtonState.Pressed)) { return(true); } return(false); }
private GamePadButtons DetectButton(GamePadState state) { GamePadButtons result = GamePadButtons.None; if (state.IsButtonDown(Buttons.A)) { result = GamePadButtons.A; } else if (state.IsButtonDown(Buttons.B)) { result = GamePadButtons.B; } return(result); }
/// <summary> /// Initializes a new instance of the GamePadState class using the specified /// GamePadThumbSticks, GamePadTriggers, GamePadButtons, and GamePadDPad. /// </summary> /// <param name="thumbSticks">Initial thumbstick state.</param> /// <param name="triggers">Initial trigger state.</param> /// <param name="buttons">Initial button state.</param> /// <param name="dPad">Initial directional pad state.</param> public GamePadState( GamePadThumbSticks thumbSticks, GamePadTriggers triggers, GamePadButtons buttons, GamePadDPad dPad ) : this() { ThumbSticks = thumbSticks; Triggers = triggers; Buttons = buttons; DPad = dPad; IsConnected = true; PacketNumber = 0; }
/// private メソッド ///--------------------------------------------------------------------------- /// パッドの入力情報を格納 private void setInputState( ref InputGamePadState inputState, GamePadButtons gamePadButtons ) { inputState = 0; /// 方向キー入力 if( (gamePadButtons & GamePadButtons.Up) != 0 ){ inputState |= InputGamePadState.Up; } if( (gamePadButtons & GamePadButtons.Down) != 0 ){ inputState |= InputGamePadState.Down; } if( (gamePadButtons & GamePadButtons.Left) != 0 ){ inputState |= InputGamePadState.Left; } if( (gamePadButtons & GamePadButtons.Right) != 0 ){ inputState |= InputGamePadState.Right; } /// ボタン入力 if( (gamePadButtons & GamePadButtons.Square) != 0 ){ inputState |= InputGamePadState.Square; } if( (gamePadButtons & GamePadButtons.Triangle) != 0 ){ inputState |= InputGamePadState.Triangle; } if( (gamePadButtons & GamePadButtons.Circle) != 0 ){ inputState |= InputGamePadState.Circle; } if( (gamePadButtons & GamePadButtons.Cross) != 0 ){ inputState |= InputGamePadState.Cross; } if( (gamePadButtons & GamePadButtons.Start) != 0 ){ inputState |= InputGamePadState.Start; } if( (gamePadButtons & GamePadButtons.Select) != 0 ){ inputState |= InputGamePadState.Select; } if( (gamePadButtons & GamePadButtons.L) != 0 ){ inputState |= InputGamePadState.L; } if( (gamePadButtons & GamePadButtons.R) != 0 ){ inputState |= InputGamePadState.R; } }
private static XInput.GamepadButtonFlags ConvertButton(GamePadButtons button) { switch (button) { case GamePadButtons.A: return XInput.GamepadButtonFlags.A; case GamePadButtons.B: return XInput.GamepadButtonFlags.B; case GamePadButtons.Back: return XInput.GamepadButtonFlags.Back; case GamePadButtons.DPadDown: return XInput.GamepadButtonFlags.DPadDown; case GamePadButtons.DPadLeft: return XInput.GamepadButtonFlags.DPadLeft; case GamePadButtons.DPadRight: return XInput.GamepadButtonFlags.DPadRight; case GamePadButtons.DPadUp: return XInput.GamepadButtonFlags.DPadUp; case GamePadButtons.LeftShoulder: return XInput.GamepadButtonFlags.LeftShoulder; case GamePadButtons.LeftThumb: return XInput.GamepadButtonFlags.LeftThumb; case GamePadButtons.RightShoulder: return XInput.GamepadButtonFlags.RightShoulder; case GamePadButtons.RightThumb: return XInput.GamepadButtonFlags.RightThumb; case GamePadButtons.Start: return XInput.GamepadButtonFlags.Start; case GamePadButtons.X: return XInput.GamepadButtonFlags.X; case GamePadButtons.Y: return XInput.GamepadButtonFlags.Y; } throw new InvalidOperationException("Unknown GamePadButton."); }
/// <summary> /// Returns true if the given button is currently up. /// </summary> /// <param name="button"></param> /// <returns></returns> public bool IsButtonUp(GamePadButtons button) { return !this.state.Buttons.HasFlag(ConvertButton(button)); }
/// <summary> /// Returns true if the given button is currently up and was down during the last update. /// </summary> /// <param name="button"></param> /// <returns></returns> public bool IsButtonReleased(GamePadButtons button) { XInput.GamepadButtonFlags internalButton = ConvertButton(button); return this.state.Buttons.HasFlag(internalButton) && !this.oldState.Buttons.HasFlag(internalButton); }
public static bool ButtonsAreDown(GamePadButtons buttons) { return (gamepadData.Buttons.HasFlag(buttons)); }
public ButtonStateEventArgs(GamePadNumber controllerNum, GamePadButtons button, bool pressed) : base(controllerNum) { this.Button = button; this.Pressed = pressed; }
internal GamePadButtons(params Buttons[] buttons) { this = new GamePadButtons(); foreach (Buttons buttons1 in buttons) this.buttons |= buttons1; }
/// <summary> /// 指定したボタンが今回のフレームで離したかを返す /// </summary> public static bool Release(GamePadButtons button) { return _padData.ButtonsUp.HasFlag(button); }
/// <summary> /// 指定したボタンが今回のフレームで押し込まれたかを返す /// </summary> public static bool Press(GamePadButtons button) { return _padData.ButtonsDown.HasFlag(button); }
/// <summary> /// 指定したボタンが押下状態かを返す /// </summary> public static bool Down(GamePadButtons button) { return (_padData.Buttons & button) != 0; }
public void updateInput() { var gamePadData = GamePad.GetData (0); // メイン処理 // 今回のフレームで押し込まれたボタンの数をカウント(スタート/セレクトは除く) foreach (GamePadButtons item in Enum.GetValues(typeof(GamePadButtons))) { if (item.ToString () != "Enter" && item.ToString () != "Back" && item.ToString () != "Start" && item.ToString () != "Select") { if (((gamePadData.Buttons & item) != 0) && ((pre_buttons & item) == 0)) button_counter++; } } // 連続して押されたボタンの数が一定数を超えたら状態遷移 if (button_counter > clear_counter) { state = CharacterState.Fly; } else if (button_counter > morph_counter) { state = CharacterState.Morph; } pre_buttons = gamePadData.Buttons; if (state != CharacterState.Morph && state != CharacterState.Fly) { int now_counter = button_counter; button_counter = 0; if (gamePadData.AnalogRightX > 0.2) { if (charge_time_top > 0) { float charge_time = ((charge_time_top > charge_time_bottom) ? charge_time_top : charge_time_bottom); float stepX = ((charge_time > bestStep) ? bestStep : charge_time); stepX = stepX * stepX / bestStep; float stepY = FMath.Sin (FMath.Atan (gamePadData.AnalogRightY / gamePadData.AnalogRightX)); positionX += stepX * 1.0f; positionY += stepY * 1.0f; charge_time_top = 0; charge_time_bottom = 0; // 一応上側優先で state = CharacterState.Stretch; } } else if (gamePadData.AnalogRightX < -0.3) { state = CharacterState.Shrink; charge_time_top += 1.0f; } else if (gamePadData.AnalogLeftX > 0.3) { if (charge_time_bottom > 0) { float charge_time = ((charge_time_top > charge_time_bottom) ? charge_time_top : charge_time_bottom); float stepX = ((charge_time > bestStep) ? bestStep : charge_time); stepX = stepX * stepX / bestStep; float stepY = FMath.Sin (FMath.Atan (gamePadData.AnalogLeftY / gamePadData.AnalogLeftX)); positionX += stepX * 1.0f; positionY += stepY * 1.0f; charge_time_bottom = 0; charge_time_top = 0; // 一応上側優先で state = CharacterState.Stretch; } } else if (gamePadData.AnalogLeftX < -0.2) { state = CharacterState.Shrink; charge_time_bottom += 1.0f; } else { state = 0; button_counter = now_counter; } } else { } }