39 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) 41 #include <visp3/io/vpKeyboard.h> 76 struct timeval tv = {0, 0};
80 FD_SET(STDIN_FILENO, &readfds);
82 return select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) == 1;
89 void vpKeyboard::init() { setRawMode(
true); }
95 void vpKeyboard::end() { setRawMode(
false); }
104 void vpKeyboard::setRawMode(
bool active)
108 tcgetattr(STDIN_FILENO, &initial_settings);
112 new_settings = initial_settings;
113 new_settings.c_lflag &= (
unsigned int)~ICANON;
114 new_settings.c_lflag &= (
unsigned int)~ECHO;
115 new_settings.c_lflag &= (
unsigned int)~ISIG;
118 new_settings.c_oflag &= (
unsigned int)~TAB0;
120 new_settings.c_cc[VMIN] = 1;
121 new_settings.c_cc[VTIME] = 0;
122 tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);
125 tcsetattr(STDIN_FILENO, TCSANOW, &initial_settings);
129 #endif // defined UNIX