extern int fbread(struct fb *fb) { fd_set fdset; struct timeval tv; int i, key; if(!fb->hw) return 0; if(fb->hw->nfds == -1) return 0; for(i=0; i<5; i++) { if(fb->hw->ms.micev[i]) { key = fb->hw->ms.micev[i]; fb->hw->ms.micev[i] = 0; return key; } } tv.tv_sec = tv.tv_usec = 0; fdset = fb->hw->fdset; if(select(fb->hw->nfds+1, &fdset, 0, 0, &tv) > 0) { if(fb->hw->kb.fd != -1) { if(FD_ISSET(fb->hw->kb.fd, &fdset)) { return kbread(fb); } } if(fb->hw->ms.fd != -1) { if(FD_ISSET(fb->hw->ms.fd, &fdset)) { int btn, oldbtn, dx, dy; if((btn = msread(fb, &dx, &dy)) != -1) { if(dx != 0) fb->hw->ms.micev[0] = dx<<16 | MICE_DX; if(dy != 0) fb->hw->ms.micev[1] = dy<<16 | MICE_DY; oldbtn = fb->hw->ms.oldbtn; if((oldbtn & 0x1) && !(btn & 0x1)) fb->hw->ms.micev[2] = MICE_LEFT | 0x8000; if(!(oldbtn & 0x1) && (btn & 0x1)) fb->hw->ms.micev[2] = MICE_LEFT; if((oldbtn & 0x2) && !(btn & 0x2)) fb->hw->ms.micev[3] = MICE_RIGHT | 0x8000; if(!(oldbtn & 0x2) && (btn & 0x2)) fb->hw->ms.micev[3] = MICE_RIGHT; if((oldbtn & 0x4) && !(btn & 0x4)) fb->hw->ms.micev[4] = MICE_MIDDLE | 0x8000; if(!(oldbtn & 0x4) && (btn & 0x4)) fb->hw->ms.micev[4] = MICE_MIDDLE; fb->hw->ms.oldbtn = btn; return fbread(fb); } } } } return 0; }
/* Process any keyboard input - removed from main() to make accessable * by other processes - K5JB */ void check_kbd() { char *ttybuf; int c; int16 cnt; int ttydriv(),cmdparse(),kbread(); #ifdef FLOW extern int ttyflow; #endif extern struct cmds cmds[]; extern char prompt[]; #ifdef SYS5 #ifdef USE_QUIT if(reportquit_flag) /* set by quit signal and report is deferred */ report_quit(); /* until now */ #endif /* note that if shellpid, kbread() always returns -1 */ while((background == 0) && ((c = kbread()) != -1)) #else while((c = kbread()) != -1) #endif { #ifdef MSDOS /* c == -2 means the command escape key (F10) */ Keyhit = c; /* a global we use for haktc */ if(c == -2) { if(mode != CMD_MODE) { #ifdef CUTE_VIDEO putca('\n',saved_attrib); /* in case we were in session */ #else printf("\n"); #endif cmdmode(); } continue; } #endif #if defined(UNIX) || defined(_OSK) if(c == escape && escape != 0) { if(mode != CMD_MODE) { printf("\n"); cmdmode(); } continue; } #endif /* UNIX or _OSK */ #ifndef FLOW if ((cnt = ttydriv(c, &ttybuf)) == 0) continue; #else cnt = ttydriv(c, &ttybuf); if (ttyflow && (mode != CMD_MODE)) go(); /* display pending chars */ if (cnt == 0) continue; #endif /* FLOW */ switch(mode) { case CMD_MODE: (void)cmdparse(cmds,ttybuf); fflush(stdout); break; case CONV_MODE: if(current->parse != NULLFP) (*current->parse)(ttybuf,cnt); break; } #if defined(FORKSHELL) && defined(SYS5) if(mode == CMD_MODE && !shellpid) #else if(mode == CMD_MODE) #endif { if(noprompt) /* k35 */ noprompt = 0; else { printf(prompt); fflush(stdout); } } } /* while */ }