Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <4.2.0.58.19990818104947.00a78dc0@dummy.mmrd.com> X-Sender: dave AT 192 DOT 2 DOT 2 DOT 24 X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58 Date: Wed, 18 Aug 1999 11:21:24 -0400 To: "Lincoln, W. Terry" , "'Philippe Noel'" From: "David W. Alderman" Subject: RE: Porting getch() and kbdhit() ??? Cc: "'Cygwin Mailing List'" In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Hi guys, kbhit and getch were defined in Xenix, I believe. They were included to allow greater compatibility with DOS :-) Unfortunately, both functions do not fit well with a mode-oriented ioctl-based input stream, although I guess you could do a kbhit() equivalent in cbreak mode, which is appropriate mode for getch(). I suspect you (Philippe?) have a program loop like this: while ( TRUE ) { if kbhit() { inchar = getch(); } } Under ioctl(), this could be implemented as: ioctl() // So we can restore later ioctl() // So read will return if no key has been pressed while (TRUE) { if (read(0, inbuf, 1) // Returns 0 if no key pressed { } } ioctl() // Be nice to your parent shell! The correct settings for ioctl() under cygwin are left as an exercise for the implementer :-) Please forgive any obvious errors (or any non-obvious ones). At 06:11 PM 8/17/1999 -0400, Lincoln, W. Terry wrote: >Those two functions are not POSIX now, are they? Sounds DOS/WINDOZISH to me >;-) >Cygwin is for porting Unix(POSIX) apps to Win32. > > -----Original Message----- > > From: Philippe Noel [mailto:pnoel AT socoint DOT com] > > I'm currently trying to port a source code that use getch() > > and kbdhit() > > under Linux. > > It really do not seems to be supported by Cygwin. Is there a > > reason for > > this? > > > > And, is there a way to do the same thing as this (very > > common) code under > > Cygwin? > > > > if( kbdhit() ) > > key = getch(); > > Dave Alderman - Democracy should not be capital intensive. Business: dave AT mmrd DOT com Personal: dwa AT atlantic DOT net -or- dwa AT netcommander DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com