/* quad.c by Michael Thorpe 2019-08-10 */ #include #include #include #include #include #include #include #include "runner.h" enum dispmode_t {WIDE,LOOKS,MHL}; static enum dispmode_t dispmode=WIDE; static int midy,midx; struct frame *curframe=0; static void cleanup() { signal(SIGINT,SIG_IGN); move(LINES-1,0); clrtoeol(); refresh(); endwin(); } void draw_titlebar(struct frame *frame) { int i,l; if(frame->title && 0y && 8<=frame->w) { l=strlen(frame->title); if(l+2<=frame->w) { move(frame->y-1,frame->x); for(i=0;i<(frame->w-(l+2))/2;i++) addch('-'); if(frame==curframe) standout(); addch(' '); addstr(frame->title); addch(' '); if(frame==curframe) standend(); i+=l+2; for(;iw;i++) addch('-'); } } } static void setupscreen() { midy=(LINES-1)/2,midx=COLS/2; if(midy<1+12 && 1+12+1input && (curframe->input)(c)) break; if('\x08'==c || '='==c || '\x7F'==c) playaudio("="); else if('+'==c) playaudio("+"); else errmsg("Unknown char"); break; } } int main(int argc,char **argv) { fd_set r; int c,i,maxfd; struct timeval tv; int testmode=0; if(1 != argc) { if(2==argc && !strcmp("-t",argv[1])) { testmode=1; } else { fputs("usage: runner [-t]\n",stderr); return(1); } } if(startaudio(testmode)) { /* this needs to be above looks_load */ fputs("failed to start audio\n",stderr); return(1); } if(looks_load()) { /* this needs to be above scenes_load */ fputs("failed to load looks\n",stderr); return(1); } if(mhl_load()) { /* this needs to be above scenes_load */ fputs("failed to load MHL settings\n",stderr); return(1); } if(scenes_load()) { fputs("failed to load scenes\n",stderr); return(1); } if(fade_init()) { /* this needs to be after looks_load */ fputs("failed to initialize fading\n",stderr); return(1); } if(dmx_setup(testmode)) { fputs("failed to load DMX\n",stderr); return(1); } if(!initscr()) { perror("initscr"); return(1); } atexit(cleanup); signal(SIGINT,cleanup); raw(); noecho(); keypad(stdscr,1); drawscreen(); while(1) { move(LINES-1,rest_column); refresh(); FD_ZERO(&r); FD_SET(0,&r); maxfd=0; if(-1 != dmxin.fd) { FD_SET(dmxin.fd,&r); if(maxfdfd) continue; FD_SET(procdmx[i]->fd,&r); if(maxfdfd) maxfd=procdmx[i]->fd; } tv.tv_sec=0; tv.tv_usec=(curlook && nullupdate != curlook->update)?25000:125000; if(-1==select(maxfd+1,&r,0,0,&tv)) { if(EINTR==errno) { /* It may be a window-resize event, in which case we need to getch the KEY_RESIZE which doesn't show up in select */ halfdelay(1); c=getch(); raw(); // this seems to clear halfdelay, so we don't need nocbreak() if(ERR != c) handle_stdin(c); continue; } perror("select"); exit(-1); } if(FD_ISSET(0,&r)) handle_stdin(getch()); if(-1 != dmxin.fd && FD_ISSET(dmxin.fd,&r)) dmx_readable(&dmxin); for(i=0;ifd,&r)) dmx_readable(procdmx[i]); } dmxout_doit(); } return(0); }