OSC updates and video resolution fixes
This commit is contained in:
@@ -114,7 +114,14 @@ void OscServer::ServerLoop()
|
||||
OscMessage message;
|
||||
std::string error;
|
||||
if (DecodeMessage(buffer.data(), byteCount, message, error))
|
||||
DispatchMessage(message, error);
|
||||
{
|
||||
if (!DispatchMessage(message, error) && !error.empty())
|
||||
OutputDebugStringA(("OSC dispatch failed: " + error + "\n").c_str());
|
||||
}
|
||||
else if (!error.empty())
|
||||
{
|
||||
OutputDebugStringA(("OSC decode failed: " + error + "\n").c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +159,17 @@ bool OscServer::DecodeMessage(const char* data, int byteCount, OscMessage& messa
|
||||
return true;
|
||||
}
|
||||
|
||||
if (valueType == 'd')
|
||||
{
|
||||
double value = 0.0;
|
||||
if (!ReadFloat64(data, byteCount, offset, value))
|
||||
return false;
|
||||
std::ostringstream stream;
|
||||
stream << std::setprecision(17) << value;
|
||||
message.valueJson = stream.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (valueType == 'i')
|
||||
{
|
||||
int value = 0;
|
||||
@@ -234,6 +252,21 @@ bool OscServer::ReadFloat32(const char* data, int byteCount, int& offset, double
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OscServer::ReadFloat64(const char* data, int byteCount, int& offset, double& value)
|
||||
{
|
||||
if (offset + 8 > byteCount)
|
||||
return false;
|
||||
|
||||
const unsigned char* bytes = reinterpret_cast<const unsigned char*>(data + offset);
|
||||
uint64_t bits = 0;
|
||||
for (int index = 0; index < 8; ++index)
|
||||
bits = (bits << 8) | static_cast<uint64_t>(bytes[index]);
|
||||
|
||||
std::memcpy(&value, &bits, sizeof(value));
|
||||
offset += 8;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string OscServer::BuildJsonString(const std::string& value)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
Reference in New Issue
Block a user