LONGITUDINAL_BACKWARD | number | number | Deprecated: Use
@@ -411,6 +414,7 @@ namespace controller {
makeButtonPair(Action::ACTION2, "SecondaryAction"),
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
+ makeButtonPair(Action::TOGGLE_PUSHTOTALK, "TogglePushToTalk"),
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
makeButtonPair(Action::SPRINT, "Sprint"),
diff --git a/libraries/controllers/src/controllers/Actions.h b/libraries/controllers/src/controllers/Actions.h
index a12a3d60a9..3e99d8d147 100644
--- a/libraries/controllers/src/controllers/Actions.h
+++ b/libraries/controllers/src/controllers/Actions.h
@@ -60,6 +60,7 @@ enum class Action {
CONTEXT_MENU,
TOGGLE_MUTE,
+ TOGGLE_PUSHTOTALK,
CYCLE_CAMERA,
TOGGLE_OVERLAY,
diff --git a/scripts/system/audio.js b/scripts/system/audio.js
index ee82c0c6ea..19ed3faef2 100644
--- a/scripts/system/audio.js
+++ b/scripts/system/audio.js
@@ -26,9 +26,15 @@ var UNMUTE_ICONS = {
icon: "icons/tablet-icons/mic-unmute-i.svg",
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
};
+var PTT_ICONS = {
+ icon: "icons/tablet-icons/mic-ptt-i.svg",
+ activeIcon: "icons/tablet-icons/mic-ptt-a.svg"
+};
function onMuteToggled() {
- if (Audio.muted) {
+ if (Audio.pushToTalk) {
+ button.editProperties(PTT_ICONS);
+ } else if (Audio.muted) {
button.editProperties(MUTE_ICONS);
} else {
button.editProperties(UNMUTE_ICONS);
@@ -57,8 +63,8 @@ function onScreenChanged(type, url) {
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
- icon: Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon,
- activeIcon: Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon,
+ icon: Audio.pushToTalk ? PTT_ICONS.icon : Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon,
+ activeIcon: Audio.pushToTalk ? PTT_ICONS.activeIcon : Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon,
text: TABLET_BUTTON_NAME,
sortOrder: 1
});
@@ -68,6 +74,7 @@ onMuteToggled();
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
Audio.mutedChanged.connect(onMuteToggled);
+Audio.pushToTalkChanged.connect(onMuteToggled);
Script.scriptEnding.connect(function () {
if (onAudioScreen) {
@@ -76,6 +83,7 @@ Script.scriptEnding.connect(function () {
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
Audio.mutedChanged.disconnect(onMuteToggled);
+ Audio.pushToTalkChanged.disconnect(onMuteToggled);
tablet.removeButton(button);
});
diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js
index 28c3e2a299..f4c0cbb0d6 100644
--- a/scripts/system/controllers/controllerDispatcher.js
+++ b/scripts/system/controllers/controllerDispatcher.js
@@ -58,6 +58,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
// is stored as the value, rather than false.
this.activitySlots = {
+ head: false,
leftHand: false,
rightHand: false,
rightHandTrigger: false,
diff --git a/scripts/system/controllers/controllerModules/pushToTalk.js b/scripts/system/controllers/controllerModules/pushToTalk.js
new file mode 100644
index 0000000000..11335ba2f5
--- /dev/null
+++ b/scripts/system/controllers/controllerModules/pushToTalk.js
@@ -0,0 +1,64 @@
+"use strict";
+
+// Created by Jason C. Najera on 3/7/2019
+// Copyright 2019 High Fidelity, Inc.
+//
+// Handles Push-to-Talk functionality for HMD mode.
+//
+// Distributed under the Apache License, Version 2.0.
+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
+
+Script.include("/~/system/libraries/controllerDispatcherUtils.js");
+Script.include("/~/system/libraries/controllers.js");
+
+(function() { // BEGIN LOCAL_SCOPE
+ function PushToTalkHandler() {
+ var _this = this;
+ this.active = false;
+
+ this.shouldTalk = function (controllerData) {
+ // Set up test against controllerData here...
+ var gripVal = controllerData.secondaryValues[LEFT_HAND] && controllerData.secondaryValues[RIGHT_HAND];
+ return (gripVal) ? true : false;
+ };
+
+ this.shouldStopTalking = function (controllerData) {
+ var gripVal = controllerData.secondaryValues[LEFT_HAND] && controllerData.secondaryValues[RIGHT_HAND];
+ return (gripVal) ? false : true;
+ };
+
+ this.isReady = function (controllerData, deltaTime) {
+ if (HMD.active && Audio.pushToTalk && this.shouldTalk(controllerData)) {
+ Audio.pushingToTalk = true;
+ return makeRunningValues(true, [], []);
+ }
+
+ return makeRunningValues(false, [], []);
+ };
+
+ this.run = function (controllerData, deltaTime) {
+ if (this.shouldStopTalking(controllerData) || !Audio.pushToTalk) {
+ Audio.pushingToTalk = false;
+ print("Stop pushing to talk.");
+ return makeRunningValues(false, [], []);
+ }
+
+ return makeRunningValues(true, [], []);
+ };
+
+ this.parameters = makeDispatcherModuleParameters(
+ 950,
+ ["head"],
+ [],
+ 100);
+ }
+
+ var pushToTalk = new PushToTalkHandler();
+ enableDispatcherModule("PushToTalk", pushToTalk);
+
+ function cleanup() {
+ disableDispatcherModule("PushToTalk");
+ };
+
+ Script.scriptEnding.connect(cleanup);
+}()); // END LOCAL_SCOPE
diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js
index 726e075fcc..ca7d041792 100644
--- a/scripts/system/controllers/controllerScripts.js
+++ b/scripts/system/controllers/controllerScripts.js
@@ -33,7 +33,8 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/nearGrabHyperLinkEntity.js",
"controllerModules/nearTabletHighlight.js",
"controllerModules/nearGrabEntity.js",
- "controllerModules/farGrabEntity.js"
+ "controllerModules/farGrabEntity.js",
+ "controllerModules/pushToTalk.js"
];
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
|