private static InputType?CheckForBackInput(XInputGamepad previousState, XInputGamepad currentState) { if (!previousState.IsButtonPressed((int)GamepadButton.XINPUT_GAMEPAD_B) && currentState.IsButtonPressed((int)GamepadButton.XINPUT_GAMEPAD_B)) { return(InputType.Back); } return(null); }
public void Copy(XInputGamepad source) { sThumbLX = source.sThumbLX; sThumbLY = source.sThumbLY; sThumbRX = source.sThumbRX; sThumbRY = source.sThumbRY; bLeftTrigger = source.bLeftTrigger; bRightTrigger = source.bRightTrigger; wButtons = source.wButtons; }
private static InputType?CheckForMenuInput(XInputGamepad previousState, XInputGamepad currentState) { const int buttonCombo = (short)GamepadButton.XINPUT_GAMEPAD_LEFT_SHOULDER | (short)GamepadButton.XINPUT_GAMEPAD_RIGHT_SHOULDER | (short)GamepadButton.XINPUT_GAMEPAD_START; var comboWasPressed = previousState.wButtons == buttonCombo; var comboIsPressed = currentState.wButtons == buttonCombo; return(!comboWasPressed && comboIsPressed ? InputType.Menu : null as InputType?); }
private static InputType?CheckForNextItemInput(XInputGamepad previousState, XInputGamepad currentState) { if (!previousState.IsButtonPressed((int)GamepadButton.XINPUT_GAMEPAD_DPAD_DOWN) && currentState.IsButtonPressed((int)GamepadButton.XINPUT_GAMEPAD_DPAD_DOWN)) { return(InputType.NextItem); } if (previousState.sThumbLY > -8000 && currentState.sThumbLY <= -8000) { return(InputType.NextItem); } return(null); }
private InputType?GetInputTypeFromStateChanges(XInputGamepad previousState, XInputGamepad currentState) { foreach (var activeInputType in this.activeInputTypes) { var stateChangeDetector = GamepadStateChangeDetectorMap[activeInputType]; var inputType = stateChangeDetector(previousState, currentState); if (inputType.HasValue) { return(inputType); } } return(null); }
public override bool Equals(object obj) { if (!(obj is XInputGamepad)) { return(false); } XInputGamepad source = (XInputGamepad)obj; return((sThumbLX == source.sThumbLX) && (sThumbLY == source.sThumbLY) && (sThumbRX == source.sThumbRX) && (sThumbRY == source.sThumbRY) && (bLeftTrigger == source.bLeftTrigger) && (bRightTrigger == source.bRightTrigger) && (wButtons == source.wButtons)); }