void ScreenRecoveryUI::Init() {
    gr_init();

    gr_font_size(&char_width, &char_height);
    text_rows_ = gr_fb_height() / char_height;
    text_cols_ = gr_fb_width() / char_width;

    text_ = Alloc2d(text_rows_, text_cols_ + 1);
    file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
    menu_ = Alloc2d(text_rows_, text_cols_ + 1);

    text_col_ = text_row_ = 0;
    text_top_ = 1;

    backgroundIcon[NONE] = nullptr;
    LoadBitmapArray("icon_installing", &installing_frames, &installation);
    backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : nullptr;
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);
    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);

    pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);

    RecoveryUI::Init();
}
Esempio n. 2
0
int main()
{
    // Create the main window

	// Start the game loop
    arc_add_dat("th105a.dat");
    arc_add_dat("th105b.dat");
    arc_add_dat("th105c.dat");
    arc_add_dat("th123a.dat");
    arc_add_dat("th123b.dat");
    arc_add_dat("th123c.dat");

    gr_init(640,480,"OpenSoku");
    sfx_init();
    scene_load_sounds();



    char_c *marisa = new char_marisa(inp_createinput(INP_TYPE_KB));

    char_c *alice = new char_alice(inp_createinput(INP_TYPE_NONE),1);


//    uint32_t i = 0;
//

    inp_kb kb;

    marisa->set_seq(0);
    alice->set_seq(0);
    background  *bkg = new background_11;



    c_scene *scn = new c_scene(bkg,marisa,alice);


    while(!kb.rawPressed(kC_Escape))
    {
        kb.update();

        gr_clear();

        scn->players_input();

        //scn.players_collisions();
        scn->update();

        scn->draw_scene();

        scn->update_char_anims();

        gr_flip();

    }



    return EXIT_SUCCESS;
}
Esempio n. 3
0
void ui_init(void)
{
    char resPath[256];

    gr_init();
    ev_init();

    text_col = text_row = 0;
    // text_rows = CUST_LCD_AVAIL_HEIGHT / CHAR_HEIGHT;
    // text_rows = CUST_LCD_AVAIL_HEIGHT % CHAR_HEIGHT ? text_rows - 1 : text_rows;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    text_rows = gr_fb_height()  % CHAR_HEIGHT ? text_rows - 1 : text_rows;


    if (text_rows > MAX_ROWS) text_rows = MAX_ROWS;
    text_top = 1;

    // text_cols = CUST_LCD_AVAIL_WIDTH / CHAR_WIDTH;
    text_cols = gr_fb_width() / CHAR_WIDTH;

    if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1;

    LOGD(TAG "CUST_LCD_AVAIL_HEIGHT=%d, CUST_LCD_AVAIL_WIDTH=%d\n",
        gr_fb_height(), gr_fb_width());
    LOGD(TAG "CUST_KEY_CONFIRM=%d, CUST_KEY_BACK=%d\n", 
        CUST_KEY_CONFIRM, CUST_KEY_BACK);
    LOGD(TAG "TEXT_ROWS=%d, TEXT_COLS=%d\n", text_rows, text_cols);

    pthread_t t;
    pthread_create(&t, NULL, input_thread, NULL);
}
Esempio n. 4
0
void ui_init(void)
{
    gr_init();
    ev_init();

    text_col = text_row = 0;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    if (text_rows > MAX_ROWS) text_rows = MAX_ROWS;
    text_top = 1;

    text_cols = gr_fb_width() / CHAR_WIDTH;
    if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1;

    int i;
    for (i = 0; BITMAPS[i].name != NULL; ++i) {
        int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface);
        if (result < 0) {
            if (result == -2) {
                LOGI("Bitmap %s missing header\n", BITMAPS[i].name);
            } else {
                LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result);
            }
            *BITMAPS[i].surface = NULL;
        }
    }

    pthread_t t;
    pthread_create(&t, NULL, progress_thread, NULL);
    pthread_create(&t, NULL, input_thread, NULL);
}
void ScreenRecoveryUI::Init()
{
    gr_init();

    gr_set_font("log");
    gr_font_size(&log_char_width, &log_char_height);
    gr_set_font("menu");
    gr_font_size(&char_width, &char_height);

    log_text_rows = gr_fb_height() / log_char_height;
    log_text_cols = gr_fb_width() / log_char_width;

    text_col = text_row = 0;
    text_rows = gr_fb_height() / char_height;
    if (max_menu_rows > kMaxMenuRows)
        max_menu_rows = kMaxMenuRows;
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;

    text_cols = gr_fb_width() / char_width;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    ScreenRecoveryUI::InitIcons();

    text_first_row = (header_height / char_height) + 1;
    menu_item_start = text_first_row * char_height;
    max_menu_rows = (text_rows - text_first_row) / 3;

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
Esempio n. 6
0
void ScreenRecoveryUI::Init()
{
    gr_init();

    text_col = text_row = 0;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;

    text_cols = gr_fb_width() / CHAR_WIDTH;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]);
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);
    
#ifndef VENDOR_EDIT
//[email protected], 2013/03/21, Remove for no need text
/*
    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);
*/
#endif /* VENDOR_EDIT */

    int i;

    progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames *
                                                    sizeof(gr_surface));
    for (i = 0; i < indeterminate_frames; ++i) {
        char filename[40];
        // "indeterminate01.png", "indeterminate02.png", ...
        sprintf(filename, "indeterminate%02d", i+1);
        LoadBitmap(filename, progressBarIndeterminate+i);
    }

    if (installing_frames > 0) {
        installationOverlay = (gr_surface*)malloc(installing_frames *
                                                   sizeof(gr_surface));
        for (i = 0; i < installing_frames; ++i) {
            char filename[40];
            // "icon_installing_overlay01.png",
            // "icon_installing_overlay02.png", ...
            sprintf(filename, "icon_installing_overlay%02d", i+1);
            LoadBitmap(filename, installationOverlay+i);
        }
    } else {
        installationOverlay = NULL;
    }

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
void ScreenRecoveryUI::Init()
{
    gr_init();

    gr_font_size(&char_width, &char_height);

    text_col = text_row = 0;
    text_rows = gr_fb_height() / char_height;
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;

    text_cols = gr_fb_width() / char_width;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]);
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);

    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);

    int i;

    progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames *
                                                    sizeof(gr_surface));
    for (i = 0; i < indeterminate_frames; ++i) {
        char filename[40];
        // "indeterminate01.png", "indeterminate02.png", ...
        sprintf(filename, "indeterminate%02d", i+1);
        LoadBitmap(filename, progressBarIndeterminate+i);
    }

    if (installing_frames > 0) {
        installationOverlay = (gr_surface*)malloc(installing_frames *
                                                   sizeof(gr_surface));
        for (i = 0; i < installing_frames; ++i) {
            char filename[40];
            // "icon_installing_overlay01.png",
            // "icon_installing_overlay02.png", ...
            sprintf(filename, "icon_installing_overlay%02d", i+1);
            LoadBitmap(filename, installationOverlay+i);
        }
    } else {
        installationOverlay = NULL;
    }

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
Esempio n. 8
0
/*
 * Get initial state of terminal, set ospeed (for termcap routines)
 * and switch off tab expansion if necessary.
 * Called by startup() in termcap.c and after returning from ! or ^Z
 */
void
gettty(){
	erase_char = '\b';
	kill_char = 21;		/* cntl-U */
	iflags.cbreak = TRUE;
	disable_ctrlP();	/* turn off ^P processing */
#if defined(MSDOS) && defined(NO_TERMS)
	gr_init();
#endif
}
Esempio n. 9
0
/*********************************************************************
 *	アナログ入力グラフ表示.(仮)
 *********************************************************************
 */
void cmdAinGraph(char *buf)
{
	gr_init(AIN_SCREEN_W,AIN_SCREEN_H,32,0);
	draw_AnalogFrame();
	do {
		draw_AnalogInput();
		Sleep(32);
	}while(gr_break()==0);
	gr_close();
}
Esempio n. 10
0
/*********************************************************************
 *	抵抗値 グラフ表示.(仮)
 *********************************************************************
 */
void cmdRegGraph(char *buf)
{
	gr_init(AIN_SCREEN_W,AIN_SCREEN_H,32,0);
	draw_RegistanceFrame();
	do {
		draw_Registance();
		Sleep(32);
	}while(gr_break()==0);
	gr_close();
}
Esempio n. 11
0
void ScreenRecoveryUI::Init()
{
    gr_init();

    text_col = text_row = 0;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;

    text_cols = gr_fb_width() / CHAR_WIDTH;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    LoadBitmap("icon_installing", &backgroundIcon[INSTALLING]);
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);

    int i;

    progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames *
                                                    sizeof(gr_surface));
    for (i = 0; i < indeterminate_frames; ++i) {
        char filename[40];
        // "indeterminate01.png", "indeterminate02.png", ...
        sprintf(filename, "indeterminate%02d", i+1);
        LoadBitmap(filename, progressBarIndeterminate+i);
    }

    if (installing_frames > 0) {
        installationOverlay = (gr_surface*)malloc(installing_frames *
                                                   sizeof(gr_surface));
        for (i = 0; i < installing_frames; ++i) {
            char filename[40];
            // "icon_installing_overlay01.png",
            // "icon_installing_overlay02.png", ...
            sprintf(filename, "icon_installing_overlay%02d", i+1);
            LoadBitmap(filename, installationOverlay+i);
        }

        // Adjust the offset to account for the positioning of the
        // base image on the screen.
        if (backgroundIcon[INSTALLING] != NULL) {
            gr_surface bg = backgroundIcon[INSTALLING];
            install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2;
            install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2;
        }
    } else {
        installationOverlay = NULL;
    }

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
Esempio n. 12
0
File: gr.c Progetto: adsgray/CServer
/* 
   same as gr_init, but puts the returned gr into
   gr_List. All gr's in this list are destroyed
   when gr_finish() is called.
*/
gr_t gr_get(int max) 
{
	gr_t gr; 

	gr = gr_init(max);
	/* LOCK */
	gr->next = gr_List;
	gr_List = gr;
	/* UNLOCK */
	return gr;
}
Esempio n. 13
0
void ScreenRecoveryUI::Init()
{
    gr_init();

    gr_set_font("log");
    gr_font_size(&log_char_width, &log_char_height);
    gr_set_font("menu");
    gr_font_size(&char_width, &char_height);

    log_text_rows = gr_fb_height() / log_char_height;
    log_text_cols = gr_fb_width() / log_char_width;

    text_col = text_row = 0;
    text_rows = gr_fb_height() / char_height;
    if (max_menu_rows > kMaxMenuRows)
        max_menu_rows = kMaxMenuRows;
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;

    text_cols = gr_fb_width() / char_width;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    LoadBitmap("icon_header", &headerIcon);
    header_height = gr_get_height(headerIcon);
    header_width = gr_get_width(headerIcon);

    text_first_row = (header_height / char_height) + 1;
    menu_item_start = text_first_row * char_height;
    max_menu_rows = (text_rows - text_first_row) / 3;

    backgroundIcon[NONE] = NULL;
    LoadBitmapArray("icon_installing", &installing_frames, &installation);
    backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : NULL;
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_info", &backgroundIcon[INFO]);
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = NULL;
    LoadBitmap("icon_headless", &backgroundIcon[HEADLESS]);

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);
    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
Esempio n. 14
0
File: ipwd.c Progetto: Raffprta/core
int i_getgrnam(const char *name, struct group *grp_r)
{
	struct group *result;

	errno = 0;
	do {
		gr_init();
		errno = getgrnam_r(name, grp_r, grbuf, grbuf_size, &result);
	} while (errno == ERANGE);
	if (result != NULL)
		return 1;
	return errno == 0 ? 0 : -1;
}
Esempio n. 15
0
File: ipwd.c Progetto: Raffprta/core
int i_getgrgid(gid_t gid, struct group *grp_r)
{
	struct group *result;

	errno = 0;
	do {
		gr_init();
		errno = getgrgid_r(gid, grp_r, grbuf, grbuf_size, &result);
	} while (errno == ERANGE);
	if (result != NULL)
		return 1;
	return errno == 0 ? 0 : -1;
}
Esempio n. 16
0
void Init() {
	/*
	  Gpx.Init(): Gpx モジュールの初期化
	*/
	int p1 = getCaliValue(); /* ISys3x */
	
	suf[0] = NULL;
	gr_init();
	
	// surface0 を pre_freesurfno として返さないように。
	pre_freesurfno = 1;
	
	DEBUG_COMMAND("Gpx.Init %d:\n", p1);
}
void test::FSTestFixture::SetUp() {
	auto currentTest = ::testing::UnitTest::GetInstance()->current_test_info();
	pushModDir(currentTest->name());

	init_cmdline();

	timer_init();

#ifndef NDEBUG
	outwnd_init();
	mprintf(("TEST: Setting up test '%s.%s'\n", currentTest->test_case_name(), currentTest->name()));
#endif

	os_init("Test", "Test");

	if (_initFlags & INIT_CFILE) {
		SCP_string cfile_dir(TEST_DATA_PATH);
		cfile_dir += DIR_SEPARATOR_CHAR;
		cfile_dir += "test"; // Cfile expects something after the path

		if (cfile_init(cfile_dir.c_str())) {
			FAIL() << "Cfile init failed!";
		}

		if (_initFlags & INIT_MOD_TABLE) {
			mod_table_init();        // load in all the mod dependent settings
		}

		lcl_init(-1);
		lcl_xstr_init();

		if (_initFlags & INIT_MOD_TABLE) {
			mod_table_init(); // load in all the mod dependent settings
		}

		if (_initFlags & INIT_GRAPHICS) {
			if (!gr_init(nullptr, GR_STUB, 1024, 768)) {
				FAIL() << "Graphics init failed!";
			}

			if (_initFlags & INIT_FONTS) {
				font::init();
			}
		}

		if (_initFlags & INIT_SHIPS) {
			ship_init();
		}
	}
}
Esempio n. 18
0
int main()
{
    void *gr;
    //gr = gr_init("test", "127.0.0.1:6785", 0);
    //gr = gr_init("test", "192.168.13.101:9001", 0);
    printf("init\n");
    gr = gr_init("test", "/var/run/garner.sock", 0);
    printf("gr_log1\n");
    gr_log(gr, "test\n");
    sleep(5);
    gr_log(gr, "test\n");
    printf("gr_log2\n");
    gr_close(gr);

#if 0
    u_int8_t buffer[1024];
    int len;
    memset(buffer, 0, sizeof(buffer));
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_log(gr, "MAIL FROM: <vinod@rhel5>\r\n");
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_log(gr, "RCPT To: <vinod@rhel5>\r\n");
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_log(gr, "DATA\r\n");
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_log(gr, "Subject: test mail from gr\r\n\r\nThis is test.\r\n.\r\n");
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_log(gr, "QUIT\r\n");
    len = gr_read(gr, buffer, sizeof(buffer));
    printf("got %d errno=%s: %s\n", len, strerror(errno), buffer);
    buffer[0] = '\0';
    gr_close(gr);
#endif

    return 0;
}
Esempio n. 19
0
File: gr.c Progetto: adsgray/CServer
/* if you get a mallocd pointer from somewhere and want to have
   it freed by gr_clear 
   If all the spots in gr->ptrs are taken, allocate/follow gr->chain.
   Note: I don't really like using goto, but it is cheaper than
   a recursive call.
   It is equivalent to replacing the goto with:
   return gr_track(gr->chain, ptr, ff);
*/
int gr_track(gr_t gr, void *ptr, free_func ff) 
{

	recurse:
	if (gr->num == gr->max) {
		if (!gr->chain) {
			if (dbg) fprintf(stderr, "gr_track: chaining %d\n",
		                 gr->max);
			/* create another gr of twice our size */
			gr->chain = gr_init(2*gr->max);
		}
		gr = gr->chain;
		goto recurse;
	}

	gr->ptrs[gr->num].data = ptr;
	gr->ptrs[gr->num++].ff = ff;
	return 1;
}
Esempio n. 20
0
bool FrameDisplayApp::OnInit()
{
    gr_init(640,480,"Frame");

    char buf[512];
    char path[512];
    path[0] = '.';
    path[1] = 0;
    if (argc == 2)
    {
    wxString str(argv[1]);
    sprintf(path,"%s",(const char*)str.mb_str(wxConvUTF8));
    }

    sprintf(buf,"%s/%s",path,"th105a.dat");
    arc_add_dat(buf);
    sprintf(buf,"%s/%s",path,"th105b.dat");
    arc_add_dat(buf);
    sprintf(buf,"%s/%s",path,"th105c.dat");
    arc_add_dat(buf);
    sprintf(buf,"%s/%s",path,"th123a.dat");
    arc_add_dat(buf);
    sprintf(buf,"%s/%s",path,"th123b.dat");
    arc_add_dat(buf);
    sprintf(buf,"%s/%s",path,"th123c.dat");
    arc_add_dat(buf);


    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    if ( wxsOK )
    {
    	FrameDisplayDialog Dlg(0);
    	SetTopWindow(&Dlg);
    	Dlg.ShowModal();
    	wxsOK = false;
    }
    //*)

    return wxsOK;

}
Esempio n. 21
0
void ScreenRecoveryUI::Init() {
    gr_init();

    gr_font_size(&char_width, &char_height);
#ifdef MTK_WEARABLE_PLATFORM
    text_rows_ = gr_fb_height() / char_height;
#else
    //tony.kuo 2013-12-23: Subtract some rows so screen could support number of text_rows
    text_rows_ = ((gr_fb_height() / char_height) - 10) ;
#endif

    text_cols_ = gr_fb_width() / char_width;

    text_ = Alloc2d(text_rows_, text_cols_ + 1);
    file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
    menu_ = Alloc2d(text_rows_, text_cols_ + 1);

    text_col_ = text_row_ = 0;
    text_top_ = 1;

    backgroundIcon[NONE] = nullptr;
    LoadBitmapArray("icon_installing", &installing_frames, &installation);
    backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : nullptr;
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);
    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);

    pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);

    RecoveryUI::Init();
}
Esempio n. 22
0
static int
gr_update(struct group * grp, char const * group)
{
	int pfd, tfd;
	struct group *gr = NULL;
	struct group *old_gr = NULL;

	if (grp != NULL)
		gr = gr_dup(grp);

	if (group != NULL)
		old_gr = GETGRNAM(group);

	if (gr_init(conf.etcpath, NULL))
		err(1, "gr_init()");

	if ((pfd = gr_lock()) == -1) {
		gr_fini();
		err(1, "gr_lock()");
	}
	if ((tfd = gr_tmp(-1)) == -1) {
		gr_fini();
		err(1, "gr_tmp()");
	}
	if (gr_copy(pfd, tfd, gr, old_gr) == -1) {
		gr_fini();
		close(tfd);
		err(1, "gr_copy()");
	}
	fsync(tfd);
	close(tfd);
	if (gr_mkdb() == -1) {
		gr_fini();
		err(1, "gr_mkdb()");
	}
	free(gr);
	gr_fini();
	return 0;
}
void ScreenRecoveryUI::Init() {
    gr_init();

    density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f;
    is_large_ = gr_fb_height() > PixelsFromDp(800);

    gr_font_size(&char_width_, &char_height_);
    text_rows_ = gr_fb_height() / char_height_;
    text_cols_ = gr_fb_width() / char_width_;

    text_ = Alloc2d(text_rows_, text_cols_ + 1);
    file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
    menu_ = Alloc2d(text_rows_, text_cols_ + 1);

    text_col_ = text_row_ = 0;
    text_top_ = 1;

    LoadBitmap("icon_error", &error_icon);

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);

    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    // Background text for "installing_update" could be "installing update"
    // or "installing security update". It will be set after UI init according
    // to commands in BCB.
    installing_text = nullptr;
    LoadLocalizedBitmap("erasing_text", &erasing_text);
    LoadLocalizedBitmap("no_command_text", &no_command_text);
    LoadLocalizedBitmap("error_text", &error_text);

    LoadAnimation();

    pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);

    RecoveryUI::Init();
}
Esempio n. 24
0
void ScreenRecoveryUI::Init()
{
    gr_init();

    gr_font_size(&char_width, &char_height);

    text_col = text_row = 0;

    //tony.kuo 2013-12-23: Subtract some rows so screen could support number of text_rows
    text_rows = ((gr_fb_height() / char_height) - 10) ;
	 
    if (text_rows > kMaxRows) text_rows = kMaxRows;
    text_top = 1;
	
    text_cols = gr_fb_width() / char_width;
    if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;

    backgroundIcon[NONE] = NULL;
    LoadBitmapArray("icon_installing", &installing_frames, &installation);
    backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : NULL;
    backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
    LoadBitmap("icon_error", &backgroundIcon[ERROR]);
    backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);
    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
    LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
    LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
    LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);

    pthread_create(&progress_t, NULL, progress_thread, NULL);

    RecoveryUI::Init();
}
Esempio n. 25
0
void arch_init(void)
{
	int t;

	if (SDL_Init(SDL_INIT_VIDEO) < 0)
		Error("SDL library initialisation failed: %s.",SDL_GetError());

	key_init();

	digi_select_system( GameArg.SndDisableSdlMixer ? SDLAUDIO_SYSTEM : SDLMIXER_SYSTEM );

	if (!GameArg.SndNoSound)
		digi_init();

	mouse_init();

	if (!GameArg.CtlNoJoystick)
		joy_init();

	if ((t = gr_init(0)) != 0)
		Error("Graphics initialization failed: %u",t);

	atexit(arch_close);
}
Esempio n. 26
0
main(int argc, char * argv[] )
{
	int x, y;
	grs_bitmap bmp;
	grs_bitmap bmp1;
	ubyte palette[768];

	minit();

	printf( "Reading %s...\n", "john.pcx" );
	gr_init( SM_320x200U );
	bmp.bm_data = NULL;
	pcx_read_bitmap( "big.pcx", &bmp, BM_LINEAR, palette );
	gr_palette_load( palette );
	key_init();

	x = y = 0;
	while(!keyd_pressed[KEY_ESC]) {
		y += keyd_pressed[KEY_UP] - keyd_pressed[KEY_DOWN];
		x += keyd_pressed[KEY_LEFT] - keyd_pressed[KEY_RIGHT];
		gr_bitmap( x, y, &bmp );
	}

}
Esempio n. 27
0
void ui_init(void)
{
    ui_has_initialized = 1;
    gr_init();
    ev_init(input_callback, NULL);
#ifdef BOARD_TOUCH_RECOVERY
    touch_init();
#endif

    text_col = text_row = 0;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    max_menu_rows = text_rows - MIN_LOG_ROWS;
#ifdef BOARD_TOUCH_RECOVERY
    max_menu_rows = get_max_menu_rows(max_menu_rows);
#endif
    if (max_menu_rows > MENU_MAX_ROWS)
        max_menu_rows = MENU_MAX_ROWS;
    if (text_rows > MAX_ROWS) text_rows = MAX_ROWS;
    text_top = 1;

    text_cols = gr_fb_width() / CHAR_WIDTH;
    if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1;

    int i;
    for (i = 0; BITMAPS[i].name != NULL; ++i) {
        int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface);
        if (result < 0) {
            LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result);
        }
    }

    gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames *
                                       sizeof(gr_surface));
    for (i = 0; i < ui_parameters.indeterminate_frames; ++i) {
        char filename[40];
        // "indeterminate01.png", "indeterminate02.png", ...
        sprintf(filename, "indeterminate%02d", i+1);
        int result = res_create_surface(filename, gProgressBarIndeterminate+i);
        if (result < 0) {
            LOGE("Missing bitmap %s\n(Code %d)\n", filename, result);
        }
    }

    if (ui_parameters.installing_frames > 0) {
        gInstallationOverlay = malloc(ui_parameters.installing_frames *
                                      sizeof(gr_surface));
        for (i = 0; i < ui_parameters.installing_frames; ++i) {
            char filename[40];
            // "icon_installing_overlay01.png",
            // "icon_installing_overlay02.png", ...
            sprintf(filename, "icon_installing_overlay%02d", i+1);
            int result = res_create_surface(filename, gInstallationOverlay+i);
            if (result < 0) {
                LOGE("Missing bitmap %s\n(Code %d)\n", filename, result);
            }
        }

        // Adjust the offset to account for the positioning of the
        // base image on the screen.
        if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) {
            gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING];
            ui_parameters.install_overlay_offset_x +=
                (gr_fb_width() - gr_get_width(bg)) / 2;
            ui_parameters.install_overlay_offset_y +=
                (gr_fb_height() - gr_get_height(bg)) / 2;
        }
    } else {
        gInstallationOverlay = NULL;
    }

    char enable_key_repeat[PROPERTY_VALUE_MAX];
    property_get("ro.cwm.enable_key_repeat", enable_key_repeat, "");
    if (!strcmp(enable_key_repeat, "true") || !strcmp(enable_key_repeat, "1")) {
        boardEnableKeyRepeat = 1;

        char key_list[PROPERTY_VALUE_MAX];
        property_get("ro.cwm.repeatable_keys", key_list, "");
        if (strlen(key_list) == 0) {
            boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_UP;
            boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_DOWN;
            boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEUP;
            boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEDOWN;
        } else {
            char *pch = strtok(key_list, ",");
            while (pch != NULL) {
                boardRepeatableKeys[boardNumRepeatableKeys++] = atoi(pch);
                pch = strtok(NULL, ",");
            }
        }
    }

    pthread_t t;
    pthread_create(&t, NULL, progress_thread, NULL);
    pthread_create(&t, NULL, input_thread, NULL);
}
int main(int argc, char **argv)
{
    int key_code = -1;
    int input = false;
    int opt;
    long int timeout = NEXT_TIMEOUT_MS;
    int64_t start;

    while ((opt = getopt(argc, argv, "t:")) != -1) {
        switch (opt) {
        case 't':
            timeout = strtol(optarg, NULL, 0);

            if (timeout < 0 || timeout >= LONG_MAX) {
                timeout = NEXT_TIMEOUT_MS;
                LOGE("invalid timeout %s, defaulting to %ld\n", optarg,
                    timeout);
            }
            break;
        default:
            return usage();
        }
    }

    if (optind >= argc) {
        return usage();
    }

    if (gr_init() == -1 || ev_init(input_cb, &key_code) == -1) {
        LOGE("failed to initialize minui\n");
        return EXIT_FAILURE;
    }

    /* display all images except the last one, switch to next image after
     * timeout or user input */

    while (optind < argc - 1) {
        draw(argv[optind++]);

        start = android::uptimeMillis();
        long int timeout_remaining = timeout;
        do {
            if (ev_wait(timeout_remaining) == 0) {
                ev_dispatch();

                if (key_code != -1) {
                    input = true;
                    break;
                }
            }
            timeout_remaining -= android::uptimeMillis() - start;
        } while (timeout_remaining > 0);
    };

    /* if there was user input while showing the images, display the last
     * image and wait until the power button is pressed or LAST_TIMEOUT_MS
     * has elapsed */

    if (input) {
        start = android::uptimeMillis();

        draw(argv[optind]);

        do {
            if (ev_wait(timeout) == 0) {
                ev_dispatch();
            }

            if (android::uptimeMillis() - start >= LAST_TIMEOUT_MS) {
                break;
            }
        } while (key_code != KEY_POWER);
    }

    clear();
    gr_exit();
    ev_exit();

    return EXIT_SUCCESS;
}
Esempio n. 29
0
File: graf.c Progetto: imr/ngspice
static int
iplot(struct plot *pl, int id)
{
    int len = pl->pl_scale->v_length;
    struct dvec *v, *xs = pl->pl_scale;
    double *lims, dy;
    double start, stop, step;
    register int j;
    bool changed = FALSE;
    int yt;
    char *yl = NULL;
    double xlims[2], ylims[2];
    static REQUEST reqst = { checkup_option, NULL };
    int inited = 0;
    char commandline[513];

    for (j = 0, v = pl->pl_dvecs; v; v = v->v_next)
        if (v->v_flags & VF_PLOT)
            j++;
    if (!j)
        return (0);
    if (ft_grdb)
        fprintf(cp_err, "Entering iplot, len = %d\n", len);

    if (len < IPOINTMIN) {
        /* Nothing yet */
        return (0);
    } else if (len == IPOINTMIN || !id) {
        resumption = FALSE;
        /* Draw the grid for the first time, and plot everything. */
        lims = ft_minmax(xs, TRUE);
        xlims[0] = lims[0];
        xlims[1] = lims[1];
        ylims[0] = HUGE;
        ylims[1] = - ylims[0];
        for (v = pl->pl_dvecs; v; v = v->v_next)
            if (v->v_flags & VF_PLOT) {
                lims = ft_minmax(v, TRUE);
                if (ylims[0] > lims[0])
                    ylims[0] = lims[0];
                if (ylims[1] < lims[1])
                    ylims[1] = lims[1];
                if (!yl)
                    yl = v->v_name;
            }
        /* generate a small difference between ymin and ymax
           to catch the y=const case */
        if (ylims[0] == ylims[1])
            ylims[1] += 1e-9;

        if (ft_grdb)
            fprintf(cp_err,
                    "iplot: after 5, xlims = %G, %G, ylims = %G, %G\n",
                    xlims[0], xlims[1], ylims[0], ylims[1]);

        for (yt = pl->pl_dvecs->v_type, v = pl->pl_dvecs->v_next; v; v = v->v_next)
            if ((v->v_flags & VF_PLOT) && (v->v_type != yt)) {
                yt = SV_NOTYPE;
                break;
            }

        /* note: have command options for iplot to specify xdelta,
           etc.  So don't need static variables hack.  Assume default
           values for now.  */
        sprintf(commandline, "plot %s", yl);

        (void) gr_init(xlims, ylims, xs->v_name,
                       pl->pl_title, NULL, j, 0.0, 0.0,
                       GRID_LIN, PLOT_LIN, xs->v_name, yl, xs->v_type, yt,
                       plot_cur->pl_typename, commandline);

        for (v = pl->pl_dvecs; v; v = v->v_next)
            if (v->v_flags & VF_PLOT) {
                gr_start_internal(v, FALSE);
                ft_graf(v, xs, TRUE);
            }
        inited = 1;

    } else {
        /* plot the last points and resize if needed */
        Input(&reqst, NULL);
        /* First see if we have to make the screen bigger */
        dy = (isreal(xs) ? xs->v_realdata[len - 1] :
              realpart(xs->v_compdata[len - 1]));
        if (ft_grdb)
            fprintf(cp_err, "x = %G\n", dy);
        if (!if_tranparams(ft_curckt, &start, &stop, &step) ||
            !ciprefix("tran", pl->pl_typename)) {
            stop = HUGE;
            start = - stop;
        }
        /* checking for x lo */
        while (dy < currentgraph->data.xmin) {
            changed = TRUE;
            if (ft_grdb)
                fprintf(cp_err, "resize: xlo %G -> %G\n",
                        currentgraph->data.xmin,
                        currentgraph->data.xmin -
                        (currentgraph->data.xmax - currentgraph->data.xmin)
                        * XFACTOR);
            /* set the new x lo value */
            currentgraph->data.xmin -=
                (currentgraph->data.xmax - currentgraph->data.xmin)
                * XFACTOR;
            if (currentgraph->data.xmin < start) {
                currentgraph->data.xmin = start;
                break;
            }
        }
        if (currentgraph->data.xmax < currentgraph->data.xmin)
            currentgraph->data.xmax = currentgraph->data.xmin;
        /* checking for x hi */
        while (dy > currentgraph->data.xmax) {
            changed = TRUE;
            if (ft_grdb)
                fprintf(cp_err, "resize: xhi %G -> %G\n",
                        currentgraph->data.xmax,
                        currentgraph->data.xmax +
                        (currentgraph->data.xmax - currentgraph->data.xmin)
                        * XFACTOR);
            /* set the new x hi value */
            currentgraph->data.xmax +=
                (currentgraph->data.xmax - currentgraph->data.xmin) *
                XFACTOR;
            if (currentgraph->data.xmax > stop) {
                currentgraph->data.xmax = stop;
                break;
            }
        }
        /* checking for all y values */
        for (v = pl->pl_dvecs; v; v = v->v_next) {
            if (!(v->v_flags & VF_PLOT))
                continue;
            dy = (isreal(v) ? v->v_realdata[len - 1] :
                  realpart(v->v_compdata[len - 1]));
            if (ft_grdb)
                fprintf(cp_err, "y = %G\n", dy);
            /* checking for y lo */
            while (dy < currentgraph->data.ymin) {
                changed = TRUE;
                if (ft_grdb)
                    fprintf(cp_err, "resize: ylo %G -> %G\n",
                            currentgraph->data.ymin,
                            currentgraph->data.ymin -
                            (currentgraph->data.ymax - currentgraph->data.ymin)
                            * YFACTOR);
                /* set the new y lo value */
                currentgraph->data.ymin -=
                    (currentgraph->data.ymax - currentgraph->data.ymin)
                    * YFACTOR;
                /* currentgraph->data.ymin +=
                  (dy - currentgraph->data.ymin) * YFACTOR;*/
                /* currentgraph->data.ymin = dy;
                  currentgraph->data.ymin *= (1 + YFACTOR); */
            }
            if (currentgraph->data.ymax < currentgraph->data.ymin)
                currentgraph->data.ymax = currentgraph->data.ymin;
            /* checking for y hi */
            while (dy > currentgraph->data.ymax) {
                changed = TRUE;
                if (ft_grdb)
                    fprintf(cp_err, "resize: yhi %G -> %G\n",
                            currentgraph->data.ymax,
                            currentgraph->data.ymax +
                            (currentgraph->data.ymax - currentgraph->data.ymin)
                            * YFACTOR);
                /* set the new y hi value */
                currentgraph->data.ymax +=
                    (currentgraph->data.ymax - currentgraph->data.ymin)
                    * YFACTOR;
                /* currentgraph->data.ymax +=
                  (dy - currentgraph->data.ymax) * YFACTOR;*/
                /* currentgraph->data.ymax = dy;
                  currentgraph->data.ymax *= (1 + YFACTOR); */
            }
        }

        if (changed) {
            /* Redraw everything. */
            gr_pmsg("Resizing screen");
            gr_resize(currentgraph);
#ifndef X_DISPLAY_MISSING
            gr_redraw(currentgraph);
#endif
        } else {
            /* Just connect the last two points. This won't be done
             * with curve interpolation, so it might look funny.  */
            for (v = pl->pl_dvecs; v; v = v->v_next)
                if (v->v_flags & VF_PLOT) {
                    gr_point(v,
                             (isreal(xs) ? xs->v_realdata[len - 1] :
                              realpart(xs->v_compdata[len - 1])),
                             (isreal(v) ? v->v_realdata[len - 1] :
                              realpart(v->v_compdata[len - 1])),
                             (isreal(xs) ? xs->v_realdata[len - 2] :
                              realpart(xs->v_compdata[len - 2])),
                             (isreal(v) ? v->v_realdata[len - 2] :
                              realpart(v->v_compdata[len - 2])),
                             len - 1);
                }
        }
    }
    DevUpdate();
    return (inited);
}
Esempio n. 30
0
void ui_init(void)
{
    ui_has_initialized = 1;
    gr_init();
    ev_init(input_callback, NULL);

    text_col = text_row = 0;
    text_rows = gr_fb_height() / CHAR_HEIGHT;
    max_menu_rows = text_rows - MIN_LOG_ROWS;
    if (max_menu_rows > MENU_MAX_ROWS)
        max_menu_rows = MENU_MAX_ROWS;
    if (text_rows > MAX_ROWS) text_rows = MAX_ROWS;
    text_top = 1;

    text_cols = gr_fb_width() / CHAR_WIDTH;
    if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1;

    int i;
    for (i = 0; BITMAPS[i].name != NULL; ++i) {
        int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface);
        if (result < 0) {
            LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result);
        }
    }

    gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames *
                                       sizeof(gr_surface));
    for (i = 0; i < ui_parameters.indeterminate_frames; ++i) {
        char filename[40];
        // "indeterminate01.png", "indeterminate02.png", ...
        sprintf(filename, "indeterminate%02d", i+1);
        int result = res_create_surface(filename, gProgressBarIndeterminate+i);
        if (result < 0) {
            LOGE("Missing bitmap %s\n(Code %d)\n", filename, result);
        }
    }

    if (ui_parameters.installing_frames > 0) {
        gInstallationOverlay = malloc(ui_parameters.installing_frames *
                                      sizeof(gr_surface));
        for (i = 0; i < ui_parameters.installing_frames; ++i) {
            char filename[40];
            // "icon_installing_overlay01.png",
            // "icon_installing_overlay02.png", ...
            sprintf(filename, "icon_installing_overlay%02d", i+1);
            int result = res_create_surface(filename, gInstallationOverlay+i);
            if (result < 0) {
                LOGE("Missing bitmap %s\n(Code %d)\n", filename, result);
            }
        }

        // Adjust the offset to account for the positioning of the
        // base image on the screen.
        if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) {
            gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING];
            ui_parameters.install_overlay_offset_x +=
                (gr_fb_width() - gr_get_width(bg)) / 2;
            ui_parameters.install_overlay_offset_y +=
                (gr_fb_height() - gr_get_height(bg)) / 2;
        }
    } else {
        gInstallationOverlay = NULL;
    }

    pthread_t t;
    pthread_create(&t, NULL, progress_thread, NULL);
    pthread_create(&t, NULL, input_thread, NULL);
}