void on_Save_Button_clicked (GtkButton *button, gpointer user_data) { if (button == NULL && user_data == NULL) { /* Bogus condition to use parameters */ ; } if (oldest == NULL) { return; } if (poll_state) { oldest->poll_period = newest.poll_period; } if (jiggle_state) { oldest->mouse_period = newest.mouse_period; } if (dist_state) { oldest->mouse_dist = newest.mouse_dist; } if (idle_state) { oldest->idle_threshold = newest.idle_threshold; } if (file_state) { strcpy(oldest->filename, newest.filename); } if (tfmt_state) { strcpy(oldest->time_format, newest.time_format); } if (userdef_state) { oldest->menu_len = newest.menu_len; oldest->menu_items = newest.menu_items; } save_configuration(oldest); }
/********************************************************** save_cal() Save all EEPROM stored variables & constants. Saves to EEPROM ***********************************************************/ byte* save_cal() { byte* addr; addr = save_configuration(); // MyInstance & Confirmed & config bytes addr = save_stops_eeprom (addr); addr = save_currentThresholds_eeprom(addr); addr = save_latest_position_eeprom (addr); return addr; }
void unjoinNetwork(void) { uint8_t buf[5]; GLOBAL_STORAGE.nid[0] = 0x00; GLOBAL_STORAGE.nid[1] = 0x00; GLOBAL_STORAGE.nid[2] = 0x00; GLOBAL_STORAGE.nid[3] = 0x00; GLOBAL_STORAGE.parent_cid = 0; buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = 0; save_configuration(buf, 5); }
void vsx_widget_desktop::command_process_back_queue(vsx_command_s *t) { if ( t->cmd == "system.shutdown" || t->cmd == "fullscreen" || t->cmd == "fullscreen_toggle" ) { system_command_queue->addc(t); } else if (t->cmd == "conf") { configuration[t->parts[1]] = t->parts[2]; save_configuration(); load_configuration(); } }
void vsx_widget_desktop::vsx_command_process_b(vsx_command_s *t) { if ( t->cmd == "system.shutdown" || t->cmd == "fullscreen" || t->cmd == "fullscreen_toggle" ) { system_command_queue->addc(t); } else if (t->cmd == "conf") { //printf("conf %s\n",t->parts[1].c_str()); configuration[t->parts[1]] = t->parts[2]; save_configuration(); load_configuration(); } }
bool state_keyredefinition_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard) { int i; if (SUBSTATE==0) { if (image!=0) SDL_FreeSurface(image); if (image2!=0) SDL_FreeSurface(image); image=IMG_Load("graphics/tittle.png"); } /* if */ SDL_BlitSurface(image,0,screen,0); surface_fader(screen,0.5F,0.5F,0.5F,-1,0); font_print_centered(sx/2,20,"REDEFINE CONTROLS:",screen); font_print_centered(sx/2,40,"[PRESS SELECT TO SKIP]",screen); if (SUBSTATE<32) { surface_fader(screen,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,-1,0); SUBSTATE++; } /* if */ if (SUBSTATE>39) { surface_fader(screen,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,-1,0); SUBSTATE++; if (SUBSTATE==64) { save_configuration(); SDL_FreeSurface(image); image=0; STATE=1; SUBSTATE=0; } /* if */ } /* if */ if (SUBSTATE>=32) { bool found; char keystr[256]; char *upstr; SUBSTATE-=32; if (SUBSTATE>=0) { font_print(16,60,"PRESS A BUTTON FOR THRUST:",screen); } /* if */ if (SUBSTATE>=1) { strcpy(keystr,get_key_name((SDLKey)THRUST_KEY)); upstr=strupr(keystr); font_print(200,60,upstr,screen); font_print(16,70,"PRESS A BUTTON FOR ANTITHRUST:",screen); } /* if */ if (SUBSTATE>=2) { strcpy(keystr,get_key_name((SDLKey)ANTITHRUST_KEY)); upstr=strupr(keystr); font_print(200,70,upstr,screen); font_print(16,80,"PRESS A BUTTON FOR LEFT:",screen); } /* if */ if (SUBSTATE>=3) { strcpy(keystr,get_key_name((SDLKey)LEFT_KEY)); upstr=strupr(keystr); font_print(200,80,upstr,screen); font_print(16,90,"PRESS A BUTTON FOR RIGHT:",screen); } /* if */ if (SUBSTATE>=4) { strcpy(keystr,get_key_name((SDLKey)RIGHT_KEY)); upstr=strupr(keystr); font_print(200,90,upstr,screen); font_print(16,100,"PRESS A BUTTON FOR FIRE:",screen); } /* if */ if (SUBSTATE>=5) { strcpy(keystr,get_key_name((SDLKey)FIRE_KEY)); upstr=strupr(keystr); font_print(200,100,upstr,screen); font_print(16,110,"PRESS A BUTTON FOR ATRACTOR:",screen); } /* if */ if (SUBSTATE>=6) { strcpy(keystr,get_key_name((SDLKey)ATRACTOR_KEY)); upstr=strupr(keystr); font_print(200,110,upstr,screen); font_print(16,120,"PRESS A BUTTON FOR PAUSE:",screen); } /* if */ if (SUBSTATE>=7) { strcpy(keystr,get_key_name((SDLKey)PAUSE_KEY)); upstr=strupr(keystr); font_print(200,120,upstr,screen); font_print(32,140,"PRESS ANY BUTTON",screen); } /* if */ found=SUBSTATE < 7 ? false : true; for(i=0;!found && i<SDLK_LAST;i++) { if (keyboard[i] && !old_keyboard[i]) { if ((SDLKey)i == SDLK_ESCAPE) { keyboard[i] = 0; SUBSTATE++; break; } switch(SUBSTATE) { case 0:THRUST_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 1:ANTITHRUST_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 2:LEFT_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 3:RIGHT_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 4:FIRE_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 5:ATRACTOR_KEY=(SDLKey)i; SUBSTATE++; found=true; break; case 6:PAUSE_KEY=(SDLKey)i; SUBSTATE++; found=true; break; } /* switch */ } /* if */ } /* for */ if (SUBSTATE==7 && ((keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) || (keyboard[FIRE_KEY] && !old_keyboard[FIRE_KEY]) )) { SUBSTATE++; } /* if */ SUBSTATE+=32; } /* if */ return true; } /* state_keyredefinition_cycle */
/** Application main. Initializes internationalization, libosso, app and appview. Calls user interface creation functions and gtk_main. Follows the component initialization order of osso-filemanager main. @param argc Number of command line arguments @param argv Command line arguments @return 0 if successful; otherwise error code */ int main(int argc, char *argv[]) { gboolean result; g_thread_init(NULL); dbus_g_thread_init(); gdk_threads_init(); mainThread = g_thread_self(); /* Allocate application data structures */ app_data = g_new0(AppData, 1); if (app_data == NULL) { OSSO_LOG_CRIT("Failed memory allocation: AppData"); exit(1); } /* there was no low memory ind from HW yet. */ app_data->low_memory = FALSE; app_data->app_ui_data = g_new0(AppUIData, 1); if (app_data->app_ui_data == NULL) { OSSO_LOG_CRIT("Failed memory allocation: AppUIData"); // free_app_data(); exit(1); } /* Add reference back to parent structure (AppData) */ app_data->app_ui_data->app_data = app_data; /* init comapp_system */ init_comapp_system(app_data); /* Initialize GnomeVFS */ result = gnome_vfs_init(); if (!result) { OSSO_LOG_CRIT("Failed initializing GnomeVFS"); return OSSO_ERROR; } /* Initialize GConf and read application configuration */ if (!init_settings(app_data)) { OSSO_LOG_CRIT("Failed initializing GConf"); return OSSO_ERROR; } if (!get_configuration(argc, argv, app_data)) { OSSO_LOG_CRIT("Failed reading configuration"); return OSSO_ERROR; } #ifdef ENABLE_NLS /* Initialize localization */ /* Gettext does not seem to work properly without the following function * call */ setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif /* ENABLE_NLS */ /* Initialize GTK */ //gtk_init(&argc, &argv); /* Initialize GTK+ and Hildon */ hildon_gtk_init(&argc, &argv); /* Create application UI */ ui_create_main_window(app_data); /* Initialize engine */ pdf_viewer_init(app_data->app_ui_data); app_data->app_ui_data->password_dialog = NULL; app_data->app_ui_data->replace_dialog = NULL; //hildon_gtk_window_take_screenshot(GTK_WINDOW(app_data->app_ui_data->app_view), TRUE); g_signal_connect(G_OBJECT(app_data->app_ui_data->app_view), "map-event", G_CALLBACK(game_get_screenshot), NULL); //prasanna GDK_THR_ENTER; gtk_main(); GDK_THR_LEAVE; if( !just_exit ) { g_debug( "Save configuration..." ); save_configuration(app_data); g_debug( "Deinit engine..." ); pdf_viewer_deinit(); g_debug( "Deinit compapp systems..." ); deinit_comapp_system(app_data); g_debug( "Deinit settings..." ); deinit_settings(); g_debug( "Deinit mime..." ); free_mime_filters(); free_application_mime_types(); g_debug( "Deinit gnomevfs..." ); if (gnome_vfs_initialized()) { gnome_vfs_shutdown(); } } /* Exit successfully, regardless of any errors */ g_debug( "Exit success" ); exit(EXIT_SUCCESS); }
int mainmenu_cycle(int width,int height) { int i; int retval=0; unsigned char *keyboard; SDL_PumpEvents(); keyboard = SDL_GetKeyState(NULL); switch(mainmenu_status) { case 0: mainmenu_substatus++; if (mainmenu_substatus>=40) { mainmenu_substatus=0; mainmenu_status=1; } /* if */ break; case 1: mainmenu_substatus++; if ((keyboard[fire_key] && !old_keyboard[fire_key]) || (( keyboard[SDLK_1] || keyboard[SDLK_KP1] ) && !old_keyboard[SDLK_1])) { mainmenu_status=4; mainmenu_substatus=0; } /* if */ if (( keyboard[SDLK_2] || keyboard[SDLK_KP2] ) && !old_keyboard[SDLK_2]) { mainmenu_status=6; mainmenu_substatus=0; } /* if */ if (( keyboard[SDLK_3] || keyboard[SDLK_KP3] ) && !old_keyboard[SDLK_3]) { mainmenu_status=2; mainmenu_substatus=0; } /* if */ if (( keyboard[SDLK_4] || keyboard[SDLK_KP4] ) && !old_keyboard[SDLK_4]) { /* Change the MAP: */ if (mapnames.EmptyP()) { /* Fill the mapnames list: */ #ifdef _WIN32 WIN32_FIND_DATA finfo; HANDLE h; h=FindFirstFile("maps/*.map",&finfo); if (h!=INVALID_HANDLE_VALUE) { if (strcmp(finfo.cFileName,".")!=0 && strcmp(finfo.cFileName,"..")!=0) { char *name; name=new char[strlen(finfo.cFileName)+1]; strcpy(name,finfo.cFileName); mapnames.Add(name); } /* if */ while(FindNextFile(h,&finfo)==TRUE) { if (strcmp(finfo.cFileName,".")!=0 && strcmp(finfo.cFileName,"..")!=0) { char *name; name=new char[strlen(finfo.cFileName)+1]; strcpy(name,finfo.cFileName); mapnames.Add(name); } /* if */ } /* while */ } /* if */ #else DIR *dp; struct dirent *ep; dp = opendir ("./maps/"); if (dp != NULL) { while (ep = readdir (dp)) { if ((strstr(ep->d_name,".map") + 4) == ep->d_name + strlen(ep->d_name)) { char *name; name=new char[strlen(ep->d_name)+1]; strcpy(name,ep->d_name); mapnames.Add(name); } } (void) closedir (dp); } #endif /* Look for the actualmap: */ mapnames.Rewind(); while(!mapnames.EndP() && strcmp(mapnames.GetObj(),mapname)!=0) mapnames.Next(); } /* if */ if (!mapnames.EmptyP()) { mapnames.Next(); if (mapnames.EndP()) mapnames.Rewind(); strcpy(mapname,mapnames.GetObj()); } /* if */ save_configuration(); } /* if */ if (( keyboard[SDLK_5] || keyboard[SDLK_KP5] ) && !old_keyboard[SDLK_5]) { mainmenu_status=5; mainmenu_substatus=0; } /* if */ break; case 2: mainmenu_substatus++; if (mainmenu_substatus>=40) { mainmenu_substatus=0; mainmenu_status=3; } /* if */ break; case 3: if (( keyboard[SDLK_1] || keyboard[SDLK_KP1] ) && !old_keyboard[SDLK_1]) { switch(SCREEN_X) { case 320: SCREEN_X=400; SCREEN_Y=300; break; case 400: SCREEN_X=640; SCREEN_Y=480; break; case 640: SCREEN_X=800; SCREEN_Y=600; break; case 800: SCREEN_X=1024; SCREEN_Y=768; break; case 1024: SCREEN_X=1280; SCREEN_Y=1024; break; case 1280: SCREEN_X=320; SCREEN_Y=240; break; default: SCREEN_X=1024; SCREEN_Y=768; } /* switch */ retval=3; save_configuration(); } /* if */ if (( keyboard[SDLK_2] || keyboard[SDLK_KP2] ) && !old_keyboard[SDLK_2]) { switch(COLOUR_DEPTH) { case 8:COLOUR_DEPTH=16; break; case 16:COLOUR_DEPTH=24; break; case 24:COLOUR_DEPTH=32; break; default: COLOUR_DEPTH=8; } /* switch */ retval=3; save_configuration(); } /* if */ if (( keyboard[SDLK_3] || keyboard[SDLK_KP3] ) && !old_keyboard[SDLK_3]) { if (fullscreen) fullscreen=false; else fullscreen=true; retval=3; save_configuration(); } /* if */ if (( keyboard[SDLK_4] || keyboard[SDLK_KP4] ) && !old_keyboard[SDLK_4]) { shadows++; if (shadows>=3) shadows=0; save_configuration(); } /* if */ if (( keyboard[SDLK_5] || keyboard[SDLK_KP5] ) && !old_keyboard[SDLK_5]) { detaillevel++; if (detaillevel>=5) detaillevel=0; save_configuration(); } /* if */ if (( keyboard[SDLK_6] || keyboard[SDLK_KP6] ) && !old_keyboard[SDLK_6]) { if (sound) sound=false; else sound=true; save_configuration(); } /* if */ if (( keyboard[SDLK_7] || keyboard[SDLK_KP7] ) && !old_keyboard[SDLK_7]) { level++; if (level>=4) level=0; save_configuration(); } /* if */ if (( keyboard[SDLK_8] || keyboard[SDLK_KP8] ) && !old_keyboard[SDLK_8]) { if (show_radar) show_radar=false; else show_radar=true; save_configuration(); } /* if */ if (( keyboard[SDLK_9] || keyboard[SDLK_KP9] ) && !old_keyboard[SDLK_9]) { mainmenu_status=0; mainmenu_substatus=0; } /* if */ break; case 4: mainmenu_substatus++; if (mainmenu_substatus>=40) { retval=1; } /* if */ break; case 5: mainmenu_substatus++; if (mainmenu_substatus>=40) { retval=2; } /* if */ break; case 6: mainmenu_substatus++; if (mainmenu_substatus>=40) { mainmenu_status=7; mainmenu_substatus=0; } /* if */ break; case 7: { int i; for(i=0;i<SDLK_LAST;i++) { if (keyboard[i] && !old_keyboard[i]) { switch(mainmenu_substatus) { case 0:up_key=i; break; case 1:down_key=i; break; case 2:left_key=i; break; case 3:right_key=i; break; case 4:fire_key=i; break; case 5:pause_key=i; break; } /* sritch */ mainmenu_substatus++; if (mainmenu_substatus==7) { mainmenu_status=0; mainmenu_substatus=0; save_configuration(); } /* if */ } /* if */ } /* for */ } break; } /* if */ for(i=0;i<SDLK_LAST;i++) old_keyboard[i]=keyboard[i]; return retval; } /* mainmenu_cycle */
int main (int argc, char *argv[]) { #ifdef GUI void *status; char path[256]; pthread_t thr_menu; #endif /* * Program setup * Handle user interrupt and alarm * Get program options * Open report file for logging if needed * Initialize UI */ signal(SIGINT, handle_break); signal(SIGALRM, handle_alarm); alarm(1); get_configuration(&opts); if (parse_options(argc, argv, &opts)) { return 1; } if (opts.save_options) { save_configuration(&opts); } if (opts.text_out) { report = fopen(opts.filename, "a"); if(report == NULL) { report = stdout; } } init_idle(); init_winmgmt(&opts); window_state_init(¤t); #ifdef GUI get_executable_path(path, sizeof(path)); init_indicator(argc, argv, path, &opts); if (opts.menu_items != NULL) { add_menu_items(opts.menu_items); } fflush(NULL); pthread_create(&thr_menu, NULL, run_indicator, ¤t.force); #endif if (opts.use_database) { open_database(opts.dbname); } while(poll_continue || current.force) { sleep(1); /* Just wait for program close */ } /* * Clean up */ alarm(1); /* Last hurrah */ sleep(1); #ifdef GUI pthread_join(thr_menu, &status); #endif if (report != stdout && opts.text_out) { fclose(report); } if (opts.use_database) { close_database(); } return 0; }
//Main int main() { //Try To Load Configuration File, If Fail Create Default if(!load_configuration()) save_configuration(); //Get Camera cv::VideoCapture cap(cv::VideoCapture(0)); //Create Server Thread pthread_t server_thread; //Camera Opened if(cap.isOpened()&&pthread_create(&server_thread,NULL,&server_thread_function,NULL)==0) { pthread_detach(server_thread); std::cout<<":)"<<std::endl; } //Camera Failed to Open else { std::cout<<":("<<std::endl; exit(0); } //Name OpenCV Window cv::namedWindow("video",CV_WINDOW_AUTOSIZE); //Set Mouse Callback cv::setMouseCallback("video",mouse_callback,NULL); //Create Tolerance Sliders cv::createTrackbar("Hue Tolerance","video",&h_tolerance,180,NULL); cv::createTrackbar("Saturation Tolerance","video",&s_tolerance,255,NULL); cv::createTrackbar("Value Tolerance","video",&v_tolerance,255,NULL); cv::createTrackbar("Area Minimum","video",&area_min_tolerance,200,NULL); //Track Objects...For Forever And Ever... while(true) { //Exit Key if(cv::waitKey(1)!=-1) { //Save Current Configuration save_configuration(); //Exit Program exit(0); } //Get Current Frame cv::Mat current_frame; cap>>current_frame; //If The Current Frame Has Data if(!current_frame.empty()) { //Set Tolerances For Tracked Object tracked.set_hsv_tolerances(h_tolerance,s_tolerance,v_tolerance); tracked.set_area_tolerances(area_min_tolerance,area_box_tolerance); //Get HSV Version of Frame cv::Mat current_frame_hsv; cv::cvtColor(current_frame,current_frame_hsv,CV_BGR2HSV); //Check If Mouse Position Is Within Window Boundry if(mouse_x>=0&&mouse_x<current_frame.cols&&mouse_y>=0&&mouse_y<current_frame.rows) { //Pixel Variable cv::Vec3b pixel; //Get Color At Mouse Position If A Mouse Button Is Pressed if(mouse_flags&CV_EVENT_FLAG_LBUTTON||mouse_flags&CV_EVENT_FLAG_RBUTTON) pixel=current_frame_hsv.at<cv::Vec3b>(mouse_y,mouse_x); //Left Mouse Button Sets Pink Object Color if(mouse_flags&CV_EVENT_FLAG_LBUTTON) { pink_color=pixel; tracked.set_pink_hsv_color(pink_color); } //Right Mouse Button Sets Lime Object Color if(mouse_flags&CV_EVENT_FLAG_RBUTTON) { lime_color=pixel; tracked.set_lime_hsv_color(lime_color); } } //Add Tracked Object Colors and Lines to Current Frame current_frame=current_frame*0.5+tracked.update(current_frame_hsv); //Debug //std::cout<<"x:"<<tracked.x()<<"\ty:"<<tracked.y()<<"\tdirection:"<<tracked.direction()<<std::endl; //Draw Current Frame cv::imshow("video",current_frame); } //Clear Mouse Button Flags mouse_callback_clear(); } //Call Me Plz T_T return 0; }
void SpectralMeterConfigWidget::on_buttonApply_clicked() { save_configuration(); emit configChanged(); }