History

Merge branch 'master' of https://github.com/worklist/hifi into 20724

Thijs Wenker committed 11 years ago

Commit a58bd4f2 parents de98a17 4cb5e71140 files · +4893 −1152Browse files

Showing the changes to interface/src/Application.cpp (1 of 140 files). Show all

Unified · Split

interface/src/Application.cpp+31−24
@@ -100,7 +100,7 @@ · 99 unmodified lines
100#include "audio/AudioScope.h"100#include "audio/AudioScope.h"
101#include "avatar/AvatarManager.h"101#include "avatar/AvatarManager.h"
102#include "CrashHandler.h"102#include "CrashHandler.h"
103#include "devices/3DConnexionClient.h"103#include "input-plugins/SpacemouseManager.h"
104#include "devices/DdeFaceTracker.h"104#include "devices/DdeFaceTracker.h"
105#include "devices/EyeTracker.h"105#include "devices/EyeTracker.h"
106#include "devices/Faceshift.h"106#include "devices/Faceshift.h"
@@ -646,11 +646,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 539 unmodified lines
646 _applicationStateDevice->addInputVariant(QString("ComfortMode"), controller::StateController::ReadLambda([]() -> float {646 _applicationStateDevice->addInputVariant(QString("ComfortMode"), controller::StateController::ReadLambda([]() -> float {
647 return (float)Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode);647 return (float)Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode);
648 }));648 }));
649 _applicationStateDevice->addInputVariant(QString("Grounded"), controller::StateController::ReadLambda([]() -> float {
650 return (float)qApp->getMyAvatar()->getCharacterController()->onGround();
651 }));
649 652
650 userInputMapper->registerDevice(_applicationStateDevice);653 userInputMapper->registerDevice(_applicationStateDevice);
651 654
652 // Setup the keyboardMouseDevice and the user input mapper with the default bindings655 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
653 userInputMapper->registerDevice(_keyboardMouseDevice);656 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
654 657
655 658
656 userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID());659 userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID());
@@ -726,9 +729,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 69 unmodified lines
726 // Now that menu is initalized we can sync myAvatar with it's state.729 // Now that menu is initalized we can sync myAvatar with it's state.
727 getMyAvatar()->updateMotionBehaviorFromMenu();730 getMyAvatar()->updateMotionBehaviorFromMenu();
728 731
732// FIXME spacemouse code still needs cleanup
729#if 0733#if 0
730 // the 3Dconnexion device wants to be initiliazed after a window is displayed.734 // the 3Dconnexion device wants to be initiliazed after a window is displayed.
731 ConnexionClient::getInstance().init();735 SpacemouseManager::getInstance().init();
732#endif736#endif
733 737
734 auto& packetReceiver = nodeList->getPacketReceiver();738 auto& packetReceiver = nodeList->getPacketReceiver();
@@ -940,14 +944,12 @@ void Application::initializeGL() { · 205 unmodified lines
940 qCDebug(interfaceapp) << "Created Display Window.";944 qCDebug(interfaceapp) << "Created Display Window.";
941 945
942 // initialize glut for shape drawing; Qt apparently initializes it on OS X946 // initialize glut for shape drawing; Qt apparently initializes it on OS X
943 #ifndef __APPLE__947 if (_isGLInitialized) {
944 static bool isInitialized = false;
945 if (isInitialized) {
946 return;948 return;
947 } else {949 } else {
948 isInitialized = true;950 _isGLInitialized = true;
949 }951 }
950 #endif952
951 // Where the gpuContext is initialized and where the TRUE Backend is created and assigned953 // Where the gpuContext is initialized and where the TRUE Backend is created and assigned
952 gpu::Context::init<gpu::GLBackend>();954 gpu::Context::init<gpu::GLBackend>();
953 _gpuContext = std::make_shared<gpu::Context>();955 _gpuContext = std::make_shared<gpu::Context>();
@@ -1031,10 +1033,7 @@ void Application::initializeUi() { · 77 unmodified lines
1031 foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {1033 foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
1032 QString name = inputPlugin->getName();1034 QString name = inputPlugin->getName();
1033 if (name == KeyboardMouseDevice::NAME) {1035 if (name == KeyboardMouseDevice::NAME) {
1034 auto kbm = static_cast<KeyboardMouseDevice*>(inputPlugin.data());1036 _keyboardMouseDevice = std::dynamic_pointer_cast<KeyboardMouseDevice>(inputPlugin);
1035 // FIXME incredibly evil.... _keyboardMouseDevice is now owned by
1036 // both a QSharedPointer and a std::shared_ptr
1037 _keyboardMouseDevice = std::shared_ptr<KeyboardMouseDevice>(kbm);
1038 }1037 }
1039 }1038 }
1040 updateInputModes();1039 updateInputModes();
@@ -1059,7 +1058,9 @@ void Application::paintGL() { · 18 unmodified lines
1059 _lastFramesPerSecondUpdate = now;1058 _lastFramesPerSecondUpdate = now;
1060 }1059 }
1061 1060
1062 idle(now);1061 if (_isGLInitialized) {
1062 idle(now);
1063 }
1063 1064
1064 PROFILE_RANGE(__FUNCTION__);1065 PROFILE_RANGE(__FUNCTION__);
1065 PerformanceTimer perfTimer("paintGL");1066 PerformanceTimer perfTimer("paintGL");
@@ -1864,8 +1865,12 @@ void Application::focusOutEvent(QFocusEvent* event) { · 798 unmodified lines
1864 inputPlugin->pluginFocusOutEvent();1865 inputPlugin->pluginFocusOutEvent();
1865 }1866 }
1866 }1867 }
1868
1869// FIXME spacemouse code still needs cleanup
1867#if 01870#if 0
1868 ConnexionData::getInstance().focusOutEvent();1871 //SpacemouseDevice::getInstance().focusOutEvent();
1872 //SpacemouseManager::getInstance().getDevice()->focusOutEvent();
1873 SpacemouseManager::getInstance().ManagerFocusOutEvent();
1869#endif1874#endif
1870 1875
1871 // synthesize events for keys currently pressed, since we may not get their release events1876 // synthesize events for keys currently pressed, since we may not get their release events
@@ -2812,7 +2817,7 @@ void Application::update(float deltaTime) { · 940 unmodified lines
2812 float timeFactor = EXPECTED_FRAME_RATE * deltaTime;2817 float timeFactor = EXPECTED_FRAME_RATE * deltaTime;
2813 myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH) / timeFactor);2818 myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH) / timeFactor);
2814 myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW) / timeFactor);2819 myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW) / timeFactor);
2815 myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW) / timeFactor);2820 myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
2816 }2821 }
2817 }2822 }
2818 myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));2823 myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
@@ -4663,7 +4668,7 @@ DisplayPlugin* Application::getActiveDisplayPlugin() { · 1844 unmodified lines
4663 updateDisplayMode();4668 updateDisplayMode();
4664 Q_ASSERT(_displayPlugin);4669 Q_ASSERT(_displayPlugin);
4665 }4670 }
4666 return _displayPlugin.data();4671 return _displayPlugin.get();
4667}4672}
4668 4673
4669const DisplayPlugin* Application::getActiveDisplayPlugin() const {4674const DisplayPlugin* Application::getActiveDisplayPlugin() const {
@@ -4703,10 +4708,10 @@ void Application::updateDisplayMode() { · 33 unmodified lines
4703 bool first = true;4708 bool first = true;
4704 foreach(auto displayPlugin, displayPlugins) {4709 foreach(auto displayPlugin, displayPlugins) {
4705 addDisplayPluginToMenu(displayPlugin, first);4710 addDisplayPluginToMenu(displayPlugin, first);
4706 QObject::connect(displayPlugin.data(), &DisplayPlugin::requestRender, [this] {4711 QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, [this] {
4707 paintGL();4712 paintGL();
4708 });4713 });
4709 QObject::connect(displayPlugin.data(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {4714 QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
4710 resizeGL();4715 resizeGL();
4711 });4716 });
4712 4717
@@ -4832,12 +4837,14 @@ void Application::updateInputModes() { · 119 unmodified lines
4832 foreach(auto inputPlugin, inputPlugins) {4837 foreach(auto inputPlugin, inputPlugins) {
4833 QString name = inputPlugin->getName();4838 QString name = inputPlugin->getName();
4834 QAction* action = menu->getActionForOption(name);4839 QAction* action = menu->getActionForOption(name);
4835 if (action->isChecked() && !_activeInputPlugins.contains(inputPlugin)) {4840
4836 _activeInputPlugins.append(inputPlugin);4841 auto it = std::find(std::begin(_activeInputPlugins), std::end(_activeInputPlugins), inputPlugin);
4837 newInputPlugins.append(inputPlugin);4842 if (action->isChecked() && it == std::end(_activeInputPlugins)) {
4838 } else if (!action->isChecked() && _activeInputPlugins.contains(inputPlugin)) {4843 _activeInputPlugins.push_back(inputPlugin);
4839 _activeInputPlugins.removeOne(inputPlugin);4844 newInputPlugins.push_back(inputPlugin);
4840 removedInputPlugins.append(inputPlugin);4845 } else if (!action->isChecked() && it != std::end(_activeInputPlugins)) {
4846 _activeInputPlugins.erase(it);
4847 removedInputPlugins.push_back(inputPlugin);
4841 }4848 }
4842 }4849 }
4843 4850