Beispiel #1
0
int
awaitkey(int timeout, int tell)
{
	struct linux_termios orig_termios, raw_termios;
	int c = 0;
	int i;

	/* set raw mode */
	linux_tcgetattr(infd, &orig_termios);
	raw_termios = orig_termios;
	linux_cfmakeraw(&raw_termios);
	linux_tcsetattr(infd, LINUX_TCSETS, &raw_termios);

	for (i = timeout; i > 0; i--) {
		if (tell) {
			char numbuf[20];
			int len, j;

			sprintf(numbuf, "%d ", i);
			len = strlen(numbuf);
			for (j = 0; j < len; j++)
				numbuf[len + j] = '\b';
			numbuf[len + j] = '\0';
			printf("%s", numbuf);
		}
		c = common_getc(infd, 1);
		if (c == 0)
			c = -1;
		if (c >= 0)
			break;
	}
	if (i == 0)
		c = '\0';

	/* set original mode */
	linux_tcsetattr(infd, LINUX_TCSETS, &orig_termios);

	if (tell)
		printf("0 \n");

	return c;
}
Beispiel #2
0
int
getchar(void)
{

	return common_getc(infd, 1);
}
int
com_getc(dev_t dev)
{
	return (common_getc(dev));
}