public HalfPadState(ControlSide side, PlayerIndex controllerIndex) { //SharpDX.XInput.Controller c; //var s = c.GetState(); //var gp = s.Gamepad; //gp. 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; } }
public override InputState GetState() { newKeyState = Keyboard.GetState(); newMouseState = Mouse.GetState(); Stick LeftStick_WASD = new Stick(newKeyState.IsKeyDown(Keys.W), newKeyState.IsKeyDown(Keys.S), newKeyState.IsKeyDown(Keys.A), newKeyState.IsKeyDown(Keys.D)); Stick RightStick_Mouse = new Stick(GetRightStick(mouseStickRadius)); newInputState = new InputState(LeftStick_WASD, RightStick_Mouse, newMouseState.RightButton, newMouseState.LeftButton, newKeyState.IsKeyDown(Keys.D1), newKeyState.IsKeyDown(Keys.D2), newKeyState.IsKeyDown(Keys.D3), newKeyState.IsKeyDown(Keys.D4), newKeyState.IsKeyDown(Keys.Up), newKeyState.IsKeyDown(Keys.Down), newKeyState.IsKeyDown(Keys.Right), newKeyState.IsKeyDown(Keys.Left), newKeyState.IsKeyDown(Keys.Tab), newKeyState.IsKeyDown(Keys.Escape), newKeyState.IsKeyDown(Keys.Q), newKeyState.IsKeyDown(Keys.E)); return(newInputState); }
//controller public InputState(ref GamePadState state, float triggerDeadZone) { this.LeftStick_WASD = new Stick(state.ThumbSticks.Left); this.LeftStick_WASD.v2.Y *= -1; //todo: fix directional buttonstates? this.RightStick_Mouse = new Stick(state.ThumbSticks.Right); this.RightStick_Mouse.v2.Y *= -1; this.LeftTrigger_Mouse2 = state.Triggers.Left > triggerDeadZone ? ButtonState.Pressed : ButtonState.Released; this.RightTrigger_Mouse1 = state.Triggers.Right > triggerDeadZone ? ButtonState.Pressed : ButtonState.Released; this.A_1 = state.Buttons.A; this.X_2 = state.Buttons.X; this.B_3 = state.Buttons.B; this.Y_4 = state.Buttons.Y; this.Dpad_UpArrow = state.DPad.Up; this.Dpad_DownArrow = state.DPad.Down; this.Dpad_RightArrow = state.DPad.Right; this.Dpad_LeftArrow = state.DPad.Left; this.Select_TAB = state.Buttons.Back; this.Start_ESC = state.Buttons.Start; this.LeftBumper_Q = state.Buttons.LeftShoulder; this.RightBumper_E = state.Buttons.RightShoulder; this.LeftTriggerAnalog = state.Triggers.Left; this.RightTriggerAnalog = state.Triggers.Right; }
public HalfPadState(FullPadMode mode, PlayerIndex controllerIndex) { GamePadState gamePadState = GamePad.GetState(controllerIndex, GamePadDeadZone.Circular); if (mode == FullPadMode.mirrorMode) { stick1 = new Stick(gamePadState.Buttons.Y, gamePadState.Buttons.A, gamePadState.Buttons.X, gamePadState.Buttons.B); if (stick1.isCentered()) { stick1 = new Stick(gamePadState.ThumbSticks.Left); } stick2 = new Stick(gamePadState.ThumbSticks.Right); if (stick2.isCentered()) { stick2 = new Stick(gamePadState.DPad.Up, gamePadState.DPad.Down, gamePadState.DPad.Left, gamePadState.DPad.Right); } Btn1 = gamePadState.Buttons.RightShoulder; if (Btn1 == ButtonState.Released) { Btn1 = gamePadState.Buttons.LeftShoulder; } Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test if (Btn2 == ButtonState.Released) { Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; } Btn2AsTrigger = Math.Max(gamePadState.Triggers.Right, gamePadState.Triggers.Left); Btn3 = gamePadState.Buttons.RightStick; if (Btn3 == ButtonState.Released) { Btn3 = gamePadState.Buttons.LeftStick; } BtnStart = gamePadState.Buttons.Start; if (BtnStart == ButtonState.Released) { BtnStart = gamePadState.Buttons.Back; } } else { stick1 = new Stick(gamePadState.ThumbSticks.Left); stick2 = new Stick(gamePadState.ThumbSticks.Right); if (stick2.isCentered()) { stick2 = new Stick(gamePadState.DPad.Up, gamePadState.DPad.Down, gamePadState.DPad.Left, gamePadState.DPad.Right); } Btn1 = gamePadState.Buttons.RightShoulder; if (Btn1 == ButtonState.Released) { Btn1 = gamePadState.Buttons.LeftShoulder; } if (Btn1 == ButtonState.Released) { Btn1 = gamePadState.Buttons.A; } Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test if (Btn2 == ButtonState.Released) { Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; } if (Btn2 == ButtonState.Released) { Btn2 = gamePadState.Buttons.B; } if (Btn2 == ButtonState.Released) { Btn2 = gamePadState.Buttons.Y; } Btn2AsTrigger = Math.Max(gamePadState.Triggers.Right, gamePadState.Triggers.Left); if (gamePadState.Buttons.B == ButtonState.Pressed || gamePadState.Buttons.Y == ButtonState.Pressed) { Btn2AsTrigger = 1.0f; } Btn3 = gamePadState.Buttons.RightStick; if (Btn3 == ButtonState.Released) { Btn3 = gamePadState.Buttons.LeftStick; } if (Btn3 == ButtonState.Released) { Btn3 = gamePadState.Buttons.X; } BtnStart = gamePadState.Buttons.Start; if (BtnStart == ButtonState.Released) { BtnStart = gamePadState.Buttons.Back; } } }