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
133133 _renderControllers = true;
134134 }
135135 #endif
136+
137+ // unregister with UserInputMapper
138+ auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
139+ userInputMapper->registerDevice(this);
140+ _registeredWithInputMapper = true;
136141 }
137142
138143 void ViveControllerManager::deactivate() {
@@ -150,6 +155,11 @@ void ViveControllerManager::deactivate() { · 11 unmodified lines
150155 }
151156 _poseStateMap.clear();
152157 #endif
158+
159+ // unregister with UserInputMapper
160+ auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
161+ userInputMapper->removeDevice(_deviceID);
162+ _registeredWithInputMapper = false;
153163 }
154164
155165 void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
@@ -270,15 +280,16 @@ void ViveControllerManager::update(float deltaTime, bool jointsCaptured) { · 114 unmodified lines
270280 auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
271281
272282 if (numTrackedControllers == 0) {
273− if (_deviceID != 0) {
283+ if (_registeredWithInputMapper) {
274284 userInputMapper->removeDevice(_deviceID);
275− _deviceID = 0;
285+ _registeredWithInputMapper = false;
276286 _poseStateMap.clear();
277287 }
278288 }
279289
280290 if (_trackedControllers == 0 && numTrackedControllers > 0) {
281291 userInputMapper->registerDevice(this);
292+ _registeredWithInputMapper = true;
282293 UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");
283294 }
284295