Cleanup, fix MOD builds
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
4ab933a073
commit
6aedd9d2f3
5 changed files with 46 additions and 27 deletions
|
@ -66,7 +66,7 @@ static const constexpr uint kCardinalStateCount = kCardinalStateBaseCount;
|
|||
extern const std::string CARDINAL_VERSION;
|
||||
|
||||
namespace rack {
|
||||
#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
#if CARDINAL_VARIANT_MINI || defined(HEADLESS)
|
||||
namespace app {
|
||||
rack::widget::Widget* createMenuBar() { return new rack::widget::Widget; }
|
||||
}
|
||||
|
|
|
@ -32,11 +32,12 @@
|
|||
# undef HAVE_LIBLO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBLO
|
||||
# include <lo/lo.h>
|
||||
#if (CARDINAL_VARIANT_MINI && !defined(HEADLESS)) || defined(HAVE_LIBLO)
|
||||
# define CARDINAL_REMOTE_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBLO
|
||||
# include <lo/lo.h>
|
||||
// # define REMOTE_HOST "localhost"
|
||||
# define REMOTE_HOST "192.168.51.1"
|
||||
#endif
|
||||
|
@ -63,6 +64,7 @@ static int osc_handler(const char* const path, const char* const types, lo_arg**
|
|||
|
||||
RemoteDetails* getRemote()
|
||||
{
|
||||
#ifdef CARDINAL_REMOTE_ENABLED
|
||||
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, nullptr);
|
||||
|
||||
|
@ -70,10 +72,14 @@ RemoteDetails* getRemote()
|
|||
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, nullptr);
|
||||
|
||||
return ui->remoteDetails;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool connectToRemote()
|
||||
{
|
||||
#ifdef CARDINAL_REMOTE_ENABLED
|
||||
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, false);
|
||||
|
||||
|
@ -82,7 +88,7 @@ bool connectToRemote()
|
|||
|
||||
RemoteDetails* remoteDetails = ui->remoteDetails;
|
||||
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
if (remoteDetails == nullptr)
|
||||
{
|
||||
ui->remoteDetails = remoteDetails = new RemoteDetails;
|
||||
|
@ -90,7 +96,7 @@ bool connectToRemote()
|
|||
remoteDetails->connected = true;
|
||||
remoteDetails->autoDeploy = true;
|
||||
}
|
||||
#elif defined(HAVE_LIBLO)
|
||||
#elif defined(HAVE_LIBLO)
|
||||
if (remoteDetails == nullptr)
|
||||
{
|
||||
const lo_server oscServer = lo_server_new_with_proto(nullptr, LO_UDP, nullptr);
|
||||
|
@ -112,9 +118,12 @@ bool connectToRemote()
|
|||
lo_send(addr, "/hello", "");
|
||||
lo_address_free(addr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return remoteDetails != nullptr;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void disconnectFromRemote(RemoteDetails* const remote)
|
||||
|
@ -138,6 +147,7 @@ void idleRemote(RemoteDetails* const remote)
|
|||
|
||||
void sendParamChangeToRemote(RemoteDetails* const remote, int64_t moduleId, int paramId, float value)
|
||||
{
|
||||
#ifdef CARDINAL_REMOTE_ENABLED
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
char paramBuf[512] = {};
|
||||
{
|
||||
|
@ -153,10 +163,12 @@ void sendParamChangeToRemote(RemoteDetails* const remote, int64_t moduleId, int
|
|||
|
||||
lo_address_free(addr);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void sendFullPatchToRemote(RemoteDetails* const remote)
|
||||
{
|
||||
#ifdef CARDINAL_REMOTE_ENABLED
|
||||
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,);
|
||||
|
||||
|
@ -204,11 +216,12 @@ void sendFullPatchToRemote(RemoteDetails* const remote)
|
|||
|
||||
lo_address_free(addr);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void sendScreenshotToRemote(RemoteDetails*, const char* const screenshot)
|
||||
{
|
||||
#ifdef HAVE_LIBLO
|
||||
#if defined(HAVE_LIBLO) && ! CARDINAL_VARIANT_MINI
|
||||
const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, CARDINAL_DEFAULT_REMOTE_HOST_PORT);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,);
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ START_NAMESPACE_DISTRHO
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
uint32_t Plugin::getBufferSize() const noexcept { return 0; }
|
||||
double Plugin::getSampleRate() const noexcept { return 0.0; }
|
||||
const char* Plugin::getBundlePath() const noexcept { return nullptr; }
|
||||
bool Plugin::isSelfTestInstance() const noexcept { return false; }
|
||||
bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
|
@ -15,10 +15,6 @@
|
|||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifdef HEADLESS
|
||||
# error wrong include
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DistrhoUtils.hpp"
|
||||
|
|
|
@ -42,6 +42,21 @@
|
|||
# undef DEBUG
|
||||
#endif
|
||||
|
||||
#include "DistrhoUI.hpp"
|
||||
#include "Application.hpp"
|
||||
#include "extra/String.hpp"
|
||||
#include "../CardinalCommon.hpp"
|
||||
#include "../PluginContext.hpp"
|
||||
#include "../WindowParameters.hpp"
|
||||
|
||||
#ifndef DGL_NO_SHARED_RESOURCES
|
||||
# include "src/Resources.hpp"
|
||||
#endif
|
||||
|
||||
#if !(defined(DGL_USE_GLES) || CARDINAL_VARIANT_MINI)
|
||||
|
||||
#define CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
|
||||
// comment out if wanting to generate a local screenshot.png
|
||||
#define STBI_WRITE_NO_STDIO
|
||||
|
||||
|
@ -52,15 +67,6 @@
|
|||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
#include "DistrhoUI.hpp"
|
||||
#include "Application.hpp"
|
||||
#include "extra/String.hpp"
|
||||
#include "../CardinalCommon.hpp"
|
||||
#include "../PluginContext.hpp"
|
||||
#include "../WindowParameters.hpp"
|
||||
|
||||
#ifndef DGL_NO_SHARED_RESOURCES
|
||||
# include "src/Resources.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef DISTRHO_OS_WASM
|
||||
|
@ -133,6 +139,7 @@ std::shared_ptr<Image> Image::load(const std::string& filename) {
|
|||
}
|
||||
|
||||
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
enum ScreenshotStep {
|
||||
kScreenshotStepNone,
|
||||
kScreenshotStepStarted,
|
||||
|
@ -140,6 +147,7 @@ enum ScreenshotStep {
|
|||
kScreenshotStepSecondPass,
|
||||
kScreenshotStepSaving
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct Window::Internal {
|
||||
|
@ -165,7 +173,7 @@ struct Window::Internal {
|
|||
|
||||
int frame = 0;
|
||||
int frameSwapInterval = 1;
|
||||
#ifndef DGL_USE_GLES
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
int generateScreenshotStep = kScreenshotStepNone;
|
||||
#endif
|
||||
double monitorRefreshRate = 60.0;
|
||||
|
@ -538,7 +546,7 @@ void Window::run() {
|
|||
}
|
||||
|
||||
|
||||
#ifndef DGL_USE_GLES
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
static void Window__flipBitmap(uint8_t* pixels, const int width, const int height, const int depth) {
|
||||
for (int y = 0; y < height / 2; y++) {
|
||||
const int flipY = height - y - 1;
|
||||
|
@ -634,7 +642,7 @@ void Window::step() {
|
|||
APP->event->handleDirty();
|
||||
}
|
||||
|
||||
#ifndef DGL_USE_GLES
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
// Hide menu and background if generating screenshot
|
||||
if (internal->generateScreenshotStep == kScreenshotStepStarted) {
|
||||
#ifdef CARDINAL_TRANSPARENT_SCREENSHOTS
|
||||
|
@ -684,7 +692,7 @@ void Window::step() {
|
|||
|
||||
++internal->frame;
|
||||
|
||||
#ifndef DGL_USE_GLES
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
if (internal->generateScreenshotStep != kScreenshotStepNone) {
|
||||
++internal->generateScreenshotStep;
|
||||
|
||||
|
@ -799,7 +807,7 @@ bool Window::isFullScreen() {
|
|||
if (emscripten_get_fullscreen_status(&status) == EMSCRIPTEN_RESULT_SUCCESS)
|
||||
return status.isFullscreen;
|
||||
return false;
|
||||
#elif defined(CARDINAL_TRANSPARENT_SCREENSHOTS) && !defined(DGL_USE_GLES)
|
||||
#elif defined(CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS) && defined(CARDINAL_TRANSPARENT_SCREENSHOTS)
|
||||
return internal->generateScreenshotStep != kScreenshotStepNone;
|
||||
#else
|
||||
return false;
|
||||
|
@ -880,7 +888,7 @@ int& Window::fbCount() {
|
|||
|
||||
|
||||
void generateScreenshot() {
|
||||
#ifndef DGL_USE_GLES
|
||||
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
|
||||
APP->window->internal->generateScreenshotStep = kScreenshotStepStarted;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue