55 #include <sys/select.h> 67 #include "rnr/rnrconfig.h" 83 PRAGMA_IGNORED(sign-conversion)
93 PRAGMA_WARNING(sign-conversion)
100 int StateKb::ClassObjRefCnt = 0;
101 int StateKb::OrigInputStatusFlags = 0;
104 int StateKb::receiveEvent()
108 struct timeval timeout;
109 int fd = fileno(stdin);
117 if( m_usecTimeOut > 0 )
120 timeout.tv_sec = (time_t)(m_usecTimeOut / 1000000);
121 timeout.tv_usec = (time_t)(m_usecTimeOut % 1000000);
123 nFd = select(fd+1, &rset, NULL, NULL, &timeout);
129 nFd = select(fd+1, &rset, NULL, NULL, NULL);
135 LOGSYSERROR(
"select(%d,...)", fd);
142 LOGDIAG4(
"select() on read timed out");
144 return KbEventTimeOut;
148 else if( (n = read(fd, &byte, (
size_t)1)) < 0 )
150 LOGSYSERROR(
"read(%d,...)", fd);
157 LOGERROR(
"0=read(%d,...)", fd);
165 LOGDIAG4(
"%s() byte=0x%02x read", LOGFUNCNAME, byte);
166 return (
int)(((uint_t)(byte)) & 0x00ff);
170 void StateKb::configInput()
173 int fd = fileno(stdin);
176 tcgetattr(fd, &OrigInputTio);
182 tio.c_lflag &= (uint_t)(~ICANON & ~ECHO);
185 tcsetattr(fd, TCSANOW, &tio);
188 OrigInputStatusFlags = fcntl(fd, F_GETFL, 0);
191 fcntl(fd, F_SETFL, OrigInputStatusFlags | O_NONBLOCK);
194 void StateKb::restoreInput()
196 int fd = fileno(stdin);
198 tcsetattr(fd, TCSANOW, &OrigInputTio);
200 fcntl(fd, F_SETFL, OrigInputStatusFlags);
static void fdset_nowarn(int fd, fd_set *pset)
FD_SET() wrapper with no annoying warnings.
Keyboard StateKb derived state class interface.
Random variable generator class interface.
State base class interface.