History

register/remove devices when the input plugins are activated/deactivated

Brad Hefta-Gaub committed 11 years ago

Commit a3cd0321 parent 9785c556 files · +49 −5Browse files

Showing the changes to libraries/input-plugins/src/input-plugins/ViveControllerManager.cpp (1 of 6 files). Show all

Unified · Split

libraries/input-plugins/src/input-plugins/ViveControllerManager.cpp+13−2
@@ -133,6 +133,11 @@ void ViveControllerManager::activate() { · 132 unmodified lines
133 _renderControllers = true;133 _renderControllers = true;
134 }134 }
135#endif135#endif
136
137 // unregister with UserInputMapper
138 auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
139 userInputMapper->registerDevice(this);
140 _registeredWithInputMapper = true;
136}141}
137 142
138void ViveControllerManager::deactivate() {143void ViveControllerManager::deactivate() {
@@ -150,6 +155,11 @@ void ViveControllerManager::deactivate() { · 11 unmodified lines
150 }155 }
151 _poseStateMap.clear();156 _poseStateMap.clear();
152#endif157#endif
158
159 // unregister with UserInputMapper
160 auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
161 userInputMapper->removeDevice(_deviceID);
162 _registeredWithInputMapper = false;
153}163}
154 164
155void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {165void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
@@ -270,15 +280,16 @@ void ViveControllerManager::update(float deltaTime, bool jointsCaptured) { · 114 unmodified lines
270 auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();280 auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
271 281
272 if (numTrackedControllers == 0) {282 if (numTrackedControllers == 0) {
273 if (_deviceID != 0) {283 if (_registeredWithInputMapper) {
274 userInputMapper->removeDevice(_deviceID);284 userInputMapper->removeDevice(_deviceID);
275 _deviceID = 0;285 _registeredWithInputMapper = false;
276 _poseStateMap.clear();286 _poseStateMap.clear();
277 }287 }
278 }288 }
279 289
280 if (_trackedControllers == 0 && numTrackedControllers > 0) {290 if (_trackedControllers == 0 && numTrackedControllers > 0) {
281 userInputMapper->registerDevice(this);291 userInputMapper->registerDevice(this);
292 _registeredWithInputMapper = true;
282 UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");293 UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");
283 }294 }
284 295