- Home /
Map Unity Keycodes to Android KeyEvents
Hi,
Is it possible to map the standard Unity KeyCodes to Android KeyEvents?
I want to add support for a Bluetooth Android Game Controller, and the controllers documentation specifies Android KeyCodes (Ex. KEYCODE_BUTTON_X for the button X). Is it possible to tell if this KEYCODE_BUTTON_X is the same as JoystickButton1 on the Unity side?
As I understand each Android KeyEvent has it's constant integer value, can this be somehow translated to a Unity Keycode?
Note: I don't have the physical device so I can't connected and see which of the inputs are triggered.
Thanks in advance,
Bari
I have a similar question about mapping the Amazon Fire TV remote, that uses Android key codes:
Select (D-Pad Center) $$anonymous$$EYCODE_DPAD_CENTER
Play/Pause $$anonymous$$EYCODE_$$anonymous$$EDIA_PLAY_PAUSE
Rewind $$anonymous$$EYCODE_$$anonymous$$EDIA_REWIND
Fast Forward $$anonymous$$EYCODE_$$anonymous$$EDIA_FAST_FORWARD
Answer by soft_sound · Mar 25, 2015 at 12:40 AM
Hmmm... It's kind of a shot in the dark. You can try Input.GetJoyStick
or maybe "Input: "+(string)Input.inputString
But without a device I'm not sure.... :(
I have an adroid phone but not a controller or anything so I can't test any of these for you.
I know you can get the int value by converting it over...
(int)KeyCode.Home
returns 278 for example....
(int)KeyCode.A
= 97 ...
As far as the values being similar, I don't think there is any correlation.
Considering I believe KEYCODE_A = 29 on some devices....
...
Nevermind, here is what you are looking for mapping android
"FireTV Button Unity KeyCode
Up Arrow KeyCode.UpArrow
Down Arrow KeyCode.DownArrow
Center Button KeyCode.JoystickButton0"