Fixed scroll bug and added keybinds

pull/108/head
Ryzerth 2021-04-24 04:06:04 +02:00
rodzic dd5490cac6
commit a35d0252e7
5 zmienionych plików z 69 dodań i 43 usunięć

Wyświetl plik

@ -434,26 +434,6 @@ void drawWindow() {
core::configManager.release(true);
}
// Handle arrow keys
if (vfo != NULL) {
if (ImGui::IsKeyPressed(GLFW_KEY_LEFT) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
setVFO(nfreq);
}
if (ImGui::IsKeyPressed(GLFW_KEY_RIGHT) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
setVFO(nfreq);
}
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;
@ -470,7 +450,7 @@ void drawWindow() {
// To Bar
ImGui::PushID(ImGui::GetID("sdrpp_menu_btn"));
if (ImGui::ImageButton(icons::MENU, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) {
if (ImGui::ImageButton(icons::MENU, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_MENU, false)) {
showMenu = !showMenu;
core::configManager.aquire();
core::configManager.conf["showMenu"] = showMenu;
@ -482,7 +462,7 @@ void drawWindow() {
if (playing) {
ImGui::PushID(ImGui::GetID("sdrpp_stop_btn"));
if (ImGui::ImageButton(icons::STOP, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) {
if (ImGui::ImageButton(icons::STOP, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) {
sigpath::sourceManager.stop();
playing = false;
}
@ -490,7 +470,7 @@ void drawWindow() {
}
else { // TODO: Might need to check if there even is a device
ImGui::PushID(ImGui::GetID("sdrpp_play_btn"));
if (ImGui::ImageButton(icons::PLAY, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) {
if (ImGui::ImageButton(icons::PLAY, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) {
sigpath::sourceManager.start();
// TODO: tune in module instead
sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency());
@ -648,12 +628,40 @@ void drawWindow() {
ImGui::EndChild();
// Handle arrow keys
if (vfo != NULL && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
if (ImGui::IsKeyPressed(GLFW_KEY_LEFT) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
setVFO(nfreq);
}
if (ImGui::IsKeyPressed(GLFW_KEY_RIGHT) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
setVFO(nfreq);
}
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);
}
// Handle scrollwheel
int wheel = ImGui::GetIO().MouseWheel;
if (wheel != 0 && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + (vfo->snapInterval * wheel);
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
double nfreq;
if (vfo != NULL) {
nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + (vfo->snapInterval * wheel);
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
}
else {
nfreq = gui::waterfall.getCenterFrequency() - (gui::waterfall.getViewBandwidth() * wheel / 20.0);
}
setVFO(nfreq);
gui::freqSelect.setFrequency(nfreq);
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
if (vfo != NULL) {

Wyświetl plik

@ -74,7 +74,8 @@ namespace displaymenu {
void draw(void* ctx) {
float menuWidth = ImGui::GetContentRegionAvailWidth();
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall)) {
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall) || ImGui::IsKeyPressed(GLFW_KEY_HOME, false)) {
if (ImGui::IsKeyPressed(GLFW_KEY_HOME, false)) { showWaterfall = !showWaterfall; }
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
core::configManager.aquire();
core::configManager.conf["showWaterfall"] = showWaterfall;

Wyświetl plik

@ -155,7 +155,7 @@ void FrequencySelect::draw() {
}
if (onDigit) {
hovered = true;
if (rightClick) {
if (rightClick || (ImGui::IsKeyPressed(GLFW_KEY_DELETE) || ImGui::IsKeyPressed(GLFW_KEY_ENTER) || ImGui::IsKeyPressed(GLFW_KEY_KP_ENTER))) {
for (int j = i; j < 12; j++) {
digits[j] = 0;
}
@ -167,7 +167,7 @@ void FrequencySelect::draw() {
if (ImGui::IsKeyPressed(GLFW_KEY_DOWN)) {
decrementDigit(i);
}
if (ImGui::IsKeyPressed(GLFW_KEY_LEFT) && i > 0) {
if ((ImGui::IsKeyPressed(GLFW_KEY_LEFT) || ImGui::IsKeyPressed(GLFW_KEY_BACKSPACE)) && i > 0) {
moveCursorToDigit(i - 1);
}
if (ImGui::IsKeyPressed(GLFW_KEY_RIGHT) && i < 11) {
@ -180,23 +180,11 @@ void FrequencySelect::draw() {
for (int j = 0; j < chars.Size; j++) {
if (chars[j] >= '0' && chars[j] <= '9') {
digits[i + j] = chars[j] - '0';
if ((i + j) < 11) { moveCursorToDigit(i + j + 1); }
frequencyChanged = true;
}
if ((i + j) < 11) { moveCursorToDigit(i + j + 1); }
frequencyChanged = true;
}
// Check each digit
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_0)) { digits[i] = 0; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_1)) { digits[i] = 1; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_2)) { digits[i] = 2; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_3)) { digits[i] = 3; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_4)) { digits[i] = 4; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_5)) { digits[i] = 5; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_6)) { digits[i] = 6; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_7)) { digits[i] = 7; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_8)) { digits[i] = 8; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
// if (ImGui::IsKeyPressed(GLFW_KEY_KP_9)) { digits[i] = 9; if (i < 11) { moveCursorToDigit(i + 1); frequencyChanged = true; } }
if (mw != 0) {
int count = abs(mw);
for (int j = 0; j < count; j++) {

Wyświetl plik

@ -5,7 +5,7 @@
#include <imutils.h>
#include <algorithm>
#include <volk/volk.h>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
float DEFAULT_COLOR_MAP[][3] = {
@ -390,6 +390,33 @@ namespace ImGui {
return;
}
// If the left and right keys are pressed while hovering the freq scale, move it too
if ((ImGui::IsKeyPressed(GLFW_KEY_LEFT) || ImGui::IsKeyPressed(GLFW_KEY_RIGHT)) && mouseInFreq) {
viewOffset += ImGui::IsKeyPressed(GLFW_KEY_LEFT) ? (viewBandwidth / 20.0) : (-viewBandwidth / 20.0);
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0);
viewOffset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
}
if (viewOffset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
double freqOffset = (viewOffset - (viewBandwidth / 2.0)) + (wholeBandwidth / 2.0);
viewOffset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
}
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
if (viewBandwidth != wholeBandwidth) {
updateAllVFOs();
if (_fullUpdate) { updateWaterfallFb(); };
}
return;
}
// Finally, if nothing else was selected, just move the VFO
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && (mouseInFFT|mouseInWaterfall)) {
if (selVfo != NULL) {

Wyświetl plik

@ -42,6 +42,8 @@ cp build/meteor_demodulator/Release/meteor_demodulator.dll sdrpp_windows_x64/mod
cp build/audio_sink/Release/audio_sink.dll sdrpp_windows_x64/modules/
cp "C:/Program Files (x86)/RtAudio/bin/rtaudio.dll" sdrpp_windows_x64/
cp build/discord_integration/Release/discord_integration.dll sdrpp_windows_x64/modules/
# Copy supporting libs
cp 'C:/Program Files/PothosSDR/bin/libusb-1.0.dll' sdrpp_windows_x64/
cp 'C:/Program Files/PothosSDR/bin/pthreadVC2.dll' sdrpp_windows_x64/