X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmisc.cpp;h=cf68055cd6de1013d5fdee5fc704cc480e4414cb;hp=ecd6a499fc5e75eb24cc2cd9989c13310ab773de;hb=95ce27f9262b63ce8eb611965e5cbc16bae815ad;hpb=5c4f6f6226c7b12bd737f10dba40b28f26f1b58d diff --git a/src/misc.cpp b/src/misc.cpp index ecd6a499..cf68055c 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -178,8 +178,24 @@ int Bioskey() return 1; return dw; } else { + // Count the number of unread input records, including keyboard, + // mouse, and window-resizing input records. GetNumberOfConsoleInputEvents(inh, &dw); - return dw <= 1 ? 0 : dw; + if (dw <= 0) + return 0; + + // Read data from console without removing it from the buffer + INPUT_RECORD rec[256]; + DWORD recCnt; + if (!PeekConsoleInput(inh, rec, Min(dw, 256), &recCnt)) + return 0; + + // Search for at least one keyboard event + for (DWORD i = 0; i < recCnt; i++) + if (rec[i].EventType == KEY_EVENT) + return 1; + + return 0; } } #endif