mirror of
https://github.com/overte-org/overte.git
synced 2025-07-26 00:40:20 +02:00
Merge pull request #10715 from zfox23/spectatorCamera_buttonMapping
Spectator Camera controller button mapping + QML Language Fix
This commit is contained in:
commit
54bf0c64a7
2 changed files with 84 additions and 7 deletions
|
@ -253,7 +253,7 @@ Rectangle {
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
anchors.top: monitorShowsSwitch.bottom;
|
anchors.top: monitorShowsSwitch.bottom;
|
||||||
anchors.topMargin: 25;
|
anchors.topMargin: 25;
|
||||||
text: "Pressing Vive's Left Thumbpad Switches Monitor View";
|
text: "";
|
||||||
boxSize: 24;
|
boxSize: 24;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
sendToScript({method: 'changeSwitchViewFromControllerPreference', params: checked});
|
sendToScript({method: 'changeSwitchViewFromControllerPreference', params: checked});
|
||||||
|
@ -288,6 +288,19 @@ Rectangle {
|
||||||
case 'updateMonitorShowsSwitch':
|
case 'updateMonitorShowsSwitch':
|
||||||
monitorShowsSwitch.checked = message.params;
|
monitorShowsSwitch.checked = message.params;
|
||||||
break;
|
break;
|
||||||
|
case 'updateControllerMappingCheckbox':
|
||||||
|
switchViewFromControllerCheckBox.checked = message.setting;
|
||||||
|
switchViewFromControllerCheckBox.enabled = true;
|
||||||
|
if (message.controller === "OculusTouch") {
|
||||||
|
switchViewFromControllerCheckBox.text = "Clicking Left Touch's Thumbstick Switches Monitor View";
|
||||||
|
} else if (message.controller === "Vive") {
|
||||||
|
switchViewFromControllerCheckBox.text = "Clicking Left Thumb Pad Switches Monitor View";
|
||||||
|
} else {
|
||||||
|
switchViewFromControllerCheckBox.text = "Pressing Ctrl+0 Switches Monitor View";
|
||||||
|
switchViewFromControllerCheckBox.checked = true;
|
||||||
|
switchViewFromControllerCheckBox.enabled = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Unrecognized message from spectatorCamera.js:', JSON.stringify(message));
|
console.log('Unrecognized message from spectatorCamera.js:', JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
// FUNCTION VAR DECLARATIONS
|
// FUNCTION VAR DECLARATIONS
|
||||||
//
|
//
|
||||||
var sendToQml, addOrRemoveButton, onTabletScreenChanged, fromQml,
|
var sendToQml, addOrRemoveButton, onTabletScreenChanged, fromQml,
|
||||||
onTabletButtonClicked, wireEventBridge, startup, shutdown;
|
onTabletButtonClicked, wireEventBridge, startup, shutdown, registerButtonMappings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function Name: inFrontOf()
|
// Function Name: inFrontOf()
|
||||||
|
@ -247,6 +245,7 @@
|
||||||
HMD.displayModeChanged.connect(onHMDChanged);
|
HMD.displayModeChanged.connect(onHMDChanged);
|
||||||
viewFinderOverlay = false;
|
viewFinderOverlay = false;
|
||||||
camera = false;
|
camera = false;
|
||||||
|
registerButtonMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -301,6 +300,70 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SWITCH_VIEW_FROM_CONTROLLER_DEFAULT = false;
|
||||||
|
var switchViewFromController = !!Settings.getValue('spectatorCamera/switchViewFromController', SWITCH_VIEW_FROM_CONTROLLER_DEFAULT);
|
||||||
|
function setControllerMappingStatus(status) {
|
||||||
|
if (status) {
|
||||||
|
controllerMapping.enable();
|
||||||
|
} else {
|
||||||
|
controllerMapping.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setSwitchViewFromController(setting) {
|
||||||
|
if (setting === switchViewFromController) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switchViewFromController = setting;
|
||||||
|
setControllerMappingStatus(switchViewFromController);
|
||||||
|
Settings.setValue('spectatorCamera/switchViewFromController', setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Function Name: registerButtonMappings()
|
||||||
|
//
|
||||||
|
// Relevant Variables:
|
||||||
|
// controllerMappingName: The name of the controller mapping
|
||||||
|
// controllerMapping: The controller mapping itself
|
||||||
|
// controllerType: "OculusTouch", "Vive", "Other"
|
||||||
|
//
|
||||||
|
// Arguments:
|
||||||
|
// None
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
// Updates controller button mappings for Spectator Camera.
|
||||||
|
//
|
||||||
|
var controllerMappingName;
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
controllerMappingName = 'Hifi-SpectatorCamera-Mapping';
|
||||||
|
controllerMapping = Controller.newMapping(controllerMappingName);
|
||||||
|
if (controllerType === "OculusTouch") {
|
||||||
|
controllerMapping.from(Controller.Standard.LS).to(function (value) {
|
||||||
|
if (value === 1.0) {
|
||||||
|
setMonitorShowsCameraViewAndSendToQml(!monitorShowsCameraView);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
} else if (controllerType === "Vive") {
|
||||||
|
controllerMapping.from(Controller.Standard.LeftPrimaryThumb).to(function (value) {
|
||||||
|
if (value === 1.0) {
|
||||||
|
setMonitorShowsCameraViewAndSendToQml(!monitorShowsCameraView);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setControllerMappingStatus(switchViewFromController);
|
||||||
|
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function Name: onTabletButtonClicked()
|
// Function Name: onTabletButtonClicked()
|
||||||
//
|
//
|
||||||
|
@ -326,8 +389,8 @@
|
||||||
tablet.loadQMLSource("../SpectatorCamera.qml");
|
tablet.loadQMLSource("../SpectatorCamera.qml");
|
||||||
onSpectatorCameraScreen = true;
|
onSpectatorCameraScreen = true;
|
||||||
sendToQml({ method: 'updateSpectatorCameraCheckbox', params: !!camera });
|
sendToQml({ method: 'updateSpectatorCameraCheckbox', params: !!camera });
|
||||||
sendToQml({ method: 'updateMonitorShowsSwitch', params: !!Settings.getValue('spectatorCamera/monitorShowsCameraView', false) });
|
sendToQml({ method: 'updateMonitorShowsSwitch', params: monitorShowsCameraView });
|
||||||
setMonitorShowsCameraViewAndSendToQml(monitorShowsCameraView);
|
sendToQml({ method: 'updateControllerMappingCheckbox', setting: switchViewFromController, controller: controllerType });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +459,7 @@
|
||||||
setMonitorShowsCameraView(message.params);
|
setMonitorShowsCameraView(message.params);
|
||||||
break;
|
break;
|
||||||
case 'changeSwitchViewFromControllerPreference':
|
case 'changeSwitchViewFromControllerPreference':
|
||||||
print('FIXME: Preference is now: ' + message.params);
|
setSwitchViewFromController(message.params);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unrecognized message from SpectatorCamera.qml:', JSON.stringify(message));
|
print('Unrecognized message from SpectatorCamera.qml:', JSON.stringify(message));
|
||||||
|
@ -442,6 +505,7 @@
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||||
HMD.displayModeChanged.disconnect(onHMDChanged);
|
HMD.displayModeChanged.disconnect(onHMDChanged);
|
||||||
Controller.keyPressEvent.disconnect(keyPressEvent);
|
Controller.keyPressEvent.disconnect(keyPressEvent);
|
||||||
|
controllerMapping.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue