int setup_getpartials_application(dataptr dz) { int exit_status; aplptr ap; if((exit_status = establish_application(dz))<0) // GLOBAL return(FAILED); ap = dz->application; // SEE parstruct FOR EXPLANATION of next 2 functions switch(dz->process) { case(PARTIALS_HARM): switch(dz->mode) { case(0): case(1): if((exit_status = set_param_data(ap,0 ,2,2,"dd" ))<0) return(FAILED); break; case(2): case(3): if((exit_status = set_param_data(ap,0 ,3,3,"ddd" ))<0) return(FAILED); break; } if((exit_status = set_vflgs(ap,"",0,"","v",1,0,"0"))<0) return(FAILED); break; } // set_legal_infile_structure --> dz->has_otherfile = FALSE; // assign_process_logic --> dz->input_data_type = ANALFILE_ONLY; dz->process_type = TO_TEXTFILE; dz->outfiletype = TEXTFILE_OUT; return application_init(dz); //GLOBAL }
static void handle_cmd(struct android_app* app, int32_t cmd) { struct VisualBenchState* state = (struct VisualBenchState*)app->userData; switch (cmd) { case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. if (state->fApp->window != nullptr && kInit_State == state->fState) { // drain any events that occurred before |window| was assigned. while (SkEvent::ProcessEvent()); // Start normal Skia sequence application_init(); SkTArray<const char*> args; args.push_back("VisualBench"); for (int i = 0; i < state->fFlags.count(); i++) { SkDebugf(state->fFlags[i].c_str()); args.push_back(state->fFlags[i].c_str()); } state->fWindow = create_sk_window((void*)state->fApp->window, args.count(), const_cast<char**>(args.begin())); state->fWindow->forceInvalAll(); state->fState = kAnimate_State; } break; case APP_CMD_TERM_WINDOW: state->fState = kDestroyRequested_State; break; } }
void startup() { set_core_freq(STARTUP_CORE_FREQ); #ifndef NVIC_PRESENT irq_init(); #endif //NVIC_PRESENT //initialize system memory pools mem_init(); //initialize thread subsystem, create idle task thread_init(); #if (DBG_CONSOLE) dbg_console_create(); #endif #if (SW_TIMER_MODULE) sw_timer_init(); #endif //initialize RTC sys_time_init(); //initialize system timers sys_timer_init(); //user application initialize application_init(); //initialize seed srand(); }
int SDL_main(int argc, char** argv) { #else int main(int argc, char** argv) { #endif if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) { report_sdl_error("Failed to init SDL."); return -1; } application_init(); SkOSWindow* window = create_sk_window(nullptr, argc, argv); // drain any events that occurred before |window| was assigned. while (SkEvent::ProcessEvent()); SkOSWindow::RunEventLoop(); delete window; application_term(); SDL_Quit(); return 0; }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPTSTR lpCmdLine) { application_init(); hInst = hInstance; // Store instance handle in our global variable HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } char* argv[4096]; int argc = 0; TCHAR exename[1024], *next; int exenameLen = GetModuleFileName(NULL, exename, 1024); argv[argc++] = tchar_to_utf8(exename); TCHAR* arg = _tcstok_s(lpCmdLine, _T(" "), &next); while (arg != NULL) { argv[argc++] = tchar_to_utf8(arg); arg = _tcstok_s(NULL, _T(" "), &next); } gSkWind = create_sk_window(hWnd, argc, argv); for (int i = 0; i < argc; ++i) { free(argv[i]); } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
/* 测试 struct window */ int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; si_t app_type = APPLICATION_TYPE_NORMAL; struct window * w = NULL; /* 初始化用户应用程序 */ application_init(video_access_mode, app_type, "single_window"); w = window_init("single_window"); /* 申请失败 */ if(w == NULL) { application_exit(); return -1; } window_set_bounds(w, 300, 100, 450, 200); /* 添加顶层窗口 */ application_add_window(NULL, w); /* 设置主窗口 */ application_set_main_window(w); /* 运行 */ application_exec(); return 0; }
int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; si_t app_type = APPLICATION_TYPE_NORMAL; struct window * w; struct scroll_bar* s; struct label* l; char show[25]; /* 初始化用户应用程序 */ application_init(video_access_mode, app_type, "scroll_bar"); /* 申请窗口 */ w = window_init("window with scroll_bar"); /* 申请失败 */ if(w == NULL) { application_exit(); return -1; } window_set_bounds(w, 300, 100, 448, 200); s = scroll_bar_init(1, 400, 20); /* 申请失败 */ if(s == NULL) { application_exit(); return -1; } scroll_bar_set_bounds(s, 428, 0, 20, 200); l = label_init(show); /* 申请失败 */ if(l == NULL) { application_exit(); return -1; } label_set_bounds(l, 10, 40, 400, 20); sprintf(show, "not started"); scroll_bar_register_move_handler(s, WIDGET_POINTER(l), SCROLL_BAR_EVENT_ALL, label_handler); object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(s)); object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(l)); /* 添加顶层窗口 */ application_add_window(NULL, w); /* 设置主窗口 */ application_set_main_window(w); /* 运行 */ application_exec(); return 0; }
int main (int argc, char **argv) { application_t app = {0}; application_init (&app, &argc, &argv); load_resource (&app); application_run (&app); return 0; }
void _kernel_call_inirtn(void) { macaddr_init( (VP_INT)(0) ); application_init( (VP_INT)(0) ); sdev_init( (VP_INT)(0) ); stdfile_init( (VP_INT)(0) ); rtc_init( (VP_INT)(0) ); mci_init( (VP_INT)(0) ); dma_init( (VP_INT)(0) ); timer_initialize( (VP_INT)(0) ); serial_initialize( (VP_INT)(0) ); }
JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env, jobject thiz, jobject jsampleActivity, jint msaaSampleCount) { // setup jni hooks to the java activity gActivityGlue.m_env = env; jclass clazz = env->FindClass("com/skia/SkiaSampleActivity"); gActivityGlue.m_obj = env->NewWeakGlobalRef(jsampleActivity); gActivityGlue.m_setTitle = GetJMethod(env, clazz, "setTitle", "(Ljava/lang/CharSequence;)V"); gActivityGlue.m_setSlideList = GetJMethod(env, clazz, "setSlideList", "([Ljava/lang/String;)V"); gActivityGlue.m_addToDownloads = GetJMethod(env, clazz, "addToDownloads", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); env->DeleteLocalRef(clazz); // setup jni hooks to the java renderer clazz = env->FindClass("com/skia/SkiaSampleRenderer"); gWindowGlue.m_obj = env->NewWeakGlobalRef(thiz); gWindowGlue.m_inval = GetJMethod(env, clazz, "requestRender", "()V"); gWindowGlue.m_queueSkEvent = GetJMethod(env, clazz, "queueSkEvent", "()V"); gWindowGlue.m_startTimer = GetJMethod(env, clazz, "startTimer", "(I)V"); gWindowGlue.m_getMSAASampleCount = GetJMethod(env, clazz, "getMSAASampleCount", "()I"); env->DeleteLocalRef(clazz); application_init(); SkTArray<const char*> args; args.push_back("SampleApp"); // TODO: push ability to select skp dir into the UI args.push_back("--pictureDir"); args.push_back("/sdcard/skiabot/skia_skp"); SkString msaaSampleCountString; if (msaaSampleCount > 0) { args.push_back("--msaa"); msaaSampleCountString.appendS32(static_cast<uint32_t>(msaaSampleCount)); args.push_back(msaaSampleCountString.c_str()); } gWindow = new SampleWindow(NULL, args.count(), const_cast<char**>(args.begin()), NULL); // send the list of slides up to the activity const int slideCount = gWindow->sampleCount(); jobjectArray slideList = env->NewObjectArray(slideCount, env->FindClass("java/lang/String"), env->NewStringUTF("")); for (int i = 0; i < slideCount; i++) { jstring slideTitle = env->NewStringUTF(gWindow->getSampleTitle(i).c_str()); env->SetObjectArrayElement(slideList, i, slideTitle); env->DeleteLocalRef(slideTitle); } env->CallVoidMethod(gActivityGlue.m_obj, gActivityGlue.m_setSlideList, slideList); env->DeleteLocalRef(slideList); }
/* 测试 eicon */ int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; ewindow * w; eicon * ic; /* 初始化用户应用程序 */ application_init(video_access_mode, "eicon"); /* 申请窗口 */ w = window_init(1); /* 申请失败 */ if(w == NULL) { application_exit(); return -1; } window_set_bounds(w,300,100,500,200); w->title = "window with eicon"; w->minimize_enable = 1; w->maximize_enable = 1; w->callback = window_default_callback; /* 申请按钮 */ ic = icon_init(2); /* 申请失败 */ if(ic == NULL) { application_exit(); return -1; } icon_set_bounds(ic ,50,50,100,120); icon_set_text(ic,"ehello"); icon_set_img_path(ic,"/home/orange/Egui2.0/img/2.bmp"); icon_set_is_text_visiable(ic ,1); ic->callback = icon_default_callback; /* 将按钮添加到窗口 */ object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(ic)); /* 添加顶层窗口 */ application_add_window(NULL, w); /* 设置主窗口 */ application_set_main_window(w); /* 运行 */ application_exec(); return 0; }
static void application_test() { if (oled_queue == NULL) { oled_queue = xQueueCreate(10, sizeof(oled_evt_t)); } application_init(); xTaskCreate(oled_task, "oled_task", 1024 * 8, NULL, 12, NULL); xTaskCreate(apds9960_task, "apds9960_task", 1024 * 8, NULL, 9, NULL); // SNTP init CWiFi *wifi = CWiFi::GetInstance(WIFI_MODE_STA); wifi->Connect(AP_SSID, AP_PASSWORD, portMAX_DELAY); xTaskCreate(&sntp_task, "sntp_task", 2048*2, NULL, 10, NULL); }
int main(int argc, char** argv){ SkOSWindow* window = create_sk_window(NULL, argc, argv); // drain any events that occurred before |window| was assigned. while (SkEvent::ProcessEvent()); // Start normal Skia sequence application_init(); window->loop(); delete window; application_term(); return 0; }
int main(int argc, char** argv){ signal(SIGALRM, catch_alarm); gWindow = create_sk_window(NULL, argc, argv); // drain any events that occurred before gWindow was assigned. while (SkEvent::ProcessEvent()); // Start normal Skia sequence application_init(); gWindow->loop(); delete gWindow; application_term(); return 0; }
int main(int argc, char **argv) { t_application app; t_args args; (void)argc; if (!args_init(&args, argv + 1)) { if (!application_init(&app, &args)) { args_free(&args); application_run(&app); } else args_free(&args); application_free(&app); } return (0); }
void rt_init_thread_entry(void* parameter) { /* initialize LCD drv for GUI */ rtgui_lcd_init(); /* Filesystem Initialization */ mci_hw_init("sd0"); /* initialize the device file system */ dfs_init(); /* initialize the elm chan FatFS file system*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); #if (RT_DFS_ELM_USE_LFN != 0) && (defined RT_DFS_ELM_CODE_PAGE_FILE) { extern void ff_convert_init(void); ff_convert_init(); } #endif } else { rt_kprintf("File System initialzation failed!\n"); } /* initialize GUI system */ rtgui_system_server_init(); /* initialize keyboard */ rt_hw_key_init(); /* initialize touch */ rt_hw_spi_init(); rtgui_touch_hw_init(); /* GUI examples initializtion */ application_init(); finsh_system_init(); }
int setup_speclean_application(dataptr dz) { int exit_status; aplptr ap; if((exit_status = establish_application(dz))<0) // GLOBAL return(FAILED); ap = dz->application; // SEE parstruct FOR EXPLANATION of next 2 functions if((exit_status = set_param_data(ap,0 ,2,2,"dd" ))<0) return(FAILED); if((exit_status = set_vflgs(ap,"",0,"","",0,0,""))<0) return(FAILED); // set_legal_infile_structure --> dz->has_otherfile = FALSE; // assign_process_logic --> dz->input_data_type = TWO_ANALFILES; dz->process_type = EQUAL_ANALFILE; dz->outfiletype = ANALFILE_OUT; return application_init(dz); //GLOBAL }
int setup_manysil_application(dataptr dz) { int exit_status; aplptr ap; if((exit_status = establish_application(dz))<0) // GLOBAL return(FAILED); ap = dz->application; // SEE parstruct FOR EXPLANATION of next 2 functions if((exit_status = set_param_data(ap,MANYSIL_DATA ,1,1,"d"))<0) return(FAILED); if((exit_status = set_vflgs(ap,"",0,"","",0,0,""))<0) return(FAILED); // set_legal_infile_structure --> dz->has_otherfile = FALSE; // assign_process_logic --> dz->input_data_type = SNDFILES_ONLY; dz->process_type = UNEQUAL_SNDFILE; dz->outfiletype = SNDFILE_OUT; return application_init(dz); //GLOBAL }
/** * main using gopt to check command line arguments * -h for help */ int main(int argc, char* argv[]) { // Set nabto to default values nabto_main_setup* nms = unabto_init_context(); // Initialise application if (!application_init()){ NABTO_LOG_FATAL(("Unable to initialise serial connection")); } // Optionally set alternative url to html device driver //nmc.nabtoMainSetup.url = "https://dl.dropbox.com/u/15998645/html_dd_demo.zip"; // Overwrite default values with command line args if (!check_args(argc, argv, nms)) { return 1; } NABTO_LOG_INFO(("Identity: '%s'", nms->id)); NABTO_LOG_INFO(("Program Release %" PRIu32 ".%" PRIu32, RELEASE_MAJOR, RELEASE_MINOR)); NABTO_LOG_INFO(("Buffer size: %d" , nms->bufsize)); // Initialize nabto if (!unabto_init()) { NABTO_LOG_FATAL(("Failed at nabto_main_init")); } // The main loop gives nabto a tick from time to time. // Everything else is taken care of behind the scenes. while (true) { unabto_tick(); nabto_yield(10); } unabto_close(); return 0; }
int main (int argc, char *argv[]) { GtkWidget *darea; GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); darea = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), darea); gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(darea), "draw", G_CALLBACK(on_draw_event), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_quit_event), NULL); g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(clicked), NULL); if (TIME_INTERVAL > 0) { // Add timer event // Register the timer and set time in mS. // The timer_event() function is called repeatedly until it returns FALSE. g_timeout_add(TIME_INTERVAL, (GSourceFunc) on_timer_event, (gpointer) window); } gtk_window_set_default_size(GTK_WINDOW(window), WINDOW_WIDTH, WINDOW_HEIGHT); gtk_window_set_title(GTK_WINDOW(window), WINDOW_NAME); if (strlen(ICON_NAME) > 0) { gtk_window_set_icon_from_file(GTK_WINDOW(window), ICON_NAME, NULL); } application_init(); gtk_widget_show_all(window); gtk_main(); return 0; }
void application() { application_init(); }
/* 测试顶层窗口和子窗口 程序一共申请了四个窗口 w1 w2 w3 w4 其中 w1 和 w2 是顶层窗口 w3 和 w4 是 w2 的同一层次子窗口 w2 总在 w3 和 w4 的后面 w3 和 w4 的前后关系则可以改变 */ int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; si_t app_type = APPLICATION_TYPE_NORMAL; struct window * w1; struct window * w2; struct window * w3; struct window * w4; struct window * w5; struct radiobutton * r, *s; /* 初始化用户应用程序 */ application_init(video_access_mode, app_type, "toplevel_child"); w1 = window_init("uncle-1"); /* 申请失败 */ if(w1 == NULL) { application_exit(); return -1; } window_set_bounds(w1, 300, 100, 448, 200); w2 = window_init("parent"); /* 申请失败 */ if(w2 == NULL) { application_exit(); return -1; } window_set_bounds(w2, 350, 150, 448, 200); w3 = window_init("child-1"); /* 申请失败 */ if(w3 == NULL) { application_exit(); return -1; } window_set_bounds(w3, 400, 200, 600, 600); w4 = window_init("child-2"); /* 申请失败 */ if(w4 == NULL) { application_exit(); return -1; } window_set_bounds(w4, 450, 250, 448, 200); w5 = window_init("uncle-2"); /* 申请失败 */ if(w5 == NULL) { application_exit(); return -1; } window_set_bounds(w5, 500, 300, 448, 200); { struct button *b = button_init("click me!"); button_set_bounds(b, 50, 50, 150, 50); b->callback = button_callback; object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(b)); } /* * Window structure illustraion: * app * / | \ * (main)w1 w5 w2 * / \ * w3 w4 */ /* 添加顶层窗口 */ application_add_window(NULL, w1); /* 添加顶层窗口 */ application_add_window(NULL, w2); /* 添加非顶层窗口 */ application_add_window(w2, w3); /* 添加非顶层窗口 */ application_add_window(w2, w4); /* 添加顶层窗口 */ application_add_window(NULL, w5); /* 设置主窗口 */ application_set_main_window(w1); r = radiobutton_init("test_group", 0); s = radiobutton_init("test_group", 1); radiobutton_set_bounds(r, 20, 20, 13, 13); radiobutton_set_bounds(s, 20, 40, 13, 13); object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(r)); object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(s)); { struct panel *p = panel_init(0); struct button *pb = button_init("button in panel"); struct checkbox *pcb = checkbox_init(0); panel_set_bounds(p, 5, 5, 500, 500); button_set_bounds(pb, 5, 5, 200, 50); checkbox_set_bounds(pcb, 210, 5, -1, -1); object_attach_child(OBJECT_POINTER(w3), OBJECT_POINTER(p)); object_attach_child(OBJECT_POINTER(p), OBJECT_POINTER(pb)); object_attach_child(OBJECT_POINTER(p), OBJECT_POINTER(pcb)); } /* 运行 */ application_exec(); return 0; }
/* * M A I N */ int main(int argc, char **argv) { struct rt_i *rtip = NULL; char *title_file = NULL, *title_obj = NULL; /* name of file and first object */ char idbuf[RT_BUFSIZE] = {0}; /* First ID record info */ void application_init(); struct bu_vls times; int i; #if defined(_WIN32) && !defined(__CYGWIN__) setmode(fileno(stdin), O_BINARY); setmode(fileno(stdout), O_BINARY); setmode(fileno(stderr), O_BINARY); #else bu_setlinebuf( stdout ); bu_setlinebuf( stderr ); #endif #ifdef HAVE_SBRK beginptr = (char *) sbrk(0); #endif azimuth = 35.0; /* GIFT defaults */ elevation = 25.0; AmbientIntensity=0.4; background[0] = background[1] = 0.0; background[2] = 1.0/255.0; /* slightly non-black */ /* Before option processing, get default number of processors */ npsw = bu_avail_cpus(); /* Use all that are present */ if ( npsw > MAX_PSW ) npsw = MAX_PSW; /* Before option processing, do application-specific initialization */ RT_APPLICATION_INIT( &ap ); application_init(); /* Process command line options */ if ( !get_args( argc, argv ) ) { (void)fputs(usage, stderr); return 1; } /* Identify the versions of the libraries we are using. */ if (rt_verbosity & VERBOSE_LIBVERSIONS) { (void)fprintf(stderr, "%s%s%s%s\n", brlcad_ident(title), rt_version(), bn_version(), bu_version() ); } #if defined(DEBUG) (void)fprintf(stderr, "Compile-time debug symbols are available\n"); #endif #if defined(NO_BOMBING_MACROS) || defined(NO_MAGIC_CHECKING) || defined(NO_BADRAY_CECHKING) || defined(NO_DEBUG_CHECKING) (void)fprintf(stderr, "WARNING: Run-time debugging is disabled and may enhance performance\n"); #endif /* Identify what host we're running on */ if (rt_verbosity & VERBOSE_LIBVERSIONS) { char hostname[512] = {0}; #ifndef _WIN32 if ( gethostname( hostname, sizeof(hostname) ) >= 0 && hostname[0] != '\0' ) (void)fprintf(stderr, "Running on %s\n", hostname); #else sprintf(hostname, "Microsoft Windows"); (void)fprintf(stderr, "Running on %s\n", hostname); #endif } if ( bu_optind >= argc ) { fprintf(stderr, "%s: MGED database not specified\n", argv[0]); (void)fputs(usage, stderr); return 1; } if (rpt_overlap) ap.a_logoverlap = ((void (*)())0); else ap.a_logoverlap = rt_silent_logoverlap; /* If user gave no sizing info at all, use 512 as default */ if ( width <= 0 && cell_width <= 0 ) width = 512; if ( height <= 0 && cell_height <= 0 ) height = 512; /* If user didn't provide an aspect ratio, use the image * dimensions ratio as a default. */ if (aspect <= 0.0) { aspect = (fastf_t)width / (fastf_t)height; } if ( sub_grid_mode ) { /* check that we have a legal subgrid */ if ( sub_xmax >= width || sub_ymax >= height ) { fprintf( stderr, "rt: illegal values for subgrid %d,%d,%d,%d\n", sub_xmin, sub_ymin, sub_xmax, sub_ymax ); fprintf( stderr, "\tFor a %d X %d image, the subgrid must be within 0, 0,%d,%d\n", width, height, width-1, height-1 ); return 1; } } if ( incr_mode ) { int x = height; if ( x < width ) x = width; incr_nlevel = 1; while ( (1<<incr_nlevel) < x ) incr_nlevel++; height = width = 1<<incr_nlevel; if (rt_verbosity & VERBOSE_INCREMENTAL) fprintf(stderr, "incremental resolution, nlevels = %d, width=%d\n", incr_nlevel, width); } /* * Handle parallel initialization, if applicable. */ #ifndef PARALLEL npsw = 1; /* force serial */ #endif if ( npsw < 0 ) { /* Negative number means "all but" npsw */ npsw = bu_avail_cpus() + npsw; } /* allow debug builds to go higher than the max */ if (!(bu_debug & BU_DEBUG_PARALLEL)) { if ( npsw > MAX_PSW ) { npsw = MAX_PSW; } } if (npsw > 1) { rt_g.rtg_parallel = 1; if (rt_verbosity & VERBOSE_MULTICPU) fprintf(stderr, "Planning to run with %d processors\n", npsw ); } else { rt_g.rtg_parallel = 0; } /* Initialize parallel processor support */ bu_semaphore_init( RT_SEM_LAST ); /* * Do not use bu_log() or bu_malloc() before this point! */ if ( bu_debug ) { bu_printb( "libbu bu_debug", bu_debug, BU_DEBUG_FORMAT ); bu_log("\n"); } if ( RT_G_DEBUG ) { bu_printb( "librt rt_g.debug", rt_g.debug, DEBUG_FORMAT ); bu_log("\n"); } if ( rdebug ) { bu_printb( "rt rdebug", rdebug, RDEBUG_FORMAT ); bu_log("\n"); } /* We need this to run rt_dirbuild */ rt_init_resource( &rt_uniresource, MAX_PSW, NULL ); bn_rand_init( rt_uniresource.re_randptr, 0 ); title_file = argv[bu_optind]; title_obj = argv[bu_optind+1]; nobjs = argc - bu_optind - 1; objtab = &(argv[bu_optind+1]); if ( nobjs <= 0 ) { bu_log("%s: no objects specified -- raytrace aborted\n", argv[0]); return 1; } /* Echo back the command line arugments as given, in 3 Tcl commands */ if (rt_verbosity & VERBOSE_MODELTITLE) { struct bu_vls str; bu_vls_init(&str); bu_vls_from_argv( &str, bu_optind, (const char **)argv ); bu_vls_strcat( &str, "\nopendb " ); bu_vls_strcat( &str, title_file ); bu_vls_strcat( &str, ";\ntree " ); bu_vls_from_argv( &str, nobjs <= 16 ? nobjs : 16, (const char **)argv+bu_optind+1 ); if ( nobjs > 16 ) bu_vls_strcat( &str, " ..."); else bu_vls_putc( &str, ';' ); bu_log("%s\n", bu_vls_addr(&str) ); bu_vls_free(&str); } /* Build directory of GED database */ bu_vls_init( × ); rt_prep_timer(); if ( (rtip=rt_dirbuild(title_file, idbuf, sizeof(idbuf))) == RTI_NULL ) { bu_log("rt: rt_dirbuild(%s) failure\n", title_file); return 2; } ap.a_rt_i = rtip; (void)rt_get_timer( ×, NULL ); if (rt_verbosity & VERBOSE_MODELTITLE) bu_log("db title: %s\n", idbuf); if (rt_verbosity & VERBOSE_STATS) bu_log("DIRBUILD: %s\n", bu_vls_addr(×) ); bu_vls_free( × ); memory_summary(); /* Copy values from command line options into rtip */ rtip->rti_space_partition = space_partition; rtip->rti_nugrid_dimlimit = nugrid_dimlimit; rtip->rti_nu_gfactor = nu_gfactor; rtip->useair = use_air; rtip->rti_save_overlaps = save_overlaps; if ( rt_dist_tol > 0 ) { rtip->rti_tol.dist = rt_dist_tol; rtip->rti_tol.dist_sq = rt_dist_tol * rt_dist_tol; } if ( rt_perp_tol > 0 ) { rtip->rti_tol.perp = rt_perp_tol; rtip->rti_tol.para = 1 - rt_perp_tol; } if (rt_verbosity & VERBOSE_TOLERANCE) rt_pr_tol( &rtip->rti_tol ); /* before view_init */ if ( outputfile && strcmp( outputfile, "-") == 0 ) outputfile = (char *)0; /* * Initialize application. * Note that width & height may not have been set yet, * since they may change from frame to frame. */ if ( view_init( &ap, title_file, title_obj, outputfile!=(char *)0, framebuffer!=(char *)0 ) != 0 ) { /* Framebuffer is desired */ register int xx, yy; int zoom; /* Ask for a fb big enough to hold the image, at least 512. */ /* This is so MGED-invoked "postage stamps" get zoomed up big enough to see */ xx = yy = 512; if ( width > xx || height > yy ) { xx = width; yy = height; } bu_semaphore_acquire( BU_SEM_SYSCALL ); fbp = fb_open( framebuffer, xx, yy ); bu_semaphore_release( BU_SEM_SYSCALL ); if ( fbp == FBIO_NULL ) { fprintf(stderr, "rt: can't open frame buffer\n"); return 12; } bu_semaphore_acquire( BU_SEM_SYSCALL ); /* If fb came out smaller than requested, do less work */ if ( fb_getwidth(fbp) < width ) width = fb_getwidth(fbp); if ( fb_getheight(fbp) < height ) height = fb_getheight(fbp); /* If the fb is lots bigger (>= 2X), zoom up & center */ if ( width > 0 && height > 0 ) { zoom = fb_getwidth(fbp)/width; if ( fb_getheight(fbp)/height < zoom ) zoom = fb_getheight(fbp)/height; } else { zoom = 1; } (void)fb_view( fbp, width/2, height/2, zoom, zoom ); bu_semaphore_release( BU_SEM_SYSCALL ); } if ( (outputfile == (char *)0) && (fbp == FBIO_NULL) ) { /* If not going to framebuffer, or to a file, then use stdout */ if ( outfp == NULL ) outfp = stdout; /* output_is_binary is changed by view_init, as appropriate */ if ( output_is_binary && isatty(fileno(outfp)) ) { fprintf(stderr, "rt: attempting to send binary output to terminal, aborting\n"); return 14; } } /* * Initialize all the per-CPU memory resources. * The number of processors can change at runtime, init them all. */ for ( i=0; i < MAX_PSW; i++ ) { rt_init_resource( &resource[i], i, rtip ); bn_rand_init( resource[i].re_randptr, i ); } memory_summary(); #ifdef SIGUSR1 (void)signal( SIGUSR1, siginfo_handler ); #endif #ifdef SIGINFO (void)signal( SIGINFO, siginfo_handler ); #endif if ( !matflag ) { int frame_retval; def_tree( rtip ); /* Load the default trees */ do_ae( azimuth, elevation ); frame_retval = do_frame( curframe ); if (frame_retval != 0) { /* Release the framebuffer, if any */ if ( fbp != FBIO_NULL ) { fb_close(fbp); } return 1; } } else if ( !isatty(fileno(stdin)) && old_way( stdin ) ) { ; /* All is done */ } else { register char *buf; register int ret; /* * New way - command driven. * Process sequence of input commands. * All the work happens in the functions * called by rt_do_cmd(). */ while ( (buf = rt_read_cmd( stdin )) != (char *)0 ) { if ( R_DEBUG&RDEBUG_PARSE ) fprintf(stderr, "cmd: %s\n", buf ); ret = rt_do_cmd( rtip, buf, rt_cmdtab ); bu_free( buf, "rt_read_cmd command buffer" ); if ( ret < 0 ) break; } if ( curframe < desiredframe ) { fprintf(stderr, "rt: Desired frame %d not reached, last was %d\n", desiredframe, curframe); } } /* Release the framebuffer, if any */ if (fbp != FBIO_NULL) { fb_close(fbp); } return(0); }
s_int16 applicatieprogramma(s_int16 state) { if (state == CIF_INIT) { /* Initialize */ application_init(phases, detectors, outging_signals, &modulemill, modules, &clock); } else if(running == TRUE) { /* Read data from interface */ if (CIF_ISWIJZ) { CIF_ISWIJZ = FALSE; } if (CIF_WUSWIJZ) { CIF_WUSWIJZ = FALSE; } // TODO: process other inputs Detectors_update(detectors, DPMAX); if (CIF_PARM1WIJZPB) { // TODO } /* Update clock and timers */ Clock_update(&clock); Phases_timers_update(phases, FCMAX, &clock); Detectors_timers_update(detectors, DPMAX, &clock); Timers_update(timers, TMMAX, &clock); /* Update state */ Phases_requests(phases, FCMAX); // TODO: update waiting green (later) Phases_extending(phases, FCMAX); // TODO: update free extending Phases_update_conflicts(phases, FCMAX); Modules_update_primary(&modulemill); //Modules_update_alternative(&modulemill, phases, FCMAX); Phases_state_update_ML(phases, FCMAX, &CIF_GUSWIJZ); Modules_move_the_mill(&modulemill, phases, FCMAX); Modules_update_segment_display(&modulemill, outging_signals, ossegm1, &CIF_GUSWIJZ); if (CIF_GUSWIJZ) { Phases_state_out_update(phases, FCMAX); Set_GUS(phases, FCMAX, outging_signals, USMAX-FCMAX); } #ifdef YATLCCLC_WIN32 /* Internal state to WIN32 environment */ int i; for (i = 0; i < FCMAX; ++i) { Phases_internal_state[i] = phases[i].CycleState; Phases_internal_state_alt[i] = phases[i].ML_Alternative; } #endif // TODO: check if we need to copy params from yatlcclc to outside buffers } return 0; }
int main (int argc, char *argv[]) { char databuf[BUFFER_SIZE]; char *section, *name, *inifn; int nBoolValue = FALSE, bFlagBool = FALSE, bFlagDump = FALSE; int firstArgIndex = 1; char* const DEFAULT_VALUE = ""; application_init(argc, argv, arg_c, arg_v, &databuf, BUFFER_SIZE); if (argc <= 1) { show_error(STR_ERR_NOT_ENOUGH_ARGS); return show_usage( THIS_APP_FILENAME ); } bFlagBool = (check_arg_flag_bool(1) ? TRUE : FALSE); bFlagDump = (check_arg_flag(1, FLAG_DUMP) ? TRUE : FALSE); if (argc == 2) { if (bFlagBool==TRUE) return show_error(STR_ERR_NOT_ENOUGH_ARGS); if (bFlagDump) return show_error(STR_ERR_NO_FILE_NAME); if (check_arg_flag(1, FLAG_VERSION)) return show_version(APP_TITLE, INI_TOOLS_VERSION); if (check_arg_flag(1, FLAG_HELP)) return show_help( THIS_APP_FILENAME ); } firstArgIndex = 1; //first arg is index 1, if (bFlagBool || bFlagDump) firstArgIndex++; //unless -b|-d is passed //--- start dump file processing --- if (bFlagDump) { inifn = argv[firstArgIndex]; if (strcmp(inifn, "-")==0) inifn = "/dev/stdin"; if (!file_exist(inifn)) return show_error(STR_ERR_FILE_NOT_FOUND); if (!file_readable(inifn)) return show_error_fmt(STR_ERR_FMT_FILE_NOT_READABLE, basename(inifn)); char * sectionName = NULL; if (argc == 4) { sectionName = argv[3]; if (!ini_section_exists(inifn, sectionName)) return show_error_fmt(STR_ERR_FMT_SECTION_NOT_FOUND, sectionName); } //dump either the entire ini file or specified [section] keys ini_browse(browsecb, sectionName, inifn); if (lastSection!="") free(lastSection); return EXIT_SUCCESS; } //--- end dump file processing --- // --- start error checking --- if (argc <= firstArgIndex) return show_error(STR_ERR_NO_SECTION_NAME); if (argc <= firstArgIndex+1) return show_error(STR_ERR_NO_KEY_NAME); if (argc <= firstArgIndex+2) return show_error(STR_ERR_NO_FILE_NAME); // --- end error checking --- section = argv[firstArgIndex+0]; name = argv[firstArgIndex+1]; inifn = argv[firstArgIndex+2]; if (strcmp(inifn, "-")==0) inifn = "/dev/stdin"; // -- start sanity checking -- if (!file_exist(inifn)) return show_error(STR_ERR_FILE_NOT_FOUND); if ((file_exist(inifn) && !file_readable(inifn)) ) return show_error_fmt(STR_ERR_FMT_FILE_NOT_READABLE, basename(inifn)); if (!valid_section_name(section)) return show_error(STR_ERR_INVALID_SECTION_NAME); if (!valid_key_name(name)) return show_error(STR_ERR_INVALID_KEY_NAME); // -- end sanity checking -- ini_gets(section, name, DEFAULT_VALUE, databuf, sizeof(databuf), inifn); if (bFlagBool) { nBoolValue = FALSE; //default value if (is_bool_str_true(databuf)) nBoolValue = TRUE; if (is_bool_str_false(databuf)) nBoolValue = FALSE; sprintf(databuf,"%d", nBoolValue); } printf("%s", databuf); return EXIT_SUCCESS; }
int main(int argc, char **argv) { int cnt, x, y, i = 0, verbose = 0; Window win = 0; Bool keysymMappingInitialized = False; int rc = 0; int inputEvents[100]; int inputEventsIndex = 0; int iEvent = 0; if (argc == 1) usage(argv[0]); const char* log_file = NULL; if (streq(argv[1],"-o") || streq(argv[1],"--logfile")) { i++; if (++i > argc) usage(argv[0]); log_file = argv[i]; } report_init(log_file); if (!xhandler_init(getenv("DISPLAY"))) exit(1); report_add_message(xhandler_get_server_time(), "Startup\n"); /* initialize subsystems */ xemu_init(xhandler.display); scheduler_init(xhandler.display); window_init(xhandler.display); application_init(); /* * Process the command line options. * Skip emulation options (--click, --drag, --key, --type), but remember they index * and process them later. */ while (++i < argc) { if (streq(argv[i],"-v") || streq(argv[i],"--verbose")) { verbose = 1; continue; } if (streq(argv[i], "-id") || streq(argv[i], "--id")) { char name[PATH_MAX]; if (++i >= argc) usage(argv[0]); cnt = sscanf(argv[i], "0x%lx", &win); if (cnt < 1) { cnt = sscanf(argv[i], "%lu", &win); } if (cnt < 1) { fprintf(stderr, "*** invalid window id '%s'\n", argv[i]); usage(argv[0]); } sprintf(name, "0x%lx", win); if (!window_add(win, application_monitor(name))) { fprintf(stderr, "Could not setup damage monitoring for window 0x%lx!\n", win); exit(1); } if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring window 0x%lx\n", win); continue; } if (streq(argv[i], "-a") || streq(argv[i], "--application")) { if (++i >= argc) usage(argv[0]); response.application = application_monitor(argv[i]); if (response.application && verbose) { report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring application '%s'\n", argv[i]); } if (!strcmp(argv[i], "*")) { application_set_monitor_all(true); } continue; } if (streq("-c", argv[i]) || streq("--click", argv[i])) { if (!xemu.pointer.dev) { fprintf(stderr, "Failed to open pointer device, unable to simulate pointer events.\n"); exit(-1); } if (inputEventsIndex == ASIZE(inputEvents)) { fprintf(stderr, "Too many input events specified\n"); exit(-1); } if (!argv[i + 1] || !match_regex(argv[i + 1], "^[0-9]+x[0-9]+(,[0-9]+)?$")) { fprintf(stderr, "Failed to parse --c options: %s\n", argv[i + 1]); exit(-1); } inputEvents[inputEventsIndex++] = i; if (++i >= argc) usage(argv[0]); continue; } if (streq("-l", argv[i]) || streq("--level", argv[i])) { if (++i >= argc) usage(argv[0]); if (!strcmp(argv[i], "raw")) { window_set_damage_level(XDamageReportRawRectangles); } else if (!strcmp(argv[i], "delta")) { window_set_damage_level(XDamageReportDeltaRectangles); } else if (!strcmp(argv[i], "box")) { window_set_damage_level(XDamageReportDeltaRectangles); } else if (!strcmp(argv[i], "nonempty")) { window_set_damage_level(XDamageReportNonEmpty); } else { fprintf(stderr, "Unrecongnized damage level: %s\n", argv[i]); usage(argv[0]); } if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Setting damage report level to %s\n", argv[i]); continue; } if (streq("-x", argv[i]) || streq("--exclude", argv[i])) { char* exclude[] = { "none", "less", "greater" }; if (options.exclude_rules != EXCLUDE_NONE) { fprintf(stderr, "Duplicated --exclude parameter detected. Aborting\n"); exit(-1); } if (++i >= argc) usage(argv[0]); char rules[32] = ""; if ((cnt = sscanf(argv[i], "%ux%u,%s", &options.exclude_rect.width, &options.exclude_rect.height, rules)) >= 2) { options.exclude_size = 0; } else if ((cnt = sscanf(argv[i], "%u,%s", &options.exclude_size, rules)) >= 1) { options.exclude_rect.width = 0; options.exclude_rect.height = 0; } else { fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } options.exclude_rules = *rules && !strcmp(rules, "greater") ? EXCLUDE_GREATER : EXCLUDE_LESS; if (verbose) { if (options.exclude_size) { report_add_message(REPORT_LAST_TIMESTAMP, "Excluding damage areas %s than %d pixels\n", exclude[options.exclude_rules], options.exclude_size); } else { report_add_message(REPORT_LAST_TIMESTAMP, "Excluding damage areas %s than (%dx%d)\n", exclude[options.exclude_rules], options.exclude_rect.width, options.exclude_rect.height); } } continue; } if (streq("-m", argv[i]) || streq("--monitor", argv[i])) { if (options.interested_damage_rect.width || options.interested_damage_rect.height || options.interested_damage_rect.x || options.interested_damage_rect.y) { fprintf(stderr, "Duplicated --monitor parameter detected. Aborting\n"); exit(-1); } if (++i >= argc) usage(argv[0]); if ((cnt = sscanf(argv[i], "%ux%u+%u+%u", &options.interested_damage_rect.width, &options.interested_damage_rect.height, &options.interested_damage_rect.x, &options.interested_damage_rect.y)) != 4) { fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } if (verbose) { report_add_message(REPORT_LAST_TIMESTAMP, "Set monitor rect to %ix%i+%i+%i\n", options.interested_damage_rect.width, options.interested_damage_rect.height, options.interested_damage_rect.x, options.interested_damage_rect.y); } continue; } if (streq("-w", argv[i]) || streq("--wait", argv[i])) { if (++i >= argc) usage(argv[0]); if (options.damage_wait_secs >= 0) { fprintf(stderr, "Duplicate -w(--wait) option detected. Discarding the previous value\n"); } if ((options.damage_wait_secs = atoi(argv[i])) < 0) { fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Set event timeout to %isecs\n", options.damage_wait_secs); continue; } if (streq("-b", argv[i]) || streq("--break", argv[i])) { if (options.break_timeout || options.break_on_damage) { fprintf(stderr, "Duplicate -b(--break)option detected. Discarding the previous value\n"); options.break_timeout = 0; options.break_on_damage = 0; } if (++i >= argc) usage(argv[0]); if (!strncmp(argv[i], "damage", 6)) { sscanf(argv[i] + 6, ",%d", &options.break_on_damage); if (!options.break_on_damage) options.break_on_damage = 1; if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Break wait on the %d damage event\n", options.break_on_damage); } else { if ((options.break_timeout = atoi(argv[i])) < 0) { fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Set break timout to %imsecs\n", options.break_timeout); } continue; } if (streq("-d", argv[i]) || streq("--drag", argv[i])) { if (!xemu.pointer.dev) { fprintf(stderr, "Failed to open pointer device, unable to simulate pointer events.\n"); exit(-1); } if (inputEventsIndex == ASIZE(inputEvents)) { fprintf(stderr, "Too many input events specified\n"); exit(-1); } if (!argv[i + 1] || (!match_regex(argv[i + 1], "^([0-9]+,)?(([0-9]+x[0-9]+,([0-9]+,)?)+[0-9]+x[0-9]+)$") && (!match_regex(argv[i + 1], "[0-9]+x[0-9]+-[0-9]+x[0-9]+") || !match_regex(argv[i + 1], "^(((([0-9]+,)?([0-9]+x[0-9]+)|([0-9]+x[0-9]+-[0-9]+x[0-9]+(\\*[0-9]+)?(\\+[1-9][0-9]*)?)),?)+)$") ) ) ) { fprintf(stderr, "Failed to parse --drag options: %s\n", argv[i + 1]); exit(-1); } inputEvents[inputEventsIndex++] = i; if (++i >= argc) usage(argv[0]); continue; } if (streq("-k", argv[i]) || streq("--key", argv[i])) { if (!xemu.keyboard.dev) { fprintf(stderr, "Failed to open keyboard device, unable to simulate keyboard events.\n"); exit(-1); } if (inputEventsIndex == ASIZE(inputEvents)) { fprintf(stderr, "Too many input events specified\n"); exit(-1); } inputEvents[inputEventsIndex++] = i; if (++i >= argc) usage(argv[0]); continue; } if (streq("-t", argv[i]) || streq("--type", argv[i])) { if (!xemu.keyboard.dev) { fprintf(stderr, "Failed to open keyboard device, unable to simulate keyboard events.\n"); exit(-1); } if (inputEventsIndex == ASIZE(inputEvents)) { fprintf(stderr, "Too many input events specified\n"); exit(-1); } inputEvents[inputEventsIndex++] = i; if (++i >= argc) usage(argv[0]); if (!keysymMappingInitialized) { xemu_load_keycodes(); keysymMappingInitialized = True; } continue; } /* since moving from command sequence approach the inspect parameter is deprecated */ if (streq("-i", argv[i]) || streq("--inspect", argv[i])) { if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Just displaying damage events until timeout\n"); continue; } /* */ if (streq("-u", argv[i]) || streq("--user", argv[i]) || (xrecord.motion = (streq("-U", argv[i]) || streq("--user-all", argv[i])) ) ) { xinput_init(xhandler.display); if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Reporting user input events\n"); continue; } if (streq(argv[i], "-r") || streq(argv[i], "--response")) { if (++i >= argc) usage(argv[0]); char option[500]; cnt = sscanf(argv[i], "%u,%s", &response.timeout, option); if (cnt < 1) { fprintf(stderr, "*** invalid response timeout value '%s'\n", argv[i]); usage(argv[0]); } if (cnt < 2) { report_set_silent(true); } else { if (strcmp(option, "verbose")) { fprintf(stderr, "*** invalid response option '%s'\n", argv[i]); usage(argv[0]); } } application_monitor_screen(); xinput_init(xhandler.display); if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring application response time\n"); continue; } fprintf(stderr, "*** Dont understand %s\n", argv[i]); usage(argv[0]); } /* start monitoring the root window if no targets are specified */ if ((window_empty() && application_empty()) || response.timeout) { application_monitor(ROOT_WINDOW_RESOURCE); } window_monitor_all(); application_start_monitor(); /* eat first damage event when options.break_on_damage set */ if (options.break_on_damage) xhandler_eat_damage(); /* monitor the whole screen of no area is specified */ if (!options.interested_damage_rect.width && !options.interested_damage_rect.height && !options.interested_damage_rect.x && !options.interested_damage_rect.y) { options.interested_damage_rect.x = 0; options.interested_damage_rect.y = 0; options.interested_damage_rect.width = DisplayWidth(xhandler.display, DefaultScreen(xhandler.display)); options.interested_damage_rect.height = DisplayHeight(xhandler.display, DefaultScreen(xhandler.display)); } /* emulate user input */ for (iEvent = 0; iEvent < inputEventsIndex; iEvent++) { i = inputEvents[iEvent]; if (!strcmp("-c", argv[i]) || !strcmp("--click", argv[i])) { unsigned long delay = 0; Time start = 0; cnt = sscanf(argv[++i], "%ux%u,%lu", &x, &y, &delay); if (cnt == 2) { start = xhandler_get_server_time(); report_add_message(start, "Using no delay between press/release\n"); delay = 0; } else if (cnt != 3) { fprintf(stderr, "cnt: %d\n", cnt); fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } /* Send the event */ start = xemu_button_event(x, y, delay); report_add_message(start, "Clicked %ix%i\n", x, y); continue; } if (!strcmp("-d", argv[i]) || !strcmp("--drag", argv[i])) { Time drag_time; char *s = NULL, *p = NULL; int button_state = XR_BUTTON_STATE_PRESS; s = p = argv[++i]; int delay = DEFAULT_DRAG_DELAY; int x1, y1, x2, y2; while (p) { p = strchr(s, ','); if (p) { *p++ = '\0'; } int count = DEFAULT_DRAG_COUNT; cnt = sscanf(s, "%ix%i-%ix%i*%i+%i", &x1, &y1, &x2, &y2, &delay, &count); if (cnt >= 4) { drag_time = xemu_drag_event(x1, y1, button_state, delay); button_state = XR_BUTTON_STATE_NONE; report_add_message(drag_time, "Dragged to %ix%i\n", x1, y1); int xdev = (x2 - x1) / (count + 1); int ydev = (y2 - y1) / (count + 1); for (i = 1; i <= count; i++) { x = x1 + xdev * i; y = y1 + ydev * i; drag_time = xemu_drag_event(x, y, button_state, delay); report_add_message(drag_time, "Dragged to %ix%i\n", x, y); } if (!p) button_state = XR_BUTTON_STATE_RELEASE; drag_time = xemu_drag_event(x2, y2, button_state, delay); report_add_message(drag_time, "Dragged to %ix%i\n", x2, y2); } else if (cnt == 2) { /* Send the event */ if (!p) { if (button_state == XR_BUTTON_STATE_PRESS) { fprintf(stderr, "*** Need at least 2 drag points!\n"); usage(argv[0]); } button_state = XR_BUTTON_STATE_RELEASE; } drag_time = xemu_drag_event(x1, y1, button_state, delay); report_add_message(drag_time, "Dragged to %ix%i\n", x1, y1); /* Make sure button state set to none after first point */ button_state = XR_BUTTON_STATE_NONE; /* reset the delay to default value */ delay = DEFAULT_DRAG_DELAY; } else if (cnt == 1) { delay = x1; } else { fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); usage(argv[0]); } s = p; } continue; } if (!strcmp("-k", argv[i]) || !strcmp("--key", argv[i])) { char *key = NULL; char separator; unsigned long delay = 0; Time start = 0; cnt = sscanf(argv[++i], "%a[^,]%c%lu", &key, &separator, &delay); if (cnt == 1) { report_add_message(REPORT_LAST_TIMESTAMP, "Using default delay between press/release\n", delay); delay = DEFAULT_KEY_DELAY; } else if (cnt != 3 || separator != ',') { fprintf(stderr, "cnt: %d\n", cnt); fprintf(stderr, "*** failed to parse '%s'\n", argv[i]); if (key != NULL) free(key); usage(argv[0]); } start = xemu_send_key(key, delay); report_add_message(start, "Simulating keypress/-release pair (keycode '%s')\n", key); free(key); continue; } if (!strcmp("-t", argv[i]) || !strcmp("--type", argv[i])) { Time start = xemu_send_string(argv[++i]); report_add_message(start, "Simulated keys for '%s'\n", argv[i]); continue; } } /* setting the default wait period */ if (options.damage_wait_secs < 0) { options.damage_wait_secs = 5; } signal(SIGINT, abort_wait); /* wait for damage events */ rc = wait_response(); scheduler_fini(); report_flush_queue(); report_fini(); xinput_fini(); xemu_fini(); window_fini(); application_fini(); xhandler_fini(); return rc; }
inline bool app::init(void* hinstance, const char* command_line) { return GRAPHIN_OK == application_init(hinstance, command_line); }
/* thread phase init */ void rt_init_thread_entry(void *parameter) { #ifdef RT_USING_SPI { extern void rt_hw_spi0_init(void); rt_hw_spi0_init(); } #endif #ifdef RT_USING_I2C { extern void rt_hw_i2c_init(void); rt_i2c_core_init(); rt_hw_i2c_init(); } #endif /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); /* init the elm FAT filesystam*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) rt_kprintf("File System initialized!\n"); else rt_kprintf("File System init failed!\n"); } #endif /* LwIP Initialization */ #ifdef RT_USING_LWIP { extern void lwip_sys_init(void); extern void lpc17xx_emac_hw_init(void); eth_system_device_init(); /* register ethernetif device */ lpc_emac_hw_init(); /* init all device */ rt_device_init_all(); /* init lwip system */ lwip_sys_init(); rt_kprintf("TCP/IP initialized!\n"); } #endif #ifdef RT_USING_RTGUI { extern void rtgui_system_server_init(void); extern void application_init(void); rt_device_t lcd; /* init lcd */ rt_hw_lcd_init(); /* re-init device driver */ rt_device_init_all(); /* find lcd device */ lcd = rt_device_find("lcd"); if (lcd != RT_NULL) { /* set lcd device as rtgui graphic driver */ rtgui_graphic_set_device(lcd); /* init rtgui system server */ rtgui_system_server_init(); rt_hw_joystick_init(); rtgui_touch_hw_init("spi20"); /* startup rtgui in demo of RT-Thread/GUI examples */ application_init(); } } #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(FINSH_DEVICE_NAME); #endif }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure LED3, LED4, LED5 and LED6 */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); BSP_LED_Init(LED5); BSP_LED_Init(LED6); /* Configure the system clock to 84 MHz */ SystemClock_Config(); /* Initialize MEMS Accelerometer mounted on STM32F4-Discovery board */ if(BSP_ACCELERO_Init() != ACCELERO_OK) { /* Initialization Error */ Error_Handler(); } /* Enable click config for pause/play */ BSP_ACCELERO_Click_ITConfig(); /* Turn ON LED4: start of application */ BSP_LED_On(LED4); /* Configure TIM4 Peripheral to manage LEDs lighting */ TIM_LED_Config(); /* Turn OFF all LEDs */ LEDsState = LEDS_OFF; /* Initialize User Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /*##-1- Link the USB Host disk I/O driver ##################################*/ application_init(); /*##-2- Init Host Library ################################################*/ USBH_Init(&hUSBHost, USBH_UserProcess, 0); /*##-3- Add Supported Class ##############################################*/ USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS); /*##-4- Start Host Process ###############################################*/ USBH_Start(&hUSBHost); /* Run Application (Blocking mode)*/ while (1) { application_task(); /* USBH_Background Process */ USBH_Process(&hUSBHost); } }
void rt_init_thread_entry(void* parameter) { { extern void rt_platform_init(void); rt_platform_init(); } /* Filesystem Initialization */ #if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT) /* initialize the device file system */ dfs_init(); /* initialize the elm chan FatFS file system*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else { rt_kprintf("File System initialzation failed!\n"); } #endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */ #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_RTGUI { rt_device_t device; struct rt_device_rect_info info; extern int rtgui_system_server_init(void); rtgui_system_server_init(); device = rt_device_find("lcd"); /* re-set graphic device */ rtgui_graphic_set_device(device); rtgui_system_server_init(); /* ´¥ÃþÆÁУ׼ calibration();*/ /* ²âÊÔ´¥ÃþÆÁ°´Å¥ ¼°¼òÒ×¼ÆËãÆ÷ ui_button();*/ /*ÔËÐÐdemo */ application_init(); } #endif }