Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE Joystick doesn't work under Android #1563

Closed
CurryKitten opened this issue May 9, 2022 · 9 comments · Fixed by #2050
Closed

BLE Joystick doesn't work under Android #1563

CurryKitten opened this issue May 9, 2022 · 9 comments · Fixed by #2050
Labels
bug 🐛 Something isn't working

Comments

@CurryKitten
Copy link

Current Behavior

I've tried using the BLE joystick on an Android device. I find that I can connect it to my Android tablet, but I can't get it to appear as a joystick when testing with a sim. I've noticed in the Dsicord group that a few people attempted to use it on Android, and also couldn't seems to get it to work using different sims and a bunch of gamepad testers. In these cases of it failing on Android, it seems absolutely fine on Windows/Mac with the same radio.

Steps to Reproduce

Put your radio/module into BLE joystick mode, pair it with your Android device - attempt to use a SIm - the Sim doesn't see any joystick connected. I was using (and a few of my users) my own CurryKitten FPV Simulator, I saw another using Freerider. Both these sims use Unity as their Game engine. unity doesn't have any special support for bluetooth devices, it simply lists the available joysticks on the system. If a bluetooth device has been paired as a joystick, then it should appear as a joystick in the sim.

Possible Solution (Not obligatory)

I don't know enough about the BlueTooth stack to suggest anything here, but given that the code appears to work fine on Windows/Mac - I assume there's something quite specific about Android that perhaps needs a more specific definition

Details

Your Environment

  • TX hardware: RadioMaster Zorro
  • RX hardware: N/A
  • Handset model: RadioMaster Zorro
  • OpenTX version (including nightly number) Edge TX 2.6.0
  • ExpressLRS version (TX & RX MUST MATCH): 2.3
  • Packet Rate: N/A
  • Telemetry Ratio: N/A
  • user_defines: N/A
@commanderguy3001
Copy link

unfortunately I'm not qualified enough to talk about the bluetooth stack, but just from general knowledge/intuition:
it might be android that hates ANY controller connected over bluetooth, to test that: did you try any other (non elrs) bluetooth controller with the sims?

otherwise it might also be unity that can't work with joysticks on android in particular (for whatever reason, but nothing can surprise me anymore when it comes to unity...)

@CurryKitten
Copy link
Author

Yes - so if I pair an Xbox One controller (for example) that is detected and works fine in the sims. I say fine, obviously, it's horrible compared to the sticks on a radio, but it works.

@commanderguy3001
Copy link

Ok, let me rephrase my question a little bit, could you test another no-name / cheapo bluetooth controller?
I don't think that an xbox controller really is a good comparison, as it is made by microsoft and might do some other funky stuff to work with android.

The intention is to find out if the bluetooth library that expresslrs uses has some flaw, or if it is android that just for whatever reason doesn't like the library.

@CurryKitten
Copy link
Author

The only bluetooth controller I found which isn't a big brand console controller is made by Sminiker - but seems to act a bit differently. Whist both the Xbox One controller and ExpressLRS Joystick have a little gamepad icon next to them in the Bluetooth setting in Android, the controller shows up as a "S600 Gamepad" with a keyboard symbol and lets me move around icons on the desktop and start up applications. It does get picked up as a joystick in the sim, but I can't pick up any movement from the axis... but probably because it's acting as a keyboard for some weird reason. At this point I've run out of Bluetooth controllers to test though

@peteallenm
Copy link

peteallenm commented May 17, 2022

I've made a BLE gamepad using an ESP32 with the BLEGamepad library and it works on my android phone (with Curry Kittens sim and FPV Freerider). I've had a quick glance through the code and they're pretty similar, but I'm happy to post my code if someone with an ELRS controller wants to look.
I'm using ESP32-BLE-Gamepad-0.3.3
Tested on Android 11 (Miui 12.1.4)
and Android 10 (Cyanogeod)

@pkendall64
Copy link
Collaborator

I've made a BLE gamepad using an ESP32 with the BLEGamepad library and it works on my android phone (with Curry Kittens sim and FPV Freerider). I've had a quick glance through the code and they're pretty similar, but I'm happy to post my code if someone with an ELRS controller wants to look. I'm using ESP32-BLE-Gamepad-0.3.3 Tested on Android 11 (Miui 12.1.4) and Android 10 (Cyanogeod)

Yes please, we're happy to take a look at the differences

@peteallenm
Copy link

Apologies, this is rather clunky as I removed a load of other functionality for this test.
I can confirm this still works on my phone however.

The big functional difference I can see with your code is that I had to add some code to only send if a value had changed. Without that (even at 100hz) the controller got more and more laggy until the axis stopped responding. However I just tested without this at 200hz, and for the 20 seconds of my test it worked perfectly.
FPVGamePadNoWifi.zip

@arthurson
Copy link

arthurson commented Nov 22, 2022

Screenshot_2022-11-22-15-57-24-681_com android settings
Screenshot_2022-11-22-20-34-46-938_com miui gallery

i have gamesir g4s for bluetooth joystick, it works for freerider and flyskydive, while elrs wont as usual

using gamepad test app and get the above data for reference

@rickard-von-essen
Copy link
Contributor

rickard-von-essen commented Dec 27, 2022

I had a similar issue with connecting a BetaFPV LiteRadio 2 (old version) to an Android device over USB.

After some research it turns out that Android is very picky about what USB HID game pads it allows, if the HID descriptor doesn't match those criterias it will not show up on Android.

For the LiteRadio 2 the problem was that it defines Sim Ctrls/throttle and rudder instead of Generic Desktop Control/X, Y, Z which Android doesn't recognize as a proper gamepad.

Maybe something similar applies to Bluetooth too.

I see that the BLE code seems to use Throttle/Rudder here:
https://github.com/ExpressLRS/ExpressLRS/blob/master/src/lib/BLE/devBLE.cpp#L59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants