39 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) 41 #include <sys/select.h> 42 #include <visp3/io/vpKeyboard.h> 77 struct timeval tv = {0, 0};
81 FD_SET(STDIN_FILENO, &readfds);
83 return select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) == 1;
90 void vpKeyboard::init() { setRawMode(
true); }
96 void vpKeyboard::end() { setRawMode(
false); }
105 void vpKeyboard::setRawMode(
bool active)
109 tcgetattr(STDIN_FILENO, &initial_settings);
113 new_settings = initial_settings;
114 new_settings.c_lflag &= (
unsigned int)~ICANON;
115 new_settings.c_lflag &= (
unsigned int)~ECHO;
116 new_settings.c_lflag &= (
unsigned int)~ISIG;
119 new_settings.c_oflag &= (
unsigned int)~TAB0;
121 new_settings.c_cc[VMIN] = 1;
122 new_settings.c_cc[VTIME] = 0;
123 tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);
126 tcsetattr(STDIN_FILENO, TCSANOW, &initial_settings);
130 #endif // defined UNIX