delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/10/11/11:12:56

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <C78815621F631C4AAFAE6FEC74ECDC9A12087C@caebe004.NOE.Nokia.com>
From: ian DOT ray AT nokia DOT com
To: cygwin AT cygwin DOT com
Subject: Re: Shell CAPS-lock settings
Date: Thu, 11 Oct 2001 18:12:01 +0300
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2652.78)
content-class: urn:content-classes:message

------_=_NextPart_000_01C15267.14F82380
Content-Type: text/plain;
	charset="iso-8859-1"

Hi,


Chris wrote:
> That someone was probably me.  I was asking for someone to provide
> a patch.
> Nobody ever has.
>
> cgf


http://www.ladybridge.com/qm_faq4f.htm
"On Windows 95, the Caps Lock key toggles all keys, not just the alpha
keys.
This is a Windows 95 bug in the Windows ReadConsoleInput API."

http://support.microsoft.com/support/kb/articles/Q140/4/56.asp
"Deadkeys cannot be accepted as input to a Windows 95 Console
application
even when the appropriate keyboard layout is selected.
ReadConsoleInput()
cannot read in deadkeys on Windows 95."

ftp://ftp.microsoft.com/developr/win32dk/kb/q137/1/95.txt
"Unpredictable results occur if you use ReadConsole and ReadConsoleInput
together in a Windows 95-based application. Do not mix the two functions
when using a single console."


I have made a proposed patch (breaking Microsoft advice, above).
I did this work against cygwin-snapshot-20011005-1.

This patch must be tested in Win95, Win98, and WinNT. I only have time
for some basic, UK-keyboard/British-English tests on Win95 and WinNT.

Comments? Testers?


Blue skies,
ianr

--



------_=_NextPart_000_01C15267.14F82380
Content-Type: application/octet-stream;
	name="fhandler_console.cc-changelog"
Content-Disposition: attachment;
	filename="fhandler_console.cc-changelog"

Thu Oct 11 15:47:15 2001  Ian Ray <ian DOT ray AT nokia DOT com>

	* fhandler_console.cc (fhandler_console::read): 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.


------_=_NextPart_000_01C15267.14F82380
Content-Type: application/octet-stream;
	name="fhandler_console.cc-patch"
Content-Disposition: attachment;
	filename="fhandler_console.cc-patch"

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


------_=_NextPart_000_01C15267.14F82380
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------_=_NextPart_000_01C15267.14F82380--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019