--- fhandler_console.cc-orig Thu Oct 11 15:44:55 2001 +++ fhandler_console.cc Thu Oct 11 15:47:15 2001 @@ -248,11 +248,34 @@ fhandler_console::read (void *pv, size_t INPUT_RECORD input_rec; const char *toadd = NULL; - if (!ReadConsoleInput (h, &input_rec, 1, &nread)) + if (!PeekConsoleInput (h, &input_rec, 1, &nread)) { __seterrno (); syscall_printf ("ReadConsoleInput failed, %E"); return -1; /* seems to be failure */ + } + + /* + * On Win95, the Caps Lock key toggles all keys, not just the alpha keys; + * we work around this by reading non-enhanced key-*presses* using the + * ReadConsole() function. + */ + int is_win95_workaround = + (!wincap.is_winnt()) + && (input_rec.EventType == KEY_EVENT) + && (input_rec.Event.KeyEvent.bKeyDown) + && (!(input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) + ; + + if (is_win95_workaround) + { + DWORD ch; + (void) ReadConsole (h, &ch, 1, &nread, NULL); + input_rec.Event.KeyEvent.uChar.AsciiChar = (unsigned char)ch; + } + else + { + (void) ReadConsoleInput (h, &input_rec, 1, &nread); } /* check the event that occurred */