Skip to content

Commit

Permalink
Don't mark autorelease keys as virtual
Browse files Browse the repository at this point in the history
Also make sure we time out the hardware_timestamp even if SDL_HardwareKeyboardKeyPressed() isn't called.
  • Loading branch information
slouken committed Aug 2, 2023
1 parent 648de4f commit 843572d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/events/SDL_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ int SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, Uint8 state, SDL_Scancode sc

int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode)
{
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL | KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode, SDLK_UNKNOWN);
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode, SDLK_UNKNOWN);
}

int SDL_SendKeyboardKeyIgnoreModifiers(Uint64 timestamp, Uint8 state, SDL_Scancode scancode)
Expand All @@ -1034,6 +1034,13 @@ void SDL_ReleaseAutoReleaseKeys(void)
}
keyboard->autorelease_pending = SDL_FALSE;
}

if (keyboard->hardware_timestamp) {
/* Keep hardware keyboard "active" for 250 ms */
if (SDL_GetTicks() >= keyboard->hardware_timestamp + 250) {
keyboard->hardware_timestamp = 0;
}
}
}

SDL_bool SDL_HardwareKeyboardKeyPressed(void)
Expand All @@ -1047,12 +1054,6 @@ SDL_bool SDL_HardwareKeyboardKeyPressed(void)
}
}

if (keyboard->hardware_timestamp) {
/* Keep hardware keyboard "active" for 250 ms */
if (SDL_GetTicks() >= keyboard->hardware_timestamp + 250) {
keyboard->hardware_timestamp = 0;
}
}
return keyboard->hardware_timestamp ? SDL_TRUE : SDL_FALSE;
}

Expand Down

0 comments on commit 843572d

Please sign in to comment.