예제 #1
0
_WCRTLINK int getch( void )
{
    int         c;
    APIRET      rc;
    KBDKEYINFO  info;

    if( (c = _RWD_cbyte) != 0 ) {
        _RWD_cbyte = 0;
        return( c );
    }
#ifdef DEFAULT_WINDOWING
    if( _WindowsGetch != NULL ) {   // Default windowing
        LPWDATA     res;
        res = _WindowsIsWindowedHandle( (int)STDIN_FILENO );
        return( _WindowsGetch( res ) );
    }
#endif
#if defined(__OS2_286__)
    if( _RWD_osmode == DOS_MODE ) {
        return( _dos( DOS_GET_CHAR_NO_ECHO_CHECK ) );
    }
#endif
    if( (c = _RWD_cbyte2) != 0 ) {
        _RWD_cbyte2 = 0;
        return( c );
    }
    rc = KbdCharIn( &info, 0, 0 );
    if( rc == ERROR_KBD_DETACHED )
        return( EOF );
    if( info.chChar == 0 || info.chChar == 0xe0 ) {
        _RWD_cbyte2 = info.chScan;
    }
    return( info.chChar );
}
예제 #2
0
_WCRTLINK int getch( void )
{
    int         c;
    HANDLE      h;
    DWORD       mode;

    if( (c = _RWD_cbyte) != 0 ) {
        _RWD_cbyte = 0;
        return( c );
    }
#ifdef DEFAULT_WINDOWING
    if( _WindowsGetch != NULL ) {
        LPWDATA res;
        res = _WindowsIsWindowedHandle( (int)STDIN_FILENO );
        c = _WindowsGetch( res );
    } else {
#endif
        _AccessFileH( STDIN_FILENO );
        h = __NTConsoleInput();
        GetConsoleMode( h, &mode );
        SetConsoleMode( h, 0 );
        c = do_getch( h );
        SetConsoleMode( h, mode );
        _ReleaseFileH( STDIN_FILENO );
#ifdef DEFAULT_WINDOWING
    }
#endif
    return( c );
}