VKeybd: fix stuck keys when changing octaves - #7957

Using the mouse/dropdown to change octaves can lead to stuck
notes when keys are held. This is because the most recently
pressed key, sends key-repeat events.

Using Arrow keys to switch octaves does not cause this problem,
because the most recently pressed key will be an arrow key.

PS. Changing Chromatic Transpose while holding keys still
can lead to stuck notes. This will need a different fix.
This commit is contained in:
Robin Gareus 2020-03-29 00:47:26 +01:00
parent 7e0abc0dbf
commit 9873e1d211
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 9 additions and 0 deletions

View File

@ -642,6 +642,15 @@ APianoKeyboard::on_key_press_event (GdkEventKey* event)
return true;
}
std::map<std::string, int>::const_iterator kv = _note_stack.find (key);
if (kv != _note_stack.end ()) {
/* key is already pressed, ignore event.
* this can happen when changing the octave with the mouse
* while playing.
*/
return true;
}
note += _octave * 12;
assert (key);