ESP32-BLE-Gamepad icon indicating copy to clipboard operation
ESP32-BLE-Gamepad copied to clipboard

Been trying to get BLE communication functioning with an ESP32 and an Oculus Quest through a Unity app.

Open 01GOD opened this issue 1 year ago • 13 comments

Firstly, thanks for posting this library!

Been trying to get bi-directional BLE communication functioning with an ESP32 and an Oculus Quest through a Unity app. Tried "Bluetooth LE for iOS, tvOS and Android" and that connected, but then the Unity app running on the quest couldn't find the BLE services.

So now looking at making it appear as a gamepad with BT serial with this library. Bi-directional communication is possible with this?

Thanks in advance for answering soon, if possible!

01GOD avatar Jul 05 '23 09:07 01GOD

Could look at using an idea of https://github.com/lemmingDev/ESP32-BLE-Gamepad/issues/111, but I think it's a hack and more than likely not going to work long run.

I think the correct way to do this is use the BLE feature/output. I was investigating this for Player LEDs and forcefeedback, but your application would need to use the HID directly, unless exposed in a standard way that is supported by host OS. Think like how the CAPSLock LED on keyboard works.

A test example has was made - https://github.com/lemmingDev/ESP32-BLE-Gamepad/issues/43#issuecomment-767186887.

Maybe it's a starting point. Still not use if the Host OS would expose this. I was thinking it might be easier to get support in SDL3 or maybe Linux.

LeeNX avatar Jul 06 '23 08:07 LeeNX

Thanks! I tried doing a custom BLE, but although the Unity app could connect to the ESP32, it couldn't find the BLE services.

May try this or making it be a keyboard. Because those are fully allowed and that likely will continue to be that way. May use the caps lock light as a way to send an on signal to the emulated keyboard.

01GOD avatar Jul 07 '23 02:07 01GOD

Is there or do you have a public copy of the Unity App? I have seen, but never used the following - https://www.hackster.io/chuartdo/ble-haptic-dual-joystick-controller-31c2c2.

I think it's basic serial.

LeeNX avatar Jul 09 '23 08:07 LeeNX

Saw now! Thanks for the recommendation! The Unity app is the example app in the Unity package called "bluetooth-le-for-ios-tvos-and-android". Talked with that software engineer and sent some code to him that should solve that, but the code it would be put into is inside of an android plugin that isn't exposed for editing. So he has to add it if using that, although sadly he said he has been too busy to do so. https://assetstore.unity.com/packages/tools/network/bluetooth-le-for-ios-tvos-and-android-26661

01GOD avatar Jul 10 '23 09:07 01GOD

PS: Did find a page that seemingly has a full Unity BLE solution for ESP32, but couldn't get it to function. Did try though. Maybe missed something small on the page that was necessary. Sadly the sw engineer wasn't easily contactable and there wasn't a github or similar. Main thing seemingly is the Android BLE bridge. So that is a java plugin that bridges Unity to Android BLE. https://nagomi0132.hateblo.jp/entry/2022/01/10/223018

If that japanese plugin would function, then could add the code from the following page to that plugin to supposedly make it function reliably on a Quest. If any here are up for getting that functioning, that would be a GREAT Unity asset to make available to the community. (including if it was low cost commercial asset, as buying a reliable solution for 5 or 10 US DOLLARS to have a reliable solution for BLE on Quest seems tolerable) https://communityforums.atmeta.com/t5/Quest-Development/Bluetooth-scan-and-permissions-BLE-and-the/m-p/970810/highlight/true#M4775

01GOD avatar Jul 10 '23 09:07 01GOD

Not use that the Oculus has BLE support - https://stackoverflow.com/questions/51320721/ble-and-bluetooth-gamepad-options-for-oculus

Looks like only Bluetooth v3, but can't confirm this. I was looking and thinking maybe you don't have admin/root access?

On Android I have used nRF Connect and BLE Scanner to investigate Services and Characteristic. This is how I did basic output/feedback into a test GamePad.

Best of luck

LeeNX avatar Jul 10 '23 10:07 LeeNX

Thanks for explaining that. There definitely doesn't seem to be admin access on the Oculus Quest.

So the issue has been either because of that, or because of the Unity app's Android BLE plugin bridge (although maybe was because I wasn't emulating a gamepad with some specific gamepad ID that I don't know about and thus the permissions didn't allow it). I plan to try this and possibly making an ESP32 emulate a keyboard also though. Thanks again for posting the library!

01GOD avatar Jul 10 '23 11:07 01GOD

Testing with a BLE keyboard or mouse would be a good test.

LeeNX avatar Jul 10 '23 12:07 LeeNX

Yes. I was thinking maybe there is a special UUID or similar that is reserved for BLE gamepads and keyboards and that maybe the Android OS on the Quest allows those, but not other BLE services. (or something such as that)

01GOD avatar Jul 10 '23 14:07 01GOD

I might be wrong about the Oculus. Have you seen https://github.com/lemmingDev/ESP32-BLE-Gamepad/issues/135#issuecomment-1282469490

LeeNX avatar Jul 10 '23 14:07 LeeNX

Ah. Saw now. Maybe it's some industry standard UUID for the services or something?

01GOD avatar Jul 11 '23 12:07 01GOD

Might be something usable here https://github.com/afpineda/Nus-NimBLE-Serial

lemmingDev avatar Feb 24 '24 03:02 lemmingDev

Might be something usable here https://github.com/afpineda/Nus-NimBLE-Serial

Thanks for mentioning that. Saw that now. Don't know how I missed that comment. Excuse the delay.

01GOD avatar Mar 07 '24 13:03 01GOD