184{
185 try {
186 decltype(lr_ipc_shared->line_)::value_type line_copy;
187 while ((line_copy = lr_ipc_shared->line_.pop()) != kTerminate) {
188#pragma warning(suppress : 26445)
189 auto [command_view, value_view] = SplitLine(line_copy);
190
191
192 if (command_view == "TerminateApplication") {
193 juce::JUCEApplication::getInstance()->systemRequestedQuit();
194 return;
195 }
196
197 if (value_view.empty()) {
198 rsj::Log(fmt::format(FMT_STRING(
"No value attached to message. Message from plugin was "
199 "\"{}\"."),
201 std::source_location::current());
202 continue;
203 }
204
205 if (command_view == "SwitchProfile") {
207 continue;
208 }
209
210 if (command_view == "Log") {
211 rsj::Log(fmt::format(FMT_STRING(
"Plugin: {}."), value_view),
212 std::source_location::current());
213 continue;
214 }
215
216 if (command_view == "SendKey") {
217 int modifiers {0};
218 auto [ptr, ec] {std::from_chars(value_view.data(),
219 value_view.data() + value_view.size(), modifiers)};
220
221 std::string_view key_view {value_view};
222 key_view.remove_prefix(static_cast<size_t>(ptr - value_view.data()));
223 if (!key_view.empty() && (key_view.front() == ' ' || key_view.front() == '\t')) {
224 key_view.remove_prefix(1);
225 }
226 if (!key_view.empty() && ec == std::errc()) {
229 continue;
230 }
232 "Message from plugin was \"{}\"."),
234 std::source_location::current());
235 continue;
236 }
237
238
239 double original_value {0.0};
240#if defined(_MSC_VER) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_3)
241 auto [ptr, ec] {std::from_chars(value_view.data(), value_view.data() + value_view.size(),
242 original_value)};
243 if (ec != std::errc()) {
245 value_view),
246 std::source_location::current());
247 continue;
248 }
249#else
250 try {
251 original_value = std::stod(std::string(value_view));
252 }
253 catch (const std::exception& ex) {
255 value_view, ex.what()),
256 std::source_location::current());
257 continue;
258 }
259#endif
261 for (const auto& msg : messages) {
266 }
267 }
268 }
269 }
270 catch (const std::exception& e) {
272 throw;
273 }
274}
rsj::CCmethod GetCcMethod(int channel, int controlnumber) const
Definition ControlsModel.h:244
int PluginToController(rsj::MidiMessageId msg_id, double value)
Definition ControlsModel.h:270
void Send(rsj::MidiMessageId id, int value) const
Definition MIDISender.cpp:53
std::vector< rsj::MidiMessageId > GetMessagesForCommand(const std::string &command) const
Definition Profile.cpp:78
void SwitchToProfile(int profile_index)
Definition ProfileManager.cpp:57
std::string ReplaceInvisibleChars(std::string_view in)
void SendKeyDownUp(const std::string &key, rsj::ActiveModifiers mods) noexcept
Definition SendKeysMac.cpp:378
void LogAndAlertError(const juce::String &error_text, const std::source_location &location=std::source_location::current()) noexcept
Definition Misc.cpp:142
static ActiveModifiers FromMidi2LR(int from) noexcept
Definition SendKeys.cpp:30