This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[ian.ray@nokia.com: incoming fax! at last!]


Does anyone have any insight into this patch:

http://sources.redhat.com/ml/cygwin/2001-10/msg00626.html

It feels wrong to me to be doing a WFMO followed by a PeekConsoleInput
followed by a ReadConsoleInput.

I've just received the assignments from Ian so I can officially start
commenting on this now...

I've included the patch below from the web page but I don't think it
will cleanly apply as is.

cgf

--- 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 */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]