void print_display(struct s_grid *grid, char *display, coord *select) { coord moove; int pc = 0; int i; init_cursor(select); system("clear"); display = write_game_data(grid, display, &pc); display = border_line(grid, display, &pc); for (i = 0; i < grid->width; ++i) { display = game_line(grid, display, &pc, i, select); if (i + 1 < grid->width) display = center_line(grid, display, &pc); } display = border_line(grid, display, &pc); write(1, display, pc); moove = coordonne(0, grid->width); init_cursor(&moove); place_cursor(select); }
/** Init WMFS */ void init(void) { /* Init lists heads */ SLIST_INIT(&bwhead); SLIST_INIT(&clients); SLIST_INIT(&trayicons); /* First init */ ewmh_init_hints(); init_conf(); init_gc(); init_font(); init_cursor(); init_key(); init_root(); screen_init_geo(); event_make_array(); infobar_init(); systray_acquire(); ewmh_update_current_tag_prop(); grabkeys(); return; }
void ft_print_list(t_list *list, int tr) { int i; t_cursor *cursor; cursor = init_cursor(0, 0); list->curr_elem = list->first_elem; i = 0; if (is_win_too_small(list) != 0) ft_putstr_fd("window too small", list->fd); else { while (i++ < list->nb_elem) { if (cursor->y == tr) { cursor->y = 0; cursor->x += list->longest + 4; } list->curr_elem->posx = cursor->x; list->curr_elem->posy = cursor->y; move_cursor(cursor); set_effect(list->curr_elem, list->fd); list->curr_elem = list->curr_elem->next; cursor->y++; } } }
int main(int argc, char **argv) { (void)argc; (void)argv; /* open connection with the server */ nil_.con = xcb_connect(0, 0); if (xcb_connection_has_error(nil_.con)) { NIL_ERR("xcb_connect %p", (void *)nil_.con); exit(1); } /* 1st stage */ if ((init_screen() != 0) || (init_key() != 0) || (init_mouse() != 0)) { xcb_disconnect(nil_.con); exit(1); } /* 2nd stage */ if ((init_cursor() != 0) || (init_color() != 0) != (init_font() != 0) || (init_bar() != 0) || (init_wm() != 0)) { cleanup(); exit(1); } xcb_flush(nil_.con); recv_events(); cleanup(); return 0; }
void draw_Cursor_at(f32 x, f32 y) { init_cursor(); if(cursor_colorVtxs == NULL) return; f32 widthScaleFactor = 1.0f / (f32)1280; f32 heightScaleFactor = 1.0f / (f32)720; int width = 20; glm::vec3 positionOffsets = glm::vec3(0.0f); positionOffsets[0] = (x-((1280)/2)+(width/2)) * widthScaleFactor * 2.0f; positionOffsets[1] = -(y-((720)/2)+(width/2)) * heightScaleFactor * 2.0f; glm::vec3 scale(width*widthScaleFactor,width*heightScaleFactor,1.0f); ColorShader::instance()->setShaders(); ColorShader::instance()->setAttributeBuffer(cursor_colorVtxs, NULL, 4); ColorShader::instance()->setAngle(0); ColorShader::instance()->setOffset(positionOffsets); ColorShader::instance()->setScale(scale); ColorShader::instance()->setColorIntensity(glm::vec4(1.0f)); ColorShader::instance()->draw(GX2_PRIMITIVE_QUADS, 4); }
void PlaybackEngine::init_tracking() { if(!command->single_frame()) tracking_active = 1; else tracking_active = 0; tracking_position = command->playbackstart; tracking_done->lock("PlaybackEngine::init_tracking"); init_cursor(); init_meters(); }
void UI_INPUTBOX::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _text_len, char *_text, int _flags, int pixel_lim, color *clr) { int tw, th; Assert(_text_len >= 0); Assert((int) strlen(_text) <= _text_len); gr_set_font(wnd->f_id); gr_get_string_size( &tw, &th, "*" ); // check to see if the user passed in a text color otherwise use the default green color if (clr){ text_color = clr; } else { text_color = &CBRIGHT; } base_create( wnd, UI_KIND_INPUTBOX, _x, _y, _w, th+4 ); text = (char *) vm_malloc( _text_len + 1); // input boxes no longer use background _flags |= UI_INPUTBOX_FLAG_NO_BACK; // if its in "password" mode, allocate a second string // and copy it if (_flags & UI_INPUTBOX_FLAG_PASSWD) { passwd_text = (char *) vm_malloc(_text_len + 1); memset(passwd_text, INPUTBOX_PASSWD_CHAR, strlen(_text)); passwd_text[strlen(_text)] = 0; } else { passwd_text = NULL; } init_cursor(); if ( _text_len > 0 ) { strncpy( text, _text, _text_len ); } text[_text_len] = 0; position = strlen(_text); oldposition = position; length = _text_len; pressed_down = 0; // first_time = 1; changed_flag = 0; flags = _flags; pixel_limit = pixel_lim; locked = 0; valid_chars = NULL; invalid_chars = NULL; }
/** Init MWM */ void init(void) { /* First init */ ewmh_init_hints(); init_conf(); init_gc(); init_font(); init_cursor(); init_key(); init_root(); screen_init_geo(); infobar_init(); systray_acquire(); init_status(); ewmh_update_current_tag_prop(); grabkeys(); return; }
int main( int argc, char *argv[] ){ int x,y; int quit = 0; init_cursor(); bClick = 0; if( SDL_Init( SDL_INIT_VIDEO ) < 0){ exit( -1 ); } if( !SDL_SetVideoMode( 320, 200, 0, 0 ) ){ SDL_Quit(); exit( -1 ); } time(&last_mouse); SDL_EnableUNICODE( 1 ); set_cursor(x, y); while( !quit ){ check_time(); while( SDL_PollEvent( &event ) ){ switch( event.type ){ case SDL_KEYDOWN: PrintKeyInfo( &event.key ); break; case SDL_QUIT: quit = 1; break; default: checkHold(); break; } } sleep(.05); } SDL_Quit(); exit( 0 ); }
Game::Game(Configuration *cfg, Screen *scr, GUI *g, nuvie_game_t type, SoundManager *sm) { game = this; config = cfg; gui = g; screen = scr; game_type = type; sound_manager = sm; script = NULL; background = NULL; cursor = NULL; dither = NULL; tile_manager = NULL; obj_manager = NULL; palette = NULL; font_manager = NULL; scroll = NULL; game_map = NULL; map_window = NULL; actor_manager = NULL; player = NULL; event = NULL; converse = NULL; conv_gump = NULL; command_bar = NULL; new_command_bar = NULL; clock = NULL; party = NULL; portrait = NULL; view_manager = NULL; save_manager = NULL; egg_manager = NULL; usecode = NULL; effect_manager = NULL; weather = NULL; magic = NULL; book = NULL; keybinder = NULL; converse_gump_type = CONVERSE_GUMP_DEFAULT; pause_flags = PAUSE_UNPAUSED; pause_user_count = 0; ignore_event_delay = 0; game_play = true; unlimited_casting = false; god_mode_enabled = false; armageddon = false; ethereal = false; free_balloon_movement = false; config->value("config/cheats/enabled", cheats_enabled, false); config->value("config/cheats/enable_hackmove", is_using_hackmove, false); config->value("config/input/enabled_dragging", dragging_enabled, true); config->value("config/general/use_text_gumps", using_text_gumps, false); config->value(config_get_game_key(config) + "/roof_mode", roof_mode, false); config->value("config/input/doubleclick_opens_containers", open_containers, false); int value; uint16 screen_width = gui->get_width(); uint16 screen_height = gui->get_height(); init_game_style(); if(is_orig_style()) { game_width = 320; game_height = 200; } else { config->value("config/video/game_width", value, 320); game_width = (value < screen_width) ? value : screen_width; config->value("config/video/game_height", value, 200); game_height = (value < screen_height) ? value : screen_height; if(game_width < 320) game_width = 320; if(game_height < 200) game_height = 200; if(is_original_plus_full_map() && screen_height <= 200) // not tall enough to show extra map space game_style = NUVIE_STYLE_ORIG_PLUS_CUTOFF_MAP; } string game_position; config->value("config/video/game_position", game_position, "center"); if(game_position == "upper_left") game_x_offset = game_y_offset = 0; else // center { game_x_offset = (screen_width - game_width)/2; game_y_offset = (screen_height - game_height)/2; } effect_manager = new EffectManager; init_cursor(); keybinder = new KeyBinder(config); }
void init_exit_menu(exit_menu_t *state, gl_t *gl_state) { // Initialize program launcher images OpenGL state int image_width = gl_state->screen_width/3.84; int image_height = gl_state->screen_height/3.846; float half_height = (image_height/(float)gl_state->screen_height); float half_width = (image_width/(float)gl_state->screen_width); float dx = (2.0f-(3.0*2.0f*half_width))/4.0f; float lower_left_y = -half_height; float lower_left_x = -1.0f + dx; state->mandelbrot_state = malloc(sizeof(image_t)); #ifdef RASPI init_image(state->mandelbrot_state, gl_state, "SPH/images/mandelbrot.png", "SPH/images/mandelbrot-selected.png", lower_left_x, lower_left_y, image_width, image_height); #else init_image(state->mandelbrot_state, gl_state, "images/mandelbrot.png", "images/mandelbrot-selected.png", lower_left_x, lower_left_y, image_width, image_height); #endif lower_left_x += 2.0f*half_width + dx; state->terminal_state = malloc(sizeof(image_t)); #ifdef RASPI init_image(state->terminal_state, gl_state, "SPH/images/terminal.png", "SPH/images/terminal-selected.png", lower_left_x, lower_left_y, image_width, image_height); #else init_image(state->terminal_state, gl_state, "images/terminal.png", "images/terminal-selected.png", lower_left_x, lower_left_y, image_width, image_height); #endif lower_left_x += 2.0f*half_width + dx; state->sph_state = malloc(sizeof(image_t)); #ifdef RASPI init_image(state->sph_state, gl_state, "SPH/images/sph.png", "SPH/images/sph-selected.png", lower_left_x, lower_left_y, image_width, image_height); #else init_image(state->sph_state, gl_state, "images/sph.png", "images/sph-selected.png", lower_left_x, lower_left_y, image_width, image_height); #endif // Initialize cursor state->cursor_state = malloc(sizeof(cursor_t)); int cursor_width = gl_state->screen_width/16.0; int cursor_height = gl_state->screen_height/7.5; #ifdef RASPI init_cursor(state->cursor_state, gl_state, "SPH/images/cursor.png", cursor_width, cursor_height); #else init_cursor(state->cursor_state, gl_state, "images/cursor.png", cursor_width, cursor_height); #endif // Initialize cursor state->rectangle_state = malloc(sizeof(rectangle_t)); init_rectangle(state->rectangle_state); }
void main() { UBYTE key1, key2, i, j, pos_x, pos_y, ch_pos; UBYTE non_flick = OFF; UWORD on_time, off_time; char str[MAX_DTMF]; char str_ms[10]; /* default dialling time setting */ on_time = DTMF_ON; off_time = DTMF_OFF; disable_interrupts(); SPRITES_8x8; /* sprites are 8x8 */ init_dial(); init_bkg(); init_key(); init_cursor(); disp(TITLE); SHOW_BKG; SHOW_SPRITES; DISPLAY_ON; enable_interrupts(); i = j = 0; ch_pos = 0; while(1) { wait_vbl_done(); key1 = joypad(); if(key1 != key2){ pos_x = i * KEY_STEP + START_CURSOR_X; pos_y = j * KEY_STEP + START_CURSOR_Y; move_cursor(pos_x, pos_y); } if(key2 & J_A){ if(key1 & J_A){ /* value set for each sound reg only numeric key pad*/ if(i <= 3 && j <= 3){ /* frequncy register set up for DTMF */ NR13_REG = row[i]; NR23_REG = col[j]; NR24_REG = 0x87U; /* sound output on */ NR51_REG = 0x33U; } /* '?' button */ /* appear the title during press A button */ if(i == 5 && j == 0 && !non_flick){ disp(TITLE); non_flick = ON; } /* incremental button */ /* decremental button */ /* appear the delay during press A button */ if(i == 5 && (j == 1 || j == 2) && !non_flick){ sprintf(str_ms, "%lu MS", on_time); disp(str_ms); non_flick = ON; } } else{ /* sound output off */ NR51_REG = 0x00U; break_button(i, j); /* '?' button */ /* incremental button */ /* decremental button */ /* return to normal display at release the A button */ if(i == 5 && (j == 0 || j == 1 || j == 2)){ non_flick = OFF; if(ch_pos == 0) clr_disp(); else disp(str); } } } else{ if(key1 & J_A){ /* button display handle */ press_button(i, j); /* numeric key pad handling */ if(i <= 3 && j <= 3){ /* string length check */ if(ch_pos < MAX_DTMF-1){ str[ch_pos] = pad[j][i]; ch_pos++; str[ch_pos] = 0x00; disp(str); } } /* ',' button */ if(i == 4 && j == 2){ /* string length check */ if(ch_pos < MAX_DTMF-1){ str[ch_pos] = pad[j][i]; ch_pos++; str[ch_pos] = 0x00; disp(str); } } /* all clear button */ if(i == 4 && j == 0){ ch_pos = 0x00; strcpy(str,""); clr_disp(); } /* delete button */ if(i == 4 && j == 1){ if(ch_pos > 0){ ch_pos--; str[ch_pos] = 0x00; if(ch_pos == 0) clr_disp(); else disp(str); } } /* incremental button */ if(i == 5 && j == 1){ if(on_time >= DTMF_ON / 2){ on_time = on_time - 10; off_time = off_time - 10; } } /* decremental button */ if(i == 5 && j == 2){ if(on_time <= DTMF_ON * 2){ on_time = on_time + 10; off_time = off_time + 10; } } /* dialing button */ if((i==4 || i==5) && j==3){ dialtone(on_time, off_time, str); } } } if(!(key1 & J_A)){ if((key1 & J_UP) && !(key2 & J_UP) && j > 0) j--; else if((key1 & J_DOWN) && !(key2 & J_DOWN) && j < 3) j++; if((key1 & J_LEFT) && !(key2 & J_LEFT) && i > 0) i--; else if((key1 & J_RIGHT) && !(key2 & J_RIGHT) && i < 5) i++; } key2 = key1; } }
int main(int argc, char *argv[]) { (void)argc; char *ptr; for (argv++;*argv;argv++) { if ('-' ==(**argv)) { switch (*(++(*argv))) { case 'v': diag_display_version(); exit(CORRECT); case 'r': if((ptr = strstr(*++argv, "0x")) != NULL){ read_start_address = strtoul(ptr,&ptr,16); //printf("start_address = 0x%08lX\n",(long unsigned int)read_start_address); if((ptr = strstr(*++argv, "0x")) != NULL){ read_end_address = strtoul(ptr,&ptr,16); //printf("end_address = 0x%08lX\n",(long unsigned int)read_end_address); } else{ fprintf(stderr, "end address prefix '0x' requires\n"); exit(ERROR); } }else{ fprintf(stderr, "start address prefix '0x' requires\n"); exit(ERROR); } long start_address_value = (long)read_start_address; long end_address_value = (long)read_end_address; if((end_address_value - start_address_value) < 0){ fprintf(stderr, "start address is bigger than end address\n"); exit(ERROR); } statMode |= READ; break; case 'w': if((ptr = strstr(*++argv, "0x")) != NULL){ write_target_address = strtoul(ptr,&ptr,16); //printf("target_address = 0x%08lX\n",(long unsigned int)write_target_address); if((ptr = strstr(*++argv, "0x")) != NULL){ write_value = strtoul(ptr,&ptr,16); //printf("write_value = 0x%08lX\n",(long unsigned int)write_value); } else{ fprintf(stderr, "write_value prefix '0x' requires\n"); exit(ERROR); } }else{ fprintf(stderr, "target_address prefix '0x' requires\n"); exit(ERROR); } statMode |= WRITE; break; /*case 'c': num_updates = atol(*++argv); printf("num_updates = %lu\n",num_updates); break;*/ default: usage(); } } } switch(statMode){ case(READ): //read_command_test(read_start_address, read_end_address); read_command(read_start_address, read_end_address); init_cursor(); break; case(WRITE): //write_command(write_target_address, write_value, statMode); write_command(write_target_address, write_value); break; default: usage(); break; } return 0; }
void PlaybackEngine::run() { start_lock->unlock(); do { // Wait for current command to finish que->output_lock->lock("PlaybackEngine::run"); wait_render_engine(); // Read the new command que->input_lock->lock("PlaybackEngine::run"); if(done) return; command->copy_from(&que->command); que->command.reset(); que->input_lock->unlock(); //printf("PlaybackEngine::run 1 %d\n", command->command); switch(command->command) { // Parameter change only case COMMAND_NONE: // command->command = last_command; perform_change(); break; case PAUSE: init_cursor(); pause_lock->lock("PlaybackEngine::run"); stop_cursor(); break; case STOP: // No changing break; case CURRENT_FRAME: last_command = command->command; perform_change(); arm_render_engine(); // Dispatch the command start_render_engine(); break; default: last_command = command->command; is_playing_back = 1; if(command->command == SINGLE_FRAME_FWD || command->command == SINGLE_FRAME_REWIND) { command->playbackstart = get_tracking_position(); } perform_change(); arm_render_engine(); // Start tracking after arming so the tracking position doesn't change. // The tracking for a single frame command occurs during PAUSE init_tracking(); // Dispatch the command start_render_engine(); break; } //printf("PlaybackEngine::run 100\n"); }while(!done); }