Showing the changes to interface/src/ControllerScriptingInterface.cpp (1 of 7 files). Show all
Unified · Split
| @@ -179,5 +179,40 @@ glm::vec3 ControllerScriptingInterface::getSpatialControlNormal(int controlIndex · 178 unmodified lines | |||
| 179 | return glm::vec3(0); // bad index | 179 | return glm::vec3(0); // bad index |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | bool ControllerScriptingInterface::isKeyCaptured(QKeyEvent* event) const { | ||
| 183 | qDebug() << "ControllerScriptingInterface::isKeyCaptured() event=" << event; | ||
| 184 | return isKeyCaptured(KeyEvent(*event)); | ||
| 185 | } | ||
| 186 | |||
| 187 | bool ControllerScriptingInterface::isKeyCaptured(const KeyEvent& event) const { | ||
| 188 | |||
| 189 | qDebug() << "ControllerScriptingInterface::isKeyCaptured() event.key=" << event.key; | ||
| 190 | |||
| 191 | // if we've captured some combination of this key it will be in the map | ||
| 192 | if (_capturedKeys.contains(event.key, event)) { | ||
| 193 | qDebug() << "ControllerScriptingInterface::isKeyCaptured() event.key=" << event.key << " returning TRUE"; | ||
| 194 | return true; | ||
| 195 | } | ||
| 196 | return false; | ||
| 197 | } | ||
| 182 | 198 | ||
| 199 | void ControllerScriptingInterface::captureKeyEvents(const KeyEvent& event) { | ||
| 200 | // if it's valid | ||
| 201 | if (event.isValid) { | ||
| 202 | // and not already captured | ||
| 203 | if (!isKeyCaptured(event)) { | ||
| 204 | // then add this KeyEvent record to the captured combos for this key | ||
| 205 | _capturedKeys.insert(event.key, event); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | void ControllerScriptingInterface::releaseKeyEvents(const KeyEvent& event) { | ||
| 211 | if (event.isValid) { | ||
| 212 | // and not already captured | ||
| 213 | if (isKeyCaptured(event)) { | ||
| 214 | _capturedKeys.remove(event.key, event); | ||
| 215 | } | ||
| 216 | } | ||
| 217 | } | ||
| 183 | 218 | ||