Gamepad support in Android (not Ouya)?

So, I’ve been digging around and searching for anything related to actual gamepad support in Android, and it seems like only Ouya is supported.

Has anyone gotten gamepads (Xbox 360 for example, or the NVIDIA SHIELD Controller on an NVIDIA SHIELD Tablet) to work on vanilla Android?

Alright I’m trying to dig into creating my own library for this, however I’m not entirely clear how the mapping for PlatformGetState happens. For example, when debugging, this call in GamePad.cs:

return PlatformGetState(index, deadZoneMode);

Maps to

private static GamePadState PlatformGetState(int index, GamePadDeadZone deadZoneMode)

in GamePad.Default.cs.

How would I get that to map to a different file, like GamePad.Android.cs? It doesn’t seem clear at least to me… (Trying to see how it works for Ouya but I am failing the mapping in the MonoGame source).

EDIT

I realize now that it’s just which GamePad.*.cs file is actually included in the MonoGame.Framework.Android.csproj file. Doh. Created a new GamePad file for Android to see if we can get some generic gamepad support in Android.

There is nothing really OUYA-specific in the gamepad support. I’m using it with minimal changes in a game port to Nvidia SHIELD at the moment, which basically stock Android.

True, but it’d be nice to actually get standardized support in MonoGame for Android GamePads, instead of having to modify around the OUYA code.

I’ve got it working removing the OUYA defines in MonoGameAndroidGameView.cs, and cleaning up the input consumption.

I’ve created a new GamePad.Android.cs implementation, it used the OUYA implementation as a base but generalizes things a bit more (and still handles the onscreen/hardware “back” button if no gamepad is connected).

Gist here: https://gist.github.com/vostok4/7a93a98060a360494d20

I’ll submit a PR as well.

Any update on this issue? I’ve created a monogame app and tried to access the GamePad object, but nothing says it’s connected:

I’ve tried this with MonoGame 3.3 (I had an old build) as well as the latest 3.6 install, and I’m always getting false.

I am able to use the controller to navigate the main Android operating system, so I know the device is connected.