/// <summary> /// Checks if a given button state is engaged in the current packet. /// </summary> /// <param name="button">The DualShock button to question.</param> /// <returns>True if the button is pressed, false if the button is released.</returns> public IDsButtonState this[IDsButton button] { get { if (button is Ds3Button && Model == DsModel.DS3) { var buttons = (uint)((RawBytes[10] << 0) | (RawBytes[11] << 8) | (RawBytes[12] << 16) | (RawBytes[13] << 24)); return(new DsButtonState { IsPressed = (!button.Equals(Ds3Button.None)) && (buttons & button.Offset) == button.Offset }); } if (button is Ds4Button && Model == DsModel.DS4) { var buttons = (uint)((RawBytes[13] << 0) | (RawBytes[14] << 8) | (RawBytes[15] << 16)); return(new DsButtonState { IsPressed = (!button.Equals(Ds4Button.None)) && (buttons & button.Offset) == button.Offset }); } return(new DsButtonState()); } }
/// <summary> /// Checks if a given button state is engaged in the current packet. /// </summary> /// <param name="button">The DualShock button to question.</param> /// <returns>True if the button is pressed, false if the button is released.</returns> public IDsButtonState this[IDsButton button] { get { if (button is Ds3Button && Model == DsModel.DS3) { var buttons = (uint)((RawBytes[10] << 0) | (RawBytes[11] << 8) | (RawBytes[12] << 16) | (RawBytes[13] << 24)); _currentDsButtonState.IsPressed = !button.Equals(Ds3Button.None) && (buttons & button.Offset) == button.Offset; _currentDsButtonState.Xbox360Button = _currentDsButtonState.IsPressed ? button.Xbox360Button : X360Button.None; return(_currentDsButtonState); } if (button is Ds4Button && Model == DsModel.DS4) { var buttons = (uint)((RawBytes[13] << 0) | (RawBytes[14] << 8) | (RawBytes[15] << 16)); _currentDsButtonState.IsPressed = !button.Equals(Ds4Button.None) && (buttons & button.Offset) == button.Offset; _currentDsButtonState.Xbox360Button = _currentDsButtonState.IsPressed ? button.Xbox360Button : X360Button.None; return(_currentDsButtonState); } return(_currentDsButtonState); } }
/// <summary> /// Checks if a given button state is engaged in the current packet. /// </summary> /// <param name="button">The DualShock button to question.</param> /// <returns>True if the button is pressed, false if the button is released.</returns> public IDsButtonState this[IDsButton button] { get { if (button is Ds3Button && Model == DsModel.DS3) { var buttons = (uint) ((RawBytes[10] << 0) | (RawBytes[11] << 8) | (RawBytes[12] << 16) | (RawBytes[13] << 24)); _currentDsButtonState.IsPressed = !button.Equals(Ds3Button.None) && (buttons & button.Offset) == button.Offset; _currentDsButtonState.Xbox360Button = _currentDsButtonState.IsPressed ? button.Xbox360Button : X360Button.None; return _currentDsButtonState; } if (button is Ds4Button && Model == DsModel.DS4) { var buttons = (uint) ((RawBytes[13] << 0) | (RawBytes[14] << 8) | (RawBytes[15] << 16)); _currentDsButtonState.IsPressed = !button.Equals(Ds4Button.None) && (buttons & button.Offset) == button.Offset; _currentDsButtonState.Xbox360Button = _currentDsButtonState.IsPressed ? button.Xbox360Button : X360Button.None; return _currentDsButtonState; } return _currentDsButtonState; } }
/// <summary> /// Checks if a given button state is engaged in the current packet. /// </summary> /// <param name="button">The DualShock button to question.</param> /// <returns>True if the button is pressed, false if the button is released.</returns> public IDsButtonState this[IDsButton button] { get { if (button is Ds3Button && Model == DsModel.DS3) { var buttons = (uint) ((RawBytes[10] << 0) | (RawBytes[11] << 8) | (RawBytes[12] << 16) | (RawBytes[13] << 24)); return new DsButtonState { IsPressed = (!button.Equals(Ds3Button.None)) && (buttons & button.Offset) == button.Offset }; } if (button is Ds4Button && Model == DsModel.DS4) { var buttons = (uint) ((RawBytes[13] << 0) | (RawBytes[14] << 8) | (RawBytes[15] << 16)); return new DsButtonState { IsPressed = (!button.Equals(Ds4Button.None)) && (buttons & button.Offset) == button.Offset }; } return new DsButtonState(); } }