Ensure tablet button shows up; protections for controller mapping

This commit is contained in:
Zach Fox 2017-07-10 15:16:16 -07:00
parent 78d12f27ed
commit 4a74522884
2 changed files with 25 additions and 11 deletions

View file

@ -227,11 +227,9 @@ Rectangle {
height: 250;
color: spectatorCameraPreview.visible ? "transparent" : "black";
AnimatedImage {
source: "../../images/static.gif"
visible: !spectatorCameraPreview.visible;
visible: !cameraToggleCheckBox.checked;
anchors.fill: parent;
opacity: 0.15;
}
@ -242,7 +240,7 @@ Rectangle {
text: "Turn on Spectator Camera for a preview\nof what your monitor shows.";
size: 16;
color: hifi.colors.lightGrayText;
visible: !spectatorCameraPreview.visible;
visible: !cameraToggleCheckBox.checked;
anchors.fill: parent;
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;

View file

@ -149,7 +149,7 @@
button.clicked.connect(onTabletButtonClicked);
}
} else if (button) {
if (!showSpectatorInDesktop || isShuttingDown) {
if ((!isHMDMode && !showSpectatorInDesktop) || isShuttingDown) {
button.clicked.disconnect(onTabletButtonClicked);
tablet.removeButton(button);
button = false;
@ -298,6 +298,9 @@
const SWITCH_VIEW_FROM_CONTROLLER_DEFAULT = false;
var switchViewFromController = !!Settings.getValue('spectatorCamera/switchViewFromController', SWITCH_VIEW_FROM_CONTROLLER_DEFAULT);
function setControllerMappingStatus(status) {
if (!controllerMapping) {
return;
}
if (status) {
controllerMapping.enable();
} else {
@ -326,11 +329,16 @@
var controllerMapping;
var controllerType = "Other";
function registerButtonMappings() {
var VRDevices = Controller.getDeviceNames().toString();
if (VRDevices.includes("Vive")) {
controllerType = "Vive";
} else if (VRDevices.includes("OculusTouch")) {
controllerType = "OculusTouch";
if (VRDevices) {
if (VRDevices.includes("Vive")) {
controllerType = "Vive";
} else if (VRDevices.includes("OculusTouch")) {
controllerType = "OculusTouch";
} else {
return; // Neither Vive nor Touch detected
}
}
controllerMappingName = 'Hifi-SpectatorCamera-Mapping';
@ -379,6 +387,9 @@
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
Menu.setIsOptionChecked("Disable Preview", false);
Menu.setIsOptionChecked("Mono Preview", true);
if (!controllerMapping) {
registerButtonMappings();
}
}
}
@ -432,8 +443,11 @@
// Function Name: onHMDChanged()
//
// Description:
// -Called from C++ when HMD mode is changed. The argument "isHMDMode" should be true if HMD is on; false otherwise.
// -Called from C++ when HMD mode is changed. The argument "isHMDMode" is true if HMD is on; false otherwise.
function onHMDChanged(isHMDMode) {
if (!controllerMapping) {
registerButtonMappings();
}
setDisplay(monitorShowsCameraView);
addOrRemoveButton(false, isHMDMode);
if (!isHMDMode && !showSpectatorInDesktop) {
@ -458,7 +472,9 @@
}
HMD.displayModeChanged.disconnect(onHMDChanged);
Controller.keyPressEvent.disconnect(keyPressEvent);
controllerMapping.disable();
if (controllerMapping) {
controllerMapping.disable();
}
}
// These functions will be called when the script is loaded.