- if (!inh)
- {
- inh = GetStdHandle(STD_INPUT_HANDLE);
- if (GetConsoleMode(inh, &dw))
- {
- SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT));
- FlushConsoleInputBuffer(inh);
- } else
- usePipe = true;
- }
-
- // 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;