mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
DEV-2575: Automatically lower raised hand if talking
This commit is contained in:
parent
c650ca6544
commit
4f7028ff0f
1 changed files with 39 additions and 0 deletions
|
@ -217,6 +217,37 @@ function targetPointInterpolate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function maybeClearInputAudioLevelsInterval() {
|
||||||
|
if (checkInputAudioLevelsInterval) {
|
||||||
|
Script.clearInterval(checkInputAudioLevelsInterval);
|
||||||
|
checkInputAudioLevelsInterval = false;
|
||||||
|
currentNumTimesAboveThreshold = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var currentNumTimesAboveThreshold = 0;
|
||||||
|
var checkInputAudioLevelsInterval;
|
||||||
|
// The values below are determined empirically and may require tweaking over time if users
|
||||||
|
// notice false-positives or false-negatives.
|
||||||
|
var CHECK_INPUT_AUDIO_LEVELS_INTERVAL_MS = 200;
|
||||||
|
var AUDIO_INPUT_THRESHOLD = 130;
|
||||||
|
var NUM_REQUIRED_LEVELS_ABOVE_AUDIO_INPUT_THRESHOLD = 4;
|
||||||
|
function checkInputLevelsCallback() {
|
||||||
|
if (MyAvatar.audioLoudness > AUDIO_INPUT_THRESHOLD) {
|
||||||
|
currentNumTimesAboveThreshold++;
|
||||||
|
} else {
|
||||||
|
currentNumTimesAboveThreshold = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentNumTimesAboveThreshold >= NUM_REQUIRED_LEVELS_ABOVE_AUDIO_INPUT_THRESHOLD) {
|
||||||
|
endReactionWrapper("raiseHand");
|
||||||
|
currentNumTimesAboveThreshold = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function beginReactionWrapper(reaction) {
|
function beginReactionWrapper(reaction) {
|
||||||
maybeDeleteRemoteIndicatorTimeout();
|
maybeDeleteRemoteIndicatorTimeout();
|
||||||
|
|
||||||
|
@ -246,6 +277,10 @@ function beginReactionWrapper(reaction) {
|
||||||
Script.update.connect(targetPointInterpolate);
|
Script.update.connect(targetPointInterpolate);
|
||||||
targetPointInterpolateConnected = true;
|
targetPointInterpolateConnected = true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case ("raiseHand"):
|
||||||
|
checkInputAudioLevelsInterval = Script.setInterval(checkInputLevelsCallback, CHECK_INPUT_AUDIO_LEVELS_INTERVAL_MS);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +406,9 @@ function endReactionWrapper(reaction) {
|
||||||
maybeClearReticleUpdateLimiterTimeout();
|
maybeClearReticleUpdateLimiterTimeout();
|
||||||
deleteOldReticles();
|
deleteOldReticles();
|
||||||
break;
|
break;
|
||||||
|
case ("raiseHand"):
|
||||||
|
maybeClearInputAudioLevelsInterval();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,6 +686,7 @@ function unload() {
|
||||||
maybeClearClapSoundInterval();
|
maybeClearClapSoundInterval();
|
||||||
maybeClearReticleUpdateLimiterTimeout();
|
maybeClearReticleUpdateLimiterTimeout();
|
||||||
maybeDeleteRemoteIndicatorTimeout();
|
maybeDeleteRemoteIndicatorTimeout();
|
||||||
|
maybeClearInputAudioLevelsInterval();
|
||||||
|
|
||||||
Window.minimizedChanged.disconnect(onWindowMinimizedChanged);
|
Window.minimizedChanged.disconnect(onWindowMinimizedChanged);
|
||||||
HMD.displayModeChanged.disconnect(onDisplayModeChanged);
|
HMD.displayModeChanged.disconnect(onDisplayModeChanged);
|
||||||
|
|
Loading…
Reference in a new issue