home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8926 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.4 KB

  1. Path: sparky!uunet!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
  2. Newsgroups: comp.os.msdos.programmer
  3. Subject: Re: Reading ALT keys with bioskey in TC++?
  4. Message-ID: <1992Aug31.151537.2189@brandonu.ca>
  5. From: dueck@brandonu.ca
  6. Date: 31 Aug 92 15:15:37 CST
  7. References: <1992Aug25.184207.7825@lclark.edu>
  8. Organization: Brandon University, Brandon, Manitoba, Canada
  9. Lines: 25
  10.  
  11. In article <1992Aug25.184207.7825@lclark.edu>, harrison@sun.lclark.edu (Mark Harrison) writes:
  12. > Hi.  I am reading ALT+<key> from the keyboard with bioskey (in TC++ 3.0.)
  13. > But that gives me values that map to the physical layout of the keyboard. 
  14. > Is there an easy way to translate this value into one that will tell me
  15. > the Ascii code of the key?  For instance, how do I transform 0x3100
  16. > (ALT+N) to get the ascii code of N?  Will I need to write a function that
  17. > will do this for all the ALT values I want to check for?  If so, then no
  18. > problem.  I just don't want to reinvent any wheels.
  19. The easiest way is to look at the keyboard status flags right after obtaining
  20. a character from the keyboard. You can obtain them via interrupt 16, function 2.
  21. This call returns the contents of 40:17 in AL. Bit 3 (mask 0x80) is set if an
  22. ALT key is depressed. So:
  23.  
  24.    if (kbhit()) {
  25.       ch = getch();
  26.       _AH = 2;
  27.       __emit__(0xcd, 0x16);
  28.       if (_AL & 0x08)
  29.          ALT was down
  30.       }
  31.  
  32. Gery Dueck
  33. dueck@brandonu.ca
  34.