Class AndroidGamepad
Represents a gamepad device on Android, providing unified support for various controller types.
Inherited Members
Namespace: UnityEngine.InputSystem.Android
Assembly: Unity.InputSystem.dll
Syntax
public class AndroidGamepad : Gamepad, IDualMotorRumble, IHaptics
Remarks
This layout covers multiple Android-supported gamepads, including but not limited to:
- ELAN PLAYSTATION(R)3 Controller
- My-Power CO., LTD. PS(R) Controller Adaptor
- Sony Interactive Entertainment Wireless (PS4 DualShock)
- Xbox Wireless Controller (Xbox One)
- NVIDIA Controller v01.03/v01.04
- (More may be added later)
Typical Android Axis and Key Mappings
| Control | Mapping |
|---|---|
| Left Stick | AXIS_X(0) / AXIS_Y(1) |
| Right Stick | AXIS_Z(11) / AXIS_RZ(14) |
| L1 | KEYCODE_BUTTON_L1(102) |
| R1 | KEYCODE_BUTTON_R1(103) |
| L2 | AXIS_BRAKE(23) |
| R2 | AXIS_GAS(22) |
| Left Thumb | KEYCODE_BUTTON_THUMBL(106) |
| Right Thumb | KEYCODE_BUTTON_THUMBR(107) |
| X | KEYCODE_BUTTON_X(99) |
| Y | KEYCODE_BUTTON_Y(100) |
| B | KEYCODE_BUTTON_B(97) |
| A | KEYCODE_BUTTON_A(96) |
| DPAD | AXIS_HAT_X(15), AXIS_HAT_Y(16) or KEYCODE_DPAD_* |
Notes
NVIDIA Shield Console
- The L2 and R2 triggers generate both
AXIS_BRAKE/AXIS_GASandAXIS_LTRIGGER/AXIS_RTRIGGERevents. - On most Android phones, only
AXIS_BRAKEandAXIS_GASare reported;AXIS_LTRIGGERandAXIS_RTRIGGERare not invoked. - For consistency across devices, triggers are mapped exclusively to
AXIS_BRAKEandAXIS_GAS. - The Shield also reports
KEYCODE_BACKinstead ofKEYCODE_BUTTON_SELECT, causing the Options (Xbox), View (DualShock), or Select buttons to be non-functional.
- The L2 and R2 triggers generate both
PS4 Controller Compatibility
- Official PS4 controller support is available starting from Android 10 and later (see: https://playstation.com/en-us/support/hardware/ps4-pair-dualshock-4-wireless-with-sony-xperia-and-android).
- On older Android versions, driver implementations vary by manufacturer. Some vendors have partially fixed DualShock support in custom drivers, leading to inconsistent mappings.
Driver-Dependent Behavior
- Gamepad mappings may differ even between devices running the same Android version.
- For example, on Android 8.0:
- NVIDIA Shield Console: buttons map correctly according to
AndroidGameControllerState(for example,L1 → ButtonL1,R1 → ButtonR1). - Samsung Galaxy S9 / S8 and Xiaomi Mi Note2: mappings are inconsistent (for example,
L1 → ButtonY,R1 → ButtonZ).
- NVIDIA Shield Console: buttons map correctly according to
- For example, on Android 8.0:
- These discrepancies stem from device-specific driver differences, not the Android OS itself.
- Gamepad mappings may differ even between devices running the same Android version.
Because mapping inconsistencies depend on vendor-specific drivers, it’s impractical to maintain per-device remaps.