fix: Companion wasn't reading/writing Haptic SF values correctly (#1571)

This commit is contained in:
Neil Horne
2022-02-08 12:18:14 +10:00
committed by GitHub
parent ba93abc30c
commit 407ada00f8
@@ -157,6 +157,9 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
case FuncPlaySound: case FuncPlaySound:
def += LookupValue(soundLut, rhs.param); def += LookupValue(soundLut, rhs.param);
break; break;
case FuncPlayHaptic:
def += std::to_string(rhs.param);
break;
case FuncPlayPrompt: case FuncPlayPrompt:
case FuncPlayScript: case FuncPlayScript:
case FuncBackgroundMusic: case FuncBackgroundMusic:
@@ -177,7 +180,7 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
case FuncVolume: case FuncVolume:
case FuncBacklight: { case FuncBacklight: {
def += YamlRawSourceEncode(RawSource(rhs.param)); def += YamlRawSourceEncode(RawSource(rhs.param));
} break; } break;
case FuncAdjustGV1: { case FuncAdjustGV1: {
// + GV # // + GV #
def += std::to_string(p1); def += std::to_string(p1);
@@ -266,6 +269,13 @@ bool convert<CustomFunctionData>::decode(const Node& node,
getline(def, snd, ','); getline(def, snd, ',');
Node(snd) >> soundLut >> rhs.param; Node(snd) >> soundLut >> rhs.param;
} break; } break;
case FuncPlayHaptic: {
std::string haptic;
getline(def, haptic, ',');
try {
rhs.param = std::stoi(haptic);
} catch(...) {}
} break;
case FuncPlayPrompt: case FuncPlayPrompt:
case FuncPlayScript: case FuncPlayScript:
case FuncBackgroundMusic: { case FuncBackgroundMusic: {
@@ -298,7 +308,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
std::string src_str; std::string src_str;
getline(def, src_str, ','); getline(def, src_str, ',');
rhs.param = YamlRawSourceDecode(src_str).toValue(); rhs.param = YamlRawSourceDecode(src_str).toValue();
} break; } break;
case FuncAdjustGV1: { case FuncAdjustGV1: {
// + GV # // + GV #
int gvar_idx=0; int gvar_idx=0;
@@ -346,7 +356,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
if (def.peek() == ',') { if (def.peek() == ',') {
def.ignore(); def.ignore();
} }
if (fnHasEnable(rhs.func)) { if (fnHasEnable(rhs.func)) {
int en = 0; int en = 0;
def >> en; def >> en;