//----------------------------------------------------------------------------- // Name: Main // Desc: ... //----------------------------------------------------------------------------- int main( int argc, char *argv[] ) { /* Check Arguments */ if ( argc != 2 ) { printf("Usage: %s: Input Audio\n", argv[0]); return EXIT_FAILURE; } /* Initialize SRC Algorithm */ initialize_src_type(); /* Initialize Glut */ initialize_glut(argc, argv); /* Initialize PortAudio */ initialize_audio(argv[1]); /* Start Curses Mode */ initscr(); cbreak(); // Line Buffering Disabled noecho(); // Comment This Out if You Want to Show Characters When They Are Typed curs_set(0); // Make ncurses Cursor Invisible /* Print Help Menu and GUI */ help(); printGUI(); /* Main Interactive Loop, Quits With 'q' */ glutMainLoop(); return EXIT_SUCCESS; }
int main() { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); // Main loop while (aptMainLoop()) { //As nop90 suggested getFB(); //Gets input (keys and touch) getInput(); //Prints the GUI printGUI(); //Do stuff app(); //Exit code if (input & KEY_START) break; // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); //Wait for VBlank gspWaitForVBlank(); } // Exit services gfxExit(); hidExit(); aptExit(); srvExit(); return 0; }
/* * Function: playOneGame * -------------------- * Starts the program by getting setting up the boggles object and * getting user input and initializing the board * * Preconditions: * * @param: Takes the dicitonary * @return: returns nothing */ void playOneGame(Lexicon& dictionary) { // Initialize GUI if(!BoggleGUI::isInitialized()){ BoggleGUI::initialize(4,4); } else { BoggleGUI::reset(); } BoggleGUI::setAnimationDelay(100); // Setup Board Boggle boggles = Boggle(dictionary,""); if (!getYesOrNo("Do you want to generate a random board? ")) { boggles = Boggle(dictionary,manualCase()); } // Setup the gui to show the words printGUI(boggles); userTurn(boggles); computerTurn(boggles); }
//----------------------------------------------------------------------------- // Name: keyboardFunc( ) // Desc: key event //----------------------------------------------------------------------------- void keyboardFunc( unsigned char key, int x, int y ) { switch( key ) { /* Fullscreen */ case 'f': if( !g_fullscreen ) { g_last_width = g_width; g_last_height = g_height; glutFullScreen(); } else glutReshapeWindow( g_last_width, g_last_height ); g_fullscreen = !g_fullscreen; printGUI(); break; /* Resets Normal Default Playback */ case 'r': data.src_data.src_ratio = 1; //Sets Default Playback Speed initialize_Filters(); data.amplitude = INITIAL_VOLUME; printGUI(); break; /* Change SRC Ratio */ case '-': if (data.src_data.src_ratio <= 2.0) { data.src_data.src_ratio += SRC_RATIO_INCREMENT; } printGUI(); break; case '=': if (data.src_data.src_ratio >= 0.5 ) { data.src_data.src_ratio -= SRC_RATIO_INCREMENT; } printGUI(); break; /* Low Pass Filter Controls */ /****************************/ /* Engage/Disengage Filter */ case 'l': if (data.lpf_On == false) { //Power On data.lpf_On = true; } else if (data.lpf_On == true) { //Power Off data.lpf_On = false; } printGUI(); break; /* Increase/Decrease Lpf Freq Cutoff */ case 'j': data.lpf_freq -= FILTER_CUTOFF_INCREMENT; if (data.lpf_freq < 20) { data.lpf_freq = 20; } printGUI(); break; case 'k': data.lpf_freq += FILTER_CUTOFF_INCREMENT; if (data.lpf_freq > 20000) { data.lpf_freq = 20000; } printGUI(); break; /* Increase/Decrease Lpf Resonance */ case 'i': data.lpf_res -= RESONANCE_INCREMENT; if (data.lpf_res <= 1) { data.lpf_res = 1; } printGUI(); break; case 'o': data.lpf_res += RESONANCE_INCREMENT; if (data.lpf_res >= 10) { data.lpf_res = 10; } printGUI(); break; /* High Pass Filter Controls */ /*****************************/ /* Engage/Disengage Filter */ case 'a': if (data.hpf_On == false) { //Power On data.hpf_On = true; } else if (data.hpf_On == true) { //Power Off data.hpf_On = false; } printGUI(); break; /* Increase/Decrease Hpf Freq Cutoff */ case 's': data.hpf_freq -= FILTER_CUTOFF_INCREMENT; if (data.hpf_freq < 20) { data.hpf_freq = 20; } printGUI(); break; case 'd': data.hpf_freq += FILTER_CUTOFF_INCREMENT; if (data.hpf_freq > 20000) { data.hpf_freq = 20000; } printGUI(); break; /* Increase/Decrease Lpf Resonance */ case 'w': data.hpf_res -= RESONANCE_INCREMENT; if (data.hpf_res <= 1) { data.hpf_res = 1; } printGUI(); break; case 'e': data.hpf_res += RESONANCE_INCREMENT; if (data.hpf_res >= 10) { data.hpf_res = 10; } printGUI(); break; /* Amplitude Controls */ /*****************************/ /* Mute Output */ case 'm': if (data.amplitude > 0 ) { //Mute data.amplitude = 0; } else if (data.amplitude == 0) { //UnMute data.amplitude = INITIAL_VOLUME; } break; /* Increase/Decrease Amplitude of Playbacl */ case ',': data.amplitude -= VOLUME_INCREMENT; if (data.amplitude < 0) { data.amplitude = 0; } break; case '.': data.amplitude += VOLUME_INCREMENT; if (data.amplitude > 1) { data.amplitude = 1; } break; /* Exit */ case 'q': /* Close Stream Before Exiting */ stop_portAudio(); /* Cleanup SRC */ src_delete (data.src_state); /* End Curses Mode */ endwin(); exit(0); break; } }
void QgarArgs::analyzeLine(int argc, char * argv[]) { int i = 1; while (i < argc) { QgarParam* pParam = findParam(argv[i]); // If the parameter is not recognized, try flags -h and -gui if (!pParam) { if (!strcmp("-h", argv[i])) { _exit = true; showUsage(argv[0]); } else { if (!strcmp("-gui", argv[i])) { _exit = true; printGUI(); } else { if (!strcmp("-interact", argv[i])) { _interactive = true; } else { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> Bad flag: " << argv[i] << endl; } } } return; } switch (pParam->paramStatus()) { // -------------------------------------------------------- case SINGLEFLAG: pParam->setUseFlag(); break; // -------------------------------------------------------- case REQPARAM: case OPTPARAM: ++i; if (i == argc) { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> No value for flag " << argv[i-1] << endl; return; } if (findParam(argv[i])) { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> Bad value for flag " << argv[i - 1] << ": " << argv[i] << endl; return; } pParam->setValue(argv[i]); pParam->setUseFlag(); break; // -------------------------------------------------------- case REQMULTIPARAM: case OPTMULTIPARAM: ++i; if (i == argc) { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> No value for flag " << argv[i-1] << endl; return; } if (findParam(argv[i])) { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> Bad value for flag " << argv[i - 1] << ": " << argv[i] << endl; return; } do { pParam->addArgument(argv[i]); ++i; } while ((i < argc) && (findParam(argv[i]))); pParam->setUseFlag(); --i; break; // -------------------------------------------------------- } // END switch // Next argument ++i; } // END while // All the arguments are processed // Check required parameters for (list<QgarParam*>::iterator it = _args.begin(); it != _args.end(); ++it) { if ((((*it)->paramStatus() == REQPARAM) || ((*it)->paramStatus() == REQMULTIPARAM)) && !((*it)->useFlag())) { _error = true; cerr << "QGAR: ERROR NOTIFIED BY AN APPLICATION" << endl << ">>> Missing flag: " << (*it)->name() << endl; return; } } }