JaydenMaalouf / JoystickPlugin

Native Input Joystick Plugin for Unreal Engine 4/5
MIT License
30 stars 6 forks source link

[Request] Add Android support and maintain updates in UE4. #52

Open Jamp3D opened 10 months ago

Jamp3D commented 10 months ago

I develop for Oculus Quest, gamepad support was removed with the OpenXR API and the old API was deprecated. Due to hardware limitations, there is a considerable loss of performance in UE5, preventing project migration at the current time.

Thanks

SDL2 Android compiled libraries could be found here: https://github.com/AlexanderAgd/SDL2-Android/releases/tag/v0.1

JaydenMaalouf commented 10 months ago

I have a feeling this will take some time for me to implement, simply because I've never had to deal with Android distributions

The SDL binaries included in my plugin are built from the Unreal Engine version of SDL2, so I will need to work out how to do that

Have you had any luck building the plugin for Android from source?

Jamp3D commented 10 months ago

Unfortunately I don't have advanced knowledge, I'm a mere BP game developer.

These links contain tutorials that teach how to quickly create plugins for Android, I hope it helps: https://isaratech.com/ue4-making-a-android-plugin-in-10-minutes/ https://hujinhan.medium.com/build-an-android-plugin-for-unreal-engine-31e485784770

It seems that when building a project in HTML5 (and perhaps in Linux) with SDL2 enabled, Unreal generates an SDL2 library in .so format, I can't confirm if it is compatible with Android. I may be talking nonsense, forgive my lack of knowledge.

demonixis commented 9 months ago

I'm also looking for that. It's easy to generate the library for Android. The hard part is that SDL2 on Android is initialized using its own Activity, which is not compatible with Unreal.. But... It's maybe possible to use the Unreal activity, I'll have to Digg deeper.

demonixis commented 8 months ago

I develop for Oculus Quest, gamepad support was removed with the OpenXR API and the old API was deprecated. Due to hardware limitations, there is a considerable loss of performance in UE5, preventing project migration at the current time.

Thanks

SDL2 Android compiled libraries could be found here: https://github.com/AlexanderAgd/SDL2-Android/releases/tag/v0.1

Can you elaborate about the gamepad removal? I'm in talk with some dev about that

Jamp3D commented 8 months ago

It seems that the gamepad detection itself is blocked by the OpenXR plugin. There are two nodes in Unreal that return information about the gamepad on Android: Node "Get Gamepad Controller Name" always returns "none" when in OpenXR, but it correctly returns the model of the gamepad connected using the Legacy OVRPlugin. Node "Is Controller Assigned to Gamepad" always returns "false" when in OpenXR, but correctly returns "true" if a gamepad is connected using the Legacy OVRPlugin.

demonixis commented 8 months ago

Hum, have you tried without the MetaXR plugin and only the OpenXR one? Could be interesting to see if it's Meta or OpenXR itself

demonixis commented 8 months ago

Hum, have you tried without the MetaXR plugin and only the OpenXR one? Could be interesting to see if it's Meta or OpenXR itself

Jamp3D commented 8 months ago

The native OpenXR Plugin has the same problem.

demonixis commented 8 months ago

Can you confirm that if you disable the plugin, it works? It's an interesting result

Jamp3D commented 8 months ago

UE5: Quest VR APP(OVRPlugin OpenXR).................. No Input .......... No Vibration Quest VR APP(Native OpenXR)........................... No Input .......... No Vibration Quest VR APP(Legacy OVRPlugin).............................(API not available)............ Quest 2D / Smartphone APP................................ Input OK .......... Vibration OK .......... (OpenXR Plugin Disabled)

UE4: Quest VR APP(OVRPlugin OpenXR) ................ No Input ........... No Vibration Quest VR APP(Native OpenXR).......................... No Input ........... No Vibration Quest VR APP(Legacy OVRPlugin) ................... Input OK ........... No Vibration ........ (OpenXR Plugin Disabled) Quest 2D / Smartphone APP............................... Input OK ........... No Vibration ........ (OpenXR Plugin Disabled)

demonixis commented 8 months ago

I saw your other post on the UE forum, i'm following the issue to see if we can move forward on that issue. I've opened an issue on the MetaXR repo too.

https://github.com/Oculus-VR/UnrealEngine/issues/360

Jamp3D commented 8 months ago

I had also opened an issue when I was still trying to understand the problem, but in short the answer was: "we don't feel there's a big benefit here to support it at this moment."

https://github.com/Oculus-VR/UnrealEngine/issues/318

Thank you for your help!

demonixis commented 8 months ago

The good news is that it's related to OpenXR and not MetaXR. I'll see of I can join some Epic folks to talk about that.

Jamp3D commented 8 months ago

I don't know if it's useful, but the OpenXR Plugin is constantly checking if the HMD is enabled. If in the app we execute the console command "bEnableHMD 0" the gamepad input starts to work (of course the screen goes black) and if we return to "bEnableHMD 1" the input is blocked again.

Jamp3D commented 8 months ago

In fact when you re-enable* the HMD, OpenXR starts recognizing the gamepad partially, the nodes "Get Gamepad Controller Name" now correctly returns the model of the gamepad and the node "Is Controller Assigned to Gamepad" now returns "true", although the app stops receiving inputs, the vibration (FFB) continues to work normally (Which is a workaround for one of the problems).

*When HMD is disabled you need to press any key on the gamepad for it to be detected.

JaydenMaalouf commented 7 months ago

What is the status of this issue? Was anyone able to compile the plugin for Android?

I may be able to get the SDL2 compiled for Android via the Engine source (which is what I do for Windows anyway)

Jamp3D commented 7 months ago

Hi @JaydenMaalouf,

the creator of the "SimpleController" plugin managed to compile an Android version with basic features. I can't share the test version that was sent to me, but you can contact him via email: david.marketplace-support@virtualbird.de

However, even with SDL2 working on Android, the OpenXR plugin continues to block all input, you can follow the discussion about this problem here: https://communityforums.atmeta.com/t5/Unreal-VR-Development/Gamepads-not-detected-when-OpenXR-is-enabled/td-p/1117823