Exemplo n.º 1
0
int vo_sdl_init(void)
{
    reinit = 0;

    if (!SDL_WasInit(SDL_INIT_VIDEO)) {
        // Unfortunately SDL_WINDOWID must be set at SDL_Init
        // and is ignored afterwards, thus it cannot work per-file.
        // Also, a value of 0 does not work for selecting the root window.
        if (WinID > 0) {
            char envstr[20];
            snprintf(envstr, sizeof(envstr), "0x%"PRIx64, WinID);
            setenv("SDL_WINDOWID", envstr, 1);
        }
        if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
            return 0;
    }

    // Setup Keyrepeats (500/30 are defaults)
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);

    // Easiest way to get uppercase characters
    SDL_EnableUNICODE(1);

    // We don't want those in our event queue.
    SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
    SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
    SDL_EventState(SDL_USEREVENT, SDL_IGNORE);

    // Try to get a sensible default for fullscreen.
    get_screensize();

    return 1;
}
Exemplo n.º 2
0
Arquivo: screen.c Projeto: xrg/pg_top
void
init_termcap(int interactive)

{
	char	   *bufptr;
	char	   *PCptr;
	char	   *term_name;
	char	   *getenv();
	int			status;

	/* set defaults in case we aren't smart */
	screen_width = MAX_COLS;
	screen_length = 0;

	if (!interactive)
	{
		/* pretend we have a dumb terminal */
		smart_terminal = No;
		return;
	}

	/* assume we have a smart terminal until proven otherwise */
	smart_terminal = Yes;

	/* get the terminal name */
	term_name = getenv("TERM");

	/* if there is no TERM, assume it's a dumb terminal */
	/* patch courtesy of Sam Horrocks at telegraph.ics.uci.edu */
	if (term_name == NULL)
	{
		smart_terminal = No;
		return;
	}

	/* now get the termcap entry */
	if ((status = tgetent(termcap_buf, term_name)) != 1)
	{
		if (status == -1)
		{
			fprintf(stderr, "%s: can't open termcap file\n", myname);
		}
		else
		{
			fprintf(stderr, "%s: no termcap entry for a `%s' terminal\n",
					myname, term_name);
		}

		/* pretend it's dumb and proceed */
		smart_terminal = No;
		return;
	}

	/* "hardcopy" immediately indicates a very stupid terminal */
	if (tgetflag("hc"))
	{
		smart_terminal = No;
		return;
	}

	/* set up common terminal capabilities */
	if ((screen_length = tgetnum("li")) <= 0)
	{
		screen_length = smart_terminal = 0;
		return;
	}

	/* screen_width is a little different */
	if ((screen_width = tgetnum("co")) == -1)
	{
		screen_width = 79;
	}
	else
	{
		screen_width -= 1;
	}

	/* terminals that overstrike need special attention */
	overstrike = tgetflag("os");

	/* initialize the pointer into the termcap string buffer */
	bufptr = string_buffer;

	/* get "ce", clear to end */
	if (!overstrike)
	{
		clear_line = tgetstr("ce", &bufptr);
	}

	/* get necessary capabilities */
	if ((clear_screen = tgetstr("cl", &bufptr)) == NULL ||
		(cursor_motion = tgetstr("cm", &bufptr)) == NULL)
	{
		smart_terminal = No;
		return;
	}

	/* get some more sophisticated stuff -- these are optional */
	clear_to_end = tgetstr("cd", &bufptr);
	terminal_init = tgetstr("ti", &bufptr);
	terminal_end = tgetstr("te", &bufptr);
	start_standout = tgetstr("so", &bufptr);
	end_standout = tgetstr("se", &bufptr);

	/* pad character */
	PC = (PCptr = tgetstr("pc", &bufptr)) ? *PCptr : 0;

	/* set convenience strings */
	(void) strcpy(home, tgoto(cursor_motion, 0, 0));
	/* (lower_left is set in get_screensize) */

	/* get the actual screen size with an ioctl, if needed */

	/*
	 * This may change screen_width and screen_length, and it always sets
	 * lower_left.
	 */
	get_screensize();

	/* if stdout is not a terminal, pretend we are a dumb terminal */
#ifdef SGTTY
	if (ioctl(STDOUT, TIOCGETP, &old_settings) == -1)
	{
		smart_terminal = No;
	}
#endif
#ifdef TERMIO
	if (ioctl(STDOUT, TCGETA, &old_settings) == -1)
	{
		smart_terminal = No;
	}
#endif
#ifdef TERMIOS
	if (tcgetattr(STDOUT, &old_settings) == -1)
	{
		smart_terminal = No;
	}
#endif
}