]> hackdaworld.org Git - my-code/dfb-photoshow.git/commitdiff
event stuff fixed, begin with directory parsing now
authorhackbard <hackbard>
Wed, 26 Feb 2003 19:57:53 +0000 (19:57 +0000)
committerhackbard <hackbard>
Wed, 26 Feb 2003 19:57:53 +0000 (19:57 +0000)
dfb-photoshow.c

index f13b926e58521a9549c8403c3050fae891964580..de27606d99b7f9e94c99c34df5453d3dd3982a51 100644 (file)
@@ -39,7 +39,7 @@ IDirectFBEventBuffer *k_buf=NULL;
 char *title_txt="directfb photoshow";
 char *exp_txt="an image presenter ...";
 char *hp_txt="http://hackdaworld.dyndns.org";
-char *msg1_txt="(press key to continue ...)";
+char *msg1_txt="(press key to continue, space pauses, esc quits ...)";
 
 void clear_primary(void) {
  DFBCHECK(primary->SetColor(primary,0x00,0x00,0x00,0x00));
@@ -91,30 +91,27 @@ int main(int argc,char **argv) {
  DFBCHECK(k_buf->WaitForEvent(k_buf));
 
  /* display pictures */
- DFBCHECK(k_buf->Reset(k_buf));
  i=2;
  while(i<argc) {
   do {
-   if(k_event.type==DIET_KEYPRESS) {
-    int a;
-    puts("debug: key pressed!");
-    a=(int)k_event.key_id;
-    printf("debug: key id -> %d\n",a);
-    printf("\tp=%d,' '=%d\n",(int)DIKI_ESCAPE,(int)DIKI_SPACE);
-    if(a==(int)DIKI_ESCAPE) {
-     i=argc;
-     break;
+   if((int)k_buf->GetEvent(k_buf,DFB_EVENT(&k_event))!=0) {
+    if(k_event.type==DIET_KEYPRESS) {
+     int a;
+     a=(int)k_event.key_id;
+     if(a==(int)DIKI_ESCAPE) {
+      i=argc;
+      break;
+     }
+     if(a==(int)DIKI_SPACE) {
+      char *pause_txt="paused (press button to continue)";
+      DFBCHECK(font->GetStringWidth(font,pause_txt,-1,&str_width));
+      DFBCHECK(primary->DrawString(primary,pause_txt,-1,(screen_width-str_width)/2,screen_height/2,DSTF_LEFT));
+      DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
+      DFBCHECK(k_buf->Reset(k_buf));
+      DFBCHECK(k_buf->WaitForEvent(k_buf));
+      k_event.key_id=DIKI_A; /* no longer pause! */
+     }
     }
-    if(a==(int)DIKI_SPACE) {
-     char *pause_txt="paused (press button to continue)";
-     DFBCHECK(font->GetStringWidth(font,pause_txt,-1,&str_width));
-     DFBCHECK(primary->DrawString(primary,pause_txt,-1,(screen_width-str_width)/2,screen_height/2,DSTF_LEFT));
-     DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
-     DFBCHECK(k_buf->Reset(k_buf));
-     DFBCHECK(k_buf->WaitForEvent(k_buf));
-    }
-    DFBCHECK(k_buf->Reset(k_buf)); /* destroy space press */
-    DFBCHECK(k_buf->Reset(k_buf)); /* destroy space release */
    }
    DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
    DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
@@ -133,6 +130,8 @@ int main(int argc,char **argv) {
    }
    DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
    // sleep(atoi(argv[1]));
+   // DFBCHECK(k_buf->Reset(k_buf));
+   DFBCHECK(k_buf->Reset(k_buf));
    k_buf->WaitForEventWithTimeout(k_buf,atoi(argv[1]),0);
    logo->Release(logo);
    ++i;