From de24842cf00db8da53f4e60d1af9e2a0b8a6ac1f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 11 Sep 2014 11:48:26 -0700 Subject: [PATCH] fix stuck drive keys for Avatar when modifier released --- interface/src/Application.cpp | 13 ++++++++++--- interface/src/avatar/MyAvatar.cpp | 6 ++++++ interface/src/avatar/MyAvatar.h | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 273b66e4dc..7fad196cd0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -905,7 +905,9 @@ void Application::keyPressEvent(QKeyEvent* event) { break; case Qt::Key_D: - _myAvatar->setDriveKeys(ROT_RIGHT, 1.f); + if (!isMeta) { + _myAvatar->setDriveKeys(ROT_RIGHT, 1.f); + } break; case Qt::Key_Return: @@ -1073,7 +1075,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { _keysPressed.remove(event->key()); _controllerScriptingInterface.emitKeyReleaseEvent(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)) { return; @@ -1125,7 +1127,12 @@ void Application::keyReleaseEvent(QKeyEvent* event) { _myAvatar->setDriveKeys(RIGHT, 0.f); _myAvatar->setDriveKeys(ROT_RIGHT, 0.f); break; - + case Qt::Key_Control: + case Qt::Key_Shift: + case Qt::Key_Meta: + case Qt::Key_Alt: + _myAvatar->clearDriveKeys(); + break; default: event->ignore(); break; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 6472ba2efa..241b39028f 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1972,3 +1972,9 @@ glm::vec3 MyAvatar::getLaserPointerTipPosition(const PalmData* palm) { return palm->getPosition(); } + +void MyAvatar::clearDriveKeys() { + for (int i = 0; i < sizeof(_driveKeys); i++) { + _driveKeys[i] = 0.0f; + } +} diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index be828e0c91..35af0faee3 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -98,6 +98,7 @@ public: AttachmentData loadAttachmentData(const QUrl& modelURL, const QString& jointName = QString()) const; // Set what driving keys are being pressed to control thrust levels + void clearDriveKeys(); void setDriveKeys(int key, float val) { _driveKeys[key] = val; }; bool getDriveKeys(int key) { return _driveKeys[key] != 0.f; }; void jump() { _shouldJump = true; };