From 6de4cd9be4d2458af3df509f113db3c0d38cc49b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 17 Jan 2021 08:04:59 -0500 Subject: [PATCH] Make Ctrl, Shift, and Ctrl+shift mods consistent between arrow key rack scrolling and knob movement. Ctrl is slow, Shift is fast, Ctrl+shift is very slow. --- src/app/AudioWidget.cpp | 8 ++++---- src/app/Knob.cpp | 9 ++++----- src/app/RackScrollWidget.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/app/AudioWidget.cpp b/src/app/AudioWidget.cpp index 96ded6b3..0c894553 100644 --- a/src/app/AudioWidget.cpp +++ b/src/app/AudioWidget.cpp @@ -111,7 +111,7 @@ static void appendAudioDeviceMenu(ui::Menu* menu, audio::Port* port) { int numOutputs = port->getDeviceNumOutputs(deviceId); std::string name = port->getDeviceName(deviceId); - // Prevents devices with a ridiculous number of channels from being displayed + // Display only 8 channel offsets per device, because some virtual devices (e.g. ALSA) can have thousands of useless channels. for (int i = 0; i < 8; i++) { int inputOffset = i * port->maxInputs; int outputOffset = i * port->maxOutputs; @@ -124,7 +124,7 @@ static void appendAudioDeviceMenu(ui::Menu* menu, audio::Port* port) { item->inputOffset = inputOffset; item->outputOffset = outputOffset; item->text = getDetailTemplate(name, numInputs, inputOffset, port->maxInputs, numOutputs, outputOffset, port->maxOutputs); - item->rightText = CHECKMARK(item->deviceId == port->getDeviceId() && inputOffset == port->inputOffset && outputOffset == port->outputOffset); + item->rightText = CHECKMARK(deviceId == port->getDeviceId() && inputOffset == port->inputOffset && outputOffset == port->outputOffset); menu->addChild(item); } } @@ -143,8 +143,8 @@ struct AudioDeviceChoice : LedDisplayChoice { if (box.size.x >= 200.0) text += "Device: "; std::string detail = ""; - if (port && port->device) - detail = getDetailTemplate(port->device->getName(), port->getNumInputs(), port->inputOffset, port->maxInputs, port->getNumOutputs(), port->outputOffset, port->maxOutputs); + if (port && port->getDevice()) + detail = getDetailTemplate(port->getDevice()->getName(), port->getNumInputs(), port->inputOffset, port->maxInputs, port->getNumOutputs(), port->outputOffset, port->maxOutputs); if (detail != "") { text += detail; diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index 16379e4d..4c609336 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -125,13 +125,12 @@ void Knob::onDragMove(const event::DragMove& e) { float modScale = 1.f; // Drag slower if Ctrl is held int mods = APP->window->getMods(); - if ((mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { + if ((mods & RACK_MOD_MASK) == RACK_MOD_CTRL) modScale /= 16.f; - } - // Drag even slower if Ctrl-Shift is held - if ((mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { + if ((mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) + modScale *= 4.f; + if ((mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) modScale /= 256.f; - } // Ratio between parameter value scale / (angle range / 2*pi) float rangeRatio; diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 462c3283..050ba21c 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -98,12 +98,12 @@ void RackScrollWidget::onHoverKey(const event::HoverKey& e) { // Scroll with arrow keys float arrowSpeed = 32.f; - if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) - arrowSpeed /= 16.f; if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) - arrowSpeed *= 4.f; - if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) arrowSpeed /= 4.f; + if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) + arrowSpeed *= 4.f; + if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) + arrowSpeed /= 16.f; if (e.action == RACK_HELD) { if (e.key == GLFW_KEY_LEFT) {