home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / backgmmn.zip / KEYIN.C < prev    next >
Text File  |  1987-07-31  |  768b  |  37 lines

  1.  
  2.  
  3. #include "ciao.h"
  4.  
  5. /*=============================*/
  6. /* keyin()                     */
  7. /*                             */
  8. /* extended ASCII chars are    */
  9. /* returned with high bits set */
  10. /*=============================*/
  11.  
  12.  
  13. int keyin( wait )  
  14. void (* wait)();
  15.  
  16. {
  17.      static int ch;
  18.  
  19.  
  20.      do 
  21.      { 
  22.        (* wait)();   /* while waiting for input */
  23.      } 
  24.      while ( !kbhit() );
  25.  
  26.  
  27.      ch = getch();
  28.      if ( kbhit() && (ch == '\0'))  /* extended ASCII */
  29.      {
  30.            ch = getch();     /* read extended char (Fn key, Keypad, etc.) */
  31.            ch |= 128;        /* set high bit to flag origin of this char  */
  32.      }
  33.  
  34.      return( ch & 0xFF );  /* kill sign extension, return values 1..255 */
  35. }
  36.  
  37.