diff --git a/src/CardinalCommon.hpp b/src/CardinalCommon.hpp index fe25487..7c9a74f 100644 --- a/src/CardinalCommon.hpp +++ b/src/CardinalCommon.hpp @@ -60,5 +60,6 @@ bool isRemoteConnected(); bool isRemoteAutoDeployed(); void setRemoteAutoDeploy(bool autoDeploy); void deployToRemote(); +void sendScreenshotToRemote(const char* screenshot); } // namespace patchUtils diff --git a/src/CardinalPlugin.cpp b/src/CardinalPlugin.cpp index 8ca8ee7..579c0fa 100644 --- a/src/CardinalPlugin.cpp +++ b/src/CardinalPlugin.cpp @@ -396,7 +396,8 @@ class CardinalPlugin : public CardinalBasePlugin std::string fAutosavePath; uint64_t fPreviousFrame; - String fStateText; + String fStateComment; + String fStateScreenshot; String fWindowSize; #ifndef HEADLESS @@ -767,8 +768,10 @@ protected: return fWindowSize; #endif - if (std::strcmp(key, "text") == 0) - return fStateText; + if (std::strcmp(key, "comment") == 0) + return fStateComment; + if (std::strcmp(key, "screenshot") == 0) + return fStateScreenshot; if (std::strcmp(key, "patch") != 0) return String(); @@ -803,9 +806,18 @@ protected: } #endif - if (std::strcmp(key, "text") == 0) + if (std::strcmp(key, "comment") == 0) { - fStateText = value; + fStateComment = value; + return; + } + + if (std::strcmp(key, "screenshot") == 0) + { + fStateScreenshot = value; + #if defined(HAVE_LIBLO) && defined(HEADLESS) + patchUtils::sendScreenshotToRemote(value); + #endif return; } diff --git a/src/override/Scene.cpp b/src/override/Scene.cpp index ad02f31..c2c5c0d 100644 --- a/src/override/Scene.cpp +++ b/src/override/Scene.cpp @@ -341,6 +341,7 @@ void Scene::onHoverKey(const HoverKeyEvent& e) { } if (e.key == GLFW_KEY_F7 && (e.mods & RACK_MOD_MASK) == 0) { patchUtils::deployToRemote(); + window::generateScreenshot(); e.consume(this); } if (e.key == GLFW_KEY_F9 && (e.mods & RACK_MOD_MASK) == 0) { @@ -543,4 +544,15 @@ void deployToRemote() { } +void sendScreenshotToRemote(const char* const screenshot) { +#ifdef HAVE_LIBLO + const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT); + DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,); + + lo_send(addr, "/screenshot", "s", screenshot); + lo_address_free(addr); +#endif +} + + } // namespace patchUtils