Showing results for 
Search instead for 
Did you mean: 

Android Gamepad Keycodes and Unity Assignments

Level 2
Hey all,

So I've been working on a spreadsheet that has the keycodes that android uses for gamepads whether through OTG or Wireless.
This was initially for me and my friends but I feel it has reached a stage where it is useful enough to share with everyone.

You can access the spreadsheet here: (Link is View Only)
Current version is 1.9 (Changelog is at the bottom of the sheet.)

Testing information:
Unity version : 5.1.2

Device 1:
Samsung Galaxy S4 - GT-I9505
Android KitKat 4.4.2 - Unlocked - Non-Rooted

Device 2:
Samsung Galaxy Note 4 - SM-N910G (Qualcomm SNapdragon 805)
Android KitKat 4.4.4 - Unlocked - Non-Rooted
There is also A 2nd sheet(At the bottom, "Compare Keycodes") where you can select two controllers from a dropdown as well as compare them to either Type A Layout, Type B Layout, or the opposite controller you've selected.
[WebM Preview]
To use the comparing sheet you'll have to make A copy of the sheet into your own google drive
"File -> Make a copy..."

However if you make a copy, it won't get updated.

Q. Why did you list controllers that connect wired via OTG?
A. A few of my friends are working with google cardboard, also in the off chance that in a later release(Or maybe in CV) of gearVR they include A OTG port.

Q. Do you own all of the controllers listed?
A. Yes, except of the Samsung Gamepad, that belongs to my friend.

Q. Why did you list the keycodes/keycode constants/motionevent constants?
A. For those not working in unity.

Q.Why haven't you listed X Controller?
A. I don't own it/have access to it.
A2. I don't have A Rooted device(I can't test the SixAxis app for wireless ps3 controller)

Q.Why can't I select A controller/compare with?
A. You need to make A copy of the sheets.
A2. It doesn't work on Mobile(Both Web App and Sheets App)

Q.Why is the Mojing controller analog striked out?
A.The controller I have the joystick is broken so I'm unsure as to whether the readout is still correct.

Porting warning.
If you plan to port your Windows game to android,
The inputs are different between Windows <-> Android,
For example on windows, the Xbox360 Right Analog auto maps to Axises 4 and 5.
where as on android it maps to Axises 3 and 4.

Rooted warning.(Aimed at users with rooted devices/different devices(google cardboard))
As members of the XDA community may know, you can rebind inputs for specific controller by adding specific Keylayout files to "/system/usr/keylayout". As I have tested these controllers on my Note4, they may differ on other model phones. One example I can think of is that the newer Xperia model phones have native ps4 wireless drivers so that it works with their remote play app where as other phones don't.

Level 15
Awesome! Thanks.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

Level 2
Sheet has been updated, Now at Ver 1.8
1.8 - Added Playstation Navigation Controller Wired
Added SHiNTEC SMACON Controller

Don't forget to re-copy the sheet to your drive if you've copied before.
And if anyone has any questions I'll answer them as best I can.

Level 2
Sheet has been updated, Now at Ver 1.9
1.9 - Added Ouya Controller

Finally had A chance to quickly borrow my friends Ouya Controller,
Unfortunately I forgot it had a touchpad and in a rush to scribble down the mapping while I was with my friends I used very messy handwriting and now I can't read it haha....
From what I can make out, the touchpad maps to androids;
and tapping it is Axis_Pressure

I think it maps to Unity's Axis X and Y and Mouse_1 but I don't remember and I don't want to add it until I'm certain so I've omitted it from the chart for now.

Don't forget to re-copy the sheet to your drive if you've copied before.