I’m using Xbox One gamepad on Android phone connected by bluetooth (and several other compatible gamepads).
Some time ago I’ve updated VisualStudio. I’m not really sure, which components got updated.
Since then, my Android game build does not react to LT and RT triggers (Windows, Linux and Mac builds are still fine).
Things I’ve tried so far:
- Making a fresh Android Monogame project (still doesn’t work).
- Testing other apps on my phone (triggers register fine).
- Upgrading Monogame from 3.8.0. to 3.8.1 (no difference).
- Changing the code, looking at GamePadState at debugger, etc…
I’m kinda out of ideas at this point.
Did anyone have this problem?
To replicate the problem:
- Create new MonoGame Android Application.
- Paste the code below.
- Connect Android phone with bluetooth gamepad connected.
- Run the app and try pressing the triggers.
Game1.cs code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace android_test_project_monogame
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void Update(GameTime gameTime)
{
// if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
// Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
Color color = Color.CornflowerBlue;
if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.LeftShoulder)) color = Color.Violet; // works
if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.RightShoulder)) color = Color.Red; // works
if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.LeftTrigger)) color = Color.White; // doesn't work on Android
if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.RightTrigger)) color = Color.Yellow; // doesn't work on Android
if (GamePad.GetState(PlayerIndex.One).Triggers.Left > 0.5f) color = Color.White; // doesn't work on Android
if (GamePad.GetState(PlayerIndex.One).Triggers.Right > 0.5f) color = Color.Yellow; // doesn't work on Android
GraphicsDevice.Clear(color);
base.Draw(gameTime);
}
}
}