DX12: GamePadState.IsButtonDown(Buttons.LeftTrigger/RightTrigger) always returns false
Prerequisites
- I have verified this issue is present in the
developbranch - I have searched open and closed issues to ensure it has not already been reported.
LLM Declaration
- I used an LLM to generate the code or fix in this Issue.
MonoGame Version
MonoGame 3.8.5.1
Which MonoGame platform are you using?
MonoGame Windows Desktop DirectX 12 Application
Operating System
Windows
Description
Since I'm not building from source, it's difficult to be sure the bug is present in the develop branch, but I'm using the VS template extension and created the project recently, so I assume it's fairly up to date, and I couldn't find any related issues already posted (save an identical one about cross-platform projects from 2016).
When using IsButtonDown to check the left or right triggers, the method always returns false, no matter how far down the triggers are pressed. A quick swap to a regular (DX11) project with otherwise identical code confirmed the issue is only present in the experimental DX12 build.
Steps to Reproduce
Create a new DirectX12 project. Plug in a gamepad. Use the following basic Game1 class to change the game window background color when various buttons on the gamepad are pressed. Observe that the color doesn't change when the triggers are pressed.
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private bool _buttonPressed;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
}
protected override void Update(GameTime gameTime)
{
GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
if (gamePadState.Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
_buttonPressed = false;
if (gamePadState.IsButtonDown(Buttons.A) ||
gamePadState.IsButtonDown(Buttons.B) ||
gamePadState.IsButtonDown(Buttons.X) ||
gamePadState.IsButtonDown(Buttons.Y) ||
gamePadState.IsButtonDown(Buttons.Start) ||
gamePadState.IsButtonDown(Buttons.Back) ||
gamePadState.IsButtonDown(Buttons.DPadUp) ||
gamePadState.IsButtonDown(Buttons.DPadDown) ||
gamePadState.IsButtonDown(Buttons.DPadLeft) ||
gamePadState.IsButtonDown(Buttons.DPadRight) ||
gamePadState.IsButtonDown(Buttons.LeftStick) ||
gamePadState.IsButtonDown(Buttons.RightStick) ||
gamePadState.IsButtonDown(Buttons.LeftThumbstickUp) ||
gamePadState.IsButtonDown(Buttons.LeftThumbstickDown) ||
gamePadState.IsButtonDown(Buttons.LeftThumbstickLeft) ||
gamePadState.IsButtonDown(Buttons.LeftThumbstickRight) ||
gamePadState.IsButtonDown(Buttons.RightThumbstickUp) ||
gamePadState.IsButtonDown(Buttons.RightThumbstickDown) ||
gamePadState.IsButtonDown(Buttons.RightThumbstickLeft) ||
gamePadState.IsButtonDown(Buttons.RightThumbstickRight) ||
gamePadState.IsButtonDown(Buttons.LeftShoulder) ||
gamePadState.IsButtonDown(Buttons.RightShoulder) ||
gamePadState.IsButtonDown(Buttons.LeftTrigger) ||
gamePadState.IsButtonDown(Buttons.RightTrigger))
_buttonPressed = true;
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(_buttonPressed ? Color.LightGray : Color.Gray);
base.Draw(gameTime);
}
}Minimal Example Repo
No response
Expected Behavior
IsButtonDown should return true when the triggers are pressed.
Resulting Behavior
IsButtonDown always returns false for Buttons.LeftTrigger and Buttons.RightTrigger.
Files
No response
Source: MonoGame/MonoGame