unity-game-enginebluetoothandroid-bluetoothgoogle-vr

Google Daydream smartphone as controller (unity-bluetooth)


Is it possible to use a smartphone as a controller for Google Daydream standalone device?

Our plan is to use Android Bluetooth socket to open a bluetooth connection between the smartphone and Daydream device. Then we just transfer bytes in our own format and interpret that on the other side. This will all be implemented in Unity.

So the real questions are: - Can we create Unity Android plugins that run in Daydream? - Do we have enough permissions to access Bluetooth APIs and use it in a custom way?

(we are also evaluating OculusGo but we have the same unknowns)


Solution

  • Yes, you can request bluetooth permissions from Unity. You might also want to use a plugin for bluetooth, unless you want to handle quirky slightly java calls. OculusGo and Daydream are internally still Android devices, you just cannot take them out and make calls.

    Surprisingly, for bluetooth to work you also need to also request location permissions in AndroidManifest.xml (that one took me a while)

      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
      <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
      <uses-permission android:name="android.permission.BLUETOOTH"/>
    

    I am not sure if BLUETOOTH_ADMIN is really needed or not. I don't have much experience with OculusGo, but I imagine it will be pretty similar to GearVR, on which the stack is heavily guarded, there's no way to pair with controller bypassing their API which is pretty locked down (you need to generate OCUSIG for your device or else the app will crash on launch). Not sure how much this applies to Go

    If you want to bridge two android devices, its far far easier to use local network as a transport instead of bluetooth - sending UDP packets worked best for me, the only condition is that devices must share a local network but opening a hotspot from one should do the trick