mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Simplify win32 read_stdin(). Still untested.
This commit is contained in:
parent
d521edd86a
commit
6f8f063b90
19
command.c
19
command.c
@ -248,25 +248,16 @@ static size_t read_stdin(char *buf, size_t size)
|
||||
// Check first if we're a pipe
|
||||
// (not console).
|
||||
DWORD avail = 0;
|
||||
BOOL ret = PeekNamedPipe(hnd, NULL, 0, NULL, &avail, NULL);
|
||||
|
||||
if (!ret) // If not a pipe, check if we're running in a console.
|
||||
// If not a pipe, check if we're running in a console.
|
||||
if (!PeekNamedPipe(hnd, NULL, 0, NULL, &avail, NULL))
|
||||
{
|
||||
DWORD mode = 0;
|
||||
DWORD mode;
|
||||
if (!GetConsoleMode(hnd, &mode))
|
||||
return 0;
|
||||
|
||||
INPUT_RECORD rec = {0};
|
||||
DWORD has_read = 0;
|
||||
|
||||
do
|
||||
{
|
||||
has_read = 0;
|
||||
PeekConsoleInput(hnd, &rec, 1, &has_read);
|
||||
} while (has_read && rec.EventType != KEY_EVENT);
|
||||
|
||||
if (rec.EventType == KEY_EVENT)
|
||||
avail = size;
|
||||
if (!GetNumberOfConsoleInputEvents(hnd, &avail))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!avail)
|
||||
|
Loading…
x
Reference in New Issue
Block a user