Skip to content

Commit

Permalink
Disable headlock when in VR videos
Browse files Browse the repository at this point in the history
VR videos are meant for users to be immersed in the whole space around them. Because headlock locks users in the front of them, it needs to be disabled in VR videos. If users enabled headlock before entering VR videos, we disable it when VR videos show and reenable it when they are exited.

Fixes #1698
  • Loading branch information
haanhvu committed Feb 1, 2025
1 parent 1e871dd commit 783f4f8
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class NavigationBarWidget extends UIWidget implements WSession.Navigation
private static final int POPUP_NOTIFICATION_ID = 3;
private static final int WEB_APP_ADDED_NOTIFICATION_ID = 4;

private boolean shouldRestoreHeadLockOnVRVideoExit;

public interface NavigationListener {
void onBack();
void onForward();
Expand Down Expand Up @@ -681,6 +683,7 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull
}

if (mAutoSelectedProjection != VIDEO_PROJECTION_NONE && autoEnter.get()) {
disableHeadlockForVRVideo();
mViewModel.setAutoEnteredVRVideo(true);
postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300);
} else {
Expand Down Expand Up @@ -755,11 +758,13 @@ private void enterFullScreenMode() {
exitVRVideo();
mAttachedWindow.reCenterFrontWindow();
} else {
disableHeadlockForVRVideo();
// Reproject while reproducing VRVideo
mWidgetManager.showVRVideo(mAttachedWindow.getHandle(), projection);
}
closeFloatingMenus();
} else {
disableHeadlockForVRVideo();
enterVRVideo(projection);
}
});
Expand All @@ -773,6 +778,14 @@ private void enterFullScreenMode() {
mWidgetManager.pushWorldBrightness(mBrightnessWidget, mBrightnessWidget.getSelectedBrightness());
}

private void disableHeadlockForVRVideo() {
SettingsStore settingsStore = SettingsStore.getInstance(getContext());
if (settingsStore.isHeadLockEnabled()) {
settingsStore.setHeadLockEnabled(false);
shouldRestoreHeadLockOnVRVideoExit = true;
}
}

private void exitFullScreenMode() {
mWidgetPlacement = mBeforeFullscreenPlacement;
updateWidget();
Expand Down Expand Up @@ -996,6 +1009,10 @@ private void exitVRVideo() {
mWidgetManager.setCylinderDensityForce(mSavedCylinderDensity);
// Reposition UI in front of the user when exiting a VR video.
mWidgetManager.recenterUIYaw(WidgetManagerDelegate.YAW_TARGET_ALL);

if (shouldRestoreHeadLockOnVRVideoExit) {
SettingsStore.getInstance(getContext()).setHeadLockEnabled(true);
}
}

private void setResizePreset(float aMultiplier) {
Expand Down

0 comments on commit 783f4f8

Please sign in to comment.