mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:00:41 +02:00
Merge branch 'controllers' of https://github.com/highfidelity/hifi into controllers
This commit is contained in:
commit
b09a159090
7 changed files with 55 additions and 10 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("-------------------------------------------------------------------");
|
||||||
});
|
});
|
|
@ -204,25 +204,24 @@ namespace controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingInterface::updateMaps() {
|
void ScriptingInterface::updateMaps() {
|
||||||
|
QVariantMap newHardware;
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
auto devices = userInputMapper->getDevices();
|
auto devices = userInputMapper->getDevices();
|
||||||
QSet<QString> foundDevices;
|
|
||||||
for (const auto& deviceMapping : devices) {
|
for (const auto& deviceMapping : devices) {
|
||||||
auto deviceID = deviceMapping.first;
|
auto deviceID = deviceMapping.first;
|
||||||
if (deviceID != userInputMapper->getStandardDeviceID()) {
|
if (deviceID != userInputMapper->getStandardDeviceID()) {
|
||||||
auto device = deviceMapping.second;
|
auto device = deviceMapping.second;
|
||||||
auto deviceName = QString(device->getName()).remove(SANITIZE_NAME_EXPRESSION);
|
auto deviceName = QString(device->getName()).remove(SANITIZE_NAME_EXPRESSION);
|
||||||
qCDebug(controllers) << "Device" << deviceMapping.first << ":" << deviceName;
|
qCDebug(controllers) << "Device" << deviceMapping.first << ":" << deviceName;
|
||||||
foundDevices.insert(device->getName());
|
if (newHardware.contains(deviceName)) {
|
||||||
if (_hardware.contains(deviceName)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose the IDs to JS
|
// Expose the IDs to JS
|
||||||
_hardware.insert(deviceName, createDeviceMap(device));
|
newHardware.insert(deviceName, createDeviceMap(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_hardware = newHardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,27 @@ void SDL2Manager::deinit() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDL2Manager::activate() {
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
for (auto joystick : _openJoysticks) {
|
||||||
|
userInputMapper->registerDevice(joystick);
|
||||||
|
emit joystickAdded(joystick.get());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL2Manager::deactivate() {
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
for (auto joystick : _openJoysticks) {
|
||||||
|
userInputMapper->removeDevice(joystick->getDeviceID());
|
||||||
|
emit joystickRemoved(joystick.get());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SDL2Manager::isSupported() const {
|
bool SDL2Manager::isSupported() const {
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,7 +34,12 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,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);
|
||||||
|
@ -136,7 +137,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__
|
||||||
|
|
|
@ -135,6 +135,11 @@ void ViveControllerManager::activate() {
|
||||||
_renderControllers = true;
|
_renderControllers = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// unregister with UserInputMapper
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
userInputMapper->registerDevice(instance);
|
||||||
|
_registeredWithInputMapper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::deactivate() {
|
void ViveControllerManager::deactivate() {
|
||||||
|
@ -152,6 +157,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) {
|
||||||
|
@ -272,15 +282,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(instance);
|
userInputMapper->registerDevice(instance);
|
||||||
|
_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