condense reused code
This commit is contained in:
@@ -20,28 +20,22 @@ KeyboardController::KeyboardController(ConfigService* config, LoggerService* log
|
||||
}
|
||||
|
||||
void KeyboardController::keyDownEvent(int key, int modifiers, const QString& text) {
|
||||
|
||||
auto it = configuration_.keymap.find(key);
|
||||
if (it == configuration_.keymap.end()) return;
|
||||
|
||||
queue_->push({
|
||||
NoteEventType::NoteOn,
|
||||
it->second,
|
||||
0.8f,
|
||||
std::chrono::high_resolution_clock::now()
|
||||
});
|
||||
|
||||
addEventToQueue(key, NoteEventType::NoteOn);
|
||||
}
|
||||
|
||||
void KeyboardController::keyUpEvent(int key, int modifiers, const QString& text) {
|
||||
addEventToQueue(key, NoteEventType::NoteOff);
|
||||
}
|
||||
|
||||
void KeyboardController::addEventToQueue(int key, NoteEventType type) {
|
||||
|
||||
auto it = configuration_.keymap.find(key);
|
||||
if (it == configuration_.keymap.end()) return;
|
||||
|
||||
queue_->push({
|
||||
NoteEventType::NoteOff,
|
||||
type,
|
||||
it->second,
|
||||
0.8f,
|
||||
defaultVelocity_,
|
||||
std::chrono::high_resolution_clock::now()
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user