Does anyone know how to use a gamepad+javascript with Android?

I tried to use a gamepad with the Anki desktop APP, and it works!

When I enter “navigator.getGamepads()” in the console, it can detect the gamepad I used.

However, it does not work on my Android device. BTW, the browser on my Android device can detect the gamepad (it works fine when opening a gamepad tester website).

Does anyone have an idea on how to solve this problem?

Thank you very much!

Thanks for the report, logged as an issue:

Out of interest, are the options in ‘settings → controls’ insufficient, and if so, what could be done better?

1 Like

Dear David:

Thank you for the effort.

The scenario I was about to use is I want to have the ability to trigger a specific function that is not provided in the default action list. For Example, one button to play the first audio, another button to stop the playing, etc. In other words, the ability to write a customized mapping to any javascript function would give users the freedom to play with their cards.

Thanks you again for the help!


Hi Ye,

This functionality will be available natively after the following feature request is completed. Should be done this month for the 2.17 alpha series.

If you subscribe to the following bug report on GitHub, I’ll have this fixed tonight, and it should be available in AnkiDroid 2.17alpha11: [Bug] `navigator.getGamepads()` returns `[null, null, null, null]` · Issue #14975 · ankidroid/Anki-Android · GitHub

Our alphas are available here: Releases · ankidroid/Anki-Android · GitHub. When testing, I’d recommend the Parallel.A apk, as this can be used alongside 2.16.5

In for review:

Dear David:

Thank you so much!! I just subscribed to the issue you mentioned. Looking forward to the update!


Dear David:
I tried the alpha11 and alpha14 versions today. However, navigator.getGamepads() still produces [null, null, null, null]. What might be the reason? I’m looking forward to hearing back from you.

Thank you!

This is debug info:

AnkiDroid Version = 2.17alpha14 (0717daab11cd9669997aea6a421ec94689120cb6)

Backend Version = 0.1.32-anki23.10.1 (23.10.1 fac9e0ee1436ba5ac3366c72dd9394a6e692b1cf)

Android Version = 10 (SDK 29)

ProductFlavor = full

Manufacturer = ONYX

Model = MaxLumi

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 10; MaxLumi Build/2023-12-12_20-35_3.5_4687b1901; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.193 Safari/537.36

ACRA UUID = 7f132363-9d0e-45dc-b638-316e139d90c9

Crash Reports Enabled = true

You need to press a button on the gamepad in order for it to be visible in Javascript

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.