]> hackdaworld.org Git - my-code/dfb-photoshow.git/commitdiff
added keyb events
authorhackbard <hackbard>
Tue, 25 Feb 2003 17:13:57 +0000 (17:13 +0000)
committerhackbard <hackbard>
Tue, 25 Feb 2003 17:13:57 +0000 (17:13 +0000)
dfb-photoshow.c
showdir

index ac06c8b2833af2ed985e8fbb7b85ac736412a96d..4975c733f7db7f1700061c2ae76f9abff8029176 100644 (file)
@@ -1,7 +1,14 @@
 /*
  * 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
  *
  */
 
@@ -24,9 +31,10 @@ int screen_height = 0;
  } \
 }
 
-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 ...)";
@@ -38,6 +46,8 @@ void clear_primary(void) {
 
 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;
@@ -54,6 +64,8 @@ int main(int argc,char **argv) {
  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;
@@ -74,32 +86,39 @@ int main(int argc,char **argv) {
  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++) {
-  DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
-  DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
-  DFBCHECK(dfb->CreateSurface(dfb,&dsc,&logo ));
-  DFBCHECK(img_prov->RenderTo(img_prov,logo,NULL));
-  img_prov->Release(img_prov);
-  DFBCHECK (primary->SetColor(primary,0x00,0x00,0x00,0x00));
-  DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height));
-  DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff));
-  DFBCHECK(primary->DrawLine(primary,0,0,screen_width-1,screen_height-1));
-  if((screen_width>=dsc.width)&&(screen_height>=dsc.height)) {
-   DFBCHECK(primary->Blit(primary,logo,NULL,(screen_width-dsc.width)/2,(screen_height-dsc.height)/2));
-  }
-  else {
-   DFBCHECK(primary->StretchBlit(primary,logo,NULL,NULL));
+ /* display pictures */
+ while(state_escape==DIKS_UP) { 
+  for(i=2;i<argc;i++) {
+   DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
+   DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
+   DFBCHECK(dfb->CreateSurface(dfb,&dsc,&logo ));
+   DFBCHECK(img_prov->RenderTo(img_prov,logo,NULL));
+   img_prov->Release(img_prov);
+   DFBCHECK (primary->SetColor(primary,0x00,0x00,0x00,0x00));
+   DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height));
+   DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff));
+   DFBCHECK(primary->DrawLine(primary,0,0,screen_width-1,screen_height-1));
+   if((screen_width>=dsc.width)&&(screen_height>=dsc.height)) {
+    DFBCHECK(primary->Blit(primary,logo,NULL,(screen_width-dsc.width)/2,(screen_height-dsc.height)/2));
+   }
+   else {
+    DFBCHECK(primary->StretchBlit(primary,logo,NULL,NULL));
+   }
+   DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
+   sleep(atoi(argv[1]));
+   logo->Release(logo);
+   DFBCHECK(keyboard->GetKeyState(keyboard,DIKI_ESCAPE,&state_escape));
   }
-  DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
-  sleep(atoi(argv[1]));
-  logo->Release(logo);
  }
 
- primary->Release(logo);
+ keyboard->Release(keyboard);
+ logo->Release(logo);
  primary->Release(primary);
  dfb->Release(dfb);
 
diff --git a/showdir b/showdir
index c276687063911c31d6ecafe404b98397b83df848..650e010a508ba4ed7d75ae0e8b34465880cf6e4a 100755 (executable)
--- a/showdir
+++ b/showdir
@@ -8,7 +8,7 @@ usage() {
  echo
 }
 
-if [ "$#" <= "2" ]; then
+if [ -z "$1" -o ! -d "$2" ]; then
        usage
        exit 0
 fi
@@ -18,9 +18,11 @@ dir="$2"
 files="`find $dir -name '*.jpg'`
 `find $dir -name '*.JPG'`
 `find $dir -name '*.jpe'`
-`find $dir -name '*.IPE'`"
+`find $dir -name '*.JPE'`
+`find $dir -name '*.png'`
+`find $dir -name '*.PNG'`"
 
-./dfb-photoshow $1 $files
+[ ! -z "`echo $files | sed 's/\ //g'`" ] && ./dfb-photoshow $1 $files
 
 echo
 echo done