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

Restore back action using B/Y buttons in non-WebXR mode #1276

Merged
merged 1 commit into from
Feb 28, 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
15 changes: 13 additions & 2 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,25 @@ BrowserWorld::State::SimulateBack() {
VRBrowser::HandleBack();
}

static bool
wasGoBackButtonClicked(const Controller& controller, bool isPresenting) {
auto WasButtonPressed = [](const Controller& controller, ControllerDelegate::Button button) {
return !(controller.lastButtonState & button) && (controller.buttonState & button);
};

return (WasButtonPressed(controller, ControllerDelegate::BUTTON_APP) ||
(!isPresenting && (WasButtonPressed(controller, ControllerDelegate::BUTTON_B) ||
WasButtonPressed(controller, ControllerDelegate::BUTTON_Y))));
};

void
BrowserWorld::State::CheckBackButton() {
for (Controller& controller: controllers->GetControllers()) {
if (!controller.enabled || (controller.index < 0)) {
continue;
}

if ((!(controller.lastButtonState & ControllerDelegate::BUTTON_APP) && (controller.buttonState & ControllerDelegate::BUTTON_APP))) {
if (wasGoBackButtonClicked(controller, externalVR->IsPresenting())) {
SimulateBack();
webXRInterstialState = WebXRInterstialState::HIDDEN;
} else if (webXRInterstialState == WebXRInterstialState::ALLOW_DISMISS
Expand Down Expand Up @@ -423,7 +434,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
controller.pointer->Load(device);
}

if ((!(controller.lastButtonState & ControllerDelegate::BUTTON_APP) && (controller.buttonState & ControllerDelegate::BUTTON_APP))) {
if (wasGoBackButtonClicked(controller, externalVR->IsPresenting())) {
if (controller.handActionEnabled && !controller.leftHanded) {
VRBrowser::HandleAppExit();
} else {
Expand Down
4 changes: 2 additions & 2 deletions docs/metrics.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- AUTOGENERATED BY glean_parser v11.0.1. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v11.1.0. DO NOT EDIT. -->

# Metrics

Expand All @@ -11,5 +11,5 @@ This means you might have to go searching through the dependency tree to get a f

Data categories are [defined here](https://wiki.mozilla.org/Firefox/Data_Collection).

<!-- AUTOGENERATED BY glean_parser v11.0.1. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v11.1.0. DO NOT EDIT. -->