OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: agena on September 08, 2014, 04:33:14 pm
-
Hello,
yesterday, I searched for hours for an alternative C implementation of kbhit which checks whether
a key on the keyboard has been pressed, and which just returns a Boolean 0 or 1 but does not
write anything to stdout.
The eCS GCC conio header files unfortunately miss this non-ANSI C function.
Do you have a hint ? Thank you.
Alex
-
"KbdGetConsole()".
-
Just copy it from Open Watcom runtime (bld\clib\conio\c\kbhitos2.c).
It looks like only KbdPeek is required for console app:
_WCRTLINK int kbhit( void ){
KBDKEYINFO info;
if( _RWD_cbyte != 0 )
return( 1 );
#ifdef DEFAULT_WINDOWING
if( _WindowsKbhit != 0 ) { // Default windowing
LPWDATA res;
res = _WindowsIsWindowedHandle( (int) STDIN_FILENO );
return( _WindowsKbhit( res ) );
}
#endif
#if defined(__OS2_286__)
if( _RWD_osmode == DOS_MODE ) {
return( _os_kbhit() );
}
KbdPeek( &info, 0 );
return( ( info.fbStatus & 0xe0 ) != 0 );
#else
KbdPeek( &info, 0 );
return( ( info.fbStatus & 0xe0 ) != 0 );
#endif
}
-
Hello,
unfortunately, I found no `[Kk]bd*` functions in the header files of various GCC distributions.
Yes, I came across the Watcom OS/2 port.
I hoped that at least the i286 assembler code I found on the Watcom source distribution site could be compiled, but failed. Also, the Watcom licence somehow does not fit to the MIT licence, but I should check this again.
There is also a kbhit clone in the sources of the Harbour 3.0 language, but found them quite difficult to try.
Alex