[Coco] [Color Computer] Inkey for Microware C Compiler

David dbree at duo-county.com
Mon Dec 8 22:30:01 EST 2003


On Mon, Dec 08, 2003 at 07:04:45PM -0500, KnudsenMJ at aol.com wrote:
> In a message dated 12/7/03 10:58:28 PM Eastern Standard Time, 
> dbree at duo-county.com writes:
> 
> > If you have the Level 2 Development system (I believe it's from there),
> >  you also have the _gs_rdy() function that returns the status of whether
> >  a character is available.
> 
> Turns out there's a getstat(fcn, channel) in the C library that I'd been 
> using on the Coco3.  It returns an antique legacy style value:  -1 if no 
> characters are waiting in the buffer, 0 if there are some.

> >  I guess there are ways around all this in unix/linux.  Remember some
> >  time ago when you(?) and I were complaining about the lack of the
> >  capability of a single-key input in linux?  Someone pointed out a very
> >  simple solution to the problem.  I've thought about writing a library
> >  inkey() function for linux, but haven't done so yet.
> 
> I recall only a messy solution with several lines of ioctl() that had to be 
> done and undone before each call to read a char.  Though I guess once
> you've  writtena nd debugged that code and it works, it's "simple"
> to keep on using it

I didn't really think it was all that messy.  You could write a
function, say, "inkey()", that would do the ioctl() sets, wait for
input, and then do the reset, and then probably return the character
that was input.  I would have preferred to have done this than what I
had done, which was, rewrite my program under ncurses simply to get the
inkey function.

> If you know how to add your own functions to the library, you're pretty 
> advanced.  I used to know in theory how to do it for OS-9.  --Mike K.

I was thinking more in terms of maybe writing a "standard" file with
a few utility functions.  However, as far as creating a "library",
although I've never done it - never had the need or opportunity to do so
yet - I don't think it's really difficult.  From my cursory
examinations, I think that using automake would simplify the maintenance
of your library.




More information about the Coco mailing list