- if (!inh)
- {
- inh = GetStdHandle(STD_INPUT_HANDLE);
- usePipe = !GetConsoleMode(inh, &dw);
- if (!usePipe)
- {
- SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT));
- FlushConsoleInputBuffer(inh);
- }
- }
-
- // If we're running under XBoard then we can't use PeekConsoleInput() as
- // the input commands are sent to us directly over the internal pipe.
- if (usePipe)
- return PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL) ? dw : 1;