void get_status(void) { char c; set_alrm(5); /* 5 second timeout to fetch status */ tty_flush(); c = '\024'; block_write(&c, 1); /* send Control-T to printer */ init_input(0); while (status == INVALID) proc_some_input(); /* wait for something back */ switch (status) { case IDLE: /* this is what we're looking for ... */ clear_alrm(); return; case WAITING: /* printer thinks it's in the middle of a job */ block_write(&eofc, 1); /* send EOF to printer */ sleep(5); exit(EXIT_REPRINT); case BUSY: case UNKNOWN: sleep(15); exit(EXIT_REPRINT); } }
void init() { init_audio(); init_input(); sysclock_start(); sei(); task_create(handle_input, 10, true); }
int main () { cmd_t last_cmd = CMD_NONE; cmd_t cmd; static const char* const cmd_name[NUM_COMMANDS] = { "none", "right", "left", "up", "down", "move left", "enter", "move right", "typed command", "quit" }; /* Grant ourselves permission to use ports 0-1023 */ if (ioperm (0, 1024, 1) == -1) { perror ("ioperm"); return 3; } init_input (); //intialize the tux ioctl(fd, TUX_INIT); while (1) { while ((cmd = get_tux_command()) == last_cmd); last_cmd = cmd; printf ("command issued: %s\n", cmd_name[cmd]); if (cmd == CMD_QUIT) break; display_time_on_tux (83); } shutdown_input (); return 0; }
int init(int argc, char** argv, t_env* env) { id_memset(env, 0, sizeof(*env)); if (argc != 4) return (id_error("id_rt width height fileToLoad")); env->width = id_atoi(argv[1]); env->height = id_atoi(argv[2]); if (env->height <= 0 || env->width <= 0) return (id_error("width and height should be over 0")); if (init_input(env, argv[3])) return (-1); env->screen = idx_init("Raytracing", env->width, env->height); if (env->screen == NULL) return (-1); env->pixels = malloc(sizeof(*env->pixels) * (env->width * env->height)); if (!env->pixels) return (-1); if (build_thread(env)) return (-1); env->global_work = 0; env->scale = (((env->width * env->height) / 10) * (ANTIALIASING / 2)) * 2; env->current_work = 0; return (0); }
FLAG init_kwestkingdom() { FLAG screen_init; allegro_init(); init_timer(); install_keyboard(); init_input(); if (!init_resources()) { /* Load images and sounds */ return OFF; } screen_init = init_screen( CANVAS_WIDTH * DEFAULT_SCREEN_RATIO, CANVAS_HEIGHT * DEFAULT_SCREEN_RATIO, OFF /* fullscreen on or off */ ); if (!screen_init) { return OFF; } change_colors(grab_color_palette()); change_canvas_size(CANVAS_WIDTH, CANVAS_HEIGHT); /*install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);*/ /*toggle_sound();*/ /* Turn off sound */ return ON; }
static void config_input(void) { int choice; char dev_type; char buf[PATH_SIZE]; USHORT idis[9]; UBYTE modes[IDR_MAX_OPTIONS]; char sbuf[80]; clear_mem(idis,sizeof(idis)); idis[vconfg.dev_type] = QCF_ASTERISK; if(!resource_exists(summa_idriver_name)) idis[1] |= QCF_DISABLED; choice = soft_qchoice(idis, "input_device" ); switch (choice) { default: return; case 0: dev_type = 0; strcpy(buf, mouse_idriver_name); break; case 1: dev_type = 1; strcpy(buf, summa_idriver_name); break; case 2: if(vconfg.dev_type == 2) strcpy(buf,vconfg.idr_name); else buf[0] = 0; if(!req_resource_name(buf,"*.idr", stack_string("idr_scroll", sbuf))) { return; } dev_type = 2; break; case 3: if (!get_serial_port()) return; goto REWRITE; } memcpy(modes,vconfg.idr_modes,sizeof(modes)); if(config_idriver(buf, modes, txtcmp(vconfg.idr_name,buf) == 0, (SHORT)vconfg.comm_port) < Success) { return; } vconfg.dev_type = dev_type; memcpy(vconfg.idr_modes,modes,sizeof(modes)); strcpy(vconfg.idr_name, buf); REWRITE: rewrite_config(); cleanup_idriver(); init_input(); }
/* this is the command execution machine */ int Parser_commands(void) { char *line, *s; int rc = 0, save_error = 0; int interactive; interactive = init_input(); while(!done) { line = readline(interactive ? parser_prompt : NULL); if (!line) break; s = skipwhitespace(line); if (*s) { add_history(s); rc = execute_line(s); } /* stop on error if not-interactive */ if (rc != 0 && !interactive) { if (save_error == 0) save_error = rc; if (!ignore_errors) done = 1; } free(line); } if (save_error) rc = save_error; return rc; }
void main(int argc, char *argv[]) { int counter, times; if(argc != 2) { printf("Get parameter first please!\n"); return ; } times = atoi(argv[1]); if(times <=0) { printf("Get param error\n"); return; } init_random(); init_input(); init_cells(); //init_kernel_platform(); //gettimeofday(&t_start, NULL); for(counter=0; counter<times; counter++) { run(); } //gettimeofday(&t_end, NULL); //close_kernel_platform(); //printf("exec digital exec success\n"); //cost_time = (t_end.tv_sec*1000000l+t_end.tv_usec) - (t_start.tv_sec*1000000l+t_start.tv_usec); //printf("run Cost time: %lds+%ldus\n", cost_time/1000000, cost_time%1000000); close_cells(); close_random(); printf("%d times exec over\n", times); }
int main(int argc, char *argv[]) { FILE *parFile = fopen(GCODE_PARAMETER_STORE, "r"); FILE *inputFile = (argc > 1 ? fopen(argv[1], "r") : stdin); char line[0xFF]; init_parameters(parFile); init_machine(NULL); init_stacks(NULL); init_tools(NULL); init_input(inputFile); //TODO: align API, add done_gcode_state(). init_gcode_state(NULL); init_cycles(NULL); //TODO: align API, make it take a pointer to init data. init_queue(); init_checker(NULL); while(machine_running() && gcode_running() && fetch_line_input(line)) { if(gcode_check(line)) update_gcode_state(line); move_machine_queue(); } /* Flush movement queue */ while(move_machine_queue()); done_checker(); done_queue(); done_cycles(); done_input(); done_tools(); done_stacks(); done_machine(); done_parameters(); return 0; }
static int ca0110_init(struct hda_codec *codec) { struct ca0110_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; int i; for (i = 0; i < spec->multiout.num_dacs; i++) init_output(codec, spec->out_pins[i], spec->multiout.dac_nids[i]); init_output(codec, cfg->hp_pins[0], spec->hp_dac); init_output(codec, cfg->dig_out_pins[0], spec->dig_out); for (i = 0; i < spec->num_inputs; i++) init_input(codec, spec->input_pins[i], spec->adcs[i]); init_input(codec, cfg->dig_in_pin, spec->dig_in); return 0; }
JNIEXPORT void JNICALL Java_net_rubygrapefruit_platform_internal_jni_WindowsConsoleFunctions_rawInputMode(JNIEnv *env, jclass target, jobject result) { init_input(env, result); DWORD mode = original_mode & ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT); if (!SetConsoleMode(console_buffer, mode)) { mark_failed_with_errno(env, "could not set console buffer mode", result); } }
void press_key( int vk_code, BOOL down ) { INPUT input; init_input( &input ); input.ki.wVk = vk_code; input.ki.wScan = MapVirtualKey( vk_code, MAPVK_VK_TO_VSC ); set_down( &input, down ); push_to_ignore_keys( vk_code, down ); press( &input ); }
wxWindow* init_input_ctl(wxWindow* parent) { return init_input( new wxCheckBox( parent, wxID_ANY, wxEmptyString ) ); }
wxWindow* init_input_ctl(wxWindow* parent) { return init_input( new wxDatePickerCtrl( parent, wxID_ANY, wxDefaultDateTime ) ); }
/* * main * DESCRIPTION: Play the adventure game. * INPUTS: none (command line arguments are ignored) * OUTPUTS: none * RETURN VALUE: 0 on success, 3 in panic situations */ int main () { game_condition_t game; /* outcome of playing */ /* Randomize for more fun (remove for deterministic layout). */ srand (time (NULL)); /* Provide some protection against fatal errors. */ clean_on_signals (); if (!build_world ()) {PANIC ("can't build world");} init_game (); /* Perform sanity checks. */ if (0 != sanity_check ()) { PANIC ("failed sanity checks"); } /* Create status message thread. */ if (0 != pthread_create (&status_thread_id, NULL, status_thread, NULL)) { PANIC ("failed to create status thread"); } push_cleanup (cancel_status_thread, NULL); { /* Start mode X. */ if (0 != set_mode_X (fill_horiz_buffer, fill_vert_buffer)) { PANIC ("cannot initialize mode X"); } push_cleanup ((cleanup_fn_t)clear_mode_X, NULL); { /* Initialize the keyboard and/or Tux controller. */ if (0 != init_input ()) { PANIC ("cannot initialize input"); } push_cleanup ((cleanup_fn_t)shutdown_input, NULL); { game = game_loop (); } pop_cleanup (1); } pop_cleanup (1); } pop_cleanup (1); /* Print a message about the outcome. */ switch (game) { case GAME_WON: printf ("You win the game! CONGRATULATIONS!\n"); break; case GAME_QUIT: printf ("Quitter!\n"); break; } /* Return success. */ return 0; }
static void features_enable_cb(struct crazychat *cc) { Debug("Changing features state\n"); cc->features_state = !cc->features_state; if (cc->features_state) { cc->input_data = init_input(cc); } else { if (cc->input_data) { gtk_widget_destroy(cc->input_data->widget); } } }
void resolve_delays_keys() { int i = 0; for ( i = 0; i < delayed_keys_count; i += 1 ) { INPUT input; init_input( &input ); key2input( &delayed_keys[ i ], &input ); press( &input ); } reset_delayed_keys(); }
int main(int argc, char **argv) { long count, total; input_t in; init_input(&in, argv[1]); switch (lex(&in, &count, &total)) { case 0: fprintf(stderr, "ok, parsed %ld HTTPs, peeked %ld chars\n", count, total); break; case 1: fprintf(stderr, "syntax error: %s\n", in.cur); break; case 2: fprintf(stderr, "fill failed\n"); break; default: fprintf(stderr, "panic!\n"); break; } free_input(&in); return 0; }
int main() { win = SDL_CreateWindow( "saddle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, // center WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); renderer = SDL_CreateRenderer(win, 0, SDL_RENDERER_ACCELERATED); init_input(); init_player(); game_loop(); SDL_DestroyWindow(win); SDL_Quit(); }
static rtems_task gui_task(rtems_task_argument argument) { init_fb_mtk(sysconfig_get_autostart_mode() == SC_AUTOSTART_FILE); sysconfig_set_mtk_language(); sysconfig_set_mtk_wallpaper(); init_input(); input_add_callback(mtk_input); init_shortcuts(); init_osc(); init_messagebox(); init_performance(); init_renderer(); init_cp(); init_keyboard(); init_ir(); init_audio(); init_midi(); init_oscsettings(); init_dmxspy(); init_dmxdesk(); init_dmx(); init_videoin(); init_rsswall(); init_patcheditor(); init_monitor(); init_firstpatch(); init_filemanager(); #ifdef WITH_PDF init_pdfreader(); #endif init_sysettings(); init_about(); init_flash(); init_shutdown(); cp_autostart(); if(sysconfig_is_rescue()) messagebox("Rescue mode", "You have booted in rescue mode.\n" "Your system will function as usual, using back-up software.\n" "From there, you can update the main software or perform\nother actions to fix the problem.\n"); /* FIXME: work around "black screen" bug in MTK */ mtk_cmd(1, "screen.refresh()"); input_eventloop(); }
wxWindow* init_input_ctl(wxWindow* parent) { return init_input( new wxTextCtrl( parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, mirror::aux::RegExValidator( valid_traits.pattern(), valid_traits.message() ) ) ); }
// ===================================================================================================================== int main(int argc, char** argv) { libdevman_server_init(); libdevman_client_init(); libdevman_client_async_init(libdevman_server_get_port()); init_screen(); init_input(); init_pty(); // register the terminal server ipc_server_register("terminal", libdevman_server_get_port()); // run the mainloop libdevman_server_run(terminal_handler); return 0; }
void init_encoder() { init_pwf_adapter(pwf_z_coeff, pwf_p_coeff); pwf_z_coeff_next[0] = pwf_p_coeff_next[0] = 1.0; pwf_z_coeff_obsolete_p = 0; init_bsf_adapter(sf_coeff); sf_coeff_next[0] = 1.0; sf_coeff_obsolete_p = 0; init_gain_adapter(gp_coeff); gp_coeff_next[0] = 1.0; gp_coeff_obsolete_p = 0; init_input(); vector_end=thequeue; #ifdef __ADSP21000__ mode2.b.cafrz = 0; interrupt(SIG_USR0, encode_vector); #endif }
static void cc_init(struct crazychat *cc) { /* initialize main crazychat thread */ assert(cc); memset(cc, 0, sizeof(*cc)); /* initialize network configuration */ cc->tcp_port = DEFAULT_CC_PORT; cc->udp_port = DEFAULT_CC_PORT; /* disable input subsystem */ //cc->features_state = 0; /* initialize input subsystem */ cc->features_state = 1; cc->input_data = init_input(cc); }
void init(int argc, char *argv[]) { Parser::check_if_user_needs_help(argc, argv); if (!sdl_init(SCREEN_WIDTH, SCREEN_HEIGHT, Parser::get_display_mode_from_command_line(argc, argv), main_window, main_context)) { Error::throw_error(Error::display_init_fail); } init_input(); print_welcome(); renderer.init(); renderer.init_uniforms(camera); Loader::load_scene(Parser::get_scene_file_from_command_line(argc, argv), &camera); renderer.init_tweak_bar(&camera); Light::init(); }
int main(int argc, char *argv[]) { program_name = argv[0] ? argv[0] : "nesalizer"; #ifndef RUN_TESTS if (argc != 2) { fprintf(stderr, "usage: %s <rom file>\n", program_name); exit(EXIT_FAILURE); } #else (void)argc; // Suppress warning #endif install_fatal_signal_handlers(); // One-time initialization of various components init_apu(); init_input(); init_mappers(); #ifndef RUN_TESTS load_rom(argv[1], true); #endif // Create a separate emulation thread and use this thread as the rendering // thread init_sdl(); SDL_Thread *emu_thread; fail_if(!(emu_thread = SDL_CreateThread(emulation_thread, "emulation", 0)), "failed to create emulation thread: %s", SDL_GetError()); sdl_thread(); SDL_WaitThread(emu_thread, 0); deinit_sdl(); #ifndef RUN_TESTS unload_rom(); #endif puts("Shut down cleanly"); }
//initialize the video, audio, and input systems on the platform // returns int - negative on failure, otherwise success int platform_init(void) { int result; if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) == 0) { result = init_video(); if(result < 0) { return result; } result = init_audio(); if(result < 0) { return result; } result = init_input(); if(result < 0) { return result; } } return 0; }
int main () { fd=open("/dev/ttyS0", O_RDWR | O_NOCTTY); int ldsic_num = N_MOUSE; ioctl(fd, TIOCSETD, &ldsic_num); ioctl(fd, TUX_INIT); cmd_t cmd; dir_t dir = DIR_UP; static const char* const cmd_name[NUM_TURNS] = { "none", "right", "back", "left" }; static const char* const dir_names[4] = { "up", "right", "down", "left" }; /* Grant ourselves permission to use ports 0-1023 */ if (ioperm (0, 1024, 1) == -1) { perror ("ioperm"); return 3; } init_input (); while (1) { //ioctl(fd, TUX_SET_LED,0x0F0FFFFF); printf ("CURRENT DIRECTION IS %s\n", dir_names[dir]); while ((cmd = get_command (dir)) == TURN_NONE); if (cmd == CMD_QUIT) break; display_time_on_tux (83); printf ("%s\n", cmd_name[cmd]); dir = (dir + cmd) % 4; } shutdown_input (); return 0; }
static void init_ui_elements(unsigned int max_x, unsigned int max_y) { ssize_t title_len; title_len = asprintf(&title, "/* %s-%s */", PKGNAME, VERSION); assert( title_len > 0 ); pw_input = init_input((unsigned int)(max_x / 2)-PASSWD_XRELPOS, (unsigned int)(max_y / 2)-PASSWD_YRELPOS, PASSWD_WIDTH, "PASSWORD: "******"[%c]"); higher = init_statusbar(0, max_x, A_BOLD | COLOR_PAIR(3), higher_statusbar_update); lower = init_statusbar(max_y - 1, max_x, COLOR_PAIR(3), lower_statusbar_update); netinfo = init_statusbar(2, max_x, COLOR_PAIR(2), netinfo_statusbar_update); uninfo = init_statusbar(1, max_x, COLOR_PAIR(2), uninfo_statusbar_update); busywnd = init_txtwindow_centered(INFOWND_WIDTH, INFOWND_HEIGHT, busywnd_update); errwnd = init_txtwindow_centered(INFOWND_WIDTH, INFOWND_HEIGHT, NULL); register_input(NULL, pw_input, passwd_input_cb); register_statusbar(higher); register_statusbar(lower); register_statusbar(netinfo); register_statusbar(uninfo); register_anic_default(heartbeat); register_txtwindow(busywnd); register_txtwindow(errwnd); activate_input(pw_input); set_statusbar_text(higher, title, title_len); }
int main (int argc, char **argv){ int ret = 0, got_frame; AVFormatContext *ofmt_ctx = NULL; AVOutputFormat *ofmt = NULL; uint8_t *sample_buf; if (argc != 4 && argc != 5) { fprintf(stderr, "input 1.source file:%s\n" "2.output_video\n" "3.output_audio\n" "4.mux video file(Optional)\n" "\n", argv[0]); exit(1); } src_filename = argv[1]; video_dst_filename = argv[2]; audio_dst_filename = argv[3]; //optional mux to any type video if(argc == 5){ out_filename = argv[4]; } /* register all formats and codecs */ av_register_all(); //for network stream avformat_network_init(); ret = init_input(); if(ret){ goto end; } ret = init_video_out_context(); if(ret){ goto end; } ret = init_audio_out_context(sample_buf); if(ret){ goto end; }else{ int aud_buffer_size; //alloc frame and packet AudFrame = av_frame_alloc(); AudFrame->nb_samples = AudCodecCtx->frame_size; AudFrame->format = AudCodecCtx->sample_fmt; AudFrame->channel_layout = AudCodecCtx->channel_layout; aud_buffer_size = av_samples_get_buffer_size(NULL, AudCodecCtx->channels,AudCodecCtx->frame_size,AudCodecCtx->sample_fmt, 1); sample_buf = (uint8_t *)av_malloc(aud_buffer_size); avcodec_fill_audio_frame(AudFrame, AudCodecCtx->channels, AudCodecCtx->sample_fmt,(const uint8_t*)sample_buf, aud_buffer_size, 1); av_new_packet(&AudPkt,aud_buffer_size); } if(argc == 5){ //alloc memory avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename); if (!ofmt_ctx) { printf( "Could not create output context\n"); ret = AVERROR_UNKNOWN; return 1; } ofmt = ofmt_ctx->oformat; ret = init_output(ofmt_ctx); if(ret){ printf("Init output ERROR\n"); goto end; } } if (!(ofmt->flags & AVFMT_NOFILE)) { ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE); if (ret < 0) { printf( "Could not open output file '%s'", out_filename); goto end; } } ret = avformat_write_header(ofmt_ctx, NULL); if (ret < 0) { printf( "Error occurred when opening output file\n"); goto end; } //this will fill up by decoder(|read frame|->packet->|decoder|->frame) frame = av_frame_alloc(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); ret = AVERROR(ENOMEM); goto end; } if (video_stream) printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename); if (audio_stream) printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename); //Write video Header avformat_write_header(pFormatCtx,NULL); //Write audio Header avformat_write_header(AudFormatCtx,NULL); //alloc packet to get copy from pkt av_new_packet(&epkt,picture_size); /*setup the convert parameter *due to input sample format AV_SAMPLE_FMT_FLTP *can't be converted to AV_SAMPLE_FMT_S16 *which only accepted by the aac encoder */ swr = swr_alloc(); av_opt_set_int(swr, "in_channel_layout", audio_dec_ctx->channel_layout, 0); av_opt_set_int(swr, "out_channel_layout", AudCodecCtx->channel_layout, 0); av_opt_set_int(swr, "in_sample_rate", audio_dec_ctx->sample_rate, 0); av_opt_set_int(swr, "out_sample_rate", AudCodecCtx->sample_rate, 0); av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); swr_init(swr); /*start read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) { //do demux & decode -> encode -> output h264 & aac file ret = decode_packet(); if (ret < 0) break; if(argc == 5){ remux_packet(ofmt_ctx,&pkt); } av_free_packet(&pkt); } /* flush cached frames */ pkt.data = NULL; pkt.size = 0; //Flush Encoder int retfe = flush_encoder(pFormatCtx,0); if (retfe < 0) { printf("Flushing encoder failed\n"); return -1; } //Flush Encoder ret = flush_encoder(pFormatCtx,0); if (ret < 0) { printf("Flushing encoder failed\n"); return -1; } //Write video trailer av_write_trailer(pFormatCtx); //Write audio Trailer av_write_trailer(AudFormatCtx); //Write remux Trailer if(argc == 5){ av_write_trailer(ofmt_ctx); } printf("Output succeeded!!!!\n"); end: //free remux if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE)) avio_close(ofmt_ctx->pb); avformat_free_context(ofmt_ctx); //free audio if (audio_st){ avcodec_close(audio_st->codec); av_free(AudFrame); av_free(sample_buf); } avio_close(AudFormatCtx->pb); avformat_free_context(AudFormatCtx); //free video if (video_st){ avcodec_close(video_st->codec); av_free(pFrame); av_free(picture_buf); } avio_close(pFormatCtx->pb); avformat_free_context(pFormatCtx); //free decode avcodec_close(video_dec_ctx); avcodec_close(audio_dec_ctx); avformat_close_input(&fmt_ctx); if (video_dst_file) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); av_frame_free(&frame); return ret < 0; }