Ejemplo n.º 1
0
Archivo: aa.c Proyecto: forthyen/SDesk
/*****************************************************************************
 * 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 );
}
Ejemplo n.º 2
0
int aa_getkey(aa_context * co, int wait)
{
    int c;
    do {
	c = aa_getevent(co, wait);
    } while (c == AA_MOUSE || c == AA_RESIZE || c>=AA_RELEASE);
    return (c);
}
Ejemplo n.º 3
0
static void 
game (void)
{
  gentable ();
  while (aa_getevent(context, 0) == AA_NONE)
    {
      drawfire ();
    }
}
Ejemplo n.º 4
0
ggi_event_mask GII_aa_poll(gii_input_t inp, void *arg)
{

	ggi_aa_priv *priv = inp->priv;
	ggi_event_mask evmask = 0;
	unsigned int aatype;

	DPRINT_EVENTS("GII_aa_poll\n");

	if (!priv->context) return 0;

	while ((aatype = aa_getevent(priv->context, 0)) != AA_NONE) {
		DPRINT_EVENTS("AA: got event %x\n", aatype);

		if (aatype == AA_MOUSE)	{
			evmask |= do_mouse(inp, priv);
		} else if (aatype >= 1 && aatype <= AA_RELEASE) {
			if (priv->lastkey == 0) {
				/* First hit */
				evmask |= emKeyPress;
				add_key_event(inp, aatype, evKeyPress);
			} else if (priv->lastkey == aatype) {
				/* Repeated keypress */
				evmask |= emKeyRepeat;
				add_key_event(inp, aatype, evKeyRepeat);
			} else {
				if (!priv->haverelease) {
					/* Whoops, different key! We send a
					   release for the lastkey first. */
					evmask |= emKeyRelease;
					add_key_event(inp, priv->lastkey,
						      evKeyRelease);
				}
				evmask |= emKeyPress;
				add_key_event(inp, aatype, evKeyPress);
			}
			priv->lastkey = aatype;
		} else if (aatype > AA_RELEASE) {
			/* Release given key.  It should match lastkey, but
			   if it doesn't, tough luck, we clear it anyway. */
			evmask |= emKeyRelease;
			add_key_event(inp, aatype, evKeyRelease);
			priv->lastkey = 0;
			priv->haverelease = 1;
		} else if (aatype == AA_RESIZE || aatype == AA_UNKNOWN) {
		}

	}
	if (!priv->haverelease && priv->lastkey) {
		/* No more events.  If priv->lastkey != 0, we release that key. */
		evmask |= emKeyRelease;
		add_key_event(inp, priv->lastkey, evKeyRelease);
		priv->lastkey = 0;
	}

	return evmask;
}
Ejemplo n.º 5
0
int aa_getevent(aa_context * c, int wait)
{
    int x, y, b;
    int ch;
    if (c->mousedriver != NULL) {
	c->mousedriver->getmouse(c, &x, &y, &b);
	if (x != c->mousex || y != c->mousey || b != c->buttons) {
	    c->mousex = x;
	    c->mousey = y;
	    c->buttons = b;
	    return (AA_MOUSE);
	}
    }
    if (c->kbddriver == NULL)
	return (AA_UNKNOWN);
    if (wait) {
	while ((ch = c->kbddriver->getkey(c, 1)) == AA_NONE) {
	    if (c->mousedriver != NULL) {
		c->mousedriver->getmouse(c, &x, &y, &b);
		if (x != c->mousex || y != c->mousey || b != c->buttons) {
		    c->mousex = x;
		    c->mousey = y;
		    c->buttons = b;
		    return (AA_MOUSE);
		}
	    }
	}
    } else
	ch = c->kbddriver->getkey(c, 0);
    if (ch == AA_RESIZE && c->resizehandler != NULL)
	c->resizehandler(c);
    if (ch == AA_MOUSE) {
	if (c->mousedriver != NULL) {
	    c->mousedriver->getmouse(c, &x, &y, &b);
	    if (x != c->mousex || y != c->mousey || b != c->buttons) {
		c->mousex = x;
		c->mousey = y;
		c->buttons = b;
		return (AA_MOUSE);
	    } else
		return (aa_getevent(c, wait));
	} else
	    return (AA_UNKNOWN);
    }
    return (ch);
}
Ejemplo n.º 6
0
static GstFlowReturn
gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer)
{
  GstAASink *aasink;

  aasink = GST_AASINK (basesink);

  GST_DEBUG ("render");

  gst_aasink_scale (aasink, GST_BUFFER_DATA (buffer),   /* src */
      aa_image (aasink->context),       /* dest */
      aasink->width,            /* sw */
      aasink->height,           /* sh */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);

  return GST_FLOW_OK;
}
Ejemplo n.º 7
0
static GstFlowReturn
gst_aasink_show_frame (GstVideoSink * videosink, GstBuffer * buffer)
{
  GstAASink *aasink;
  GstVideoFrame frame;

  aasink = GST_AASINK (videosink);

  GST_DEBUG ("show frame");

  if (!gst_video_frame_map (&frame, &aasink->info, buffer, GST_MAP_READ))
    goto invalid_frame;

  gst_aasink_scale (aasink, GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),     /* src */
      aa_image (aasink->context),       /* dest */
      GST_VIDEO_INFO_WIDTH (&aasink->info),     /* sw */
      GST_VIDEO_INFO_HEIGHT (&aasink->info),    /* sh */
      GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0), /* ss */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);
  gst_video_frame_unmap (&frame);

  return GST_FLOW_OK;

  /* ERRORS */
invalid_frame:
  {
    GST_DEBUG_OBJECT (aasink, "invalid frame");
    return GST_FLOW_ERROR;
  }
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
Archivo: aa.c Proyecto: chouquette/vlc
/**
 * 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;
        }
    }
}
Ejemplo n.º 10
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 );
}
static void
check_events(void) {
    /*
     * any events?
     * called by show_image and mplayer
     */
    int key;
    while ((key=aa_getevent(c,0))!=AA_NONE ){
	if (key>255){
	    /* some conversations */
	    switch (key) {
		case AA_UP:
		    mplayer_put_key(KEY_UP);
		    break;
		case AA_DOWN:
		    mplayer_put_key(KEY_DOWN);
		    break;
		case AA_LEFT:
		    mplayer_put_key(KEY_LEFT);
		    break;
		case AA_RIGHT:
		    mplayer_put_key(KEY_RIGHT);
		    break;
		case AA_ESC:
		    mplayer_put_key(KEY_ESC);
		    break;
		case 65765:
		    mplayer_put_key(KEY_PAGE_UP);
		    break;
		case 65766:
		    mplayer_put_key(KEY_PAGE_DOWN);
		    break;
		default:
		    continue; /* aa lib special key */
		    break;
	    }
	}
	if (key=='a' || key=='A'){
	    aaconfigmode=!aaconfigmode;
	    osdmessage(MESSAGE_DURATION, 1, "aa config mode is now %s",
		    aaconfigmode==1 ? "on. use keys 5-7" : "off");
	}
	if (aaconfigmode==1) {
	    switch (key) {
		/* AA image controls */
		case '5':
		    fast=!fast;
		    osdmessage(MESSAGE_DURATION, 1, "Fast mode is now %s", fast==1 ? "on" : "off");
		    break;
		case '6':
		    if (p->dither==AA_FLOYD_S){
			p->dither=AA_NONE;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Off");
		    }else if (p->dither==AA_NONE){
			p->dither=AA_ERRORDISTRIB;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Error Distribution");
		    }else if (p->dither==AA_ERRORDISTRIB){
			p->dither=AA_FLOYD_S;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Floyd Steinberg");
		    }
		    break;
		case '7':
		    p->inversion=!p->inversion;
		    osdmessage(MESSAGE_DURATION, 1, "Invert mode is now %s",
				p->inversion==1 ? "on" : "off");
		    break;

		default :
		    /* nothing if we're interested in?
		     * the mplayer should handle it!
		     */
		    mplayer_put_key(key);
		    break;
	    }
	}// aaconfigmode
	else mplayer_put_key(key);
    }
}