mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:58:27 +02:00
set up sixense/vive menu items with correct event forwarding
This commit is contained in:
parent
e3bc4b3b89
commit
505ef4c5cc
7 changed files with 31 additions and 14 deletions
|
@ -4870,13 +4870,15 @@ void Application::removeMenu(const QString& menuName) {
|
||||||
Menu::getInstance()->removeMenu(menuName);
|
Menu::getInstance()->removeMenu(menuName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName) {
|
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();
|
auto menu = Menu::getInstance();
|
||||||
MenuWrapper* parentItem = menu->getMenu(path);
|
MenuWrapper* parentItem = menu->getMenu(path);
|
||||||
QAction* action = parentItem->addAction(name);
|
QAction* action = parentItem->addAction(name);
|
||||||
connect(action, &QAction::triggered, [=] {
|
connect(action, &QAction::triggered, [=] {
|
||||||
onClicked();
|
onClicked(action->isChecked());
|
||||||
});
|
});
|
||||||
|
action->setCheckable(checkable);
|
||||||
|
action->setChecked(checked);
|
||||||
_currentDisplayPluginActions.push_back({ path, name });
|
_currentDisplayPluginActions.push_back({ path, name });
|
||||||
_currentInputPluginActions.push_back({ path, name });
|
_currentInputPluginActions.push_back({ path, name });
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ public:
|
||||||
// Plugin container support
|
// Plugin container support
|
||||||
virtual void addMenu(const QString& menuName);
|
virtual void addMenu(const QString& menuName);
|
||||||
virtual void removeMenu(const QString& menuName);
|
virtual void removeMenu(const QString& menuName);
|
||||||
virtual void addMenuItem(const QString& path, const QString& name, std::function<void()> onClicked, bool checkable, bool checked, const QString& groupName);
|
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 void removeMenuItem(const QString& menuName, const QString& menuItem);
|
||||||
virtual bool isOptionChecked(const QString& name);
|
virtual bool isOptionChecked(const QString& name);
|
||||||
virtual void setIsOptionChecked(const QString& path, bool checked);
|
virtual void setIsOptionChecked(const QString& path, bool checked);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "ControllerScriptingInterface.h"
|
#include "ControllerScriptingInterface.h"
|
||||||
|
|
||||||
// TODO: this needs to be removed, as well as any related controller-specific information
|
// TODO: this needs to be removed, as well as any related controller-specific information
|
||||||
#include <input-plugins\SixenseManager.h>
|
#include <input-plugins/SixenseManager.h>
|
||||||
|
|
||||||
|
|
||||||
ControllerScriptingInterface::ControllerScriptingInterface() :
|
ControllerScriptingInterface::ControllerScriptingInterface() :
|
||||||
|
|
|
@ -56,7 +56,6 @@ const QString SixenseManager::NAME = "Sixense";
|
||||||
const QString MENU_PARENT = "Avatar";
|
const QString MENU_PARENT = "Avatar";
|
||||||
const QString MENU_NAME = "Sixense";
|
const QString MENU_NAME = "Sixense";
|
||||||
const QString MENU_PATH = MENU_PARENT + ">" + MENU_NAME;
|
const QString MENU_PATH = MENU_PARENT + ">" + MENU_NAME;
|
||||||
const QString RENDER_CONTROLLERS = "Render Hand Controllers";
|
|
||||||
const QString TOGGLE_SMOOTH = "Smooth Sixense Movement";
|
const QString TOGGLE_SMOOTH = "Smooth Sixense Movement";
|
||||||
|
|
||||||
SixenseManager& SixenseManager::getInstance() {
|
SixenseManager& SixenseManager::getInstance() {
|
||||||
|
@ -91,11 +90,8 @@ void SixenseManager::activate(PluginContainer* container) {
|
||||||
|
|
||||||
container->addMenu(MENU_PATH);
|
container->addMenu(MENU_PATH);
|
||||||
container->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
container->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
||||||
[this, &container] { this->setFilter(container->isOptionChecked(TOGGLE_SMOOTH)); },
|
[this, container] (bool clicked) { this->setFilter(clicked); },
|
||||||
true, true);
|
true, true);
|
||||||
container->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
|
||||||
[this, &container] { /*this->setShouldRenderController(container->isOptionChecked(RENDER_CONTROLLERS));*/ },
|
|
||||||
true, true);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
@ -128,7 +124,6 @@ void SixenseManager::activate(PluginContainer* container) {
|
||||||
|
|
||||||
void SixenseManager::deactivate(PluginContainer* container) {
|
void SixenseManager::deactivate(PluginContainer* container) {
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
container->removeMenuItem(MENU_NAME, RENDER_CONTROLLERS);
|
|
||||||
container->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
container->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
||||||
container->removeMenu(MENU_PATH);
|
container->removeMenu(MENU_PATH);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <display-plugins\openvr\OpenVrHelpers.h>
|
#include <display-plugins/openvr/OpenVrHelpers.h>
|
||||||
#include "NumericalConstants.h"
|
#include "NumericalConstants.h"
|
||||||
|
#include <plugins/PluginContainer.h>
|
||||||
#include "UserActivityLogger.h"
|
#include "UserActivityLogger.h"
|
||||||
|
|
||||||
extern vr::IVRSystem* _hmd;
|
extern vr::IVRSystem* _hmd;
|
||||||
|
@ -44,12 +45,18 @@ const QString CONTROLLER_MODEL_STRING = "vr_controller_05_wireless_b";
|
||||||
|
|
||||||
const QString ViveControllerManager::NAME = "OpenVR";
|
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() :
|
ViveControllerManager::ViveControllerManager() :
|
||||||
InputDevice("SteamVR Controller"),
|
InputDevice("SteamVR Controller"),
|
||||||
_trackedControllers(0),
|
_trackedControllers(0),
|
||||||
_modelLoaded(false),
|
_modelLoaded(false),
|
||||||
_leftHandRenderID(0),
|
_leftHandRenderID(0),
|
||||||
_rightHandRenderID(0)
|
_rightHandRenderID(0),
|
||||||
|
_renderControllers(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +66,11 @@ bool ViveControllerManager::isSupported() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::activate(PluginContainer* container) {
|
void ViveControllerManager::activate(PluginContainer* container) {
|
||||||
|
container->addMenu(MENU_PATH);
|
||||||
|
container->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
||||||
|
[this, &container] (bool clicked) { this->setRenderControllers(clicked); },
|
||||||
|
true, true);
|
||||||
|
|
||||||
hmdRefCount++;
|
hmdRefCount++;
|
||||||
if (!_hmd) {
|
if (!_hmd) {
|
||||||
vr::HmdError eError = vr::HmdError_None;
|
vr::HmdError eError = vr::HmdError_None;
|
||||||
|
@ -111,10 +123,14 @@ void ViveControllerManager::activate(PluginContainer* container) {
|
||||||
_texture->autoGenerateMips(-1);
|
_texture->autoGenerateMips(-1);
|
||||||
|
|
||||||
_modelLoaded = true;
|
_modelLoaded = true;
|
||||||
|
_renderControllers = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::deactivate(PluginContainer* container) {
|
void ViveControllerManager::deactivate(PluginContainer* container) {
|
||||||
|
container->removeMenuItem(MENU_NAME, RENDER_CONTROLLERS);
|
||||||
|
container->removeMenu(MENU_PATH);
|
||||||
|
|
||||||
hmdRefCount--;
|
hmdRefCount--;
|
||||||
|
|
||||||
if (hmdRefCount == 0 && _hmd) {
|
if (hmdRefCount == 0 && _hmd) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
AXIS_3,
|
AXIS_3,
|
||||||
AXIS_4,
|
AXIS_4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum JointChannel {
|
enum JointChannel {
|
||||||
LEFT_HAND = 0,
|
LEFT_HAND = 0,
|
||||||
RIGHT_HAND,
|
RIGHT_HAND,
|
||||||
|
@ -68,6 +68,8 @@ public:
|
||||||
virtual void focusOutEvent() override;
|
virtual void focusOutEvent() override;
|
||||||
|
|
||||||
void updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges);
|
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(unsigned int button, int index);
|
||||||
UserInputMapper::Input makeInput(JoystickAxisChannel axis, int index);
|
UserInputMapper::Input makeInput(JoystickAxisChannel axis, int index);
|
||||||
|
@ -86,6 +88,8 @@ private:
|
||||||
model::Geometry _modelGeometry;
|
model::Geometry _modelGeometry;
|
||||||
gpu::TexturePointer _texture;
|
gpu::TexturePointer _texture;
|
||||||
|
|
||||||
|
bool _renderControllers;
|
||||||
|
|
||||||
int _leftHandRenderID;
|
int _leftHandRenderID;
|
||||||
int _rightHandRenderID;
|
int _rightHandRenderID;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class PluginContainer {
|
||||||
public:
|
public:
|
||||||
virtual void addMenu(const QString& menuName) = 0;
|
virtual void addMenu(const QString& menuName) = 0;
|
||||||
virtual void removeMenu(const QString& menuName) = 0;
|
virtual void removeMenu(const QString& menuName) = 0;
|
||||||
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 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 void removeMenuItem(const QString& menuName, const QString& menuItem) = 0;
|
||||||
virtual bool isOptionChecked(const QString& name) = 0;
|
virtual bool isOptionChecked(const QString& name) = 0;
|
||||||
virtual void setIsOptionChecked(const QString& path, bool checked) = 0;
|
virtual void setIsOptionChecked(const QString& path, bool checked) = 0;
|
||||||
|
|
Loading…
Reference in a new issue