mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 06:23:35 +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 () {
|
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
|
#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 {
|
bool SDL2Manager::isSupported() const {
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -35,6 +35,11 @@ public:
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual void deinit() 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 pluginFocusOutEvent() override;
|
||||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override;
|
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,8 @@ void SixenseManager::activate() {
|
||||||
|
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
userInputMapper->registerDevice(this);
|
userInputMapper->registerDevice(this);
|
||||||
|
qDebug() << "just called registerDevice hydra id:" << _deviceID;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
@ -125,6 +127,7 @@ void SixenseManager::activate() {
|
||||||
|
|
||||||
void SixenseManager::deactivate() {
|
void SixenseManager::deactivate() {
|
||||||
InputPlugin::deactivate();
|
InputPlugin::deactivate();
|
||||||
|
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
CONTAINER->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
CONTAINER->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
||||||
CONTAINER->removeMenu(MENU_PATH);
|
CONTAINER->removeMenu(MENU_PATH);
|
||||||
|
@ -135,7 +138,6 @@ void SixenseManager::deactivate() {
|
||||||
if (_deviceID != controller::Input::INVALID_DEVICE) {
|
if (_deviceID != controller::Input::INVALID_DEVICE) {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
userInputMapper->removeDevice(_deviceID);
|
userInputMapper->removeDevice(_deviceID);
|
||||||
_deviceID = controller::Input::INVALID_DEVICE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
|
@ -133,6 +133,11 @@ void ViveControllerManager::activate() {
|
||||||
_renderControllers = true;
|
_renderControllers = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// unregister with UserInputMapper
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
userInputMapper->registerDevice(this);
|
||||||
|
_registeredWithInputMapper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::deactivate() {
|
void ViveControllerManager::deactivate() {
|
||||||
|
@ -150,6 +155,11 @@ void ViveControllerManager::deactivate() {
|
||||||
}
|
}
|
||||||
_poseStateMap.clear();
|
_poseStateMap.clear();
|
||||||
#endif
|
#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) {
|
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>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
|
||||||
if (numTrackedControllers == 0) {
|
if (numTrackedControllers == 0) {
|
||||||
if (_deviceID != 0) {
|
if (_registeredWithInputMapper) {
|
||||||
userInputMapper->removeDevice(_deviceID);
|
userInputMapper->removeDevice(_deviceID);
|
||||||
_deviceID = 0;
|
_registeredWithInputMapper = false;
|
||||||
_poseStateMap.clear();
|
_poseStateMap.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_trackedControllers == 0 && numTrackedControllers > 0) {
|
if (_trackedControllers == 0 && numTrackedControllers > 0) {
|
||||||
userInputMapper->registerDevice(this);
|
userInputMapper->registerDevice(this);
|
||||||
|
_registeredWithInputMapper = true;
|
||||||
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");
|
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "steamVR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,9 @@ private:
|
||||||
bool _renderControllers;
|
bool _renderControllers;
|
||||||
|
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
|
|
||||||
|
bool _registeredWithInputMapper { false };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi__ViveControllerManager
|
#endif // hifi__ViveControllerManager
|
||||||
|
|
Loading…
Reference in a new issue