mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:57:37 +02:00
Scratch that; going to shoehorn joystick data into palms.
This commit is contained in:
parent
20eadab970
commit
c42368594d
3 changed files with 3 additions and 33 deletions
|
@ -44,16 +44,10 @@ JoystickManager::~JoystickManager() {
|
|||
#endif
|
||||
}
|
||||
|
||||
QVector<JoystickState> JoystickManager::getJoystickStates() {
|
||||
QMutexLocker locker(&_joystickMutex);
|
||||
return _joystickStates;
|
||||
}
|
||||
|
||||
void JoystickManager::update() {
|
||||
#ifdef HAVE_SDL
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
QMutexLocker locker(&_joystickMutex);
|
||||
for (int i = 0; i < _joystickStates.size(); i++) {
|
||||
SDL_Joystick* joystick = _joysticks.at(i);
|
||||
JoystickState& state = _joystickStates[i];
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#ifndef hifi_JoystickManager_h
|
||||
#define hifi_JoystickManager_h
|
||||
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
|
@ -32,13 +31,12 @@ public:
|
|||
JoystickManager();
|
||||
virtual ~JoystickManager();
|
||||
|
||||
QVector<JoystickState> getJoystickStates();
|
||||
const QVector<JoystickState>& getJoystickStates() const { return _joystickStates; }
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
QVector<JoystickState> _joystickStates;
|
||||
QMutex _joystickMutex;
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
QVector<SDL_Joystick*> _joysticks;
|
||||
|
|
|
@ -74,7 +74,6 @@ bool ControllerScriptingInterface::isPrimaryButtonPressed() const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,24 +87,10 @@ glm::vec2 ControllerScriptingInterface::getPrimaryJoystickPosition() const {
|
|||
}
|
||||
|
||||
int ControllerScriptingInterface::getNumberOfButtons() const {
|
||||
int buttonCount = 0;
|
||||
foreach (const JoystickState& state, Application::getInstance()->getJoystickManager()->getJoystickStates()) {
|
||||
buttonCount += state.buttons.size();
|
||||
}
|
||||
return buttonCount + getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM;
|
||||
return getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM;
|
||||
}
|
||||
|
||||
bool ControllerScriptingInterface::isButtonPressed(int buttonIndex) const {
|
||||
int managedButtonIndex = buttonIndex - getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM;
|
||||
if (managedButtonIndex >= 0) {
|
||||
foreach (const JoystickState& state, Application::getInstance()->getJoystickManager()->getJoystickStates()) {
|
||||
if (managedButtonIndex < state.buttons.size()) {
|
||||
return state.buttons.at(managedButtonIndex);
|
||||
}
|
||||
managedButtonIndex -= state.buttons.size();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int palmIndex = buttonIndex / NUMBER_OF_BUTTONS_PER_PALM;
|
||||
int buttonOnPalm = buttonIndex % NUMBER_OF_BUTTONS_PER_PALM;
|
||||
const PalmData* palmData = getActivePalm(palmIndex);
|
||||
|
@ -143,18 +128,11 @@ float ControllerScriptingInterface::getTriggerValue(int triggerIndex) const {
|
|||
}
|
||||
|
||||
int ControllerScriptingInterface::getNumberOfJoysticks() const {
|
||||
return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM +
|
||||
Application::getInstance()->getJoystickManager()->getJoystickStates().size();
|
||||
return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM;
|
||||
}
|
||||
|
||||
glm::vec2 ControllerScriptingInterface::getJoystickPosition(int joystickIndex) const {
|
||||
// we know there's one joystick per palm, so the joystickIndex is the palm Index
|
||||
int managedJoystickIndex = joystickIndex - getNumberOfActivePalms();
|
||||
if (managedJoystickIndex >= 0) {
|
||||
const JoystickState& state = Application::getInstance()->getJoystickManager()->getJoystickStates().at(
|
||||
managedJoystickIndex);
|
||||
return glm::vec2(state.axes.size() > 0 ? state.axes.at(0) : 0.0f, state.axes.size() > 1 ? state.axes.at(1) : 0.0f);
|
||||
}
|
||||
int palmIndex = joystickIndex;
|
||||
const PalmData* palmData = getActivePalm(palmIndex);
|
||||
if (palmData) {
|
||||
|
|
Loading…
Reference in a new issue