mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:59:20 +02:00
Merge pull request #6330 from Atlante45/master
// FIXME incredibly evil....
This commit is contained in:
commit
1dc392bb36
7 changed files with 24 additions and 25 deletions
|
@ -1027,10 +1027,7 @@ void Application::initializeUi() {
|
||||||
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
|
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
|
||||||
QString name = inputPlugin->getName();
|
QString name = inputPlugin->getName();
|
||||||
if (name == KeyboardMouseDevice::NAME) {
|
if (name == KeyboardMouseDevice::NAME) {
|
||||||
auto kbm = static_cast<KeyboardMouseDevice*>(inputPlugin.data());
|
_keyboardMouseDevice = std::dynamic_pointer_cast<KeyboardMouseDevice>(inputPlugin);
|
||||||
// FIXME incredibly evil.... _keyboardMouseDevice is now owned by
|
|
||||||
// both a QSharedPointer and a std::shared_ptr
|
|
||||||
_keyboardMouseDevice = std::shared_ptr<KeyboardMouseDevice>(kbm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateInputModes();
|
updateInputModes();
|
||||||
|
@ -4645,7 +4642,7 @@ DisplayPlugin* Application::getActiveDisplayPlugin() {
|
||||||
updateDisplayMode();
|
updateDisplayMode();
|
||||||
Q_ASSERT(_displayPlugin);
|
Q_ASSERT(_displayPlugin);
|
||||||
}
|
}
|
||||||
return _displayPlugin.data();
|
return _displayPlugin.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayPlugin* Application::getActiveDisplayPlugin() const {
|
const DisplayPlugin* Application::getActiveDisplayPlugin() const {
|
||||||
|
@ -4685,10 +4682,10 @@ void Application::updateDisplayMode() {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach(auto displayPlugin, displayPlugins) {
|
foreach(auto displayPlugin, displayPlugins) {
|
||||||
addDisplayPluginToMenu(displayPlugin, first);
|
addDisplayPluginToMenu(displayPlugin, first);
|
||||||
QObject::connect(displayPlugin.data(), &DisplayPlugin::requestRender, [this] {
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, [this] {
|
||||||
paintGL();
|
paintGL();
|
||||||
});
|
});
|
||||||
QObject::connect(displayPlugin.data(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
|
||||||
resizeGL();
|
resizeGL();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4814,12 +4811,14 @@ void Application::updateInputModes() {
|
||||||
foreach(auto inputPlugin, inputPlugins) {
|
foreach(auto inputPlugin, inputPlugins) {
|
||||||
QString name = inputPlugin->getName();
|
QString name = inputPlugin->getName();
|
||||||
QAction* action = menu->getActionForOption(name);
|
QAction* action = menu->getActionForOption(name);
|
||||||
if (action->isChecked() && !_activeInputPlugins.contains(inputPlugin)) {
|
|
||||||
_activeInputPlugins.append(inputPlugin);
|
auto it = std::find(std::begin(_activeInputPlugins), std::end(_activeInputPlugins), inputPlugin);
|
||||||
newInputPlugins.append(inputPlugin);
|
if (action->isChecked() && it == std::end(_activeInputPlugins)) {
|
||||||
} else if (!action->isChecked() && _activeInputPlugins.contains(inputPlugin)) {
|
_activeInputPlugins.push_back(inputPlugin);
|
||||||
_activeInputPlugins.removeOne(inputPlugin);
|
newInputPlugins.push_back(inputPlugin);
|
||||||
removedInputPlugins.append(inputPlugin);
|
} else if (!action->isChecked() && it != std::end(_activeInputPlugins)) {
|
||||||
|
_activeInputPlugins.erase(it);
|
||||||
|
removedInputPlugins.push_back(inputPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ namespace controller {
|
||||||
void ScriptingInterface::updateMaps() {
|
void ScriptingInterface::updateMaps() {
|
||||||
QVariantMap newHardware;
|
QVariantMap newHardware;
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
auto devices = userInputMapper->getDevices();
|
const auto& devices = userInputMapper->getDevices();
|
||||||
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()) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace controller {
|
||||||
void setSensorToWorldMat(glm::mat4 sensorToWorldMat) { _sensorToWorldMat = sensorToWorldMat; }
|
void setSensorToWorldMat(glm::mat4 sensorToWorldMat) { _sensorToWorldMat = sensorToWorldMat; }
|
||||||
glm::mat4 getSensorToWorldMat() { return _sensorToWorldMat; }
|
glm::mat4 getSensorToWorldMat() { return _sensorToWorldMat; }
|
||||||
|
|
||||||
DevicesMap getDevices() { return _registeredDevices; }
|
const DevicesMap& getDevices() { return _registeredDevices; }
|
||||||
uint16 getStandardDeviceID() const { return STANDARD_DEVICE; }
|
uint16 getStandardDeviceID() const { return STANDARD_DEVICE; }
|
||||||
InputDevice::Pointer getStandardDevice() { return _registeredDevices[getStandardDeviceID()]; }
|
InputDevice::Pointer getStandardDevice() { return _registeredDevices[getStandardDeviceID()]; }
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ InputPluginList getInputPlugins() {
|
||||||
|
|
||||||
InputPluginList result;
|
InputPluginList result;
|
||||||
for (int i = 0; PLUGIN_POOL[i]; ++i) {
|
for (int i = 0; PLUGIN_POOL[i]; ++i) {
|
||||||
InputPlugin * plugin = PLUGIN_POOL[i];
|
InputPlugin* plugin = PLUGIN_POOL[i];
|
||||||
if (plugin->isSupported()) {
|
if (plugin->isSupported()) {
|
||||||
plugin->init();
|
plugin->init();
|
||||||
result.push_back(InputPluginPointer(plugin));
|
result.push_back(InputPluginPointer(plugin));
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QList>
|
#include <vector>
|
||||||
#include <QVector>
|
#include <memory>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
class DisplayPlugin;
|
class DisplayPlugin;
|
||||||
class InputPlugin;
|
class InputPlugin;
|
||||||
|
@ -17,8 +16,8 @@ class Plugin;
|
||||||
class PluginContainer;
|
class PluginContainer;
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
|
|
||||||
using DisplayPluginPointer = QSharedPointer<DisplayPlugin>;
|
using DisplayPluginPointer = std::shared_ptr<DisplayPlugin>;
|
||||||
using DisplayPluginList = QVector<DisplayPluginPointer>;
|
using DisplayPluginList = std::vector<DisplayPluginPointer>;
|
||||||
using InputPluginPointer = QSharedPointer<InputPlugin>;
|
using InputPluginPointer = std::shared_ptr<InputPlugin>;
|
||||||
using InputPluginList = QVector<InputPluginPointer>;
|
using InputPluginList = std::vector<InputPluginPointer>;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include "Forward.h"
|
#include "Forward.h"
|
||||||
|
|
||||||
class PluginManager : public QObject {
|
class PluginManager : public QObject {
|
||||||
|
|
|
@ -132,8 +132,7 @@ int main(int argc, char** argv) {
|
||||||
inputPlugin->activate();
|
inputPlugin->activate();
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
if (name == KeyboardMouseDevice::NAME) {
|
if (name == KeyboardMouseDevice::NAME) {
|
||||||
auto keyboardMouseDevice = static_cast<KeyboardMouseDevice*>(inputPlugin.data()); // TODO: this seems super hacky
|
userInputMapper->registerDevice(std::dynamic_pointer_cast<KeyboardMouseDevice>(inputPlugin));
|
||||||
userInputMapper->registerDevice(std::shared_ptr<InputDevice>(keyboardMouseDevice));
|
|
||||||
}
|
}
|
||||||
inputPlugin->pluginUpdate(0, false);
|
inputPlugin->pluginUpdate(0, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue