mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 04:00:37 -06:00
@@ -216,21 +216,20 @@ void checkJoystickStatus() {
|
||||
state.isConnected = true;
|
||||
state.name = glfwGetJoystickName(i);
|
||||
|
||||
std::fill(state.axes.begin(), state.axes.end(), 0.f);
|
||||
std::fill(state.buttons.begin(), state.buttons.end(), JoystickAction::Idle);
|
||||
|
||||
// Check axes and buttons
|
||||
glfwGetJoystickAxes(i, &state.nAxes);
|
||||
glfwGetJoystickButtons(i, &state.nButtons);
|
||||
state.axes.resize(state.nAxes);
|
||||
state.buttons.resize(state.nButtons);
|
||||
|
||||
std::fill(state.axes.begin(), state.axes.end(), 0.f);
|
||||
std::fill(state.buttons.begin(), state.buttons.end(), JoystickAction::Idle);
|
||||
}
|
||||
|
||||
const float* axes = glfwGetJoystickAxes(i, &state.nAxes);
|
||||
state.axes.resize(state.nAxes);
|
||||
std::memcpy(state.axes.data(), axes, state.nAxes * sizeof(float));
|
||||
|
||||
const unsigned char* buttons = glfwGetJoystickButtons(i, &state.nButtons);
|
||||
state.buttons.resize(state.nButtons);
|
||||
|
||||
for (int j = 0; j < state.nButtons; ++j) {
|
||||
const bool currentlyPressed = buttons[j] == GLFW_PRESS;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
@@ -63,7 +64,10 @@ void JoystickCameraStates::updateStateFromInput(
|
||||
}
|
||||
|
||||
int nAxes = joystickInputStates.numAxes(joystickInputState.name);
|
||||
for (int i = 0; i < nAxes; ++i) {
|
||||
for (int i = 0;
|
||||
i < std::min(static_cast<size_t>(nAxes), joystick->axisMapping.size());
|
||||
++i)
|
||||
{
|
||||
AxisInformation t = joystick->axisMapping[i];
|
||||
if (t.type == AxisType::None) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user