home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / G4CHAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  1.4 KB  |  77 lines

  1.  
  2. /* g4char.c  (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3. */
  4.  
  5. #include "p4misc.h"
  6. #include "w4.h"
  7.  
  8. /* The character is returned according to the IBM scan code format. */
  9.  
  10. #ifdef OS2
  11.    typedef struct  kbd_info_st
  12.    {
  13.       unsigned char   char_code ;
  14.       unsigned char   scan_code ;
  15.       unsigned char   char_status ;
  16.       unsigned char   shift_status ;
  17.       int    shift_state ;
  18.       double time_stamp ;
  19.    }  KBD_INFO ;
  20.  
  21.    extern far pascal KBDCHARIN( KBD_INFO far *, int, int ) ;
  22.  
  23. int  g4char()
  24. {
  25.    KBD_INFO  kbd_info ;
  26.  
  27.    KBDCHARIN( (KBD_INFO far *) &kbd_info, 0, 0 ) ;
  28.  
  29.    if ( kbd_info.char_code )
  30.    {
  31.       if ( kbd_info.char_code == (unsigned char) 0xE0 )
  32.      kbd_info.char_code =  0 ;
  33.       else
  34.      return ( (int) kbd_info.char_code ) ;
  35.    }
  36.  
  37.    return ( *((int *) &kbd_info.char_code) ) ;
  38. }
  39. #else
  40. #ifdef UNIX
  41. int  g4char()
  42. {
  43.    int  rc ;
  44.  
  45.    for( rc = -1; rc <= 0; rc =  getch() ) ;
  46.  
  47.    return ( rc ) ;
  48. }
  49.  
  50. #else
  51.  
  52. #include <dos.h>
  53.  
  54. int  g4char()
  55. {
  56.    union  REGS    regs ;
  57.  
  58.    regs.h.ah = 0x7 ;
  59.    #ifdef IS_386
  60.       int386( 0x21, ®s, ®s ) ;
  61.    #else
  62.       int86( 0x21, ®s, ®s ) ;
  63.    #endif
  64.  
  65.    if ( regs.h.al != 0 )   return ( (int) regs.h.al ) ;
  66.  
  67.    #ifdef IS_386
  68.       int386( 0x21, ®s, ®s ) ;
  69.    #else
  70.       int86( 0x21, ®s, ®s ) ;
  71.    #endif
  72.    return ( (int) (regs.h.al << 8) ) ;
  73. }
  74. #endif
  75. #endif
  76.  
  77.