Skip to content

Commit

Permalink
Try to avoid invalid scancodes (#503)
Browse files Browse the repository at this point in the history
* Try to avoid invalid scancodes

* Try to only check reasonable scancodes

* clang format
  • Loading branch information
Vagabond authored Jun 25, 2024
1 parent ce461b8 commit 9968578
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/game/scenes/mainmenu/menu_presskey.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ void menu_presskey_tick(component *c) {
int keys = 0;
const unsigned char *state = SDL_GetKeyboardState(&keys);
for(int i = 0; i < keys; i++) {
if(i < SDL_SCANCODE_A || (i > SDL_SCANCODE_EXSEL && i < SDL_SCANCODE_KP_00) ||
i > SDL_SCANCODE_KP_HEXADECIMAL) {
continue;
}

if(state[i]) {
if(is_key_bound(i) && strcmp(SDL_GetScancodeName(i), *(local->key)) != 0) {
// Set texts to red as a warning
Expand Down

0 comments on commit 9968578

Please sign in to comment.