mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Support stylus input on the mini tablet
This commit is contained in:
parent
f6a607efcc
commit
e25b2f6e0f
2 changed files with 32 additions and 1 deletions
|
@ -58,6 +58,12 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
enabled: true
|
||||
});
|
||||
|
||||
this.miniTabletID = null;
|
||||
|
||||
this.setMiniTabletID = function (id) {
|
||||
this.miniTabletID = id;
|
||||
};
|
||||
|
||||
this.disable = false;
|
||||
|
||||
this.otherModuleNeedsToRun = function(controllerData) {
|
||||
|
@ -123,6 +129,14 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
}
|
||||
|
||||
// Add the mini tablet.
|
||||
if (this.miniTabletID && Overlays.getProperty(this.miniTabletID, "visible")) {
|
||||
stylusTarget = getOverlayDistance(controllerPosition, this.miniTabletID);
|
||||
if (stylusTarget) {
|
||||
stylusTargets.push(stylusTarget);
|
||||
}
|
||||
}
|
||||
|
||||
var WEB_DISPLAY_STYLUS_DISTANCE = 0.5;
|
||||
var nearStylusTarget = isNearStylusTarget(stylusTargets, WEB_DISPLAY_STYLUS_DISTANCE * sensorScaleFactor);
|
||||
|
||||
|
@ -191,6 +205,15 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
}
|
||||
|
||||
function onMessageReceived(channel, message, sender) {
|
||||
if (sender === MyAvatar.sessionUUID) {
|
||||
if (channel === 'Hifi-MiniTablet-UI-ID') {
|
||||
leftTabletStylusInput.setMiniTabletID(message);
|
||||
rightTabletStylusInput.setMiniTabletID(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var leftTabletStylusInput = new StylusInput(LEFT_HAND);
|
||||
var rightTabletStylusInput = new StylusInput(RIGHT_HAND);
|
||||
|
||||
|
@ -201,7 +224,11 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
Overlays.hoverLeaveOverlay.connect(mouseHoverLeave);
|
||||
Overlays.mousePressOnOverlay.connect(mousePress);
|
||||
|
||||
Messages.subscribe('Hifi-MiniTablet-UI-ID');
|
||||
Messages.messageReceived.connect(onMessageReceived);
|
||||
|
||||
this.cleanup = function () {
|
||||
Messages.messageReceived.disconnect(onMessageReceived);
|
||||
leftTabletStylusInput.cleanup();
|
||||
rightTabletStylusInput.cleanup();
|
||||
disableDispatcherModule("LeftTabletStylusInput");
|
||||
|
|
|
@ -180,6 +180,8 @@
|
|||
function updateMiniTabletID() {
|
||||
// Send mini-tablet overlay ID to controllerDispatcher so that it can use a smaller near grab distance.
|
||||
Messages.sendLocalMessage("Hifi-MiniTablet-ID", proxyOverlay);
|
||||
// Send mini-tablet UI overlay ID to stylusInput so that it styluses can be used on it.
|
||||
Messages.sendLocalMessage("Hifi-MiniTablet-UI-ID", proxyUIOverlay);
|
||||
}
|
||||
|
||||
function updateMutedStatus() {
|
||||
|
@ -271,7 +273,7 @@
|
|||
proxyOverlayObject = Overlays.getOverlayObject(proxyUIOverlay);
|
||||
proxyOverlayObject.webEventReceived.connect(onWebEventReceived);
|
||||
|
||||
updateMiniTabletID();
|
||||
// updateMiniTabletID(); Other scripts relying on this may not be ready yet so do this in showUI().
|
||||
}
|
||||
|
||||
function showUI() {
|
||||
|
@ -293,6 +295,8 @@
|
|||
visible: true
|
||||
});
|
||||
|
||||
updateMiniTabletID();
|
||||
|
||||
if (!proxyUIOverlayEnabled) {
|
||||
// Overlay content is created the first time it is visible to the user. The initial creation displays artefacts.
|
||||
// Delay showing UI overlay until after giving it time for its content to be created.
|
||||
|
|
Loading…
Reference in a new issue