Skip to content

Commit

Permalink
[OpenXR] Refactor the controllers ready callback
Browse files Browse the repository at this point in the history
We call it from a couple of places so it does make sense to
refactor it in a helper method.
  • Loading branch information
svillar committed May 23, 2024
1 parent 6bd2ac9 commit 630ff1c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/src/openxr/cpp/DeviceDelegateOpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,20 @@ struct DeviceDelegateOpenXR::State {
// TODO: Check if activity globarRef needs to be released
}

void MaybeNotifyControllersReady() {
ASSERT(input);
if (!controllersReadyCallback || !input->AreControllersReady())
return;
controllersReadyCallback();
controllersReadyCallback = nullptr;
}

void UpdateInteractionProfile(const char* emulateProfile = nullptr) {
if (!input || !controller)
return;

input->UpdateInteractionProfile(*controller, emulateProfile);
if (controllersReadyCallback && input->AreControllersReady()) {
controllersReadyCallback();
controllersReadyCallback = nullptr;
}
MaybeNotifyControllersReady();
}

bool IsPassthroughLayerReady() {
Expand Down Expand Up @@ -1570,10 +1575,7 @@ DeviceDelegateOpenXR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {

m.input = OpenXRInput::Create(m.instance, m.session, m.systemProperties, *m.controller.get());
ProcessEvents();
if (m.controllersReadyCallback && m.input && m.input->AreControllersReady()) {
m.controllersReadyCallback();
m.controllersReadyCallback = nullptr;
}
m.MaybeNotifyControllersReady();
m.input->SetKeyboardTrackingEnabled(m.keyboardTrackingSupported && m.renderModelLoadingSupported);

vrb::RenderContextPtr context = m.context.lock();
Expand Down

0 comments on commit 630ff1c

Please sign in to comment.