Upload Source/Helper/HelperIPC.cpp
Browse files28 unmodified lines2930313232333438 unmodified lines7374757677787980818283848586878889909192933 unmodified lines9798998610010110265 unmodified lines1681691701711721731741751761771781791801811821831841854 unmodified lines19019119219319419519627 unmodified lines22422522620122722820320422923023123223323423523623723823924024124224324424520624624720820924824925025125225325425525625722 unmodified lines28028128223828328428528628 unmodified lines socketFd = socket(AF_UNIX, SOCK_STREAM, 0); if (socketFd < 0) return false;
// Set SO_NOSIGPIPE (macOS) int nosigpipe = 1; setsockopt(socketFd, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
38 unmodified lines sendMessage(juce::String(msg.dump()));}
void HelperIPC::sendGuiReady(const juce::String& portName, int width, int height){ json msg = {{"notify", "gui_ready"}, {"layerPortName", portName.toStdString()}, {"width", width}, {"height", height}}; sendMessage(juce::String(msg.dump()));}
void HelperIPC::sendGuiResized(int width, int height){ json msg = {{"notify", "resized"}, {"width", width}, {"height", height}}; sendMessage(juce::String(msg.dump()));}
void HelperIPC::sendParamChanged(int index, float value){ json msg = {{"notify", "param_changed"}, {"index", index}, {"value", value}};3 unmodified linesvoid HelperIPC::sendMessage(const juce::String& jsonStr){ if (socketFd < 0) return;
auto data = jsonStr + "\n"; auto bytes = data.toRawUTF8(); auto len = (size_t)data.getNumBytesAsUTF8();65 unmodified lines host.unloadPlugin(); sendMessage("{\"ok\":true}"); } else if (cmd == "show_gui") { host.showGui(); // GUI ready notification is sent asynchronously after GUI is created // (see HelperPluginHost::showGui which calls ipc->sendGuiReady) sendMessage("{\"ok\":true}"); } else if (cmd == "hide_gui") { host.hideGui(); sendMessage("{\"ok\":true}"); } else if (cmd == "search_param") { auto keyword = j.value("keyword", "");4 unmodified lines { arr.push_back({ {"i", p.index}, {"id", p.id.toStdString()}, {"n", p.name.toStdString()}, {"v", std::round(p.value * 1000.0f) / 1000.0f}, {"t", p.displayText.toStdString()}27 unmodified lines bool ok = host.setParams(values); sendMessage(ok ? "{\"ok\":true}" : "{\"ok\":false}"); } else if (cmd == "show_gui") else if (cmd == "mouse") { host.showGui(); sendMessage("{\"ok\":true}"); auto type = j.value("type", ""); float x = j.value("x", 0.0f); float y = j.value("y", 0.0f); int button = j.value("button", 0);
if (type == "down") host.injectMouseDown(x, y, button); else if (type == "up") host.injectMouseUp(x, y, button); else if (type == "move") host.injectMouseMove(x, y); else if (type == "drag") host.injectMouseDrag(x, y, button); else if (type == "scroll") { float dx = j.value("dx", 0.0f); float dy = j.value("dy", 0.0f); host.injectMouseScroll(x, y, dx, dy); } // No response for mouse events (fire-and-forget for low latency) } else if (cmd == "hide_gui") else if (cmd == "key") { host.hideGui(); sendMessage("{\"ok\":true}"); auto type = j.value("type", ""); int keyCode = j.value("keyCode", 0); auto chars = j.value("chars", ""); int modifiers = j.value("modifiers", 0);
if (type == "down") host.injectKeyDown(keyCode, juce::String(chars), modifiers); else if (type == "up") host.injectKeyUp(keyCode, juce::String(chars), modifiers); } else if (cmd == "get_state") {22 unmodified lines } catch (const std::exception& e) { DBG("HelperIPC: Error handling message: " + juce::String(e.what())); DBG("HelperIPC: Error: " + juce::String(e.what())); sendMessage("{\"ok\":false,\"error\":\"parse error\"}"); }}Source/Helper/HelperIPC.cpp+54-9