mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge remote-tracking branch 'sam2/sam/input-plugins' into plugins
This commit is contained in:
commit
4ad72be0c7
28 changed files with 191 additions and 56 deletions
|
@ -143,6 +143,7 @@
|
|||
#include "ui/AddressBarDialog.h"
|
||||
#include "ui/UpdateDialog.h"
|
||||
|
||||
#include <qopenglcontext.h>
|
||||
|
||||
// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
|
||||
#if defined(Q_OS_WIN)
|
||||
|
@ -754,14 +755,14 @@ Application::~Application() {
|
|||
|
||||
ModelEntityItem::cleanupLoadedAnimations();
|
||||
|
||||
getActiveDisplayPlugin()->deactivate();
|
||||
getActiveDisplayPlugin()->deactivate(this);
|
||||
|
||||
auto inputPlugins = getInputPlugins();
|
||||
foreach(auto inputPlugin, inputPlugins) {
|
||||
QString name = inputPlugin->getName();
|
||||
QAction* action = Menu::getInstance()->getActionForOption(name);
|
||||
if (action->isChecked()) {
|
||||
inputPlugin->deactivate();
|
||||
inputPlugin->deactivate(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4773,7 +4774,7 @@ void Application::updateDisplayMode() {
|
|||
_displayPlugin = newDisplayPlugin;
|
||||
|
||||
if (oldDisplayPlugin) {
|
||||
oldDisplayPlugin->deactivate();
|
||||
oldDisplayPlugin->deactivate(this);
|
||||
_offscreenContext->makeCurrent();
|
||||
}
|
||||
}
|
||||
|
@ -4811,7 +4812,7 @@ void Application::updateInputModes() {
|
|||
}
|
||||
if (removedInputPlugins.size() > 0) { // A plugin was unchecked
|
||||
foreach(auto removedInputPlugin, removedInputPlugins) {
|
||||
removedInputPlugin->deactivate();
|
||||
removedInputPlugin->deactivate(this);
|
||||
//removedInputPlugin->removeEventFilter(qApp);
|
||||
//removedInputPlugin->removeEventFilter(offscreenUi.data());
|
||||
}
|
||||
|
@ -4828,17 +4829,39 @@ void Application::updateInputModes() {
|
|||
//}
|
||||
}
|
||||
|
||||
void Application::addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName) {
|
||||
void Application::addMenu(const QString& menuName) {
|
||||
Menu::getInstance()->addMenu(menuName);
|
||||
}
|
||||
|
||||
void Application::removeMenu(const QString& menuName) {
|
||||
Menu::getInstance()->removeMenu(menuName);
|
||||
}
|
||||
|
||||
void Application::addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {
|
||||
auto menu = Menu::getInstance();
|
||||
MenuWrapper* parentItem = menu->getMenu(path);
|
||||
QAction* action = parentItem->addAction(name);
|
||||
connect(action, &QAction::triggered, [=] {
|
||||
onClicked();
|
||||
onClicked(action->isChecked());
|
||||
});
|
||||
action->setCheckable(checkable);
|
||||
action->setChecked(checked);
|
||||
_currentDisplayPluginActions.push_back({ path, name });
|
||||
_currentInputPluginActions.push_back({ path, name });
|
||||
}
|
||||
|
||||
void Application::removeMenuItem(const QString& menuName, const QString& menuItem) {
|
||||
Menu::getInstance()->removeMenuItem(menuName, menuItem);
|
||||
}
|
||||
|
||||
bool Application::isOptionChecked(const QString& name) {
|
||||
return Menu::getInstance()->isOptionChecked(name);
|
||||
}
|
||||
|
||||
void Application::setIsOptionChecked(const QString& path, bool checked) {
|
||||
Menu::getInstance()->setIsOptionChecked(path, checked);
|
||||
}
|
||||
|
||||
GlWindow* Application::getVisibleWindow() {
|
||||
return _glWindow;
|
||||
}
|
||||
|
|
|
@ -279,7 +279,12 @@ public:
|
|||
virtual qreal getDevicePixelRatio();
|
||||
|
||||
// Plugin container support
|
||||
virtual void addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName);
|
||||
virtual void addMenu(const QString& menuName);
|
||||
virtual void removeMenu(const QString& menuName);
|
||||
virtual void addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName);
|
||||
virtual void removeMenuItem(const QString& menuName, const QString& menuItem);
|
||||
virtual bool isOptionChecked(const QString& name);
|
||||
virtual void setIsOptionChecked(const QString& path, bool checked);
|
||||
virtual GlWindow* getVisibleWindow();
|
||||
|
||||
private:
|
||||
|
|
|
@ -45,7 +45,7 @@ const InputPluginList& getInputPlugins() {
|
|||
InputPlugin* PLUGIN_POOL[] = {
|
||||
new KeyboardMouseDevice(),
|
||||
new SDL2Manager(),
|
||||
// Sixense is causing some sort of memory corruption on OSX
|
||||
// Sixense is causing some sort of memory corruption on OSX
|
||||
#ifndef Q_OS_MAC
|
||||
new SixenseManager(),
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "devices/DdeFaceTracker.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/RealSense.h"
|
||||
#include <input-plugins/SixenseManager.h> // TODO: should be able to remove this once input plugin architecture is finished
|
||||
#include "MainWindow.h"
|
||||
#include "scripting/MenuScriptingInterface.h"
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
|
@ -443,14 +442,6 @@ Menu::Menu() {
|
|||
qApp, SLOT(setLowVelocityFilter(bool)));
|
||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
|
||||
|
||||
MenuWrapper* sixenseOptionsMenu = handOptionsMenu->addMenu("Sixense");
|
||||
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu,
|
||||
MenuOption::FilterSixense,
|
||||
0,
|
||||
true,
|
||||
&SixenseManager::getInstance(),
|
||||
SLOT(setFilter(bool)));
|
||||
|
||||
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
|
||||
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);
|
||||
|
||||
|
|
|
@ -190,7 +190,6 @@ namespace MenuOption {
|
|||
const QString ExpandPaintGLTiming = "Expand /paintGL";
|
||||
const QString ExpandUpdateTiming = "Expand /update";
|
||||
const QString Faceshift = "Faceshift";
|
||||
const QString FilterSixense = "Smooth Sixense Movement";
|
||||
const QString FirstPerson = "First Person";
|
||||
const QString Forward = "Forward";
|
||||
const QString FrameTimer = "Show Timer";
|
||||
|
@ -271,7 +270,6 @@ namespace MenuOption {
|
|||
const QString ShowRealtimeEntityStats = "Show Realtime Entity Stats";
|
||||
const QString ShowWhosLookingAtMe = "Show Who's Looking at Me";
|
||||
const QString SimpleShadows = "Simple";
|
||||
const QString SixenseEnabled = "Enable Hydra Support";
|
||||
const QString ShiftHipsForIdleAnimations = "Shift hips for idle animations";
|
||||
const QString StandingHMDSensorMode = "Standing HMD Sensor Mode";
|
||||
const QString Stars = "Stars";
|
||||
|
|
|
@ -7,8 +7,76 @@
|
|||
//
|
||||
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
||||
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <QWindow>
|
||||
|
||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("2D Display");
|
||||
|
||||
const QString & Basic2DWindowOpenGLDisplayPlugin::getName() const {
|
||||
const QString MENU_PARENT = "View";
|
||||
const QString MENU_NAME = "Display Options";
|
||||
const QString MENU_PATH = MENU_PARENT + ">" + MENU_NAME;
|
||||
const QString FULLSCREEN = "Fullscreen";
|
||||
|
||||
const QString& Basic2DWindowOpenGLDisplayPlugin::getName() const {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::activate(PluginContainer* container) {
|
||||
// container->addMenu(MENU_PATH);
|
||||
// container->addMenuItem(MENU_PATH, FULLSCREEN,
|
||||
// [this] (bool clicked) { this->setFullscreen(clicked); },
|
||||
// true, false);
|
||||
MainWindowOpenGLDisplayPlugin::activate(container);
|
||||
}
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
||||
// container->removeMenuItem(MENU_NAME, FULLSCREEN);
|
||||
// container->removeMenu(MENU_PATH);
|
||||
MainWindowOpenGLDisplayPlugin::deactivate(container);
|
||||
}
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::setFullscreen(bool fullscreen) {
|
||||
// The following code block is useful on platforms that can have a visible
|
||||
// app menu in a fullscreen window. However the OSX mechanism hides the
|
||||
// application menu for fullscreen apps, so the check is not required.
|
||||
//#ifndef Q_OS_MAC
|
||||
// if (fullscreen) {
|
||||
// // Move menu to a QWidget floating above _glWidget so that show/hide doesn't adjust viewport.
|
||||
// _menuBarHeight = Menu::getInstance()->height();
|
||||
// Menu::getInstance()->setParent(_fullscreenMenuWidget);
|
||||
// Menu::getInstance()->setFixedWidth(_window->windowHandle()->screen()->size().width());
|
||||
// _fullscreenMenuWidget->show();
|
||||
// }
|
||||
// else {
|
||||
// // Restore menu to being part of MainWindow.
|
||||
// _fullscreenMenuWidget->hide();
|
||||
// _window->setMenuBar(Menu::getInstance());
|
||||
// _window->menuBar()->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
// }
|
||||
//#endif
|
||||
|
||||
// Work around Qt bug that prevents floating menus being shown when in fullscreen mode.
|
||||
// https://bugreports.qt.io/browse/QTBUG-41883
|
||||
// Known issue: Top-level menu items don't highlight when cursor hovers. This is probably a side-effect of the work-around.
|
||||
// TODO: Remove this work-around once the bug has been fixed and restore the following lines.
|
||||
//_window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
|
||||
// (_window->windowState() & ~Qt::WindowFullScreen));
|
||||
auto window = this->getWindow();
|
||||
window->hide();
|
||||
if (fullscreen) {
|
||||
auto state = window->windowState() | Qt::WindowFullScreen;
|
||||
window->setWindowState(Qt::WindowState((int)state));
|
||||
// The next line produces the following warning in the log:
|
||||
// [WARNING][03 / 06 12:17 : 58] QWidget::setMinimumSize: (/ MainWindow) Negative sizes
|
||||
// (0, -1) are not possible
|
||||
// This is better than the alternative which is to have the window slightly less than fullscreen with a visible line
|
||||
// of pixels for the remainder of the screen.
|
||||
//window->setContentsMargins(0, 0, 0, -1);
|
||||
}
|
||||
else {
|
||||
window->setWindowState(Qt::WindowState(window->windowState() & ~Qt::WindowFullScreen));
|
||||
//window->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
window->show();
|
||||
}
|
||||
|
|
|
@ -13,8 +13,14 @@ class Basic2DWindowOpenGLDisplayPlugin : public MainWindowOpenGLDisplayPlugin {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual const QString & getName() const override;
|
||||
|
||||
public slots:
|
||||
void setFullscreen(bool fullscreen);
|
||||
|
||||
private:
|
||||
static const QString NAME;
|
||||
};
|
||||
|
|
|
@ -33,4 +33,4 @@ void NullDisplayPlugin::display(GLuint sceneTexture, const glm::uvec2& sceneSize
|
|||
void NullDisplayPlugin::finishFrame() {}
|
||||
|
||||
void NullDisplayPlugin::activate(PluginContainer * container) {}
|
||||
void NullDisplayPlugin::deactivate() {}
|
||||
void NullDisplayPlugin::deactivate(PluginContainer* container) {}
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
virtual const QString & getName() const override;
|
||||
|
||||
void activate(PluginContainer * container) override;
|
||||
void deactivate() override;
|
||||
void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual glm::uvec2 getRecommendedRenderSize() const override;
|
||||
virtual bool hasFocus() const override;
|
||||
|
|
|
@ -72,7 +72,7 @@ void OpenGLDisplayPlugin::activate(PluginContainer * container) {
|
|||
_timer.start(1);
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::deactivate() {
|
||||
void OpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
||||
_timer.stop();
|
||||
|
||||
makeCurrent();
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
virtual void preDisplay() override;
|
||||
virtual void finishFrame() override;
|
||||
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void activate(PluginContainer* container) override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ void WindowOpenGLDisplayPlugin::activate(PluginContainer * container) {
|
|||
customizeContext(container);
|
||||
}
|
||||
|
||||
void WindowOpenGLDisplayPlugin::deactivate() {
|
||||
OpenGLDisplayPlugin::deactivate();
|
||||
void WindowOpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
||||
OpenGLDisplayPlugin::deactivate(container);
|
||||
destroyWindow();
|
||||
_window = nullptr;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
virtual bool hasFocus() const override;
|
||||
virtual QWindow* getWindow() const override;
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
virtual void installEventFilter(QObject* filter) override;
|
||||
virtual void removeEventFilter(QObject* filter) override;
|
||||
|
||||
|
|
|
@ -99,11 +99,11 @@ void Oculus_0_5_DisplayPlugin::activate(PluginContainer * container) {
|
|||
Q_ASSERT(result);
|
||||
}
|
||||
|
||||
void Oculus_0_5_DisplayPlugin::deactivate() {
|
||||
void Oculus_0_5_DisplayPlugin::deactivate(PluginContainer* container) {
|
||||
_hmdWindow->deleteLater();
|
||||
_hmdWindow = nullptr;
|
||||
|
||||
OculusBaseDisplayPlugin::deactivate();
|
||||
OculusBaseDisplayPlugin::deactivate(container);
|
||||
|
||||
ovrHmd_Destroy(_hmd);
|
||||
_hmd = nullptr;
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
virtual const QString & getName() const override;
|
||||
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
|
||||
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
|
|
|
@ -220,14 +220,14 @@ void Oculus_0_6_DisplayPlugin::customizeContext(PluginContainer * container) {
|
|||
_sceneFbo->Init(getRecommendedRenderSize());
|
||||
}
|
||||
|
||||
void Oculus_0_6_DisplayPlugin::deactivate() {
|
||||
void Oculus_0_6_DisplayPlugin::deactivate(PluginContainer* container) {
|
||||
makeCurrent();
|
||||
_sceneFbo.reset();
|
||||
_mirrorFbo.reset();
|
||||
doneCurrent();
|
||||
PerformanceTimer::setActive(false);
|
||||
|
||||
OculusBaseDisplayPlugin::deactivate();
|
||||
OculusBaseDisplayPlugin::deactivate(container);
|
||||
|
||||
ovrHmd_Destroy(_hmd);
|
||||
_hmd = nullptr;
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
virtual const QString & getName() const override;
|
||||
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
|
||||
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
|
|
|
@ -31,6 +31,8 @@ Q_LOGGING_CATEGORY(displayplugins, "hifi.displayplugins")
|
|||
|
||||
const QString OpenVrDisplayPlugin::NAME("OpenVR (Vive)");
|
||||
|
||||
const QString StandingHMDSensorMode = "Standing HMD Sensor Mode"; // this probably shouldn't be hardcoded here
|
||||
|
||||
const QString & OpenVrDisplayPlugin::getName() const {
|
||||
return NAME;
|
||||
}
|
||||
|
@ -80,6 +82,8 @@ bool OpenVrDisplayPlugin::isSupported() const {
|
|||
}
|
||||
|
||||
void OpenVrDisplayPlugin::activate(PluginContainer * container) {
|
||||
container->setIsOptionChecked(StandingHMDSensorMode, true);
|
||||
|
||||
hmdRefCount++;
|
||||
vr::HmdError eError = vr::HmdError_None;
|
||||
if (!_hmd) {
|
||||
|
@ -120,7 +124,9 @@ void OpenVrDisplayPlugin::activate(PluginContainer * container) {
|
|||
MainWindowOpenGLDisplayPlugin::activate(container);
|
||||
}
|
||||
|
||||
void OpenVrDisplayPlugin::deactivate() {
|
||||
void OpenVrDisplayPlugin::deactivate(PluginContainer* container) {
|
||||
container->setIsOptionChecked(StandingHMDSensorMode, false);
|
||||
|
||||
hmdRefCount--;
|
||||
|
||||
if (hmdRefCount == 0 && _hmd) {
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
virtual bool isHmd() const override { return true; }
|
||||
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual glm::uvec2 getRecommendedRenderSize() const override;
|
||||
virtual glm::uvec2 getRecommendedUiSize() const override { return uvec2(1920, 1080); }
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
const QString& getName() const { return NAME; }
|
||||
|
||||
virtual void activate(PluginContainer * container) override {};
|
||||
virtual void deactivate() override {};
|
||||
virtual void deactivate(PluginContainer* container) override {};
|
||||
|
||||
virtual void pluginFocusOutEvent() override { focusOutEvent(); }
|
||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override { update(deltaTime, jointsCaptured); }
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual void init() override;
|
||||
virtual void deinit() override;
|
||||
virtual void activate(PluginContainer * container) override {};
|
||||
virtual void deactivate() override {};
|
||||
virtual void deactivate(PluginContainer* container) override {};
|
||||
|
||||
virtual void pluginFocusOutEvent() override;
|
||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <NumericalConstants.h>
|
||||
|
||||
#include "NumericalConstants.h"
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include "SixenseManager.h"
|
||||
#include "UserActivityLogger.h"
|
||||
|
||||
|
@ -52,6 +53,11 @@ typedef int (*SixenseTakeIntAndSixenseControllerData)(int, sixenseControllerData
|
|||
|
||||
const QString SixenseManager::NAME = "Sixense";
|
||||
|
||||
const QString MENU_PARENT = "Avatar";
|
||||
const QString MENU_NAME = "Sixense";
|
||||
const QString MENU_PATH = MENU_PARENT + ">" + MENU_NAME;
|
||||
const QString TOGGLE_SMOOTH = "Smooth Sixense Movement";
|
||||
|
||||
SixenseManager& SixenseManager::getInstance() {
|
||||
static SixenseManager sharedInstance;
|
||||
return sharedInstance;
|
||||
|
@ -69,7 +75,7 @@ SixenseManager::SixenseManager() :
|
|||
|
||||
bool SixenseManager::isSupported() const {
|
||||
#ifdef HAVE_SIXENSE
|
||||
return false;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -82,6 +88,11 @@ void SixenseManager::activate(PluginContainer* container) {
|
|||
// as the "torso" is below it.
|
||||
_neckBase = glm::vec3(NECK_X, -NECK_Y, NECK_Z);
|
||||
|
||||
container->addMenu(MENU_PATH);
|
||||
container->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
||||
[this] (bool clicked) { this->setFilter(clicked); },
|
||||
true, true);
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
if (!_sixenseLibrary) {
|
||||
|
@ -111,8 +122,12 @@ void SixenseManager::activate(PluginContainer* container) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void SixenseManager::deinit() {
|
||||
#ifdef HAVE_SIXENSE_
|
||||
void SixenseManager::deactivate(PluginContainer* container) {
|
||||
#ifdef HAVE_SIXENSE
|
||||
container->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
||||
container->removeMenu(MENU_PATH);
|
||||
|
||||
_poseStateMap.clear();
|
||||
|
||||
#ifdef __APPLE__
|
||||
SixenseBaseFunction sixenseExit = (SixenseBaseFunction)_sixenseLibrary->resolve("sixenseExit");
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "sixense.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <QCoreApplication>
|
||||
#include <qlibrary.h>
|
||||
#endif
|
||||
|
||||
|
@ -62,9 +63,8 @@ public:
|
|||
virtual bool isJointController() const override { return true; }
|
||||
const QString& getName() const { return NAME; }
|
||||
|
||||
virtual void deinit() override;
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override { _poseStateMap.clear(); }
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual void pluginFocusOutEvent() override { focusOutEvent(); }
|
||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override { update(deltaTime, jointsCaptured); }
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <DeferredLightingEffect.h>
|
||||
#include <display-plugins/openvr/OpenVrHelpers.h>
|
||||
#include "NumericalConstants.h"
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include "UserActivityLogger.h"
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
|
@ -46,12 +47,18 @@ const QString CONTROLLER_MODEL_STRING = "vr_controller_05_wireless_b";
|
|||
|
||||
const QString ViveControllerManager::NAME = "OpenVR";
|
||||
|
||||
const QString MENU_PARENT = "Avatar";
|
||||
const QString MENU_NAME = "Vive Controllers";
|
||||
const QString MENU_PATH = MENU_PARENT + ">" + MENU_NAME;
|
||||
const QString RENDER_CONTROLLERS = "Render Hand Controllers";
|
||||
|
||||
ViveControllerManager::ViveControllerManager() :
|
||||
InputDevice("SteamVR Controller"),
|
||||
_trackedControllers(0),
|
||||
_modelLoaded(false),
|
||||
_leftHandRenderID(0),
|
||||
_rightHandRenderID(0)
|
||||
_rightHandRenderID(0),
|
||||
_renderControllers(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -66,6 +73,11 @@ bool ViveControllerManager::isSupported() const {
|
|||
|
||||
void ViveControllerManager::activate(PluginContainer* container) {
|
||||
#ifndef Q_OS_MAC
|
||||
container->addMenu(MENU_PATH);
|
||||
container->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
||||
[this] (bool clicked) { this->setRenderControllers(clicked); },
|
||||
true, true);
|
||||
|
||||
hmdRefCount++;
|
||||
if (!_hmd) {
|
||||
vr::HmdError eError = vr::HmdError_None;
|
||||
|
@ -118,12 +130,16 @@ void ViveControllerManager::activate(PluginContainer* container) {
|
|||
_texture->autoGenerateMips(-1);
|
||||
|
||||
_modelLoaded = true;
|
||||
_renderControllers = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ViveControllerManager::deactivate() {
|
||||
void ViveControllerManager::deactivate(PluginContainer* container) {
|
||||
#ifndef Q_OS_MAC
|
||||
container->removeMenuItem(MENU_NAME, RENDER_CONTROLLERS);
|
||||
container->removeMenu(MENU_PATH);
|
||||
|
||||
hmdRefCount--;
|
||||
|
||||
if (hmdRefCount == 0 && _hmd) {
|
||||
|
@ -199,18 +215,18 @@ void ViveControllerManager::renderHand(UserInputMapper::PoseValue pose, gpu::Bat
|
|||
void ViveControllerManager::update(float deltaTime, bool jointsCaptured) {
|
||||
#ifndef Q_OS_MAC
|
||||
_poseStateMap.clear();
|
||||
|
||||
// TODO: This shouldn't be necessary
|
||||
if (!_hmd) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
_buttonPressedMap.clear();
|
||||
|
||||
|
||||
PerformanceTimer perfTimer("ViveControllerManager::update");
|
||||
|
||||
int numTrackedControllers = 0;
|
||||
|
||||
|
||||
for (vr::TrackedDeviceIndex_t device = vr::k_unTrackedDeviceIndex_Hmd + 1;
|
||||
device < vr::k_unMaxTrackedDeviceCount && numTrackedControllers < 2; ++device) {
|
||||
|
||||
|
@ -360,7 +376,6 @@ void ViveControllerManager::registerToUserInputMapper(UserInputMapper& mapper) {
|
|||
|
||||
void ViveControllerManager::assignDefaultInputMapping(UserInputMapper& mapper) {
|
||||
const float JOYSTICK_MOVE_SPEED = 1.0f;
|
||||
const float BOOM_SPEED = 0.1f;
|
||||
|
||||
// Left Trackpad: Movement, strafing
|
||||
mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(AXIS_Y_POS, 0), makeInput(TRACKPAD_BUTTON, 0), JOYSTICK_MOVE_SPEED);
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
AXIS_3,
|
||||
AXIS_4,
|
||||
};
|
||||
|
||||
|
||||
enum JointChannel {
|
||||
LEFT_HAND = 0,
|
||||
RIGHT_HAND,
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
const QString& getName() const { return NAME; }
|
||||
|
||||
virtual void activate(PluginContainer * container) override;
|
||||
virtual void deactivate() override;
|
||||
virtual void deactivate(PluginContainer* container) override;
|
||||
|
||||
virtual void pluginFocusOutEvent() override { focusOutEvent(); }
|
||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) override { update(deltaTime, jointsCaptured); }
|
||||
|
@ -68,6 +68,8 @@ public:
|
|||
virtual void focusOutEvent() override;
|
||||
|
||||
void updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges);
|
||||
|
||||
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
||||
|
||||
UserInputMapper::Input makeInput(unsigned int button, int index);
|
||||
UserInputMapper::Input makeInput(JoystickAxisChannel axis, int index);
|
||||
|
@ -89,6 +91,8 @@ private:
|
|||
int _leftHandRenderID;
|
||||
int _rightHandRenderID;
|
||||
|
||||
bool _renderControllers;
|
||||
|
||||
static const QString NAME;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ public:
|
|||
virtual void deinit();
|
||||
|
||||
/// Called when a plugin is being activated for use. May be called multiple times.
|
||||
virtual void activate(PluginContainer * container) = 0;
|
||||
virtual void activate(PluginContainer* container) = 0;
|
||||
/// Called when a plugin is no longer being used. May be called multiple times.
|
||||
virtual void deactivate() = 0;
|
||||
virtual void deactivate(PluginContainer* container) = 0;
|
||||
|
||||
/**
|
||||
* Called by the application during it's idle phase. If the plugin needs to do
|
||||
|
|
|
@ -7,6 +7,11 @@ class GlWindow;
|
|||
|
||||
class PluginContainer {
|
||||
public:
|
||||
virtual void addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "") = 0;
|
||||
virtual void addMenu(const QString& menuName) = 0;
|
||||
virtual void removeMenu(const QString& menuName) = 0;
|
||||
virtual void addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "") = 0;
|
||||
virtual void removeMenuItem(const QString& menuName, const QString& menuItem) = 0;
|
||||
virtual bool isOptionChecked(const QString& name) = 0;
|
||||
virtual void setIsOptionChecked(const QString& path, bool checked) = 0;
|
||||
virtual GlWindow* getVisibleWindow() = 0;
|
||||
};
|
||||
|
|
|
@ -213,7 +213,6 @@ public:
|
|||
ShowBordersEntityNodes,
|
||||
ShowIKConstraints,
|
||||
SimpleShadows,
|
||||
SixenseEnabled,
|
||||
ShiftHipsForIdleAnimations,
|
||||
Stars,
|
||||
Stats,
|
||||
|
|
Loading…
Reference in a new issue