From bebb787325f689cf5950c6ee4a545a67583735e5 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 23 Jan 2014 09:21:07 -0800 Subject: [PATCH] SCP: Fix problem on Windows which inhibited the ability to enter console input (^E) when bells characters were being output too often. Fixes #102 --- sim_console.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sim_console.c b/sim_console.c index 0e588a5f..c7fec1b8 100644 --- a/sim_console.c +++ b/sim_console.c @@ -2124,12 +2124,25 @@ if ((std_input == NULL) || /* No keyboard for */ return (WAIT_OBJECT_0 == WaitForSingleObject (std_input, ms_timeout)); } +#define BELL_CHAR 7 /* Bell Character */ +#define BELL_INTERVAL_MS 500 /* No more than 2 Bell Characters Per Second */ static t_stat sim_os_putchar (int32 c) { DWORD unused; +static uint32 last_bell_time; -if (c != 0177) - WriteConsoleA(std_output, &c, 1, &unused, NULL); +if (c != 0177) { + if (c == BELL_CHAR) { + uint32 now = sim_os_msec (); + + if ((now - last_bell_time) > BELL_INTERVAL_MS) { + WriteConsoleA(std_output, &c, 1, &unused, NULL); + last_bell_time = now; + } + } + else + WriteConsoleA(std_output, &c, 1, &unused, NULL); + } return SCPE_OK; }