Ignore:
Timestamp:
Jan 9, 2004, 10:51:53 AM (17 years ago)
Author:
Sam Hocevar
Message:
  • test/event.c: + Do not refresh after each event, but only when there is no event

pending.

+ If the pressed key is a printable character, display it.

  • src/time.c: + Moved _caca_getticks() to this file.
  • src/caca.c: + Set the escape delay to a very low value in the ncurses driver,

because I don't want escape sequences to be entered manually.

  • src/io.c: + Autorepeat emulation in the ncurses and slang drivers: do not

immediately send the key release event.

  • configure.ac: + Check for usleep. + Improvements in the win32 platform detection.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test/event.c

    r330 r331  
    3434{
    3535    int *events;
    36     int i, h;
     36    int i, h, quit;
    3737
    3838    if(caca_init())
     
    4949    memset(events, 0, h * sizeof(int));
    5050
    51     for( ; ; )
     51    for(quit = 0; !quit; )
    5252    {
    5353        unsigned int event = caca_wait_event(CACA_EVENT_ANY);
     
    5656            continue;
    5757
    58         memmove(events + 1, events, (h - 1) * sizeof(int));
    59         events[0] = event;
     58        do
     59        {
     60            /* q quits */
     61            if(event == (CACA_EVENT_KEY_PRESS | 'q'))
     62                quit = 1;
     63
     64            memmove(events + 1, events, (h - 1) * sizeof(int));
     65            events[0] = event;
     66
     67            event = caca_get_event(CACA_EVENT_ANY);
     68        }
     69        while(event);
    6070
    6171        caca_clear();
     
    6474        caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
    6575        caca_draw_line(0, 0, caca_get_width() - 1, 0, ' ');
    66         print_event(0, 0, event);
     76        print_event(0, 0, events[0]);
    6777
    6878        /* Print previous events */
     
    7080        for(i = 1; i < h && events[i]; i++)
    7181            print_event(0, i, events[i]);
    72 
    73         /* q quits */
    74         if(event == (CACA_EVENT_KEY_PRESS | 'q'))
    75             break;
    7682
    7783        caca_refresh();
     
    8692static void print_event(int x, int y, unsigned int event)
    8793{
     94    int character;
     95
    8896    switch(event & 0xff000000)
    8997    {
     
    92100        break;
    93101    case CACA_EVENT_KEY_PRESS:
    94         caca_printf(x, y, "CACA_EVENT_KEY_PRESS 0x%02x",
    95                     event & 0x00ffffff);
     102        character = event & 0x00ffffff;
     103        caca_printf(x, y, "CACA_EVENT_KEY_PRESS 0x%02x (%c)", character,
     104                    (character > 0x20 && character < 0x80) ? character : '?');
    96105        break;
    97106    case CACA_EVENT_KEY_RELEASE:
    98         caca_printf(x, y, "CACA_EVENT_KEY_RELEASE 0x2%x",
    99                     event & 0x00ffffff);
     107        character = event & 0x00ffffff;
     108        caca_printf(x, y, "CACA_EVENT_KEY_RELEASE 0x%02x (%c)", character,
     109                    (character > 0x20 && character < 0x80) ? character : '?');
    100110        break;
    101111    case CACA_EVENT_MOUSE_MOTION:
Note: See TracChangeset for help on using the changeset viewer.