nanogui: reading the keyboard
Subject:
reading the keyboard
From:
Yan Seiner ####@####.####
Date:
10 Dec 2005 18:44:42 +0000
Message-Id: <439B2181.7050705@seiner.com>
I am trying to run nano-X progs from init....
One of the programs needs to read the keyboard. Here's the code:
FD_ZERO (&rfds);
FD_SET (0, &rfds);
printf ("k0: %d %d %d\n", k, delay, retval);
retval = select (1, &rfds, NULL, NULL, &tv);
printf ("k1: %d %d %d\n", k, delay, retval);
if (retval)
{
buffer[0] = '\0';
printf ("waiting for ch: %d", read (0, buffer, 1));
.............
}
What happens is that select returns with a 1, but read() blocks. If I
open /dev/stdin O_NONBLOCK, then read() returns -1, signifying an
interrupted read.
I can hold a key down, and I will occasionally get read() to read the
correct char....
So, how do I read the keyboard?
Or, how do I automatically start (and restart) nano-X apps so that they
have access to the keyboard input?
--Yan