mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 10:28:57 +02:00
register/remove devices when the input plugins are activated/deactivated
This commit is contained in:
parent
9785c55c58
commit
a3cd032a41
6 changed files with 49 additions and 5 deletions
|
@ -91,5 +91,11 @@ Object.keys(Controller.Actions).forEach(function (actionName) {
|
|||
|
||||
|
||||
Controller.hardwareChanged.connect(function () {
|
||||
print("hardwareChanged");
|
||||
print("hardwareChanged ---------------------------------------------------");
|
||||
Object.keys(Controller.Hardware).forEach(function (deviceName) {
|
||||
Object.keys(Controller.Hardware[deviceName]).forEach(function (input) {
|
||||
print("Controller.Hardware." + deviceName + "." + input + ":" + Controller.Hardware[deviceName][input]);
|
||||
});
|
||||
});
|
||||
print("-------------------------------------------------------------------");
|
||||
});
|
|
@ -74,6 +74,23 @@ void SDL2Manager::deinit() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void SDL2Manager::activate() {
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
for (auto joystick : _openJoysticks) {
|
||||
userInputMapper->registerDevice(joystick);
|
||||
emit joystickAdded(joystick);
|
||||
}
|
||||
}
|
||||
|
||||
void SDL2Manager::deactivate() {
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
for (auto joystick : _openJoysticks) {
|
||||
userInputMapper->removeDevice(joystick->getDeviceID());
|
||||
emit joystickRemoved(joystick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SDL2Manager::isSupported() const {
|
||||
#ifdef HAVE_SDL2
|
||||
return true;
|
||||
|
|
|
@ -34,7 +34,12 @@ public:
|
|||
|
||||
virtual void init() override;
|
||||
virtual void deinit() override;
|
||||
|
||||
|
||||
/// Called when a plugin is being activated for use. May be called multiple times.
|
||||
virtual void activate() override;
|
||||
/// Called when a plugin is no longer being used. May be called multiple times.
|
||||
virtual void deactivate() override;
|
||||
|
||||
virtual void pluginFocusOutEvent() override;
|
||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override;
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ void SixenseManager::activate() {
|
|||
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
userInputMapper->registerDevice(this);
|
||||
qDebug() << "just called registerDevice hydra id:" << _deviceID;
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
|
@ -125,6 +127,7 @@ void SixenseManager::activate() {
|
|||
|
||||
void SixenseManager::deactivate() {
|
||||
InputPlugin::deactivate();
|
||||
|
||||
#ifdef HAVE_SIXENSE
|
||||
CONTAINER->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
||||
CONTAINER->removeMenu(MENU_PATH);
|
||||
|
@ -135,7 +138,6 @@ void SixenseManager::deactivate() {
|
|||
if (_deviceID != controller::Input::INVALID_DEVICE) {
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
userInputMapper->removeDevice(_deviceID);
|
||||
_deviceID = controller::Input::INVALID_DEVICE;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -133,6 +133,11 @@ void ViveControllerManager::activate() {
|
|||
_renderControllers = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// unregister with UserInputMapper
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
userInputMapper->registerDevice(this);
|
||||
_registeredWithInputMapper = true;
|
||||
}
|
||||
|
||||
void ViveControllerManager::deactivate() {
|
||||
|
@ -150,6 +155,11 @@ void ViveControllerManager::deactivate() {
|
|||
}
|
||||
_poseStateMap.clear();
|
||||
#endif
|
||||
|
||||
// unregister with UserInputMapper
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
userInputMapper->removeDevice(_deviceID);
|
||||
_registeredWithInputMapper = false;
|
||||
}
|
||||
|
||||
void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
|
||||
|
@ -270,15 +280,16 @@ void ViveControllerManager::update(float deltaTime, bool jointsCaptured) {
|
|||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
|
||||
if (numTrackedControllers == 0) {
|
||||
if (_deviceID != 0) {
|
||||
if (_registeredWithInputMapper) {
|
||||
userInputMapper->removeDevice(_deviceID);
|
||||
_deviceID = 0;
|
||||
_registeredWithInputMapper = false;
|
||||
_poseStateMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (_trackedControllers == 0 && numTrackedControllers > 0) {
|
||||
userInputMapper->registerDevice(this);
|
||||
_registeredWithInputMapper = true;
|
||||
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,9 @@ private:
|
|||
bool _renderControllers;
|
||||
|
||||
static const QString NAME;
|
||||
|
||||
bool _registeredWithInputMapper { false };
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi__ViveControllerManager
|
||||
|
|
Loading…
Reference in a new issue