OSC updates and video resolution fixes
This commit is contained in:
@@ -43,6 +43,14 @@ void AppendFloat32(std::vector<char>& packet, float value)
|
||||
AppendInt32(packet, static_cast<int>(bits));
|
||||
}
|
||||
|
||||
void AppendFloat64(std::vector<char>& packet, double value)
|
||||
{
|
||||
uint64_t bits = 0;
|
||||
std::memcpy(&bits, &value, sizeof(bits));
|
||||
for (int shift = 56; shift >= 0; shift -= 8)
|
||||
packet.push_back(static_cast<char>((bits >> shift) & 0xff));
|
||||
}
|
||||
|
||||
std::vector<char> BuildOscPacket(const std::string& address, const std::string& typeTags)
|
||||
{
|
||||
std::vector<char> packet;
|
||||
@@ -89,6 +97,19 @@ void TestDecodeFloatMessage()
|
||||
Expect(message.valueJson.find("0.75") == 0, "float OSC value becomes JSON number");
|
||||
}
|
||||
|
||||
void TestDecodeDoubleMessage()
|
||||
{
|
||||
OscServer server;
|
||||
std::vector<char> packet = BuildOscPacket("/VideoShaderToys/fisheye-reproject/panDegrees", ",d");
|
||||
AppendFloat64(packet, 51.5);
|
||||
|
||||
OscServerTestAccess::Message message;
|
||||
std::string error;
|
||||
Expect(OscServerTestAccess::Decode(server, packet, message, error), "double OSC message decodes");
|
||||
Expect(message.address == "/VideoShaderToys/fisheye-reproject/panDegrees", "double OSC address is preserved");
|
||||
Expect(message.valueJson.find("51.5") == 0, "double OSC value becomes JSON number");
|
||||
}
|
||||
|
||||
void TestDecodeIntStringAndBoolMessages()
|
||||
{
|
||||
OscServer server;
|
||||
@@ -161,6 +182,7 @@ void TestRejectsUnsupportedAddress()
|
||||
int main()
|
||||
{
|
||||
TestDecodeFloatMessage();
|
||||
TestDecodeDoubleMessage();
|
||||
TestDecodeIntStringAndBoolMessages();
|
||||
TestDispatchValidAddress();
|
||||
TestRejectsUnsupportedAddress();
|
||||
|
||||
Reference in New Issue
Block a user