Multi-context, basic keyboard input
This commit is contained in:
parent
c19b9fd34d
commit
beb0965051
6 changed files with 162 additions and 123 deletions
|
|
@ -22,11 +22,14 @@
|
||||||
#include <library.hpp>
|
#include <library.hpp>
|
||||||
#include <keyboard.hpp>
|
#include <keyboard.hpp>
|
||||||
#include <midi.hpp>
|
#include <midi.hpp>
|
||||||
|
#include <patch.hpp>
|
||||||
#include <plugin.hpp>
|
#include <plugin.hpp>
|
||||||
#include <random.hpp>
|
#include <random.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
#include <system.hpp>
|
#include <system.hpp>
|
||||||
|
|
||||||
|
#include <app/Scene.hpp>
|
||||||
|
#include <engine/Engine.hpp>
|
||||||
#include <ui/common.hpp>
|
#include <ui/common.hpp>
|
||||||
#include <window/Window.hpp>
|
#include <window/Window.hpp>
|
||||||
|
|
||||||
|
|
@ -99,38 +102,23 @@ struct Initializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO("Initializing environment");
|
INFO("Initializing environment");
|
||||||
// network::init();
|
|
||||||
audio::init();
|
audio::init();
|
||||||
// rtaudioInit();
|
|
||||||
midi::init();
|
midi::init();
|
||||||
// rtmidiInit();
|
|
||||||
keyboard::init();
|
keyboard::init();
|
||||||
#ifndef DPF_AS_GLFW
|
|
||||||
gamepad::init();
|
|
||||||
#endif
|
|
||||||
plugin::init();
|
plugin::init();
|
||||||
library::init();
|
library::init();
|
||||||
// discord::init();
|
|
||||||
|
|
||||||
ui::init();
|
ui::init();
|
||||||
window::init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Initializer()
|
~Initializer()
|
||||||
{
|
{
|
||||||
using namespace rack;
|
using namespace rack;
|
||||||
|
|
||||||
window::destroy();
|
|
||||||
ui::destroy();
|
ui::destroy();
|
||||||
|
|
||||||
// discord::destroy();
|
|
||||||
library::destroy();
|
library::destroy();
|
||||||
midi::destroy();
|
midi::destroy();
|
||||||
audio::destroy();
|
audio::destroy();
|
||||||
plugin::destroy();
|
plugin::destroy();
|
||||||
#ifndef DPF_AS_GLFW
|
|
||||||
gamepad::destroy();
|
|
||||||
#endif
|
|
||||||
INFO("Destroying logger");
|
INFO("Destroying logger");
|
||||||
logger::destroy();
|
logger::destroy();
|
||||||
}
|
}
|
||||||
|
|
@ -146,10 +134,46 @@ static const Initializer& getInitializerInstance()
|
||||||
|
|
||||||
class CardinalPlugin : public Plugin
|
class CardinalPlugin : public Plugin
|
||||||
{
|
{
|
||||||
|
rack::Context* const fContext;
|
||||||
|
|
||||||
|
struct ScopedContext {
|
||||||
|
ScopedContext(CardinalPlugin* const plugin)
|
||||||
|
{
|
||||||
|
rack::contextSet(plugin->fContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedContext()
|
||||||
|
{
|
||||||
|
rack::contextSet(nullptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CardinalPlugin()
|
CardinalPlugin()
|
||||||
: Plugin(0, 0, 0)
|
: Plugin(0, 0, 0),
|
||||||
|
fContext(new rack::Context)
|
||||||
{
|
{
|
||||||
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
fContext->engine = new rack::engine::Engine;
|
||||||
|
fContext->history = new rack::history::State;
|
||||||
|
fContext->event = new rack::widget::EventState;
|
||||||
|
fContext->scene = new rack::app::Scene;
|
||||||
|
fContext->event->rootWidget = fContext->scene;
|
||||||
|
fContext->patch = new rack::patch::Manager;
|
||||||
|
fContext->engine->startFallbackThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
~CardinalPlugin() override
|
||||||
|
{
|
||||||
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
delete fContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
rack::Context* getRackContext() const noexcept
|
||||||
|
{
|
||||||
|
return fContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -246,6 +270,11 @@ private:
|
||||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CardinalPlugin)
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CardinalPlugin)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
rack::Context* getRackContextFromPlugin(void* const ptr)
|
||||||
|
{
|
||||||
|
return static_cast<CardinalPlugin*>(ptr)->getRackContext();
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------------------
|
||||||
* Plugin entry point, called by DPF to create a new plugin instance. */
|
* Plugin entry point, called by DPF to create a new plugin instance. */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,6 @@
|
||||||
#include <app/common.hpp>
|
#include <app/common.hpp>
|
||||||
#include <app/Scene.hpp>
|
#include <app/Scene.hpp>
|
||||||
#include <context.hpp>
|
#include <context.hpp>
|
||||||
#include <engine/Engine.hpp>
|
|
||||||
#include <network.hpp>
|
|
||||||
#include <patch.hpp>
|
|
||||||
#include <ui/common.hpp>
|
#include <ui/common.hpp>
|
||||||
#include <window/Window.hpp>
|
#include <window/Window.hpp>
|
||||||
|
|
||||||
|
|
@ -30,15 +27,6 @@
|
||||||
#include "DistrhoUI.hpp"
|
#include "DistrhoUI.hpp"
|
||||||
#include "ResizeHandle.hpp"
|
#include "ResizeHandle.hpp"
|
||||||
|
|
||||||
namespace rack {
|
|
||||||
namespace network {
|
|
||||||
std::string encodeUrl(const std::string&) { return {}; }
|
|
||||||
json_t* requestJson(Method, const std::string&, json_t*, const CookieMap&) { return nullptr; }
|
|
||||||
bool requestDownload(const std::string&, const std::string&, float*, const CookieMap&) { return false; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DPF_AS_GLFW
|
|
||||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
|
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
|
||||||
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
|
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
|
||||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
|
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
|
||||||
|
|
@ -48,89 +36,66 @@ namespace rack {
|
||||||
namespace window {
|
namespace window {
|
||||||
DISTRHO_NAMESPACE::UI* lastUI = nullptr;
|
DISTRHO_NAMESPACE::UI* lastUI = nullptr;
|
||||||
|
|
||||||
void mouseButtonCallback(Window* win, int button, int action, int mods);
|
void mouseButtonCallback(Context* ctx, int button, int action, int mods);
|
||||||
void cursorPosCallback(Window* win, double xpos, double ypos);
|
void cursorPosCallback(Context* ctx, double xpos, double ypos);
|
||||||
void scrollCallback(Window* win, double x, double y);
|
void cursorEnterCallback(Context* ctx, int entered);
|
||||||
|
void scrollCallback(Context* ctx, double x, double y);
|
||||||
|
void charCallback(Context* ctx, unsigned int codepoint);
|
||||||
|
void keyCallback(Context* ctx, int key, int scancode, int action, int mods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
struct Initializer2 {
|
rack::Context* getRackContextFromPlugin(void* ptr);
|
||||||
Initializer2()
|
|
||||||
{
|
|
||||||
using namespace rack;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~Initializer2()
|
|
||||||
{
|
|
||||||
using namespace rack;
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Initializer2& getInitializer2Instance()
|
|
||||||
{
|
|
||||||
static const Initializer2 init;
|
|
||||||
return init;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CardinalUI : public UI
|
class CardinalUI : public UI
|
||||||
{
|
{
|
||||||
|
rack::Context* const fContext;
|
||||||
ResizeHandle fResizeHandle;
|
ResizeHandle fResizeHandle;
|
||||||
|
|
||||||
|
struct ScopedContext {
|
||||||
|
ScopedContext(CardinalUI* const ui)
|
||||||
|
{
|
||||||
|
rack::contextSet(ui->fContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedContext()
|
||||||
|
{
|
||||||
|
rack::contextSet(nullptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CardinalUI()
|
CardinalUI()
|
||||||
: UI(1280, 720),
|
: UI(1280, 720),
|
||||||
|
fContext(getRackContextFromPlugin(getPluginInstancePointer())),
|
||||||
fResizeHandle(this)
|
fResizeHandle(this)
|
||||||
{
|
{
|
||||||
using namespace rack;
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
/*
|
|
||||||
The following code was based from VCVRack adapters/standalone.cpp
|
|
||||||
|
|
||||||
Copyright (C) 2016-2021 VCV
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the
|
|
||||||
GNU General Public License as published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
*/
|
|
||||||
// Initialize context
|
// Initialize context
|
||||||
d_stdout("UI context ptr %p", NanoVG::getContext());
|
d_stdout("UI context ptr %p", NanoVG::getContext());
|
||||||
#ifdef DPF_AS_GLFW
|
rack::window::lastUI = this;
|
||||||
window::lastUI = this;
|
fContext->window = new rack::window::Window;
|
||||||
#endif
|
rack::window::lastUI = nullptr;
|
||||||
contextSet(new Context);
|
|
||||||
APP->engine = new engine::Engine;
|
|
||||||
APP->history = new history::State;
|
|
||||||
APP->event = new widget::EventState;
|
|
||||||
APP->scene = new app::Scene;
|
|
||||||
APP->event->rootWidget = APP->scene;
|
|
||||||
APP->patch = new patch::Manager;
|
|
||||||
/*if (!settings::headless)*/ {
|
|
||||||
APP->window = new window::Window;
|
|
||||||
}
|
|
||||||
#ifdef DPF_AS_GLFW
|
|
||||||
window::lastUI = nullptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
APP->engine->startFallbackThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CardinalUI() override
|
~CardinalUI() override
|
||||||
{
|
{
|
||||||
using namespace rack;
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
delete APP;
|
delete fContext->window;
|
||||||
contextSet(NULL);
|
fContext->window = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onNanoDisplay() override
|
void onNanoDisplay() override
|
||||||
{
|
{
|
||||||
APP->window->step();
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
fContext->window->step();
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiIdle() override
|
void uiIdle() override
|
||||||
|
|
@ -152,9 +117,10 @@ protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef DPF_AS_GLFW
|
|
||||||
bool onMouse(const MouseEvent& ev) override
|
bool onMouse(const MouseEvent& ev) override
|
||||||
{
|
{
|
||||||
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
int button;
|
int button;
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
int action = ev.press;
|
int action = ev.press;
|
||||||
|
|
@ -206,22 +172,25 @@ protected:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mouseButtonCallback(APP->window, button, action, mods);
|
rack::window::mouseButtonCallback(fContext, button, action, mods);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onMotion(const MotionEvent& ev) override
|
bool onMotion(const MotionEvent& ev) override
|
||||||
{
|
{
|
||||||
cursorPosCallback(APP->window, ev.pos.getX(), ev.pos.getY());
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
rack::window::cursorPosCallback(fContext, ev.pos.getX(), ev.pos.getY());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onScroll(const ScrollEvent& ev) override
|
bool onScroll(const ScrollEvent& ev) override
|
||||||
{
|
{
|
||||||
scrollCallback(APP->window, ev.delta.getX(), ev.delta.getY());
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
rack::window::scrollCallback(fContext, ev.delta.getX(), ev.delta.getY());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void onResize(const ResizeEvent& ev) override
|
void onResize(const ResizeEvent& ev) override
|
||||||
|
|
@ -233,6 +202,36 @@ protected:
|
||||||
|
|
||||||
// TODO uiFocus
|
// TODO uiFocus
|
||||||
|
|
||||||
|
bool onCharacterInput(const CharacterInputEvent& ev) override
|
||||||
|
{
|
||||||
|
if (ev.character == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
rack::window::charCallback(fContext, ev.character);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool onKeyboard(const KeyboardEvent& ev) override
|
||||||
|
{
|
||||||
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
|
int mods = 0;
|
||||||
|
int action = ev.press;
|
||||||
|
|
||||||
|
if (ev.mod & kModifierControl)
|
||||||
|
mods |= GLFW_MOD_CONTROL;
|
||||||
|
if (ev.mod & kModifierShift)
|
||||||
|
mods |= GLFW_MOD_SHIFT;
|
||||||
|
if (ev.mod & kModifierAlt)
|
||||||
|
mods |= GLFW_MOD_ALT;
|
||||||
|
|
||||||
|
// TODO special key conversion
|
||||||
|
rack::window::keyCallback(fContext, ev.key, ev.keycode, action, mods);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
Set our UI class as non-copyable and add a leak detector just in case.
|
Set our UI class as non-copyable and add a leak detector just in case.
|
||||||
|
|
@ -245,7 +244,6 @@ private:
|
||||||
|
|
||||||
UI* createUI()
|
UI* createUI()
|
||||||
{
|
{
|
||||||
getInitializer2Instance();
|
|
||||||
return new CardinalUI();
|
return new CardinalUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,9 @@
|
||||||
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
|
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
|
||||||
// #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin"
|
// #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin"
|
||||||
// #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer"
|
// #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer"
|
||||||
// #define DISTRHO_PLUGIN_HAS_EMBED_UI 1
|
|
||||||
// #define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 1
|
|
||||||
#define DISTRHO_UI_USE_NANOVG 1
|
#define DISTRHO_UI_USE_NANOVG 1
|
||||||
#define DISTRHO_UI_USER_RESIZABLE 0
|
#define DISTRHO_UI_USER_RESIZABLE 0
|
||||||
|
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
|
||||||
#define DPF_AS_GLFW 1
|
|
||||||
|
|
||||||
enum Parameters {
|
enum Parameters {
|
||||||
kParameterCount
|
kParameterCount
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,13 @@ FILES_DSP = \
|
||||||
CardinalPlugin.cpp
|
CardinalPlugin.cpp
|
||||||
|
|
||||||
FILES_UI = \
|
FILES_UI = \
|
||||||
CardinalUI.cpp
|
CardinalUI.cpp \
|
||||||
|
dep.cpp \
|
||||||
FILES_UI += dep.cpp
|
Window.cpp
|
||||||
FILES_UI += Window.cpp
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Import base definitions
|
# Import base definitions
|
||||||
|
|
||||||
# UI_TYPE = external
|
|
||||||
USE_NANOVG_FBO = true
|
USE_NANOVG_FBO = true
|
||||||
include ../../dpf/Makefile.base.mk
|
include ../../dpf/Makefile.base.mk
|
||||||
|
|
||||||
|
|
@ -35,7 +33,6 @@ FILES_DSP += Rack/dep/pffft/pffft.c
|
||||||
FILES_DSP += Rack/dep/pffft/fftpack.c
|
FILES_DSP += Rack/dep/pffft/fftpack.c
|
||||||
|
|
||||||
FILES_UI += Rack/dep/oui-blendish/blendish.c
|
FILES_UI += Rack/dep/oui-blendish/blendish.c
|
||||||
# FILES_UI += Rack/dep/nanovg/src/nanovg.c
|
|
||||||
|
|
||||||
# FIXME dont use this
|
# FIXME dont use this
|
||||||
FILES_UI += Rack/dep/osdialog/osdialog.c
|
FILES_UI += Rack/dep/osdialog/osdialog.c
|
||||||
|
|
@ -63,10 +60,6 @@ endif
|
||||||
|
|
||||||
EXTRA_LIBS += Rack/dep/lib/libzstd.a
|
EXTRA_LIBS += Rack/dep/lib/libzstd.a
|
||||||
|
|
||||||
# for raw GLFW window
|
|
||||||
# EXTRA_LIBS += Rack/dep/lib/libglfw3.a
|
|
||||||
# FILES_DSP += Rack/src/gamepad.cpp Rack/src/window/Window.cpp
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Do some magic
|
# Do some magic
|
||||||
|
|
||||||
|
|
@ -87,8 +80,6 @@ Rack/dep/lib/libarchive.a: Rack/dep/lib/libzstd.a
|
||||||
|
|
||||||
Rack/dep/lib/libarchive_static.a: Rack/dep/lib/libzstd.a
|
Rack/dep/lib/libarchive_static.a: Rack/dep/lib/libzstd.a
|
||||||
|
|
||||||
Rack/dep/lib/libcrypto.a: Rack/dep/lib/libssl.a
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Extra flags for VCV stuff
|
# Extra flags for VCV stuff
|
||||||
|
|
||||||
|
|
@ -98,10 +89,7 @@ BASE_FLAGS += -IRack/include
|
||||||
BASE_FLAGS += -IRack/dep/include
|
BASE_FLAGS += -IRack/dep/include
|
||||||
BASE_FLAGS += -IRack/dep/filesystem/include
|
BASE_FLAGS += -IRack/dep/filesystem/include
|
||||||
BASE_FLAGS += -IRack/dep/fuzzysearchdatabase/src
|
BASE_FLAGS += -IRack/dep/fuzzysearchdatabase/src
|
||||||
# BASE_FLAGS += -IRack/dep/glew-2.1.0/include
|
|
||||||
# BASE_FLAGS += -IRack/dep/glfw/deps
|
|
||||||
BASE_FLAGS += -IRack/dep/glfw/include
|
BASE_FLAGS += -IRack/dep/glfw/include
|
||||||
# BASE_FLAGS += -IRack/dep/nanovg/src
|
|
||||||
BASE_FLAGS += -IRack/dep/nanosvg/src
|
BASE_FLAGS += -IRack/dep/nanosvg/src
|
||||||
BASE_FLAGS += -IRack/dep/osdialog
|
BASE_FLAGS += -IRack/dep/osdialog
|
||||||
BASE_FLAGS += -IRack/dep/oui-blendish
|
BASE_FLAGS += -IRack/dep/oui-blendish
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ bool& Window::fbDirtyOnSubpixelChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mouseButtonCallback(Window* win, int button, int action, int mods) {
|
void mouseButtonCallback(Context* ctx, int button, int action, int mods) {
|
||||||
/*
|
/*
|
||||||
#if defined ARCH_MAC
|
#if defined ARCH_MAC
|
||||||
// Remap Ctrl-left click to right click on Mac
|
// Remap Ctrl-left click to right click on Mac
|
||||||
|
|
@ -379,29 +379,35 @@ void mouseButtonCallback(Window* win, int button, int action, int mods) {
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
APP->event->handleButton(win->internal->lastMousePos, button, action, mods);
|
ctx->event->handleButton(ctx->window->internal->lastMousePos, button, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cursorPosCallback(Window* win, double xpos, double ypos) {
|
void cursorPosCallback(Context* ctx, double xpos, double ypos) {
|
||||||
math::Vec mousePos = math::Vec(xpos, ypos).div(win->pixelRatio / win->windowRatio).round();
|
math::Vec mousePos = math::Vec(xpos, ypos).div(ctx->window->pixelRatio / ctx->window->windowRatio).round();
|
||||||
math::Vec mouseDelta = mousePos.minus(win->internal->lastMousePos);
|
math::Vec mouseDelta = mousePos.minus(ctx->window->internal->lastMousePos);
|
||||||
|
|
||||||
// Workaround for GLFW warping mouse to a different position when the cursor is locked or unlocked.
|
// Workaround for GLFW warping mouse to a different position when the cursor is locked or unlocked.
|
||||||
if (win->internal->ignoreNextMouseDelta) {
|
if (ctx->window->internal->ignoreNextMouseDelta) {
|
||||||
win->internal->ignoreNextMouseDelta = false;
|
ctx->window->internal->ignoreNextMouseDelta = false;
|
||||||
mouseDelta = math::Vec();
|
mouseDelta = math::Vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
win->internal->lastMousePos = mousePos;
|
ctx->window->internal->lastMousePos = mousePos;
|
||||||
|
|
||||||
APP->event->handleHover(mousePos, mouseDelta);
|
ctx->event->handleHover(mousePos, mouseDelta);
|
||||||
|
|
||||||
// Keyboard/mouse MIDI driver
|
// Keyboard/mouse MIDI driver
|
||||||
math::Vec scaledPos(xpos / win->internal->ui->getWidth(), ypos / win->internal->ui->getHeight());
|
math::Vec scaledPos(xpos / ctx->window->internal->ui->getWidth(), ypos / ctx->window->internal->ui->getHeight());
|
||||||
keyboard::mouseMove(scaledPos);
|
keyboard::mouseMove(scaledPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollCallback(Window* win, double x, double y) {
|
void cursorEnterCallback(Context* ctx, int entered) {
|
||||||
|
if (!entered) {
|
||||||
|
ctx->event->handleLeave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollCallback(Context* ctx, double x, double y) {
|
||||||
math::Vec scrollDelta = math::Vec(x, y);
|
math::Vec scrollDelta = math::Vec(x, y);
|
||||||
#if defined ARCH_MAC
|
#if defined ARCH_MAC
|
||||||
scrollDelta = scrollDelta.mult(10.0);
|
scrollDelta = scrollDelta.mult(10.0);
|
||||||
|
|
@ -409,14 +415,25 @@ void scrollCallback(Window* win, double x, double y) {
|
||||||
scrollDelta = scrollDelta.mult(50.0);
|
scrollDelta = scrollDelta.mult(50.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
APP->event->handleScroll(win->internal->lastMousePos, scrollDelta);
|
ctx->event->handleScroll(ctx->window->internal->lastMousePos, scrollDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void charCallback(Context* ctx, unsigned int codepoint) {
|
||||||
void init() {
|
if (ctx->event->handleText(ctx->window->internal->lastMousePos, codepoint))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void keyCallback(Context* ctx, int key, int scancode, int action, int mods) {
|
||||||
|
if (ctx->event->handleKey(ctx->window->internal->lastMousePos, key, scancode, action, mods))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Keyboard/mouse MIDI driver
|
||||||
|
if (action == GLFW_PRESS && (mods & RACK_MOD_MASK) == 0) {
|
||||||
|
keyboard::press(key);
|
||||||
|
}
|
||||||
|
if (action == GLFW_RELEASE) {
|
||||||
|
keyboard::release(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,13 @@
|
||||||
#define NANOSVG_IMPLEMENTATION
|
#define NANOSVG_IMPLEMENTATION
|
||||||
#define NANOSVG_ALL_COLOR_KEYWORDS
|
#define NANOSVG_ALL_COLOR_KEYWORDS
|
||||||
#include <nanosvg.h>
|
#include <nanosvg.h>
|
||||||
|
|
||||||
|
#include <network.hpp>
|
||||||
|
|
||||||
|
namespace rack {
|
||||||
|
namespace network {
|
||||||
|
std::string encodeUrl(const std::string&) { return {}; }
|
||||||
|
json_t* requestJson(Method, const std::string&, json_t*, const CookieMap&) { return nullptr; }
|
||||||
|
bool requestDownload(const std::string&, const std::string&, float*, const CookieMap&) { return false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue