[Coco] [Color Computer] INKEY equivalent for C?

Mannequin* mannslists at invigorated.org
Sun Dec 25 18:43:05 EST 2005


James Gerrie wrote:
> Can someone tell me how to get an INKEY like function for OS9 C for the 
> CoCo?  Is there something like a KBHIT function that someone has created. A 
> work around?
> 
> Jim G 

I've been playing around with this a little. With Bob Devries' help, I
came up with something that acts like an INKEY$, but doesn't deal with
the OS-9 echo issue... YET! ;)

> #include <stdio.h>
> 
> int main (void)
> {
>   int c;                                 /* 1 Character buffer */
> 
>   setbuf (stdin, NULL);                  /* Turns off stdin buffering */
>   while ((c = getchar ()) != 35)         /* 35 is the '#' character */
>     printf ("%c, ", c);                  /* Print out the character */
> 
>   printf ("\n");
>   return 0;
> }

This is just something that I was playing around with last night. The
output is something like this:

> ff, qq, 55, hh, #

Or something similar, anyway. The user entered the keys, 'f', 'q', '5',
'h', and '#' The duplicates are because of OS-9's echoing. (Which Bob
and I are working to re-figure out. :) )

Once everything is working as I want it to (and it isn't quite as much a
hack), I might release this under the GNU GPL so that these kind of
issues will be, once again, in the past.

-M.



More information about the Coco mailing list