From owner-freebsd-hackers@FreeBSD.ORG Wed May 7 19:06:34 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CD9B106566C for ; Wed, 7 May 2008 19:06:34 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [IPv6:2001:770:10:300::86e2:510b]) by mx1.freebsd.org (Postfix) with SMTP id E8C858FC0A for ; Wed, 7 May 2008 19:06:32 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie ([134.226.81.10] helo=walton.maths.tcd.ie) by salmon.maths.tcd.ie with SMTP id ; 7 May 2008 20:06:31 +0100 (BST) Date: Wed, 7 May 2008 20:06:31 +0100 From: David Malone To: rmgls@free.fr Message-ID: <20080507190631.GA90936@walton.maths.tcd.ie> References: <20080507153903.41F6C322858@smtp7-g19.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080507153903.41F6C322858@smtp7-g19.free.fr> User-Agent: Mutt/1.5.6i Sender: dwmalone@maths.tcd.ie Cc: freebsd-hackers@freebsd.org Subject: Re: general i/o question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2008 19:06:34 -0000 On Wed, May 07, 2008 at 05:39:00PM +0200, rmgls@free.fr wrote: > i need to test (NOWAIT), the presence of keypressed/depressed on a terminal > and then read the scan code, like for a piano pc keyboard. > > my questions are as follows: > > 1. is it a general C function which may scan a terminal without waiting? There isn't a general way of doing this, as even if there is a terminal attached, the terminal may actaully be an ssh session, and which does not transmit key up/down events. If you look at the Unix TTY stuff, you can get the stream of keys pressed, but this may not be enough for a piano type application. If you're only targeting the FreeBSD console there may be other options, but it will be more specific that TTY calls. If you are trageting X11, then it does support key up/down events and a book or tutorial on X programming should help. David.