Пример #1
0
/*****************************************************************************
 * Manage: handle aa events
 *****************************************************************************
 * This function should be called regularly by video output thread. It manages
 * console events. It returns a non null value on error.
 *****************************************************************************/
static int Manage( vout_thread_t *p_vout )
{
    int event, x, y, b;
    event = aa_getevent( p_vout->p_sys->aa_context, 0 );
    switch ( event )
    {
    case AA_MOUSE:
        aa_getmouse( p_vout->p_sys->aa_context, &x, &y, &b );
        if ( b & AA_BUTTON3 )
        {
            intf_thread_t *p_intf;
            p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
            if( p_intf )
            {
                p_intf->b_menu_change = 1;
                vlc_object_release( p_intf );
            }
        }
        break;
    case AA_RESIZE:
        p_vout->i_changes |= VOUT_SIZE_CHANGE;
        aa_resize( p_vout->p_sys->aa_context );
        p_vout->p_sys->i_width = aa_imgwidth( p_vout->p_sys->aa_context );
        p_vout->p_sys->i_height = aa_imgheight( p_vout->p_sys->aa_context );
        break;
    default:
        break;
    }
    return( 0 );
}
Пример #2
0
static inline ggi_event_mask
do_mouse(gii_input_t inp, ggi_aa_priv *priv)
{
	ggi_event_mask ret = 0;
	ggi_event ggievent;
	int x, y, buttons;

	aa_getmouse(priv->context, &x, &y, &buttons);

	/* Mouse movement is in screen coordinates;
	   we assume one screen pixel : four image pixels */
	x *= AA_SCRMULT_X;
	y *= AA_SCRMULT_Y;

	if (x != priv->lx || y != priv->ly) {
		_giiEventBlank(&ggievent, sizeof(ggi_pmove_event));
		ggievent.any.size   = sizeof(ggi_pmove_event);
		ggievent.any.type   = evPtrAbsolute;
		ggievent.any.origin = inp->origin;

		ggievent.pmove.x = x;
		ggievent.pmove.y = y;
		
		ret |= emPtrAbsolute;
		_giiEvQueueAdd(inp, &ggievent);

		priv->lx = x;
		priv->ly = y;
	}

	/* Now check the buttons */
	if (buttons != priv->lb) {
		int change = buttons ^ priv->lb;
		int i;

		for (i = 0; i < 3; i++) {
			int diff = change & (1<<i);
			if (! diff) continue;
			
			_giiEventBlank(&ggievent, sizeof(ggi_pbutton_event));
			ggievent.any.size = sizeof(ggi_pbutton_event);
			ggievent.any.origin = inp->origin;
			if ((diff & buttons)) {
				ggievent.any.type = evPtrButtonPress;
				ret |= emPtrButtonPress;
			} else {
				ggievent.any.type = evPtrButtonRelease;
				ret |= emPtrButtonRelease;
			}
			ggievent.pbutton.button = i+1;

			_giiEvQueueAdd(inp, &ggievent);
		}
		priv->lb = buttons;
	}
	
	return ret;
}	
Пример #3
0
int main(int argc, char **argv)
{
	aa_context *c;
	int i, y;
	char s[256];
	aa_renderparams *p;
	strcpy(s, "line editor.");
	if (!aa_parseoptions(NULL, NULL, &argc, argv) || argc != 1) {
		printf("%s\n", aa_help);
		exit(1);
	}
	c = aa_autoinit(&aa_defparams);
	if (c == NULL) {
		printf("Can not intialize aalib\n");
		exit(2);
	}
	if (!aa_autoinitkbd(c, 0)) {
		printf("Can not intialize keyboard\n");
		aa_close(c);
		exit(3);
	}
	for (i = 0; i < aa_imgwidth(c); i++)
		for (y = 0; y < aa_imgheight(c); y++)
			aa_putpixel(c, i, y, i + y < 80 ? i : ((i + y) < 100 ? (i + y == 89 ? 150 : 0) : y * 8));
	aa_hidecursor(c);
	aa_fastrender(c, 0, 0, aa_scrwidth(c), aa_scrheight(c));
	aa_printf(c, 0, 0, AA_SPECIAL, "Fast rendering routine %i",1);
	aa_flush(c);
	aa_getkey(c, 1);
	aa_edit(c, 0, 1, 20, s, 256);
	aa_puts(c, 0, 0, AA_SPECIAL, "Key lookup test        ");
	aa_flush(c);
	int ch;
	while ((ch = aa_getevent(c, 1)) != ' ') {
		char s[80];
		sprintf(s, "Key event test-space to exit. c:%i", ch);
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
	}
	if (aa_autoinitmouse(c, AA_MOUSEALLMASK)) {
		int co = 0;
		sprintf(s, "Mouse test-space to exit");
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_hidemouse(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Hidden mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_uninitmouse(c);
	}
	p = aa_getrenderparams();
	for (i = 0; i < AA_DITHERTYPES; i++) {
		p->dither = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, aa_dithernames[i]);
		aa_flush(c);
		aa_getkey(c, 1);
	}
	for (i = 0; i < 255; i += 32) {
		p->bright = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - bright changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->bright = 0;
	for (i = 0; i < 128; i += 16) {
		p->contrast = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - contrast changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->contrast = 0;
	for (i = 0; i < 255; i += 32) {
		p->gamma = 1 + i / 32.0;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - gamma changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->gamma = 1.0;
	for (i = 0; i < 255; i += 32) {
		p->randomval = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - randomval changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	aa_close(c);
	return 0;
}
Пример #4
0
/**
 * Proccess pending event
 */
static void Manage(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;

    for (;;) {
        const int event = aa_getevent(sys->aa_context, 0);
        if (!event)
            return;

        switch (event) {
        case AA_MOUSE: {
            int x, y;
            int button;
            int vlc;
            aa_getmouse(sys->aa_context, &x, &y, &button);

            vlc = 0;
            if (button & AA_BUTTON1)
                vlc |= 1 << MOUSE_BUTTON_LEFT;
            if (button & AA_BUTTON2)
                vlc |= 1 << MOUSE_BUTTON_CENTER;
            if (button & AA_BUTTON3)
                vlc |= 1 << MOUSE_BUTTON_RIGHT;

            vout_display_SendEventMouseState(vd, x, y, vlc);

            aa_showcursor(sys->aa_context); /* Not perfect, we show it on click too */
            break;
        }

        case AA_RESIZE:
            aa_resize(sys->aa_context);
            vout_display_SendEventDisplaySize(vd,
                                              aa_imgwidth(sys->aa_context),
                                              aa_imgheight(sys->aa_context));
            break;

        /* TODO keys support to complete */
        case AA_UP:
            vout_display_SendEventKey(vd, KEY_UP);
            break;
        case AA_DOWN:
            vout_display_SendEventKey(vd, KEY_DOWN);
            break;
        case AA_RIGHT:
            vout_display_SendEventKey(vd, KEY_RIGHT);
            break;
        case AA_LEFT:
            vout_display_SendEventKey(vd, KEY_LEFT);
            break;
        case AA_BACKSPACE:
            vout_display_SendEventKey(vd, KEY_BACKSPACE);
            break;
        case AA_ESC:
            vout_display_SendEventKey(vd, KEY_ESC);
            break;
        default:
            if (event >= 0x20 && event <= 0x7f)
                vout_display_SendEventKey(vd, event);
            break;
        }
    }
}
Пример #5
0
void AA_PumpEvents(_THIS)
{
	int posted = 0;
	int mouse_button, mouse_x, mouse_y;
	int evt;
	SDL_keysym keysym;

	static int prev_button = -1, prev_x = -1, prev_y = -1;

	if( ! this->screen ) /* Wait till we got the screen initialized */
	  return;

	do {
		posted = 0;
		/* Gather events */

		/* Get mouse status */
		SDL_mutexP(AA_mutex);
		aa_getmouse (AA_context, &mouse_x, &mouse_y, &mouse_button);
		SDL_mutexV(AA_mutex);
		mouse_x = mouse_x * this->screen->w / aa_scrwidth (AA_context);
		mouse_y = mouse_y * this->screen->h / aa_scrheight (AA_context);

		/* Compare against previous state and generate events */
		if( prev_button != mouse_button ) {
			if( mouse_button & AA_BUTTON1 ) {
				if ( ! (prev_button & AA_BUTTON1) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON1 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
				}
			}
			if( mouse_button & AA_BUTTON2 ) {
				if ( ! (prev_button & AA_BUTTON2) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON2 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0);
				}
			}
			if( mouse_button & AA_BUTTON3 ) {
				if ( ! (prev_button & AA_BUTTON3) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON3 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
				}
			}
		}
		if ( prev_x != mouse_x || prev_y != mouse_y ) {
			posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y);
		}

		prev_button = mouse_button;
		prev_x = mouse_x; prev_y = mouse_y;

		/* Get keyboard event */
		SDL_mutexP(AA_mutex);
		evt = aa_getevent(AA_context, 0);
		SDL_mutexV(AA_mutex);
		if ( (evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) && (evt != AA_RESIZE) ) {
			/* Key pressed */
/*    			printf("Key pressed: %d (%c)\n", evt, evt); */
			posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym));
		} else if ( evt >= AA_RELEASE ) {
			/* Key released */
			evt &= ~AA_RELEASE;
/*  			printf("Key released: %d (%c)\n", evt, evt); */
			posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym));
		}
	} while ( posted );
}