/*
* dfb-photoshow.c
*
- * author: hackbard
+ * build: gcc -o dfb-photoshow -O3 -Wall -I/usr/X11/include \
+ * -I/usr/include/directfb dfb-photoshow.c
+ * usage: ./showdir <seconds> <directory>
+ *
+ * author:
+ * hackbard@hackdaworld.dyndns.org
+ * download:
+ * cvs -d:pserver:anonymous@hackdaworld.dyndns.org:/my-code co dfb-photoshow
*
*/
} \
}
-IDirectFBSurface *logo = NULL;
-IDirectFBFont *font = NULL;
-char *title_txt = "directfb photoshow";
+IDirectFBInputDevice *keyboard=NULL;
+IDirectFBSurface *logo=NULL;
+IDirectFBFont *font=NULL;
+char *title_txt="directfb photoshow";
char *author_txt="hackbard@hackdaworld.dyndns.org";
char *hp_txt="http://hackdaworld.dyndns.org";
char *msg1_txt="(press return to continue ...)";
int main(int argc,char **argv) {
int i,str_width;
+ DFBInputDeviceKeyState state_enter=DIKS_UP;
+ DFBInputDeviceKeyState state_escape=DIKS_UP;
DFBSurfaceDescription dsc;
DFBFontDescription font_dsc;
IDirectFBImageProvider *img_prov;
DFBCHECK(primary->GetSize(primary,&screen_width,&screen_height));
fprintf(stdout,"dimensions: %dx%d\n",screen_width,screen_height);
+ DFBCHECK(dfb->GetInputDevice(dfb,DIDID_KEYBOARD,&keyboard));
+
/* title */
font_dsc.flags=DFDESC_HEIGHT;
font_dsc.height=screen_height/20;
DFBCHECK(font->GetStringWidth(font,msg1_txt,-1,&str_width));
DFBCHECK(primary->DrawString(primary,msg1_txt,-1,(screen_width-str_width)/2,(screen_height/2)+3*font_dsc.height,DSTF_LEFT));
DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
- getc(stdin);
+ DFBCHECK(keyboard->GetKeyState(keyboard,DIKI_ESCAPE,&state_enter));
+ while(state_enter==DIKS_UP) {
+ DFBCHECK(keyboard->GetKeyState(keyboard,DIKI_ENTER,&state_enter));
+ }
font->Release(font);
- /* display pictures */
- for(i=2;i<argc;i++) {
+ /* display pictures */
+ i=2;
+ while(state_escape==DIKS_UP) {
DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
DFBCHECK(dfb->CreateSurface(dfb,&dsc,&logo ));
DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
sleep(atoi(argv[1]));
logo->Release(logo);
+ DFBCHECK(keyboard->GetKeyState(keyboard,DIKI_ESCAPE,&state_escape));
+ i++;
+ if(i==argc) state_escape=DIKS_DOWN;
}
- primary->Release(logo);
+
+ keyboard->Release(keyboard);
+ logo->Release(logo);
primary->Release(primary);
dfb->Release(dfb);