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

View file

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