Merge pull request #10935 from zfox23/spectatorCamera_tabletButtonFix

Ensure tablet button shows up; protections for controller mapping; Ensure instructions show
This commit is contained in:
Zach Fox 2017-07-10 15:52:21 -07:00 committed by GitHub
commit 5ce409e2e2
2 changed files with 27 additions and 12 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 {
@ -327,10 +330,15 @@
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 {
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
return; // Neither Vive nor Touch detected
}
}
controllerMappingName = 'Hifi-SpectatorCamera-Mapping';
@ -376,7 +384,11 @@
tablet.loadQMLSource(SPECTATOR_CAMERA_QML_SOURCE);
sendToQml({ method: 'updateSpectatorCameraCheckbox', params: !!camera });
sendToQml({ method: 'updateMonitorShowsSwitch', params: monitorShowsCameraView });
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
if (!controllerMapping) {
registerButtonMappings();
} else {
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
}
Menu.setIsOptionChecked("Disable Preview", false);
Menu.setIsOptionChecked("Mono Preview", true);
}
@ -432,8 +444,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 +473,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.