Forum Discussion
demonixis
2 years agoPartner
Gamepads not detected when OpenXR is enabled
Hey there,
I'm working on a game that requires a gamepad to improve the gameplay. I can confirm that my two bluetooth gamepad are working with compatibles apps, like Xbox Streaming Beta. When OpenXR is enabled, gamepad are not detected and don't send inputs. It seems to be related to the OpenXR implementation into Unreal. If you disable the OpenXR plugin (or use the old OVRPlugin, which is no more supported), it works.
Any idea to fix it please? I can do changes in the source code, but after hours of searching, I still have no clues.
Best
26 Replies
Replies have been turned off for this discussion
- peppenordholmExplorer
We have a similar problem. As soon as the MetaXR or OpenXR plugin is enabled, game pad stops working.
Did some debugging and saw that the event is received in the android main event loop but not being propagated to the game event loop since it is being processed in event predispatching.
Our workaround for the problem is to skip preDispatchEvent for game pad A button events.
And in a plugin call AddOculusGamePadSupport
#include <android_native_app_glue.h> extern struct android_app* GNativeAndroidApp; ​ static void process_input( struct android_app* app, struct android_poll_source* source) { AInputEvent* event = NULL; while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { bool skip_predispatch = AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY && AKeyEvent_getKeyCode(event) == AKEYCODE_BUTTON_A; ​ if (!skip_predispatch && AInputQueue_preDispatchEvent(app->inputQueue, event)) { continue; } ​ int32_t handled = 0; if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); AInputQueue_finishEvent(app->inputQueue, event, handled); } } ​ static void AddOculusGamePadSupport() { GNativeAndroidApp->inputPollSource.process = &process_input; }PS! The code will only work for button a events.
- demonixisPartner
Thank you for that code! Finally some lights 🙂
If I want to support all buttons/axis, I've to make a big condition for skip_redispatch right?
- peppenordholmExplorer
Yeah.. It think that will do it.
You can try to call AInputEvent_getSource and skip_predispatch for all AINPUT_SOURCE_GAMEPAD events
https://developer.android.com/ndk/reference/group/input
- demonixisPartner
I'll give it a try asap, tbh if it fixes the gamepad issue, it's fine and acceptable. However, I'll open an issue on Unreal because it's not a desired behaviour.
- peppenordholmExplorer
https://github.com/Oculus-VR/UnrealEngine/issues/318 More information. You need to have a registered github account and access to the unreal source code to read the issue
- peppenordholmExplorer
Awesome!
Please post the link to the issue here so that we can follow the status of it.
- JampDevExplorer
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, but the 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).
- JayLu2000Explorer
oh.. I didn't know that it seems like MetaXRPlugin broke gamepad event... that's something new.
let me spread the word to the team to see what they think.
thanks!- demonixisPartner
Hey
The fault is on the VR integration of Unreal. We’ve the same issue with de default OpenXR plugin without MetaXR. It worked with the legacy OVR plugin because of the integrated game pad API. I’m speaking some folks at Epic to see howto fix that.
But it could be great to have some help from Meta too.
- JayLu2000Explorer
"We’ve the same issue with de default OpenXR plugin without MetaXR"? oh.. that's interesting. 🙂
Not sure which Epic engineer you talked to? I could talk to him/her directly as well.
- demonixisPartner
Hello,
I just talked to a technical account manager of this issue and he told me that I'll talk about that to the team behind that. In the mean time, I've opened an issue "Case # 00706549: Gamepad are not detected on Android when VR is enabled".
I can confirm that if VR is disabled, gamepad input are working well. I've an hybrid game (flat/VR) that works with gamepad inputs on Android, but only works with controllers input on Meta Quest 3. I started to look at the code, and it' seems it's not blocked in the Java activity, but more deeply in the code, not sure where.
- JayLu2000Explorer
cool, I will sync w/ Epic on this next week.
thanks
- JayLu2000Explorer
fyi: I just synced w/ Epic side engineers quickly, and they tried gamepad in editor w/ latest main branch (Epic's main branch), it seemed work.
Any of you tried editor's vrpreview? or only mobile side? Also, VRTemplate has gamepad setup as well, did any of you try that to see if it works? We use VRTemplate as a very important test for our release.
I need to work w/ our QA to repro this issue then, but the more information I could collect here, the easier from our side, 🙂 thanks!
- JampDevExplorer
Hi JayLu2000, I think you're probably fed up with me by now, but I think it's important to give you an overview of things at the moment:
The problem is strictly related to the OpenXR Plugin on the Quest platform (Android) while on the PC everything works normally, including the VR preview.
A simple test can be done to determine the problem:
Package four versions of the same App with gamepad support:
Meta OpenXR Api, Native OpenXR Api, Legacy OVR Api and Standard 2D App with OpenXR and MetaXR disabled.(UE 4(v49) / Quest 2)
Meta OpenXR: No Input / No FFB*
Native OpenXR: No Input / No FFB*
Legacy OVR: Input OK / No FFB*
2D App: Input OK / No FFB*(UE 5(v60) / Quest 2)
Meta OpenXR: No Input / No FFB
Native OpenXR: No Input / No FFB
Legacy OVR: Api not available
2D App: Input OK / FFB OK*(FFB support has been fixed in UE 5 and the controller now vibrates correctly (When not blocked by the OpenXR Plugin).)
Some discoveries:
In Quest, when in an OpenXR App, if you use the console command "vr.bEnableHMD 0", the gamepad starts to work correctly (of course the screen goes black), also the FFB (UE5 App), if we re-enable the hmd "vr.bEnableHMD 1" the gamepad stops working but strangely the FFB continues to work, and 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".
peppenordholm: "...the event is received in the android main event loop but not being propagated to the game event loop since it is being processed in event predispatching.
Our workaround for the problem is to skip preDispatchEvent for gamepad A button events..."demonixis:"I started to look at the code, and it' seems it's not blocked in the Java activity, but more deeply in the code, not sure where." (Maybe at the level of the OpenXR Plugin DLLs?)
ps: FFB only works on wired Xinput gamepads, for some reason Bluetooth gamepads are not supported.
- demonixisPartner
Hey,
Yes it works in the editor, it happens only on native builds (Android). I can confirm that if VR is disabled on Android, the gamepad input works. If you enable VR (like what we do for Oculus development), you get no input from gamepad. Very easy to reproduce. Thanks for the time you spend on that issue, our game DVR Simulator requires gamepad, and I can't publish the big update without that support.
Best,
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 2 years ago
- 3 years ago