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 From: "Philippe Noel" To: "David W. Alderman" Cc: "Cygwin-List" Subject: RE: Porting getch() and kbdhit() ??? Date: Wed, 18 Aug 1999 16:56:05 -0400 Message-ID: <003d01bee9bc$16d90f40$400010ac@philippe.socoint.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 In-Reply-To: <4.2.0.58.19990818104947.00a78dc0@dummy.mmrd.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Importance: Normal Hi, > > I suspect you (Philippe?) have a program loop like this: > > while ( TRUE ) > { > if kbhit() > { > inchar = getch(); > > } > > > } > Exactly. :) What I want to do is, in my mind, extremely simple and common. In fact, I need the application catch any characters typed on the keyboard if there is any. For example, if the user wants to quit during the process is running, he press Q, the application catch the character and quit. So, a function like getchar() don't do the job because this function waits for a keypress before returning... > 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! > Yes great, but I really don't find any actions in ioctl (or tcsetattr :) ) that allowed to switch to a kind of "RAW MODE". So, the question about read() stay unresolved (for me): It seems the read function waits for a character infinitly and there's no way to make it returns if no character is catched on STDIN. P.S.: The kbhit() function I was searching for is exaclty the one Warren found in is "M$-C book" (?) : the function kbhit() should return a 0 if no characters have been struck otherwise the character-code of the struck key (without removing the key from the KB queue). PN -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com