-#else
-
-int data_available()
-{
- static HANDLE inh = NULL;
- static bool usePipe;
- INPUT_RECORD rec[256];
- DWORD dw, recCnt;
-
- 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;
-
- // Count the number of unread input records, including keyboard,
- // mouse, and window-resizing input records.
- GetNumberOfConsoleInputEvents(inh, &dw);