public static OtherState GetState() { GamePadState state = GamePad.GetState(PlayerIndex.One); OtherState newState = new OtherState(); newState.LeftStickFlickDown = (state.ThumbSticks.Left.Y > 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.LeftStickFlickUp = (state.ThumbSticks.Left.Y < 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.LeftStickFlickLeft = (state.ThumbSticks.Left.X < 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.LeftStickFlickRight = (state.ThumbSticks.Left.X > 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.RightStickFlickDown = (state.ThumbSticks.Right.Y > 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.RightStickFlickUp = (state.ThumbSticks.Right.Y < 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.RightStickFlickLeft = (state.ThumbSticks.Right.X < 0.0f ? OtherInputState.Pressed : OtherInputState.Released); newState.RightStickFlickRight = (state.ThumbSticks.Right.X > 0.0f ? OtherInputState.Pressed : OtherInputState.Released); return newState; }
private void UpdateOther() { OtherState oldState = sOtherState; sOtherState = OtherState.GetState(); OtherInput[] otherInputs = sOtherInputState.Keys.ToArray<OtherInput>(); foreach (OtherInput otherInput in otherInputs) { InputState state = new InputState(); OtherInputState curOtherState = GetOtherState(otherInput, sOtherState); OtherInputState oldOtherState = GetOtherState(otherInput, oldState); state.Down = (curOtherState == OtherInputState.Pressed); state.Pressed = ((curOtherState == OtherInputState.Pressed) && (oldOtherState == OtherInputState.Released)); state.Released = ((curOtherState == OtherInputState.Released) && (oldOtherState == OtherInputState.Pressed)); sOtherInputState[otherInput] = state; } }
public InputManager() { sKeyState = Keyboard.GetState(); sGamePadState = GamePad.GetState(PlayerIndex.One); sMouseState = Mouse.GetState(); sOtherState = OtherState.GetState(); sKeyAlias = new Dictionary<string, List<Keys>>(); sGamePadAlias = new Dictionary<string, List<Buttons>>(); sMouseAlias = new Dictionary<string, List<MouseButtons>>(); sOtherAlias = new Dictionary<string, List<OtherInput>>(); sKeyInputState = new Dictionary<Keys, InputState>(); sGamePadInputState = new Dictionary<Buttons, InputState>(); sMouseInputState = new Dictionary<MouseButtons, InputState>(); sOtherInputState = new Dictionary<OtherInput, InputState>(); }
private OtherInputState GetOtherState(OtherInput pOtherInput, OtherState pOtherState) { OtherInputState state = OtherInputState.Released; switch (pOtherInput) { case OtherInput.LeftStickFlickDown: state = pOtherState.LeftStickFlickDown; break; case OtherInput.LeftStickFlickLeft: state = pOtherState.LeftStickFlickLeft; break; case OtherInput.LeftStickFlickRight: state = pOtherState.LeftStickFlickRight; break; case OtherInput.LeftStickFlickUp: state = pOtherState.LeftStickFlickUp; break; case OtherInput.RightStickFlickDown: state = pOtherState.RightStickFlickDown; break; case OtherInput.RightStickFlickLeft: state = pOtherState.RightStickFlickLeft; break; case OtherInput.RightStickFlickRight: state = pOtherState.RightStickFlickRight; break; case OtherInput.RightStickFlickUp: state = pOtherState.RightStickFlickUp; break; } return state; }