Exemple #1
0
static gnmc_t *gnmc_init (char *sysname) {

	gnmc_t *monitor;
	box_t *sysinfo_box,*moninfo_box;
	int32_t rows,cols,i;
  screen_t **scrs;
  struct timeval conn_time;

	getmaxyx (stdscr,rows,cols);

	monitor = calloc (1, sizeof (gnmc_t));
	monitor->name = strdup (sysname);

	monitor->nscrs = 4;
	monitor->main_scrs = calloc (monitor->nscrs,sizeof (screen_t*));
	monitor->top_screen = NULL; 

  monitor->info = calloc (1, sizeof (info_t));
  monitor->info->deliveries = 0;
  
  for (i=0;i<4;i++) {
    monitor->info->crates[i] = 0;
  }
  
  conn_time = monitor->info->conn_time;

  gettimeofday (&conn_time,NULL);

  scrs = monitor->main_scrs;

  scrs[STAT_SCR] = screen_create ("Station",rows/2,cols/2,0,0);

  sysinfo_box = box_create (scrs[STAT_SCR], NAME, 5);
  box_set_name (sysinfo_box,"sysinfo");

  moninfo_box = box_create (scrs[STAT_SCR], NAME, 2);
  box_set_name (moninfo_box,"moninfo");

	scrs[MIX_SCR] = screen_create ("Mixer",rows/2,cols/2,0,cols/2);
	scrs[COMP_SCR] = screen_create ("Compositor",rows/2,cols/2,rows/2,0);
	scrs[TRANS_SCR] = screen_create ("Transponder",rows/2,cols/2,rows/2,cols/2);

	scrs[STAT_SCR]->focus = 1;

	gnmc_krcomp_boxes_init (scrs[COMP_SCR]);

	screen_focus_curr (scrs,monitor->nscrs);

	return monitor;
}
Exemple #2
0
bool engine_init(const int width, const int height, const int scale, const int fps) {
    atexit(SDL_Quit);
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        engine_crash("SDL initilization failed");
    }
    
    // Init Screen
    engine->screen = screen_create(width, height, scale);
    fps_set(fps);
    
    // Stuff
    engine->mouse_x = 0;
    engine->mouse_y = 0;
    engine->list_tilemaps = list_create(8);
    engine->list_surfaces = list_create(16);
    engine->running = true;
    engine->paused = false;
    
    for(int i = 0; i < 322; i++) {
        engine->keys[i] = 0;
    }

    for(int i = 0; i < 8; i++) {
        engine->mouse[i] = 0;
    }
    return true;
}
Exemple #3
0
/* -------------------------------------------------------------------------- */
static bool mpd_init(struct lcd_stuff_mpd *mpd)
{
    char     *string;

    /* register client */
    service_thread_register_client(mpd->lcd->service_thread, &mpd_client, mpd);

    screen_create(&mpd->screen, mpd->lcd, MODULE_NAME);

    /* register keys */
    service_thread_command(mpd->lcd->service_thread,
                           "client_add_key Up\n");
    service_thread_command(mpd->lcd->service_thread,
                           "client_add_key Down\n");

    /* add standby menu */
    service_thread_command(mpd->lcd->service_thread,
                           "menu_add_item \"\" mpd_standby ring \"Standby\" "
                           "-strings \"0\t15\t30\t45\t60\t75\t90\t115\t130\t145\t160\"\n");

    /* set the title */
    string = key_file_get_string_default_l1(MODULE_NAME, "name", "Music Player");
    screen_set_title(&mpd->screen, string);
    g_free(string);

    return true;
}
Exemple #4
0
LOCAL ICACHE_FLASH_ATTR int handleCommandNewScreen(clientInfo_t *cl)
{
    screen_t *s = screen_create(cl->argv[0]);
    if (s) {
        client_sendOK(cl,"NEWSCREEN");
    } else {
        client_senderror(cl,"TOOMANY");
    }
    return s!=NULL;
}
Exemple #5
0
static void gnmc_interactive_box_handler (gnmc_t *mon, kr_client_t *client) {

	box_list_t *boxpos;
	box_t *box;
	screen_t *screen;
	int32_t rows,cols;

	getmaxyx (stdscr,rows,cols);

	screen = screen_focused (mon->main_scrs,mon->nscrs);

	boxpos = screen->fbox;
	
	if (boxpos == NULL) {
		return;
	}

	box = boxpos->box;

	if (!strncmp (box->id.val.name,"texts",5)) {
		kr_compositor_subunit_list (client);
		mon->top_screen = screen_create ("Texts",rows,cols,0,0);
    mon->top_screen->cache = crcache_init ();
		curses_win_focus (panel_window (mon->top_screen->mainp),
      mon->top_screen->name);
	}
	else if (!strncmp (box->id.val.name,"sprites",5)) {
		kr_compositor_subunit_list (client);
		mon->top_screen = screen_create ("Sprites",rows,cols,0,0);
		curses_win_focus (panel_window (mon->top_screen->mainp),
      mon->top_screen->name);
	}


	return;
}
ErrorScreen *errorscreen_create(Display *display, const gchar *message, GError **err) {
	g_return_val_if_fail(err == NULL || *err == NULL, NULL);
	g_assert(display != NULL);

	ErrorScreen *error = g_new0(ErrorScreen, 1);
	error->display = display;
	error->screen = screen_create(error, errorscreen_quark());
	error->screen->update = errorscreen_update;
	error->screen->process_event = errorscreen_process_event;
	error->screen->free = errorscreen_free_from_entity;

	// Create a semi-transparent background
	error->background = rect_osd_create(display, 0, 0, screenWidth, screenHeight, NULL, err);
	if (error->background == NULL) {
		errorscreen_free(error);
		return NULL;
	}
	rect_osd_set_opacity(error->background, 80);
	rect_osd_set_alignment(error->background, ALIGN_CENTER, ALIGN_MIDDLE);

	const Renderable* parent = rect_osd_get_renderable(error->background);

	// Create a pause message
	error->message = text_osd_create(display, message, parent, err);
	if (error->message == NULL) {
		errorscreen_free(error);
		return NULL;
	}
	text_osd_set_alignment(error->message, ALIGN_CENTER, ALIGN_MIDDLE);
	text_osd_set_position(error->message, 0, -20);
	text_osd_set_size(error->message, 240, 7);
	text_osd_set_color(error->message, 220, 220, 220);

	error->quit = button_create(display, "Quit", 90, 80, 60, 15, &errorscreen_on_quit, parent, err);
	if (error->quit == NULL) {
		errorscreen_free(error);
		return NULL;
	}

	return error;
}
/**
 * Tells the server the client has another screen to offer
 *
 *\verbatim
 * Usage: screen_add <id>
 *\endverbatim
 */
int
screen_add_func(Client *c, int argc, char **argv)
{
	int err = 0;
	Screen *s;

	if (c->state != ACTIVE)
		return 1;

	if (argc != 2) {
		sock_send_error(c->sock, "Usage: screen_add <screenid>\n");
		return 0;
	}

	debug(RPT_DEBUG, "screen_add: Adding screen %s", argv[1]);

	s = client_find_screen(c, argv[1]);
	if (s != NULL) {
		sock_send_error(c->sock, "Screen already exists\n");
		return 0;
	}

	s = screen_create(argv[1], c);
	if (s == NULL) {
		sock_send_error(c->sock, "failed to create screen\n");
		return 0;
	}

	err = client_add_screen(c, s);

	if (err == 0) {
		sock_send_string(c->sock, "success\n");
	} else {
		sock_send_error(c->sock, "failed to add screen\n");
	}
	report(RPT_INFO, "Client on socket %d added added screen \"%s\"", c->sock, s->id);
	return 0;
}
PUBLIC struct radeon_winsys *
radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
{
    struct radeon_drm_winsys *ws;

    pipe_mutex_lock(fd_tab_mutex);
    if (!fd_tab) {
        fd_tab = util_hash_table_create(hash_fd, compare_fd);
    }

    ws = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
    if (ws) {
        pipe_reference(NULL, &ws->reference);
        pipe_mutex_unlock(fd_tab_mutex);
        return &ws->base;
    }

    ws = CALLOC_STRUCT(radeon_drm_winsys);
    if (!ws) {
        pipe_mutex_unlock(fd_tab_mutex);
        return NULL;
    }

    ws->fd = dup(fd);

    if (!do_winsys_init(ws))
        goto fail;

    /* Create managers. */
    ws->kman = radeon_bomgr_create(ws);
    if (!ws->kman)
        goto fail;

    ws->cman = pb_cache_manager_create(ws->kman, 500000, 2.0f, 0,
                                       MIN2(ws->info.vram_size, ws->info.gart_size));
    if (!ws->cman)
        goto fail;

    if (ws->gen >= DRV_R600) {
        ws->surf_man = radeon_surface_manager_new(ws->fd);
        if (!ws->surf_man)
            goto fail;
    }

    /* init reference */
    pipe_reference_init(&ws->reference, 1);

    /* Set functions. */
    ws->base.unref = radeon_winsys_unref;
    ws->base.destroy = radeon_winsys_destroy;
    ws->base.query_info = radeon_query_info;
    ws->base.cs_request_feature = radeon_cs_request_feature;
    ws->base.query_value = radeon_query_value;
    ws->base.read_registers = radeon_read_registers;

    radeon_bomgr_init_functions(ws);
    radeon_drm_cs_init_functions(ws);
    radeon_surface_init_functions(ws);

    pipe_mutex_init(ws->hyperz_owner_mutex);
    pipe_mutex_init(ws->cmask_owner_mutex);
    pipe_mutex_init(ws->cs_stack_lock);

    ws->ncs = 0;
    pipe_semaphore_init(&ws->cs_queued, 0);
    if (ws->num_cpus > 1 && debug_get_option_thread())
        ws->thread = pipe_thread_create(radeon_drm_cs_emit_ioctl, ws);

    /* Create the screen at the end. The winsys must be initialized
     * completely.
     *
     * Alternatively, we could create the screen based on "ws->gen"
     * and link all drivers into one binary blob. */
    ws->base.screen = screen_create(&ws->base);
    if (!ws->base.screen) {
        radeon_winsys_destroy(&ws->base);
        pipe_mutex_unlock(fd_tab_mutex);
        return NULL;
    }

    util_hash_table_set(fd_tab, intptr_to_pointer(ws->fd), ws);

    /* We must unlock the mutex once the winsys is fully initialized, so that
     * other threads attempting to create the winsys from the same fd will
     * get a fully initialized winsys and not just half-way initialized. */
    pipe_mutex_unlock(fd_tab_mutex);

    return &ws->base;

fail:
    pipe_mutex_unlock(fd_tab_mutex);
    if (ws->cman)
        ws->cman->destroy(ws->cman);
    if (ws->kman)
        ws->kman->destroy(ws->kman);
    if (ws->surf_man)
        radeon_surface_manager_free(ws->surf_man);
    if (ws->fd >= 0)
        close(ws->fd);

    FREE(ws);
    return NULL;
}
Exemple #9
0
int
menuscreens_init(void)
{
	const char *tmp;

	debug(RPT_DEBUG, "%s()", __FUNCTION__);

	/*
	 * Get keys from config file: MenuKey, EnterKey, UpKey, DownKey,
	 * LeftKey, RightKey. For a working menu at least 3 are necessary:
	 * MenuKey, EnterKey, UpKey/DownKey.
	 */
	keymask = 0;
	menu_key = enter_key = NULL;
	tmp = config_get_string("menu", "MenuKey", 0, NULL);
	if (tmp != NULL) {
		menu_key = strdup(tmp);
		keymask |= MENUTOKEN_MENU;
	}
	tmp = config_get_string("menu", "EnterKey", 0, NULL);
	if (tmp != NULL) {
		enter_key = strdup(tmp);
		keymask |= MENUTOKEN_ENTER;
	}

	up_key = down_key = NULL;
	tmp = config_get_string("menu", "UpKey", 0, NULL);
	if (tmp != NULL) {
		up_key = strdup(tmp);
		keymask |= MENUTOKEN_UP;
	}
	tmp = config_get_string("menu", "DownKey", 0, NULL);
	if (tmp != NULL) {
		down_key = strdup(tmp);
		keymask |= MENUTOKEN_DOWN;
	}

	left_key = right_key = NULL;
	tmp = config_get_string("menu", "LeftKey", 0, NULL);
	if (tmp != NULL) {
		left_key = strdup(tmp);
		keymask |= MENUTOKEN_LEFT;
	}
	tmp = config_get_string("menu", "RightKey", 0, NULL);
	if (tmp != NULL) {
		right_key = strdup(tmp);
		keymask |= MENUTOKEN_RIGHT;
	}

	/* Now reserve the keys that were defined */
	if (menu_key != NULL)
		input_reserve_key(menu_key, true, NULL);
	if (enter_key != NULL)
		input_reserve_key(enter_key, false, NULL);
	if (up_key != NULL)
		input_reserve_key(up_key, false, NULL);
	if (down_key != NULL)
		input_reserve_key(down_key, false, NULL);
	if (left_key != NULL)
		input_reserve_key(left_key, false, NULL);
	if (right_key != NULL)
		input_reserve_key(right_key, false, NULL);

	/* Create screen */
	menuscreen = screen_create("_menu_screen", NULL);
	if (menuscreen != NULL)
		menuscreen->priority = PRI_HIDDEN;
	active_menuitem = NULL;

	screenlist_add(menuscreen);

	/* Build menu */
	menuscreen_create_menu();

	return 0;
}
Exemple #10
0
int main(int argc, char *argv[])
{	
	char input = 0;
	char save_name[50];


	//Prepare engine
	Engine *engine = prepare_game(save_name);

	GoF_Screen *screen = screen_create(0, 0, 30, 30, 20);
	Graphics g;
	graphics_init(&g, 800, 900, "The Game of Life!");

	input = 0;
	while(input != 'k')
	{
		screen_draw(screen, &g, engine);
		input = graphics_event(&g);

		if(input == 1)
			engine_add_entity(engine, entity_create(g.last_x/screen->entity_length, g.last_y/screen->entity_length));
		else if(input == 3)
			engine_remove_entity(engine, g.last_x/screen->entity_length, g.last_y/screen->entity_length);
	}

	//Input
	input = 0;
	int sens = 5;

	//Main game loop
	while(input != 'q')
	{	
		//Draw on screen
		screen_draw(screen, &g, engine);

		//Update Engine
		engine_update(engine);
		
		//Process input
		while(graphics_check_event(&g))
		{
			input = graphics_event(&g);
			switch(input)
			{
				case 'p':
					engine->ups++;
					break;
				case 'm':
					if(engine->ups > 1)
						engine->ups--;
					break;
				case '.':
					sens++;
					break;
				case ',':
					if(sens > 1)
						sens--;
					break;
				case UP_ARROW:
					screen->y -= sens;
					break;
				case DOWN_ARROW:
					screen->y += sens;
					break;
				case LEFT_ARROW:
					screen->x -= sens;
					break;
				case RIGHT_ARROW:
					screen->x += sens;
					break;
			}
		}

		//Sleep
		usleep((1000/engine->ups) * 1000);
	}

	//Close graphics
	graphics_close(&g);

	//Save game
	printf("Saving game...\n");
	engine_save(engine, save_name);

	//Free mem
	engine_free(engine);
	screen_free(screen);

	return 0;
}