int GetRCCode(char *key, int timeout) { int tmo=timeout; timeout>>=1; if(key) { while(Translate(rccode)!=(int)(*key)) { RCKeyPressed(); usleep(10000L); if(tmo &&((timeout-=10)<=0)) { return 'X'; } } } else { while(!RCKeyPressed()) { usleep(10000L); if(tmo &&((timeout-=10)<=0)) { return 'X'; } } } return Translate(rccode); }
int GetRCCode(void) { int rv; if(!RCKeyPressed() || (get_instance()>instance)) { return -1; } rv=rccode; while(RCKeyPressed()); return RCTranslate(rv); }
int GetRCCode(int timeout_in_ms) { int rv = -1; if (get_instance()>instance) { return rv; } if (timeout_in_ms) { struct pollfd pfd; struct timeval tv; uint64_t ms_now, ms_final; pfd.fd = rc; pfd.events = POLLIN; pfd.revents = 0; gettimeofday( &tv, NULL ); ms_now = tv.tv_usec/1000 + tv.tv_sec * 1000; if (timeout_in_ms > 0) ms_final = ms_now + timeout_in_ms; else ms_final = UINT64_MAX; while (ms_final > ms_now) { switch(poll(&pfd, 1, timeout_in_ms)) { case -1: perror("GetRCCode: poll() failed"); case 0: return -1; default: ; } if(RCKeyPressed()) { rv = rccode; while(RCKeyPressed()); return RCTranslate(rv); } gettimeofday( &tv, NULL ); ms_now = tv.tv_usec/1000 + tv.tv_sec * 1000; if (timeout_in_ms > 0) timeout_in_ms = (int)(ms_final - ms_now); } } else if(RCKeyPressed()) { rv = rccode; while(RCKeyPressed()); return RCTranslate(rv); } return rv; }
int GetCode(void) { if(!RCKeyPressed() || (get_instance()>instance)) { return -1; } do { rc_last_key = ev.code; } while(RCKeyPressed()); return RCTranslate(rc_last_key); }
int InitRC(void) { rc = open(RC_DEVICE, O_RDONLY | O_CLOEXEC); if(rc == -1) { perror(__plugin__ " <open remote control>"); exit(1); } fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC); while(RCKeyPressed()); return 1; }
int GetRCCode(char *key, int timeout) { int tmo=timeout; timeout>>=1; if(key) { while(Translate(ev.code)!=(int)(*key)) { RCKeyPressed(); usleep(10000L); if(tmo &&((timeout-=10)<=0)) { return 'X'; } } } else { while(!RCKeyPressed()) { usleep(10000L); if(tmo &&((timeout-=10)<=0)) { return 'X'; } } } do { rc_last_key = ev.code; } while(RCKeyPressed()); rccode=Translate(rc_last_key); return rccode; }
int InitRC(void) { rc = open(RC_DEVICE, O_RDONLY); #ifdef MARTII if (rc < 0) rc = open(RC_DEVICE_FALLBACK, O_RDONLY); #endif if(rc == -1) { perror("msgbox <open remote control>"); exit(1); } fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC); while(RCKeyPressed()); return 1; }
int main (int argc, char **argv) { int tv,index,i,j,cmct=CMCT,cmc=CMC,trnspi=TRANSP,trnsp=0,found,loop=1,first=1,x0,x1,x2,x3,x4,x5,x6,x7; int xdir=1, ydir=1; double xstep=1, ystep=1; double csx, cex, csy, cey; time_t atim; struct tm *ltim; char *aptr,*rptr; char dstr[2]={0,0}; printf("SSaver Version %s\n",CL_VERSION); ReadConf(); for(i=1; i<argc; i++) { aptr=argv[i]; if((rptr=strchr(aptr,'='))!=NULL) { rptr++; if(strstr(aptr,"DATE=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { sdat=j; } } if(strstr(aptr,"BIG=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { big=(j)?1:0; } } if(strstr(aptr,"SEC=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { secs=j; } } if(strstr(aptr,"SLOW=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { if(!j) { j=1; } slow=j; } } if(strstr(aptr,"FCOL=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { fcol=j; } } if(strstr(aptr,"BCOL=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { bcol=j; } } } } if((sx=Read_Neutrino_Cfg("screen_StartX"))<0) sx=80; if((ex=Read_Neutrino_Cfg("screen_EndX"))<0) ex=620; if((sy=Read_Neutrino_Cfg("screen_StartY"))<0) sy=80; if((ey=Read_Neutrino_Cfg("screen_EndY"))<0) ey=505; if(!slow) { slow=1; } if(slow>10) { slow=10; } xpos=ex/2; ypos=ey/2; for(index=CMCST; index<=CMH; index++) { sprintf(tstr,"menu_%s_alpha",menucoltxt[index-1]); if((tv=Read_Neutrino_Cfg(tstr))>=0) tr[index-1]=(tv<<8); sprintf(tstr,"menu_%s_blue",menucoltxt[index-1]); if((tv=Read_Neutrino_Cfg(tstr))>=0) bl[index-1]=(tv+(tv<<8)); sprintf(tstr,"menu_%s_green",menucoltxt[index-1]); if((tv=Read_Neutrino_Cfg(tstr))>=0) gn[index-1]=(tv+(tv<<8)); sprintf(tstr,"menu_%s_red",menucoltxt[index-1]); if((tv=Read_Neutrino_Cfg(tstr))>=0) rd[index-1]=(tv+(tv<<8)); } fb = open(FB_DEVICE, O_RDWR); if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) { printf("Clock <FBIOGET_FSCREENINFO failed>\n"); return -1; } if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) { printf("Clock <FBIOGET_VSCREENINFO failed>\n"); return -1; } if(ioctl(fb, FBIOGETCMAP, &colormap) == -1) { printf("Clock <FBIOGETCMAP failed>\n"); return -1; } if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0))) { printf("Clock <mapping of Framebuffer failed>\n"); return -1; } //init fontlibrary if((error = FT_Init_FreeType(&library))) { printf("Clock <FT_Init_FreeType failed with Errorcode 0x%.2X>", error); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager))) { printf("Clock <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_SBitCache_New(manager, &cache))) { printf("Clock <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_Manager_Lookup_Face(manager, FONT, &face))) { printf("Clock <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } use_kerning = FT_HAS_KERNING(face); #ifdef FT_NEW_CACHE_API desc.face_id = FONT; desc.flags = FT_LOAD_MONOCHROME; #else desc.font.face_id = FONT; desc.image_type = ftc_image_mono; #endif if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres))) { printf("Clock <allocating of Backbuffer failed>\n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres); startx = sx; starty = sy; xstep/=(double)slow; ystep/=(double)slow; InitRC(); while(loop) { usleep(15000L); ioctl(fb, FBIOGETCMAP, &colormap); found=0; trnsp=0; for(i=colormap.start;i<colormap.len && found!=7;i++) { if(!colormap.red[i] && !colormap.green[i] && !colormap.blue[i] && !colormap.transp[i]) { cmc=i; found|=1; } if(colormap.red[i]>=0xF000 && colormap.green[i]>=0xF000 && colormap.blue[i]>=0xF000 && !colormap.transp[i]) { cmct=i; found|=2; } if(colormap.transp[i]>trnsp) { trnspi=i; trnsp=colormap.transp[i]; found|=4; } } if(first) { first=0; memset(lbb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres); memset(lfb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres); } if(big) { x0=3; x1=14; x2=26; x3=BIG; x4=30; x5=60; } else { x0=7; x1=12; x2=18; x3=MED; x4=18; x5=40; } x6=0; x7=0; time(&atim); ltim=localtime(&atim); if(secs) { sprintf(tstr,"%02d:%02d:%02d",ltim->tm_hour,ltim->tm_min,ltim->tm_sec); } else { sprintf(tstr," %02d%c%02d",ltim->tm_hour,(ltim->tm_sec & 1)?':':' ',ltim->tm_min); if(!sdat) { x6=3; x7=36+4*big; } } xpos+=xstep*(double)xdir; ypos+=ystep*(double)ydir; csx=xpos+x7; csy=ypos; cex=xpos+x7+100+20*big; cey=ypos+x2+2*(1+big)+sdat*x4; if(csx<0 || (sx+cex)>=ex) { xdir*=-1; xpos+=xstep*(double)xdir; csx=xpos+x7; cex=xpos+x7+100+20*big; xstep=rand()&3; if(!xstep) { xstep=1; } xstep/=(double)slow; } if(csy<0 || (sy+cey)>=ey) { ydir*=-1; ypos+=ystep*(double)ydir; csy=ypos; cey=ypos+x2+2*(1+big)+sdat*x4; ystep=rand()&3; if(!ystep || (ystep==3 && ydir==1)) { ystep=1; } ystep/=(double)slow; } for(i=x6; i<strlen(tstr); i++) { *dstr=tstr[i]; RenderString(dstr, xpos-x0+(i*x1), ypos+x2, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc)); } if(sdat) { sprintf(tstr,"%02d.%02d.%02d",ltim->tm_mday,ltim->tm_mon+1,ltim->tm_year-100); for(i=0; i<strlen(tstr); i++) { *dstr=tstr[i]; RenderString(dstr, xpos-x0+(i*x1), ypos+x5-2-2*big, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc)); } } for(i=0;i<=((sdat)?40:20)*(1+big);i++) { j=(starty+ypos+i)*var_screeninfo.xres+xpos+startx; if((j+100+20*big)<var_screeninfo.xres*var_screeninfo.yres) { memcpy(lfb+j, lbb+j, 100+20*big); } } RenderBox(csx, csy, cex, cey, FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct)); if(++loop>10) { if(RCKeyPressed()||ExistFile("/tmp/.ssaver_kill")) { loop=0; } } } cmct=0; cmc=0; for(i=colormap.start;i<colormap.len;i++) { if(colormap.transp[i]>cmct) { cmc=i; cmct=colormap.transp[i]; } } memset(lfb, cmc, var_screeninfo.xres*var_screeninfo.yres); FTC_Manager_Done(manager); FT_Done_FreeType(library); free(lbb); munmap(lfb, fix_screeninfo.smem_len); close(fb); CloseRC(); remove("/tmp/.ssaver_kill"); return 0; }
int main (int argc, char **argv) { unsigned int margin_left_F, digit_width, margin_top_t, font_size, margin_top_box, margin_top_d, digits, secs_width, adj_height; int i = 0; int j = 0; int w = 0; int ms = 0; int mw = 0; int loop = 1; unsigned int newmail = 0; unsigned int mailgfx = 0; int xdir = 1, ydir = 1; double xstep = 1, ystep = 1; double csx, cex, csy, cey; time_t atim; struct tm *ltim; char *aptr,*rptr; char dstr[2] = {0,0}; FILE *tfh; printf("Clock / SSaver Version %s\n",CL_VERSION); for (i = 1; i < argc; i++) { if (!strncmp(argv[i], "-ss", 3)) { ssaver = 1; continue; } } if (ssaver) { time(&atim); srand((unsigned int)atim); ReadConf(SCFG_FILE); } else { ReadConf(CCFG_FILE); } for (i = 1; i < argc; i++) { aptr=argv[i]; if((rptr=strchr(aptr,'='))!=NULL) { rptr++; if (!ssaver) { if(strstr(aptr,"X=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { xpos=j; } } if(strstr(aptr,"Y=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { ypos=j; } } if(strstr(aptr,"MAIL=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { mail=j; } } } if(strstr(aptr,"DATE=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { show_date=j; } } if(strstr(aptr,"BIG=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { big=(j)?1:0; } } if(strstr(aptr,"SEC=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { show_sec=j; } } if(strstr(aptr,"BLINK=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { blink=j; } } if(strstr(aptr,"SLOW=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { if(!j) { j=1; } slow=j; } } if(strstr(aptr,"FCOL=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { fcol=j; } } if(strstr(aptr,"BCOL=")!=NULL) { if(sscanf(rptr,"%d",&j)==1) { bcol=j; } } } } if((sx=Read_Neutrino_Cfg("screen_StartX"))<0) sx=80; if((ex=Read_Neutrino_Cfg("screen_EndX"))<0) ex=620; if((sy=Read_Neutrino_Cfg("screen_StartY"))<0) sy=80; if((ey=Read_Neutrino_Cfg("screen_EndY"))<0) ey=505; fb = open(FB_DEVICE, O_RDWR); if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) { printf("Clock / SSaver <FBIOGET_FSCREENINFO failed>\n"); return -1; } if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) { printf("Clock / SSaver <FBIOGET_VSCREENINFO failed>\n"); return -1; } if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0))) { printf("Clock / SSaver <mapping of Framebuffer failed>\n"); return -1; } //init fontlibrary if((error = FT_Init_FreeType(&library))) { printf("Clock / SSaver <FT_Init_FreeType failed with Errorcode 0x%.2X>", error); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager))) { printf("Clock / SSaver <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_SBitCache_New(manager, &cache))) { printf("Clock / SSaver <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_Manager_Lookup_Face(manager, FONT, &face))) { printf("Clock / SSaver <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } use_kerning = FT_HAS_KERNING(face); #ifdef FT_NEW_CACHE_API desc.face_id = FONT; #else desc.font.face_id = FONT; #endif #if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 desc.image_type = ftc_image_mono; #else desc.flags = FT_LOAD_MONOCHROME; #endif //init backbuffer if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres))) { printf("Clock / SSaver <allocating of Backbuffer failed>\n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; } if (!slow) slow=1; if (slow>10) slow=10; if (fcol > MAXCOL && !(ssaver == 1 && fcol == 99)) fcol = 2; if (bcol > 3 && !(bcol == 10)) bcol = 1; if (ssaver) { memset(lbb, col[bcol], var_screeninfo.xres*var_screeninfo.yres); memset(lfb, col[bcol], var_screeninfo.xres*var_screeninfo.yres); } else memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres); if (big) //grosse Schrift (time/date) { margin_left_F = 3; // 3 digit_width = 14; // 14 margin_top_t = 26; // 26 font_size = BIG; // 40 margin_top_box = 30; // 30 margin_top_d = 60; // 60 } else { margin_left_F = 7; //7 Abstand links digit_width = 12; //12 Ziffernblockbreite margin_top_t = 19; //19 Abstand "TimeString"-Unterkante von oben font_size = MED; //30 Schriftgroesse margin_top_box = 20; //20 Abstand Renderbox von oben margin_top_d = 40; //40 Abstand "DateString" von oben } digits = 0; secs_width = 0; startx = sx; starty = sy; mw = (big) ? 42 : 36; //mailwidth adj_height = 1 * (!big && !show_date); //max steprange == 3, so we need always a top/bottom margin of >=3 if (!show_sec && !show_date) { digits = 3; //3 Platzhalter ':ss' secs_width = digits * digit_width; } if (ssaver) { xpos = rand() %480 + 10; ypos = rand() %460 + 10; xdir *= (rand() &1) == 0 ? -1 : 1; ydir *= (rand() &1) == 0 ? -1 : 1; xstep/=(double)slow; ystep/=(double)slow; if (fcol == 99) { cCol = 1; Change_Col(&fcol, &bcol); } InitRC(); } while (loop) { if (ssaver) usleep(15000L); else { usleep(150000L); newmail = 0; if(mail && ExistFile(MAIL_FILE)) { if((tfh = fopen(MAIL_FILE,"r")) != NULL) { if(fgets(tstr, 511, tfh)) { if(sscanf(tstr, "%d", &i)) { newmail = i; } } fclose(tfh); } } } time(&atim); ltim=localtime(&atim); if (show_sec) { sprintf(tstr,"%02d:%02d:%02d", ltim->tm_hour, ltim->tm_min, ltim->tm_sec); } else { if (blink) sprintf(tstr," %02d%c%02d", ltim->tm_hour, (ltim->tm_sec & 1)? ' ' : ':', ltim->tm_min); else sprintf(tstr," %02d:%02d", ltim->tm_hour, ltim->tm_min); } if (!ssaver) { if (((int)xpos >= mw) || (!show_sec)) { ms = (int)xpos + ((show_sec) ? 0 : mw) - mw; //mail left } else { ms = (int)xpos + 100 + 20 * big; //mail right } //paint Backgroundcolor to clear digit RenderBox(xpos+secs_width, ypos, xpos+secs_width+100+20*big, ypos+margin_top_box + adj_height, FILL, col[bcol]); } if (ssaver) { xpos += xstep * (double)xdir; ypos += ystep * (double)ydir; csx = xpos + secs_width; csy = ypos; cex = xpos + secs_width + 100 + 20 * big; cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height; if ((int)csx < 0 || (sx + (int)cex) > ex) { if (cCol) Change_Col(&fcol, &bcol); xdir *= -1; xpos += xstep * (double)xdir; csx = xpos + secs_width; cex = xpos + secs_width + 100 + 20 * big; xstep = rand() &3; if (!xstep) { xstep = 1; } xstep /= (double)slow; } if ((int)csy < 0 || (sy + (int)cey) > ey) { if (cCol) Change_Col(&fcol, &bcol); ydir *= -1; ypos += ystep * (double)ydir; csy = ypos; cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height; ystep = rand() &3; if (!ystep) { ystep = 1; } ystep /= (double)slow; } RenderBox(csx, csy, cex, cey, FILL, col[bcol]); } for (i = digits; i < strlen(tstr); i++) { *dstr = tstr[i]; RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_t, 30, CENTER, font_size, col[fcol]); } if (show_date) { sprintf(tstr, "%02d.%02d.%02d", ltim->tm_mday, ltim->tm_mon + 1, ltim->tm_year - 100); if (!ssaver) { //Backgroundbox color Date RenderBox(xpos, ypos + margin_top_box, xpos + 100 + 20 * big, ypos + margin_top_d, FILL, col[bcol]); } for(i = 0; i < strlen(tstr); i++) { *dstr = tstr[i]; RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_d - 2 - (2 * big), 30, CENTER, font_size, col[fcol]); } } if (ssaver) { w = 100 + 20 * big + ((show_sec) ? 0 : - secs_width); for (i = 0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++) { j = (starty + (int)ypos + i) * var_screeninfo.xres + (int)xpos + ((show_sec) ? 0 : secs_width) + startx; if ((j + w) < var_screeninfo.xres * var_screeninfo.yres) { memcpy(lfb+j, lbb+j, w); } } } else { if (newmail > 0) { mailgfx = 1; //Background mail, left site from clock RenderBox(ms, ypos, ms+mw, ypos+margin_top_box + adj_height, FILL, col[bcol]); //bcol if(!(ltim->tm_sec & 1)) { RenderBox (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big), GRID, col[fcol]); DrawLine (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big), col[fcol]); DrawLine (ms+8, ypos+margin_top_box+adj_height-2-(3*big), ms+mw-8, ypos+5+(1+big), col[fcol]); DrawLine (ms+(9+1*big), ypos+4+(1+big), ms+(mw/2), ypos+1, col[fcol]); DrawLine (ms+(9+1*big), ypos+5+(1+big), ms+(mw/2), ypos+2, col[fcol]); DrawLine (ms+(mw/2), ypos+1, ms+mw-(9+1*big), ypos+4+(1+big), col[fcol]); DrawLine (ms+(mw/2), ypos+2, ms+mw-(9+1*big), ypos+5+(1+big), col[fcol]); } else { sprintf(tstr,"%d",newmail); RenderString(tstr, ms, ypos+margin_top_t, mw, CENTER, font_size, col[fcol]); } } else { if (mailgfx > 0) RenderBox(ms, ypos, ms+mw, ypos + margin_top_box + adj_height, FILL, (!show_date || show_sec) ? TRANSP : col[bcol]); else ms=(int)xpos; } w = 100 + 20 * big + ((mailgfx) ? ((show_sec) ? mw : 0) : - secs_width); for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++) { j = (starty + (int)ypos + i) * var_screeninfo.xres + ( ((ms < (int)xpos) ? ms : (int)xpos) + ((show_sec) ? 0 : ((mailgfx) ? 0 : secs_width)) ) + startx; if ((j + w) < var_screeninfo.xres * var_screeninfo.yres) { memcpy(lfb+j, lbb+j, w); } } if (newmail == 0 && mailgfx > 0) mailgfx = 0; } if (++loop > 10) { if ( (ssaver && (RCKeyPressed() || ExistFile("/tmp/.ssaver_kill"))) || (!ssaver && ExistFile("/tmp/.clock_kill")) ) loop = 0; } } /**************************** * close down Clock / SSaver ****************************/ if (ssaver) { memset(lfb, 0, var_screeninfo.xres*var_screeninfo.yres); remove("/tmp/.ssaver_kill"); CloseRC(); } else { memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres); remove("/tmp/.clock_kill"); for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++) { j=(starty+(int)ypos+i)*var_screeninfo.xres+((ms<(int)xpos)?ms:(int)xpos)+((show_sec)?0:((mailgfx)?0:secs_width))+startx; if((j+100+20*big+((mail)?mw:0))<var_screeninfo.xres*var_screeninfo.yres) { memcpy(lfb+j, lbb+j, w); } } } FTC_Manager_Done(manager); FT_Done_FreeType(library); free(lbb); munmap(lfb, fix_screeninfo.smem_len); close(fb); return 0; }
int CloseRC(void) { while(RCKeyPressed()); close(rc); return 1; }
int GetRCCode(void) { if(!RCKeyPressed() || (get_instance()>instance)) { return -1; } do { rc_last_key = ev.code; } while(RCKeyPressed()); switch(rc_last_key) { case KEY_UP: rccode = RC_UP; break; case KEY_DOWN: rccode = RC_DOWN; break; case KEY_LEFT: rccode = RC_LEFT; break; case KEY_RIGHT: rccode = RC_RIGHT; break; case KEY_OK: rccode = RC_OK; break; case KEY_0: rccode = RC_0; break; case KEY_1: rccode = RC_1; break; case KEY_2: rccode = RC_2; break; case KEY_3: rccode = RC_3; break; case KEY_4: rccode = RC_4; break; case KEY_5: rccode = RC_5; break; case KEY_6: rccode = RC_6; break; case KEY_7: rccode = RC_7; break; case KEY_8: rccode = RC_8; break; case KEY_9: rccode = RC_9; break; case KEY_RED: rccode = RC_RED; break; case KEY_GREEN: rccode = RC_GREEN; break; case KEY_YELLOW: rccode = RC_YELLOW; break; case KEY_BLUE: rccode = RC_BLUE; break; case KEY_VOLUMEUP: rccode = RC_PLUS; break; case KEY_VOLUMEDOWN: rccode = RC_MINUS; break; case KEY_MUTE: rccode = RC_MUTE; break; case KEY_HELP: rccode = RC_HELP; break; case KEY_SETUP: rccode = RC_DBOX; break; case KEY_HOME: rccode = RC_HOME; break; case KEY_POWER: rccode = RC_STANDBY; break; default: rccode = -1; } return rccode; }