Added more keyboard controls

This commit is contained in:
Ryzerth 2021-04-23 17:53:25 +02:00
parent b8e4a79188
commit d43f501819
2 changed files with 27 additions and 0 deletions

View File

@ -379,6 +379,7 @@ void drawWindow() {
vfo = gui::waterfall.vfos[gui::waterfall.selectedVFO];
}
// Handke VFO movement
if (vfo != NULL) {
if (vfo->centerOffsetChanged) {
if (centerTuning) {
@ -394,12 +395,14 @@ void drawWindow() {
sigpath::vfoManager.updateFromWaterfall(&gui::waterfall);
// Handle selection of another VFO
if (gui::waterfall.selectedVFOChanged && vfo != NULL) {
gui::waterfall.selectedVFOChanged = false;
gui::freqSelect.setFrequency(vfo->generalOffset + gui::waterfall.getCenterFrequency());
gui::freqSelect.frequencyChanged = false;
}
// Handle change in selected frequency
if (gui::freqSelect.frequencyChanged) {
gui::freqSelect.frequencyChanged = false;
setVFO(gui::freqSelect.frequency);
@ -416,6 +419,7 @@ void drawWindow() {
core::configManager.release(true);
}
// Handle dragging the frequency scale
if (gui::waterfall.centerFreqMoved) {
gui::waterfall.centerFreqMoved = false;
sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency());
@ -430,6 +434,22 @@ void drawWindow() {
core::configManager.release(true);
}
// Handle arrow keys
if (vfo != NULL) {
if (ImGui::IsKeyPressed(GLFW_KEY_LEFT)) {
setVFO(gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval);
}
if (ImGui::IsKeyPressed(GLFW_KEY_RIGHT)) {
setVFO(gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval);
}
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
if (vfo != NULL) {
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset;
}
core::configManager.release(true);
}
int _fftHeight = gui::waterfall.getFFTHeight();
if (fftHeight != _fftHeight) {
fftHeight = _fftHeight;

View File

@ -1,6 +1,7 @@
#include <gui/widgets/frequency_select.h>
#include <config.h>
#include <gui/style.h>
#include <GLFW/glfw3.h>
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
@ -150,6 +151,12 @@ void FrequencySelect::draw() {
}
frequencyChanged = true;
}
if (ImGui::IsKeyPressed(GLFW_KEY_UP)) {
incrementDigit(i);
}
if (ImGui::IsKeyPressed(GLFW_KEY_DOWN)) {
decrementDigit(i);
}
if (mw != 0) {
int count = abs(mw);
for (int j = 0; j < count; j++) {