Skip to content

Commit

Permalink
BUGFIX: Fix L=A by comparing the rawkeys to the previous keyinput ins…
Browse files Browse the repository at this point in the history
…tead of the converted keys
  • Loading branch information
AreaZR committed Oct 3, 2024
1 parent 9a24c03 commit 8795933
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,21 @@ static void ReadKeys(void)
{
u16 keyInput = REG_KEYINPUT ^ KEYS_MASK;
gMain.newKeysRaw = keyInput & ~gMain.heldKeysRaw;

gMain.newKeys = gMain.newKeysRaw;
gMain.newAndRepeatedKeys = gMain.newKeysRaw;

// BUG: Key repeat won't work when pressing L using L=A button mode
// because it compares the raw key input with the remapped held keys.
// Note that newAndRepeatedKeys is never remapped either.

#if BUGFIX
if (keyInput != 0 && gMain.heldKeysRaw == keyInput)
#else
if (keyInput != 0 && gMain.heldKeys == keyInput)
#endif
{
gMain.keyRepeatCounter--;

if (gMain.keyRepeatCounter == 0)
if (--gMain.keyRepeatCounter == 0)
{
gMain.newAndRepeatedKeys = keyInput;
gMain.keyRepeatCounter = gKeyRepeatContinueDelay;
Expand All @@ -285,6 +288,10 @@ static void ReadKeys(void)

if (JOY_HELD(L_BUTTON))
gMain.heldKeys |= A_BUTTON;
#if BUGFIX
if (JOY_REPEAT(L_BUTTON))
gMain.newAndRepeatedKeys |= A_BUTTON;
#endif
}

if (JOY_NEW(gMain.watchedKeysMask))
Expand Down

0 comments on commit 8795933

Please sign in to comment.