Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated use of ALooper_PollAll and double spawn. #139

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Chapter1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down
2 changes: 1 addition & 1 deletion Chapter2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down
2 changes: 1 addition & 1 deletion Chapter3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down
8 changes: 5 additions & 3 deletions Chapter4/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ class OpenXRTutorial {
// Each Action here has two paths, one for each SubAction path.
any_ok |= SuggestBindings("/interaction_profiles/khr/simple_controller", {{m_changeColorAction, CreateXrPath("/user/hand/left/input/select/click")},
{m_grabCubeAction, CreateXrPath("/user/hand/right/input/select/click")},
{m_spawnCubeAction, CreateXrPath("/user/hand/right/input/menu/click")},
{m_palmPoseAction, CreateXrPath("/user/hand/left/input/grip/pose")},
{m_palmPoseAction, CreateXrPath("/user/hand/right/input/grip/pose")},
{m_buzzAction, CreateXrPath("/user/hand/left/output/haptic")},
Expand Down Expand Up @@ -893,8 +894,9 @@ class OpenXRTutorial {
thisBlock.color = color;
}
} else {
// not near a block? We can spawn one.
if (m_spawnCubeState.isActive == XR_TRUE && m_spawnCubeState.currentState == XR_FALSE && m_spawnCubeState.changedSinceLastSync == XR_TRUE) {
// right hand not near a block?
// i = 1 means sub action path /user/hand/right
if (i == 1 && m_spawnCubeState.isActive == XR_TRUE && m_spawnCubeState.currentState == XR_FALSE && m_spawnCubeState.changedSinceLastSync == XR_TRUE) {
XrQuaternionf q = {0.0f, 0.0f, 0.0f, 1.0f};
XrVector3f color = {pseudorandom_distribution(pseudo_random_generator), pseudorandom_distribution(pseudo_random_generator), pseudorandom_distribution(pseudo_random_generator)};
m_blocks.push_back({{q, FixPosition(m_handPose[i].position)}, {0.095f, 0.095f, 0.095f}, color});
Expand Down Expand Up @@ -1329,7 +1331,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down
2 changes: 1 addition & 1 deletion Chapter5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down
2 changes: 1 addition & 1 deletion Chapter6_1_Multiview/Chapter6/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ class OpenXRTutorial {
int events = 0;
// The timeout depends on whether the application is active.
const int timeoutMilliseconds = (!androidAppState.resumed && !m_sessionRunning && androidApp->destroyRequested == 0) ? -1 : 0;
if (ALooper_pollAll(timeoutMilliseconds, nullptr, &events, (void **)&source) >= 0) {
if (ALooper_pollOnce(timeoutMilliseconds, nullptr, &events, (void**)&source) >= 0) {
if (source != nullptr) {
source->process(androidApp, source);
}
Expand Down