Get handle to an already running OpenXR instance and session

So I would like to use the input and haptics system to get controller input from my own diy controller (a raspberry pi pico) into any application that uses OpenXR. So I could for example simulate an Oculus Touch Controller with an interaction profile /interaction_profiles/oculus/touch_controller. The problem I am facing is that I don’t know how to get a handle to an OpenXR instance and session already created by an app using OpenXR. So how would I get those into my own c++ app?

The best way would likely be to make an OpenXR API layer. The layers are launched by the loader when the application starts, and stay alive for as long as the application instance. If you need the driver to keep running when no OpenXR applications are running, you would need to have the driver and layer as separate processes with some inter-process communication.

There is a handy C++ template for API layers available:

1 Like