Fix OSC value sending and butons

This commit is contained in:
Malin E
2021-12-08 10:44:41 +01:00
parent 7abd3f0c09
commit 8d0e7fb0de
2 changed files with 13 additions and 12 deletions
+6 -7
View File
@@ -48,13 +48,12 @@ local X52HOTAS = {
Mode1 = 23,
Mode2 = 24,
Mode3 = 25,
-- Only 32 buttons are supported
-- ButtomMiniJoystick = {
-- Up = 34,
-- Right = 35,
-- Down = 36,
-- Left = 37
-- }
ButtomMiniJoystick = {
Up = 34,
Right = 35,
Down = 36,
Left = 37
}
},
Thruster = {
Thrust = { 2 }, -- up/down
+7 -5
View File
@@ -89,6 +89,8 @@ void JoystickCameraStates::updateStateFromInput(
value *= -1.f;
}
float oscValue = value;
if (t.joystickType == JoystickType::TriggerLike ||
t.type == AxisType::Property)
{
@@ -174,8 +176,8 @@ void JoystickCameraStates::updateStateFromInput(
}
if (oscLable != joystickInputState.name) {
std::string oscScript = "openspace.sendOSCMessage(\"/" + oscLable +
"\", " + std::to_string(rawValue) + ")";
std::string oscScript = fmt::format("openspace.sendOSCMessage('/{}', {});",
oscLable, std::to_string(oscValue));
global::scriptEngine->queueScript(
oscScript,
scripting::ScriptEngine::RemoteScripting(true)
@@ -185,7 +187,7 @@ void JoystickCameraStates::updateStateFromInput(
for (int i = 0; i < JoystickInputState::MaxButtons; ++i) {
std::string oscLable =
joystickInputState.name + "_button_" + std::to_string(i + 1);
joystickInputState.name + "_button_" + std::to_string(i);
auto itRange = joystick->buttonMapping.equal_range(i);
for (auto it = itRange.first; it != itRange.second; ++it) {
bool active = global::joystickInputStates->button(
@@ -195,8 +197,8 @@ void JoystickCameraStates::updateStateFromInput(
);
if (active) {
std::string oscScript = "openspace.sendOSCMessage(\"/" + oscLable +
"\", " + std::to_string(1.f) + ")";
std::string oscScript = fmt::format("openspace.sendOSCMessage('/{}', {});",
oscLable, std::to_string(1.f));
global::scriptEngine->queueScript(
oscScript,
scripting::ScriptEngine::RemoteScripting(true)