Skip to content

Commit

Permalink
Fix notes playing twice on key press
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Jul 20, 2023
1 parent e3af2a0 commit 337af07
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
}
@Override
public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) {
unlockFocused();
unlockFocused(pKeyCode);

final NoteButton note = getNoteByKey(pKeyCode);
if (note != null)
Expand All @@ -224,6 +224,7 @@ public NoteButton getNoteByKey(final int keyCode) {

return noteMap().containsKey(key) ? noteMap().get(key) : null;
}

/**
* Unlocks any focused {@link NoteButton}s
*/
Expand All @@ -234,6 +235,15 @@ private void unlockFocused() {
return;
}
}
/**
* Unlocks the {@link NoteButton} who matches with the given keycode
*/
private void unlockFocused(final int keycode) {
final NoteButton note = getNoteByKey(keycode);

if (note != null)
note.locked = false;
}


//#region Making the options screen function
Expand Down

0 comments on commit 337af07

Please sign in to comment.