mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
map PrioVR to new JoystickScriptingInterface
This commit is contained in:
parent
13d3eb02e3
commit
9348888ae5
2 changed files with 17 additions and 9 deletions
|
@ -39,6 +39,9 @@ public:
|
|||
|
||||
const QString& getName() const { return _name; }
|
||||
|
||||
const QVector<float>& getAxes() const { return _axes; }
|
||||
const QVector<bool>& getButtons() const { return _buttons; }
|
||||
|
||||
int getNumAxes() const { return _axes.size(); }
|
||||
int getNumButtons() const { return _buttons.size(); }
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "Application.h"
|
||||
#include "PrioVR.h"
|
||||
#include "scripting/JoystickScriptingInterface.h"
|
||||
#include "ui/TextRenderer.h"
|
||||
|
||||
#ifdef HAVE_PRIOVR
|
||||
|
@ -61,18 +62,22 @@ static void setPalm(float deltaTime, int index) {
|
|||
palm->setActive(true);
|
||||
|
||||
// Read controller buttons and joystick into the hand
|
||||
if (!Application::getInstance()->getJoystickManager()->getJoysticks().isEmpty()) {
|
||||
const JoystickState& state = Application::getInstance()->getJoystickManager()->getJoystickStates().at(0);
|
||||
if (state.axes.size() >= 4 && state.buttons.size() >= 4) {
|
||||
const QString PRIO_JOYSTICK_NAME = "PrioVR";
|
||||
Joystick* prioJoystick = JoystickScriptingInterface::getInstance().joystickWithName(PRIO_JOYSTICK_NAME);
|
||||
if (prioJoystick) {
|
||||
const QVector<float> axes = prioJoystick->getAxes();
|
||||
const QVector<bool> buttons = prioJoystick->getButtons();
|
||||
|
||||
if (axes.size() >= 4 && buttons.size() >= 4) {
|
||||
if (index == LEFT_HAND_INDEX) {
|
||||
palm->setControllerButtons(state.buttons.at(1) ? BUTTON_FWD : 0);
|
||||
palm->setTrigger(state.buttons.at(0) ? 1.0f : 0.0f);
|
||||
palm->setJoystick(state.axes.at(0), -state.axes.at(1));
|
||||
palm->setControllerButtons(buttons[1] ? BUTTON_FWD : 0);
|
||||
palm->setTrigger(buttons[0] ? 1.0f : 0.0f);
|
||||
palm->setJoystick(axes[0], -axes[1]);
|
||||
|
||||
} else {
|
||||
palm->setControllerButtons(state.buttons.at(3) ? BUTTON_FWD : 0);
|
||||
palm->setTrigger(state.buttons.at(2) ? 1.0f : 0.0f);
|
||||
palm->setJoystick(state.axes.at(2), -state.axes.at(3));
|
||||
palm->setControllerButtons(buttons[3] ? BUTTON_FWD : 0);
|
||||
palm->setTrigger(buttons[2] ? 1.0f : 0.0f);
|
||||
palm->setJoystick(axes[2], -axes[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue