Skip to content

Commit

Permalink
Limit WIN32 input char repeat count, to avoid starvation if rendering…
Browse files Browse the repository at this point in the history
… is slow.
  • Loading branch information
gwsw committed Sep 24, 2023
1 parent 9d0b541 commit a0c369d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,7 @@ public void putbs(void)

#if MSDOS_COMPILER==WIN32C

#define WIN32_MAX_REPEAT 3
#define LAST_DOWN_COUNT 8
static LWCHAR last_downs[LAST_DOWN_COUNT] = { 0 };
static int last_down_index = 0;
Expand Down Expand Up @@ -3002,7 +3003,10 @@ static int win32_key_event(XINPUT_RECORD *xip)
if (win32_scan_code(xip))
return (TRUE);

for (repeat = xip->ir.Event.KeyEvent.wRepeatCount; repeat > 0; --repeat)
repeat = xip->ir.Event.KeyEvent.wRepeatCount;
if (repeat > WIN32_MAX_REPEAT)
repeat = WIN32_MAX_REPEAT;
for (; repeat > 0; --repeat)
{
char utf8[UTF8_MAX_LENGTH];
char *up = utf8;
Expand Down

0 comments on commit a0c369d

Please sign in to comment.