From 20487b2ad1adb1a10b16bac8cb48e3bf12e93e44 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Sun, 10 Mar 2019 19:39:45 -0700 Subject: [PATCH] connecting pushingToTalkChanged with handlePushedToTalk --- interface/src/Application.cpp | 19 +++++++++---------- interface/src/Application.h | 2 -- interface/src/scripting/Audio.cpp | 3 ++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fc9fcd1bbb..215736001c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1435,8 +1435,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); connect(this, &Application::activeDisplayPluginChanged, reinterpret_cast(audioScriptingInterface.data()), &scripting::Audio::onContextChanged); - connect(this, &Application::pushedToTalk, - reinterpret_cast(audioScriptingInterface.data()), &scripting::Audio::handlePushedToTalk); } // Create the rendering engine. This can be slow on some machines due to lots of @@ -1609,13 +1607,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo bool navAxis = false; switch (actionEnum) { case Action::TOGGLE_PUSHTOTALK: - if (audioScriptingInterface->getPTT()) { - if (state > 0.0f) { - audioScriptingInterface->setPushingToTalk(false); - } else if (state < 0.0f) { - audioScriptingInterface->setPushingToTalk(true); - } + if (state > 0.0f) { + audioScriptingInterface->setPushingToTalk(false); + } else if (state < 0.0f) { + audioScriptingInterface->setPushingToTalk(true); } + break; case Action::UI_NAV_VERTICAL: navAxis = true; @@ -4218,7 +4215,8 @@ void Application::keyPressEvent(QKeyEvent* event) { break; case Qt::Key_T: - emit pushedToTalk(true); + auto audioScriptingInterface = reinterpret_cast(DependencyManager::get().data()); + audioScriptingInterface->setPushingToTalk(true); break; case Qt::Key_P: { @@ -4329,7 +4327,8 @@ void Application::keyReleaseEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_T: - emit pushedToTalk(false); + auto audioScriptingInterface = reinterpret_cast(DependencyManager::get().data()); + audioScriptingInterface->setPushingToTalk(false); break; } } diff --git a/interface/src/Application.h b/interface/src/Application.h index 1c86326f90..a8cc9450c5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -358,8 +358,6 @@ signals: void miniTabletEnabledChanged(bool enabled); - void pushedToTalk(bool enabled); - public slots: QVector pasteEntities(float x, float y, float z); bool exportEntities(const QString& filename, const QVector& entityIDs, const glm::vec3* givenOffset = nullptr); diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 669856198d..c4dfcffb61 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -40,6 +40,8 @@ Audio::Audio() : _devices(_contextIsHMD) { connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged); connect(client, &AudioClient::inputVolumeChanged, this, &Audio::setInputVolume); connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged); + // when pushing to talk changed, handle it. + connect(this, &Audio::pushingToTalkChanged, this, &Audio::handlePushedToTalk); enableNoiseReduction(enableNoiseReductionSetting.get()); onContextChanged(); } @@ -344,7 +346,6 @@ void Audio::handlePushedToTalk(bool enabled) { } else { setMuted(true); } - setPushingToTalk(enabled); } }