[SOLVED] Bluetooth jostick on Android

This is not a PlayCanvas related issue, but a known issue in Android devices, and I would like to know how you worked around it. I’ve been working on this for a couple of weeks intermitently so my hope is not that high.

I have a jostick which all buttons are detected as undefined. It works well in PC and I guess on iPhone. Also it’s said that Android Apps would be able to distinguish them. Using Android + Chrome, no.

My current approach is to intercept the buttons and fire a single custom event and work my UI around the fact that we only have the jostick movement and a virtual left click button.

Suggestions would be appreciated.


Odd that the buttons are undefined. Can you check with https://gamepad-tester.com/ as that uses the Browser GamePad API directly and see if the buttons can be detected.

I’m not sure if iOS supports the browser gamepad API so you have issues on iOS

1 Like

Oddly enough, my pc can open that website but my phone can’t.

I used this website and here is the output for all the buttons:

 "key": "Unidentified",
 "keyCode": 0,
 "which": 0,
 "code": "",
 "location": 0,
 "altKey": false,
 "ctrlKey": false,
 "metaKey": false,
 "shiftKey": false,
 "repeat": false

It doesn’t detect it as gamepad either, I tried navigator.getGamepads() and returned a list of nulls.

The gamepad is the cheapest VR version you can find online. It has a VR mode and a Mouse mode:

  • The Mouse mode has detectable keys and you can move the cursor, but the mouse is useless to move around because the mousemove event doesn’t work on Android. Other properties as :hover doesn’t work either, so you can’t calculate what the user is doing with the jostick.
  • The VR mode has some keys to open menu, go to the previous page and such. They are more a nuisance than something helpful, and the keydown events triggered in the browser are exactly the same, without key code.

I want to share a link to the problem, there are dozens but the one I shared links to the official bug report.

Basically, buttons are different, and the phone uses them differently, but Chrome in Android doesn’t like at all non-printable characters and zeroes them.

Some of these Chinese controllers will have an ‘Android’/gamepad/mouse/keyboard mode so might be worth checking if you switch between them in the instructions?

I tried and analyzed all 4 modes. They are ready for Android and iPhone Apps, not browsers.

Anyway, knowing the limitations, let’s work around them.

Thanks yaustar.