home *** CD-ROM | disk | FTP | other *** search
-
- /* g4char.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
- */
-
- #include "p4misc.h"
- #include "w4.h"
-
- /* The character is returned according to the IBM scan code format. */
-
- #ifdef OS2
- typedef struct kbd_info_st
- {
- unsigned char char_code ;
- unsigned char scan_code ;
- unsigned char char_status ;
- unsigned char shift_status ;
- int shift_state ;
- double time_stamp ;
- } KBD_INFO ;
-
- extern far pascal KBDCHARIN( KBD_INFO far *, int, int ) ;
-
- int g4char()
- {
- KBD_INFO kbd_info ;
-
- KBDCHARIN( (KBD_INFO far *) &kbd_info, 0, 0 ) ;
-
- if ( kbd_info.char_code )
- {
- if ( kbd_info.char_code == (unsigned char) 0xE0 )
- kbd_info.char_code = 0 ;
- else
- return ( (int) kbd_info.char_code ) ;
- }
-
- return ( *((int *) &kbd_info.char_code) ) ;
- }
- #else
- #ifdef UNIX
- int g4char()
- {
- int rc ;
-
- for( rc = -1; rc <= 0; rc = getch() ) ;
-
- return ( rc ) ;
- }
-
- #else
-
- #include <dos.h>
-
- int g4char()
- {
- union REGS regs ;
-
- regs.h.ah = 0x7 ;
- #ifdef IS_386
- int386( 0x21, ®s, ®s ) ;
- #else
- int86( 0x21, ®s, ®s ) ;
- #endif
-
- if ( regs.h.al != 0 ) return ( (int) regs.h.al ) ;
-
- #ifdef IS_386
- int386( 0x21, ®s, ®s ) ;
- #else
- int86( 0x21, ®s, ®s ) ;
- #endif
- return ( (int) (regs.h.al << 8) ) ;
- }
- #endif
- #endif
-
-