int has_imps2(int fd) { uint8 query = 0xF2; purgefd(fd); if(write(fd, &query, sizeof (query)) != sizeof(query)) return 0; uint8 ch = 0; fd_set fdset; struct timeval tv; while(1) { FD_ZERO(&fdset); FD_SET(fd, &fdset); tv.tv_sec = 1; tv.tv_usec = 0; if(select(fd+1, &fdset, 0, 0, &tv) < 1) break; if(read(fd, &ch, sizeof(ch)) != sizeof(ch)) break; switch(ch) { case 0xFA: case 0xAA: continue; case 3: case 4: return 1; default: return 0; } } return 0; }
void filesrv::fhetimeout (void) { purgefhe (); purgefd (0); fhetmo = delaycb (fhe_timer, wrap (this, &filesrv::fhetimeout)); }
int set_imps2(int fd, int b) { uint8 set[] = {0xf3, 200, 0xf3, 100, 0xf3, 80}; uint8 reset[] = {0xff}; int retval = 0; if(b && write(fd, &set, sizeof(set)) != sizeof(set)) return 0; //SDL says not to reset, some mice wont work with it if(!b && write(fd, &reset, sizeof (reset)) != sizeof(reset)) return 0; purgefd(fd); return 1; }
int filesrv::checkfd (void) { if (fd_n < fd_max) return 1; purgefd(1); if (fd_n < fd_max) { return 1; } else { warnx << "checkfd: ENFILE\n"; errno = ENFILE; return 0; } }