allow audio engine to react to keyboard inputs

This commit is contained in:
2026-06-10 20:44:04 -05:00
parent 7231d948bc
commit 8eb5a619ad
8 changed files with 67 additions and 29 deletions

View File

@@ -5,6 +5,10 @@
// #include <yaml-cpp/yaml.h>
#include <filesystem>
KeyboardController::KeyboardController(QObject* parent) : QObject(parent) {
}
KeyboardController::KeyboardController(ConfigService* config, LoggerService* logger, NoteQueue* queue) : config_(config), logger_(logger), queue_(queue) {
// load keymap from config service
@@ -15,11 +19,10 @@ KeyboardController::KeyboardController(ConfigService* config, LoggerService* log
}
void KeyboardController::handleKeyPress(QKeyEvent* e) {
if (e->isAutoRepeat()) return;
void KeyboardController::keyDownEvent(int key, int modifiers, const QString& text) {
auto it = keymap_.find(e->key());
if (it == keymap_.end()) return;
auto it = configuration_.keymap.find(key);
if (it == configuration_.keymap.end()) return;
queue_->push({
NoteEventType::NoteOn,
@@ -27,13 +30,13 @@ void KeyboardController::handleKeyPress(QKeyEvent* e) {
0.8f,
std::chrono::high_resolution_clock::now()
});
}
void KeyboardController::handleKeyRelease(QKeyEvent* e) {
if (e->isAutoRepeat()) return;
void KeyboardController::keyUpEvent(int key, int modifiers, const QString& text) {
auto it = keymap_.find(e->key());
if (it == keymap_.end()) return;
auto it = configuration_.keymap.find(key);
if (it == configuration_.keymap.end()) return;
queue_->push({
NoteEventType::NoteOff,