mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 02:17:11 +02:00
Added check for if user is in VR and made temporary mouse look disable persist over opening tablet. It will stay disabled until re-enabled manually, or will self reset after cycling away state or taking off VR headset.
This commit is contained in:
parent
a824fe01e0
commit
5d7c9c1cbb
1 changed files with 94 additions and 48 deletions
|
@ -4,45 +4,61 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
||||||
*/
|
*/
|
||||||
(function() { // BEGIN LOCAL_SCOPE
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
var oldMode;
|
|
||||||
|
|
||||||
var tabletUp;
|
|
||||||
|
|
||||||
var away;
|
var away;
|
||||||
|
|
||||||
|
var hmd;
|
||||||
|
|
||||||
var mouseLookEnabled = false;
|
var mouseLookEnabled = false;
|
||||||
|
|
||||||
|
var oldMode;
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
|
|
||||||
|
var tabletUp;
|
||||||
|
|
||||||
|
var tempOff = false;
|
||||||
|
|
||||||
if (mouseLookEnabled) {
|
hmd = AvatarInputs.isHMD;
|
||||||
if (!tablet.tabletShown){
|
|
||||||
mouseLookOn();
|
if (!hmd){
|
||||||
|
if (mouseLookEnabled) {
|
||||||
|
if (!tablet.tabletShown){
|
||||||
|
Window.displayAnnouncement("Mouse look: ON");
|
||||||
|
mouseLookOn();
|
||||||
|
} else {
|
||||||
|
Window.displayAnnouncement("Tablet is up – mouse look temporarily off.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.keyPressEvent.connect(onKeyPressEvent);
|
Controller.keyPressEvent.connect(onKeyPressEvent);
|
||||||
|
|
||||||
function onKeyPressEvent(event) {
|
function onKeyPressEvent(event) {
|
||||||
if (event.text === 'm') {
|
if (!hmd){
|
||||||
if (mouseLookEnabled) {
|
if (event.text === 'm') {
|
||||||
if (!Camera.getCaptureMouse()){
|
if (mouseLookEnabled) {
|
||||||
Window.displayAnnouncement("Mouse look: ON");
|
if (!Camera.getCaptureMouse()){
|
||||||
mouseLookOn();
|
tempOff = false;
|
||||||
} else {
|
Window.displayAnnouncement("Mouse look: ON");
|
||||||
Window.displayAnnouncement("Mouse look: TEMPORARILY OFF");
|
mouseLookOn();
|
||||||
mouseLookOff();
|
} else {
|
||||||
|
tempOff = true;
|
||||||
|
Window.displayAnnouncement("Mouse look: TEMPORARILY OFF");
|
||||||
|
mouseLookOff();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (event.text === 'M') {
|
||||||
if (event.text === 'M') {
|
if (!mouseLookEnabled){
|
||||||
if (!mouseLookEnabled){
|
Window.displayAnnouncement("Mouse look: ENABLED")
|
||||||
Window.displayAnnouncement("Mouse look: ENABLED")
|
mouseLookEnabled = true;
|
||||||
mouseLookEnabled = true;
|
mouseLookOn();
|
||||||
mouseLookOn();
|
} else {
|
||||||
} else {
|
Window.displayAnnouncement("Mouse look: DISABLED")
|
||||||
Window.displayAnnouncement("Mouse look: DISABLED")
|
mouseLookEnabled = false;
|
||||||
mouseLookEnabled = false;
|
tempOff = false;
|
||||||
mouseLookOff();
|
mouseLookOff();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,19 +66,25 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
||||||
tablet.tabletShownChanged.connect(onTabletShownChanged);
|
tablet.tabletShownChanged.connect(onTabletShownChanged);
|
||||||
|
|
||||||
function onTabletShownChanged() {
|
function onTabletShownChanged() {
|
||||||
if (mouseLookEnabled) {
|
if (!hmd) {
|
||||||
if (!tablet.toolbarMode) {
|
if (mouseLookEnabled) {
|
||||||
if (tablet.tabletShown) {
|
if (!tablet.toolbarMode) {
|
||||||
tabletUp = true;
|
if (tablet.tabletShown) {
|
||||||
if (!away) {
|
tabletUp = true;
|
||||||
Window.displayAnnouncement("Tablet is up – mouse look temporarily off.");
|
if (!tempOff) {
|
||||||
mouseLookOff();
|
if (!away) {
|
||||||
}
|
Window.displayAnnouncement("Tablet is up – mouse look temporarily off.");
|
||||||
} else if (!tablet.tabletShown) {
|
mouseLookOff();
|
||||||
tabletUp = false;
|
}
|
||||||
if (!away) {
|
}
|
||||||
Window.displayAnnouncement("Tablet hidden – mouse look on.");
|
} else if (!tablet.tabletShown) {
|
||||||
mouseLookOn();
|
tabletUp = false;
|
||||||
|
if (!tempOff) {
|
||||||
|
if (!away) {
|
||||||
|
Window.displayAnnouncement("Tablet hidden – mouse look on.");
|
||||||
|
mouseLookOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,11 +94,14 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
||||||
MyAvatar.wentAway.connect(onWentAway);
|
MyAvatar.wentAway.connect(onWentAway);
|
||||||
|
|
||||||
function onWentAway() {
|
function onWentAway() {
|
||||||
if (mouseLookEnabled) {
|
if (!hmd) {
|
||||||
away = true;
|
if (mouseLookEnabled) {
|
||||||
if (!tabletUp){
|
away = true;
|
||||||
Window.displayAnnouncement("Away state ON – mouse look temporarily off.")
|
if (!tabletUp){
|
||||||
mouseLookOff()
|
Window.displayAnnouncement("Away state ON – mouse look temporarily off.")
|
||||||
|
tempOff = false;
|
||||||
|
mouseLookOff()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,11 +109,31 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
||||||
MyAvatar.wentActive.connect(onWentActive);
|
MyAvatar.wentActive.connect(onWentActive);
|
||||||
|
|
||||||
function onWentActive() {
|
function onWentActive() {
|
||||||
|
if (!hmd) {
|
||||||
|
if (mouseLookEnabled) {
|
||||||
|
away = false;
|
||||||
|
if (!tabletUp) {
|
||||||
|
Window.displayAnnouncement("Away state OFF – mouse look on.");
|
||||||
|
mouseLookOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AvatarInputs.isHMDChanged.connect(onIsHMDChanged);
|
||||||
|
|
||||||
|
function onIsHMDChanged() {
|
||||||
if (mouseLookEnabled) {
|
if (mouseLookEnabled) {
|
||||||
away = false;
|
if (AvatarInputs.isHMD) {
|
||||||
if (!tabletUp) {
|
hmd = true;
|
||||||
Window.displayAnnouncement("Away state OFF – mouse look on.");
|
mouseLookOff();
|
||||||
mouseLookOn();
|
} else {
|
||||||
|
hmd = false;
|
||||||
|
if (!tempOff) {
|
||||||
|
if (!tabletUp) {
|
||||||
|
mouseLookOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,8 +165,9 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
||||||
tablet.tabletShownChanged.disconnect(onTabletShownChanged);
|
tablet.tabletShownChanged.disconnect(onTabletShownChanged);
|
||||||
MyAvatar.wentAway.disconnect(onWentAway);
|
MyAvatar.wentAway.disconnect(onWentAway);
|
||||||
MyAvatar.wentActive.disconnect(onWentActive);
|
MyAvatar.wentActive.disconnect(onWentActive);
|
||||||
|
AvatarInputs.isHMDChanged.disconnect(onIsHMDChanged);
|
||||||
Camera.modeUpdated.disconnect(onCameraModeUpdated);
|
Camera.modeUpdated.disconnect(onCameraModeUpdated);
|
||||||
Script.scriptEnding.disconnect();
|
Script.scriptEnding.disconnect(onScriptEnding);
|
||||||
}
|
}
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue