Fix unset audio device; Force never cursor lock; Cleanup
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
d11db41c43
commit
16be4fcabb
4 changed files with 17 additions and 51 deletions
|
|
@ -50,6 +50,7 @@ struct Initializer {
|
||||||
{
|
{
|
||||||
using namespace rack;
|
using namespace rack;
|
||||||
|
|
||||||
|
settings::allowCursorLock = false;
|
||||||
settings::autoCheckUpdates = false;
|
settings::autoCheckUpdates = false;
|
||||||
settings::autosaveInterval = 0;
|
settings::autosaveInterval = 0;
|
||||||
settings::discordUpdateActivity = false;
|
settings::discordUpdateActivity = false;
|
||||||
|
|
@ -222,7 +223,7 @@ protected:
|
||||||
if (fCurrentDevice != dev)
|
if (fCurrentDevice != dev)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fCurrentDevice = dev;
|
fCurrentDevice = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ protected:
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
rack::math::Vec mousePos = rack::math::Vec(ev.pos.getX(), ev.pos.getY());
|
rack::math::Vec mousePos = rack::math::Vec(ev.pos.getX(), ev.pos.getY()).div(1).round();
|
||||||
// .div(ctx->window->pixelRatio / ctx->window->windowRatio).round();
|
// .div(ctx->window->pixelRatio / ctx->window->windowRatio).round();
|
||||||
rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);
|
rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ protected:
|
||||||
if (ctx->window->internal->ignoreNextMouseDelta)
|
if (ctx->window->internal->ignoreNextMouseDelta)
|
||||||
{
|
{
|
||||||
ctx->window->internal->ignoreNextMouseDelta = false;
|
ctx->window->internal->ignoreNextMouseDelta = false;
|
||||||
mouseDelta = math::Vec();
|
mouseDelta = rack::math::Vec();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ struct CardinalAudioDevice : rack::audio::Device {
|
||||||
|
|
||||||
std::string getName() override
|
std::string getName() override
|
||||||
{
|
{
|
||||||
return "Plugin Device";
|
return "Cardinal";
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNumInputs() override
|
int getNumInputs() override
|
||||||
|
|
@ -115,7 +115,7 @@ struct CardinalAudioDriver : rack::audio::Driver {
|
||||||
|
|
||||||
std::string getDeviceName(int) override
|
std::string getDeviceName(int) override
|
||||||
{
|
{
|
||||||
return "Plugin Driver Device";
|
return "Plugin Device";
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDeviceNumInputs(int) override
|
int getDeviceNumInputs(int) override
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ struct Window::Internal {
|
||||||
std::string lastWindowTitle;
|
std::string lastWindowTitle;
|
||||||
|
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
bool ignoreNextMouseDelta = false;
|
|
||||||
int frameSwapInterval = 1;
|
int frameSwapInterval = 1;
|
||||||
double monitorRefreshRate = 60.0; // FIXME
|
double monitorRefreshRate = 60.0; // FIXME
|
||||||
double frameTime = 0.0;
|
double frameTime = 0.0;
|
||||||
|
|
@ -150,19 +149,12 @@ void Window::step() {
|
||||||
internal->frameTime = frameTime;
|
internal->frameTime = frameTime;
|
||||||
internal->lastFrameDuration = frameTime - lastFrameTime;
|
internal->lastFrameDuration = frameTime - lastFrameTime;
|
||||||
// DEBUG("%.2lf Hz", 1.0 / internal->lastFrameDuration);
|
// DEBUG("%.2lf Hz", 1.0 / internal->lastFrameDuration);
|
||||||
double t1 = 0.0, t2 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0;
|
|
||||||
|
|
||||||
// Make event handlers and step() have a clean NanoVG context
|
// Make event handlers and step() have a clean NanoVG context
|
||||||
// nvgReset(vg);
|
// nvgReset(vg);
|
||||||
|
|
||||||
bndSetFont(uiFont->handle);
|
bndSetFont(uiFont->handle);
|
||||||
|
|
||||||
// Poll events
|
|
||||||
// Save and restore context because event handler set their own context based on which window they originate from.
|
|
||||||
// Context* context = contextGet();
|
|
||||||
// glfwPollEvents();
|
|
||||||
// contextSet(context);
|
|
||||||
|
|
||||||
// Set window title
|
// Set window title
|
||||||
std::string windowTitle = APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION;
|
std::string windowTitle = APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION;
|
||||||
if (APP->patch->path != "") {
|
if (APP->patch->path != "") {
|
||||||
|
|
@ -189,7 +181,6 @@ void Window::step() {
|
||||||
int fbWidth = winWidth;// * newPixelRatio;
|
int fbWidth = winWidth;// * newPixelRatio;
|
||||||
int fbHeight = winHeight;// * newPixelRatio;
|
int fbHeight = winHeight;// * newPixelRatio;
|
||||||
windowRatio = (float)fbWidth / winWidth;
|
windowRatio = (float)fbWidth / winWidth;
|
||||||
t1 = system::getTime();
|
|
||||||
|
|
||||||
if (APP->scene) {
|
if (APP->scene) {
|
||||||
// DEBUG("%f %f %d %d", pixelRatio, windowRatio, fbWidth, winWidth);
|
// DEBUG("%f %f %d %d", pixelRatio, windowRatio, fbWidth, winWidth);
|
||||||
|
|
@ -198,40 +189,22 @@ void Window::step() {
|
||||||
|
|
||||||
// Step scene
|
// Step scene
|
||||||
APP->scene->step();
|
APP->scene->step();
|
||||||
t2 = system::getTime();
|
|
||||||
|
|
||||||
// Render scene
|
// Render scene
|
||||||
bool visible = true;
|
// Update and render
|
||||||
if (visible) {
|
nvgScale(vg, pixelRatio, pixelRatio);
|
||||||
// Update and render
|
|
||||||
// nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio);
|
|
||||||
nvgScale(vg, pixelRatio, pixelRatio);
|
|
||||||
|
|
||||||
// Draw scene
|
// Draw scene
|
||||||
widget::Widget::DrawArgs args;
|
widget::Widget::DrawArgs args;
|
||||||
args.vg = vg;
|
args.vg = vg;
|
||||||
args.clipBox = APP->scene->box.zeroPos();
|
args.clipBox = APP->scene->box.zeroPos();
|
||||||
APP->scene->draw(args);
|
APP->scene->draw(args);
|
||||||
t3 = system::getTime();
|
|
||||||
|
|
||||||
glViewport(0, 0, fbWidth, fbHeight);
|
glViewport(0, 0, fbWidth, fbHeight);
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
// nvgEndFrame(vg);
|
|
||||||
t4 = system::getTime();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t5 = system::getTime();
|
|
||||||
|
|
||||||
// DEBUG("pre-step %6.1f step %6.1f draw %6.1f nvgEndFrame %6.1f glfwSwapBuffers %6.1f total %6.1f",
|
|
||||||
// (t1 - frameTime) * 1e3f,
|
|
||||||
// (t2 - t1) * 1e3f,
|
|
||||||
// (t3 - t2) * 1e3f,
|
|
||||||
// (t4 - t2) * 1e3f,
|
|
||||||
// (t5 - t4) * 1e3f,
|
|
||||||
// (t5 - frameTime) * 1e3f
|
|
||||||
// );
|
|
||||||
internal->frame++;
|
internal->frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,23 +223,15 @@ void Window::close() {
|
||||||
|
|
||||||
|
|
||||||
void Window::cursorLock() {
|
void Window::cursorLock() {
|
||||||
if (!settings::allowCursorLock)
|
|
||||||
return;
|
|
||||||
|
|
||||||
internal->ignoreNextMouseDelta = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Window::cursorUnlock() {
|
void Window::cursorUnlock() {
|
||||||
if (!settings::allowCursorLock)
|
|
||||||
return;
|
|
||||||
|
|
||||||
internal->ignoreNextMouseDelta = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Window::isCursorLocked() {
|
bool Window::isCursorLocked() {
|
||||||
return internal->ignoreNextMouseDelta;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue