|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 768 (0x300)
Types: TextFile
Names: »getkey.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Snake2/getkey.c«
/* getkey.c - Don Libes
getkey() - return the last key struck by the user or -1.
If user has struct multiple keys, ignore all but the last.
*/
#include "snake2.h"
#include <stdio.h>
#if BSD42 || BSD41 || EUNICE
#include <sys/ioctl.h>
#endif
#if SYSV
#include <sys/termio.h>
#endif
#ifdef FIONREAD
int
getkey()
{
long chars = 0;
if (-1 == ioctl(fileno(stdin),FIONREAD,&chars)) {
cleanup();
perror("ioctl in getkey");
exit(0);
}
if (chars == 0) return(-1);
while (chars-- > 1) getchar();
return(getchar() & 0x7f); /* strip parity */
}
#else
makehalfdelay()
{
struct termio curtty;
ioctl(1, TCGETA, &curtty);
curtty.c_cc[VMIN] = 0;
curtty.c_cc[VTIME] = TIMEOUT;
ioctl(1, TCSETAW, &curtty);
}
int
getkey()
{
return getchar();
}
#endif FIONREAD