int Controls_Handle_Keyboard(unsigned char key, int x, int y) { /* According to zoom factor we will use a desired_step matching it in order to have smooth movement over the image RefreshDesiredStep_AccordingToPosition calculates it and loads it in frame.desired_step variable */ // RefreshDesiredStep_AccordingToPosition(); /*---------------------------------------------------------------------------------------------------------------*/ char label[256]={0}; int nokey=0; if (PrintDevMsg()) fprintf(stderr,"Key %u \n",key); switch (key) { case 1 : /* UP */ MoveToPicture(D_UP); break; case 2 : /* DOWN */ MoveToPicture(D_DOWN); break; case 3 : /* LEFT */ MoveToPicture(D_LEFT); break; case 4 : /* RIGHT */ MoveToPicture(D_RIGHT); break; case 9 : /* TAB */ frame.show_information=550; /* 550 is the time !*/ break; case '`' : /*Tilda button*/ frame.show_time=550; break; case 13 : /* ENTER */ ToggleAutomaticSlideshow(); break; case ' ' : /* SPACE */ ToggleAutomaticSlideshow(); break; //Buttons 0 - 9 , directory transactions case 48+0 : /*Number 0*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),0)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+1 : /*Number 1*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),1)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+2 : /*Number 2*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),2)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+3 : /*Number 3*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),3)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+4 : /*Number 4*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),4)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+5 : /*Number 5*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),5)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+6 : /*Number 6*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),6)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+7 : /*Number 7*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),7)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+8 : /*Number 8*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),8)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 48+9 : /*Number 9*/ if (PerformDirectoryTransaction(GetPictureDirectoryListIndex(frame.active_image_place),9)>0) {TriggerNextPictureSlideShow(); usleep(10000); return 0; } break; case 'o': ResetCameraOrientation(); NewLabel(frame.desired_x,frame.desired_y,(char *) "Reset Camera to center..!"); break; case 'u': CreateObjectFountain(2); /*"PARTICLE" EFFECT*/ break; case 'i': CreateObjectFountain(3); /*"PARTICLE" EFFECT*/ break; case 'k': CreateObjectFountain(6); /*"PARTICLE" EFFECT*/ break; case 'j': return 1; /*This key is reserved for fullscreen*/ break; //case 'j': CreateObjectFountain(5); /*"PARTICLE" EFFECT*/ break; case 'q': RotatePictureLeft(); break; case 'e': RotatePictureRight(); break; case 'r': MoveDestinationCenter(D_OUT); /*frame.desired_z+=frame.desired_step;*/ break; case 'f': MoveDestinationCenter(D_IN); /*frame.desired_z-=frame.desired_step;*/ break; case 'a': MoveDestinationCenter(D_LEFT); /*frame.desired_x+=frame.desired_step;*/ break; case 'd': MoveDestinationCenter(D_RIGHT); /*frame.desired_x-=frame.desired_step;*/ break; case 's': MoveDestinationCenter(D_UP); /*frame.desired_y+=frame.desired_step;*/ break; case 'w': MoveDestinationCenter(D_DOWN); /*frame.desired_y-=frame.desired_step;*/ break; case '-': if ( frame.time_ms_between_two_transitions >= 100 ) { SetTransitionTime(frame.time_ms_between_two_transitions-100); } break; case '+': SetTransitionTime(frame.time_ms_between_two_transitions+100); break; case 'z': frame.angle_x-=0.5; break; case 'c': frame.angle_x+=0.5; break; case 't': frame.angle_y-=0.5; break; case 'g': frame.angle_y+=0.5; break; case 'y': frame.angle_z-=0.5; break; case 'h': frame.angle_z+=0.5; break; case 'n': ChangeLayout(); sprintf(label," Layout set to %s (%u)",GetLayoutName(),frame.layout.layout_mode); NewLabel(frame.desired_x,frame.desired_y,(char *) label); break; //if (ENABLE_WIGGLING) {ENABLE_WIGGLING=0;} else {ENABLE_WIGGLING=1;} case 'm': ToggleTransitionMode(); break; case 153: MoveToPicture(D_UP); MoveToPicture(D_UP); MoveToPicture(D_UP); MoveToPicture(D_UP); sprintf(label," Go To %u/%u",frame.active_image_place,frame.total_images); NewLabel(frame.desired_x,frame.desired_y,(char *) label); break; //PAGE UP case 161: MoveToPicture(D_DOWN); MoveToPicture(D_DOWN); MoveToPicture(D_DOWN); MoveToPicture(D_DOWN); sprintf(label," Go To %u/%u",frame.active_image_place,frame.total_images); NewLabel(frame.desired_x,frame.desired_y,(char *) label); break; //PAGE DOWN case 'b': break; default : nokey=1; break; } return nokey; }
int parseArguments(int argc, char *argv[]) { if ( argc <1 ) { fprintf(stderr,"Something weird is happening , argument zero should be executable path :S \n"); return 1; } else if ( argc == 1 ) { fprintf(stderr,"Usage flashyslideshow \"path\\to\\directory\\of\\album\"\n\n"); strncpy((char * ) frame.program_data_directory,argv[0],MAX_PATH); } else { int i=0; for (i=0; i<argc; i++) { if (strcmp(argv[i],"-web")==0) { //Recursive Directory command fprintf(stderr,"Web Interface Enabled %u - %s\n",i,argv[i]); if (!WebInterfaceCompiledIn()) { //Web interface has been enabled by user BUT its not compiled in! :S EmmitDialogWarning( (char *) "Please note that this build of FlashySlideshow hasn't got a compiled in WebInterface..!\n To download it run ./update_from_git.sh from the project's root dir and enable it at the CMake file..\n\n\nCheck here for more info :\nhttps://github.com/AmmarkoV/FlashySlideshows\n"); } frame.enable_web_interface=1; } else if (strcmp(argv[i],"-r")==0) { //Recursive Directory command fprintf(stderr,"Recursive Directory Enabled %u - %s\n",i,argv[i]); frame.recursive=1; } else if (strcmp(argv[i],"-fullscreen")==0) { //Fullscreen window fprintf(stderr,"Auto Fullscreen %u - %s\n",i,argv[i]); frame.fullscreen=1; } else if (strcmp(argv[i],"-play")==0) { //Recursive Directory command fprintf(stderr,"AutoStarting Playback %u - %s\n",i,argv[i]); ToggleAutomaticSlideshow(); } else if (strcmp(argv[i],"-sfx")==0) { //Sound Effects command fprintf(stderr,"%u Sound Effects Enabled %s\n",i,argv[i]); frame.enable_sound_effects=1; } else if (strcmp(argv[i],"-file_move")==0) { //Move Files command fprintf(stderr,"%u Move Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_move=1; } else if (strcmp(argv[i],"-file_resize")==0) { //Resize Files command if (i+1<=argc) { fprintf(stderr,"%u Move Resized Enabled at Resolution %s with keys 0 to 9 %s\n",i,argv[i+1],argv[i]); frame.allow_operation_resize=1; strcpy(frame.rescale_resolution_string,argv[i+1]); } } else if (strcmp(argv[i],"-file_copy")==0) { //File Copy command fprintf(stderr,"%u Move Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_copy=1; } else if (strcmp(argv[i],"-file_link")==0) { //File Copy command fprintf(stderr,"%u Link Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_link=1; } else if (strcmp(argv[i],"-no_hud")==0) { //File Copy command fprintf(stderr,"Hud Disabled.."); frame.disable_hud=1; } else if (strcmp(argv[i],"-no_background")==0) { //File Copy command fprintf(stderr,"Background Disabled.."); frame.plain_background_no_image=1; } else if (strcmp(argv[i],"-fd")==0) { //Face Detection command fprintf(stderr,"%u Face Detection Enabled %s\n",i,argv[i]); } else if (strcmp(argv[i],"-v")==0) { //Visuals Enabled command fprintf(stderr,"%u Visuals Enabled %s\n",i,argv[i]); } else if (strcmp(argv[i],"-m")==0) { //Mipmaping Enabled command fprintf(stderr,"%u Mipmaping Enabled %s\n",i,argv[i]); frame.mipmaping=1; } else if (strcmp(argv[i],"-q")==0) { //Quality command if (i+1<=argc) { frame.quality_setting=atoi(argv[i+1]); // Quality fprintf(stderr,"%u Image Quality %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.quality_setting); if (frame.quality_setting>=3) { frame.try_for_best_render_quality=1; } fprintf(stderr," Rendering Quality Switch %u\n",frame.try_for_best_render_quality); //THIS HAS A SECOND PAYLOAD THAT HAPPENS AFTERWARDS----> to initialize frame.gpu.maximum_frame_total_size } } else if (strcmp(argv[i],"-images_per_line")==0) { //Images per line command if (i+1<=argc) { frame.images_per_line=atoi(argv[i+1]); // Background fprintf(stderr,"%u Images per line Manually Chosen %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.images_per_line); frame.active_image_x=((unsigned int) frame.images_per_line/2); frame.active_image_y=1; frame.active_image_place=PictureXYtoID(frame.active_image_x,frame.active_image_y); frame.last_image_x=frame.active_image_x; frame.last_image_y=frame.active_image_y; frame.last_image_place=frame.active_image_place; GetLayoutCoordinatesForXY(frame.active_image_x,frame.active_image_y,&frame.vx,&frame.vy,&frame.vz); frame.vz=8.0; frame.desired_x=frame.vx; frame.desired_y=frame.vy; frame.desired_z=GetLayoutMaximumZ()-0.5; fprintf(stderr,"Setting Center to %u,%u (%u) --> coords %0.2f,%0.2f,%0.2f\n",frame.active_image_x,frame.active_image_y,frame.active_image_place,frame.vx,frame.vy,frame.vz); } } else if (strcmp(argv[i],"-b")==0) { //Quality command if (i+1<=argc) { frame.background_number=atoi(argv[i+1]); // Background fprintf(stderr,"%u Frame Background Manually Chosen %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.background_number); } } else if (strcmp(argv[i],"-d")==0) { //Transition delay command if (i+1<=argc) { frame.time_ms_between_two_transitions=atoi(argv[i+1]); fprintf(stderr,"%u Transition Delay %s = %s ( %u ) \n",i,argv[i],argv[i+1],frame.time_ms_between_two_transitions); } } else if (strcmp(argv[i],"-t")==0) { //Transition Type command if (i+1<=argc) { fprintf(stderr,"%u Transition Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"3D Seek\n"); frame.transitions.transition_mode=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Immediate\n"); frame.transitions.transition_mode=1; } else if ( *argv[i+1]=='2' ) { fprintf(stderr,"Transparency\n"); frame.transitions.transition_mode=2; } else { fprintf(stderr,"Incorrect Transition Type..\n"); } } } else if (strcmp(argv[i],"-l")==0) { //Layout Type command if (i+1<=argc) { fprintf(stderr,"%u Layout Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"Basic Layout\n"); frame.layout.layout_mode=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Expo\n"); frame.layout.layout_mode=1; } else { fprintf(stderr,"Incorrect Layout Type..\n"); } } } else if (strcmp(argv[i],"-s")==0) { //Sorting Type command if (i+1<=argc) { fprintf(stderr,"%u Sorting Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"Ascending Name\n"); frame.sort_type=0; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Ascending Date\n"); frame.sort_type=1; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='2' ) { fprintf(stderr,"Ascending Size\n"); frame.sort_type=2; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='3' ) { fprintf(stderr,"Descending Name\n"); frame.sort_type=0; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='4' ) { fprintf(stderr,"Descending Date\n"); frame.sort_type=1; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='5' ) { fprintf(stderr,"Descending Size\n"); frame.sort_type=2; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='r' ) { fprintf(stderr,"Randomized\n"); frame.sort_randomization=1; } else { fprintf(stderr,"Incorrect Sorting Type..\n"); } } } } strncpy((char * ) frame.program_data_directory,argv[0],MAX_PATH); strncpy((char * ) frame.album_directory,argv[argc-1],MAX_PATH); if ( strncmp((char*)frame.album_directory,"pick",4)==0 ) { /* PICK ALBUM DIR VIA GUI */ if ( LaunchGUI_PickDir() == 0 ) { fprintf(stderr,"No dir selected! \n"); return 0; } } } strcat((char * ) frame.album_directory,"/"); fprintf(stderr,"Slideshow directory is = %s (%u chars) \n", frame.album_directory ,(unsigned int) strlen((char*) frame.album_directory)); return 1; }