mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Fix OSC value sending and butons
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user