dethrace-labs/dethrace

Holding down SHIFT makes key repeat go crazy quick

Closed this issue · 1 comments

madebr commented

In places where you can enter text, such as the Driver Selection menu or Save Game menu, when you hold down the SHIFT key while entering text, the text is repeated very fast.

How to reproduce

  1. Start a new game
  2. Click on one of the drivers
  3. Remove all text using backspace
  4. Hold down the SHIFT (with your pink)
  5. Press any other letter key

Expected result

The letter is entered, with a moderate speed

Actual result

The complete input box is filled with the letter

madebr commented

The issue happend here in TypeKey:

default:
DoRLTypeLetter(PDGetASCIIFromKey(pKey), pSlot_index);

The PDGetASCIIFromKey checks whether the SHIFT key is down, which will modify the last key that was down.

Modifying the above lines to:

{
    printf("before: gLast_key_down=%d\n", gLast_key_down);
    int v = PDGetASCIIFromKey(pKey);
    printf("after: gLast_key_down=%d\n", gLast_key_down);
    DoRLTypeLetter(v, pSlot_index);
}

will print the following output (with #322 applied) when typing text with the SHIFT key down.

before: gLast_key_down=21
after: gLast_key_down=0

Because gLast_key_down was modified to KEY_SHIFT_ALL, the code will a new key has been entered.