TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: John Gladkih
from: David Noon
date: 1996-03-08 22:16:04
subject: next .

On Saturday, 96/03/02, John Gladkih wrote to David Muir about "next
." as follows:

JG> #define INCL_KBD
JG> #include 
JG> 
JG> void setBinaryKbdMode()
JG> {
JG>   static KBDINFO ki;
      ^^^^^^
JG> 
JG>   ki.cb = sizeof(ki);
JG>   KbdGetStatus(&ki, 0);
                        ^
JG> 
JG>   ki.fsMask &= ~KEYBOARD_ASCII_MODE;
JG>   ki.fsMask |= KEYBOARD_BINARY_MODE;
JG>   ki.cb = sizeof(ki);
JG>   KbdSetStatus(&ki, 0);
                        ^
JG> }

Hi John,

Do you think this code will be thread safe?

While it is rare that multiple threads will access the keyboard it is
possible, especially with multiple VIO windows open from the same app.

Perhaps

 #define INCL_KBD
 #include 
 
 void setBinaryKbdMode(HKBD kb)
 {
   KBDINFO ki;

   ki.cb = sizeof(ki);
   KbdGetStatus(&ki, kb);

   ki.fsMask &= ~KEYBOARD_ASCII_MODE;
   ki.fsMask |= KEYBOARD_BINARY_MODE;
   ki.cb = sizeof(ki);
   KbdSetStatus(&ki, kb);
 }

would be a little safer. If you want it to manipulate the default
keyboard call it using a parameter of NULLSHANDLE or 0.

Regards

Dave


 * KWQ/2 1.2i * If ignorance is bliss, I'm in hog heaven!!
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 440/4 141/209 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.