mirror of
https://github.com/simplysanatori/KartFrame.git
synced 2026-10-18 03:01:37 +02:00
24 lines
770 B
C++
24 lines
770 B
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#pragma once
|
|
|
|
namespace mkw::vr {
|
|
// Model loading is optional. Only borrow an existing SteamVR client; never
|
|
// initialize a second VR client or repeatedly query an unavailable one.
|
|
class ControllerModelConnection {
|
|
bool attempted_ = false;
|
|
bool connected_ = false;
|
|
public:
|
|
template<class QueryExisting>
|
|
bool Connect(bool steamvr, QueryExisting query) {
|
|
if (!steamvr) return false;
|
|
if (!attempted_) {
|
|
attempted_ = true;
|
|
// SDL/the OpenXR runtime may already own this process's client.
|
|
// Reinitializing it can invalidate its interfaces and input state.
|
|
connected_ = query();
|
|
}
|
|
return connected_;
|
|
}
|
|
};
|
|
} // namespace mkw::vr
|