From 07ddd4e1dd1d716d78c9c29db8b6d6ec880d7005 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 11 Mar 2019 14:27:47 -0700 Subject: [PATCH] moving key press detection to JSON --- .../resources/controllers/keyboardMouse.json | 1 + interface/src/Application.cpp | 15 ++------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/interface/resources/controllers/keyboardMouse.json b/interface/resources/controllers/keyboardMouse.json index 74c11203ef..9b3c711c63 100644 --- a/interface/resources/controllers/keyboardMouse.json +++ b/interface/resources/controllers/keyboardMouse.json @@ -5,6 +5,7 @@ { "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" }, { "from": "Keyboard.E", "when": "!Keyboard.Control", "to": "Actions.LATERAL_RIGHT" }, { "from": "Keyboard.Q", "when": "!Keyboard.Control", "to": "Actions.LATERAL_LEFT" }, + { "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" }, { "comment" : "Mouse turn need to be small continuous increments", "from": { "makeAxis" : [ diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3230419816..de4a6bb167 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1608,9 +1608,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo switch (actionEnum) { case Action::TOGGLE_PUSHTOTALK: if (state > 0.0f) { - audioScriptingInterface->setPushingToTalk(false); - } else if (state < 0.0f) { audioScriptingInterface->setPushingToTalk(true); + } else if (state <= 0.0f) { + audioScriptingInterface->setPushingToTalk(false); } break; @@ -4047,7 +4047,6 @@ void Application::keyPressEvent(QKeyEvent* event) { _keysPressed.insert(event->key(), *event); } - auto audioScriptingInterface = reinterpret_cast(DependencyManager::get().data()); _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts // if one of our scripts have asked to capture this event, then stop processing it if (_controllerScriptingInterface->isKeyCaptured(event) || isInterstitialMode()) { @@ -4215,10 +4214,6 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; - case Qt::Key_T: - audioScriptingInterface->setPushingToTalk(true); - break; - case Qt::Key_P: { if (!isShifted && !isMeta && !isOption && !event->isAutoRepeat()) { AudioInjectorOptions options; @@ -4325,12 +4320,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) { _keyboardMouseDevice->keyReleaseEvent(event); } - auto audioScriptingInterface = reinterpret_cast(DependencyManager::get().data()); - switch (event->key()) { - case Qt::Key_T: - audioScriptingInterface->setPushingToTalk(false); - break; - } } void Application::focusOutEvent(QFocusEvent* event) {