Skip to content

Commit

Permalink
console: fix first input sometimes being lost
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 27, 2024
1 parent 9af5ec5 commit 626fdac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- fixed toggling fullscreen not always saving (regression from 4.4)
- fixed main menu music volume when exiting while underwater with certain music settings (#1540, regression from 4.4)
- fixed `/kill` command unable to target a special object
- fixed really fast typing in console sometimes losing the first input (regression from 4.4)
- improved object name matching in console commands to work like TR2X

## [4.4](https://github.com/LostArtefacts/TR1X/compare/4.3-102-g458cd96...4.4) - 2024-09-20
Expand Down
6 changes: 0 additions & 6 deletions src/game/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ void Shell_ExitSystemFmt(const char *fmt, ...)

void Shell_ProcessInput(void)
{
if (g_InputDB.enter_console) {
Console_Open();
g_Input.any = 0;
g_InputDB.any = 0;
}

if (g_InputDB.toggle_bilinear_filter) {
g_Config.rendering.texture_filter =
(g_Config.rendering.texture_filter + 1) % GFX_TF_NUMBER_OF;
Expand Down
16 changes: 14 additions & 2 deletions src/specific/s_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,21 @@ void S_Shell_SpinMessageLoop(void)
}
break;

case SDL_KEYDOWN:
UI_HandleKeyDown(event.key.keysym.sym);
case SDL_KEYDOWN: {
// NOTE: This normally would get handled by Input_Update,
// but by the time Input_Update gets ran, we may already have lost
// some keypresses if the player types really fast, so we need to
// react sooner.
const INPUT_SCANCODE open_console_scancode =
Input_GetAssignedScancode(
g_Config.input.layout, INPUT_ROLE_ENTER_CONSOLE);
if (event.key.keysym.scancode == open_console_scancode) {
Console_Open();
} else {
UI_HandleKeyDown(event.key.keysym.sym);
}
break;
}

case SDL_TEXTEDITING:
UI_HandleTextEdit(event.text.text);
Expand Down

0 comments on commit 626fdac

Please sign in to comment.