Fix for SDL stalling the pacing thread

This commit is contained in:
iChris4 committed 2026-09-23 15:28:38 +02:00
1 parent 1d66ae87bf
commit b2353e1410
7 files changed
+141 -25

No files matched your search

+8 -2
View File
@@ -76,8 +76,10 @@ struct OpenXRPointerScreen {
// Lifetime: Create after the session exists (attaches the action set, which
// OpenXR permits once per session), Sync once per xrWaitFrame, Idle while the
// session is not running, Destroy before the session is destroyed. All of them
// run on the XR pacing thread; SDL's virtual joystick setters and the Wii
// Remote bridge are internally locked, so the game thread may read concurrently.
// run on the XR pacing thread. The Wii Remote bridge is internally locked, so
// the game thread may read it concurrently, and the virtual gamepad is only
// published here: OpenXRApplyVirtualGamepad() performs the SDL writes on the
// game thread, keeping SDL's joystick lock off this thread entirely.
class OpenXRInput final {
public:
explicit OpenXRInput(OpenXRLogCallback logger = {});
@@ -185,6 +187,10 @@ private:
std::string m_last_error;
};
// Game thread: writes the gamepad the pacing thread last published, if any.
// Does nothing when no OpenXR controllers are attached.
void OpenXRApplyVirtualGamepad() noexcept;
} // namespace mkw::vr
#endif // defined(MKW_ENABLE_OPENXR)
+7
View File
@@ -34,6 +34,13 @@ void OpenXRShutdownBeforeAurora() noexcept;
void OpenXRServiceProducerFrameBoundary() noexcept;
bool OpenXRIsRunning() noexcept;
// Writes the controllers the pacing thread last published to the virtual
// gamepad. Call it from the thread that polls controllers, wherever the game
// is about to read them: the pacing thread deliberately leaves SDL alone, since
// SDL's joystick lock is held for the length of a device enumeration and an
// OpenXR frame may not wait that long. Cheap and safe to call when VR is off.
void OpenXRApplyControllerState() noexcept;
std::string OpenXRLastError();
// Recenters on where the player is sitting now: it moves the immersive race