Changeset 331 for libcaca/trunk/test
- Timestamp:
- Jan 9, 2004, 10:51:53 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/test/event.c
r330 r331 34 34 { 35 35 int *events; 36 int i, h ;36 int i, h, quit; 37 37 38 38 if(caca_init()) … … 49 49 memset(events, 0, h * sizeof(int)); 50 50 51 for( ;; )51 for(quit = 0; !quit; ) 52 52 { 53 53 unsigned int event = caca_wait_event(CACA_EVENT_ANY); … … 56 56 continue; 57 57 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); 60 70 61 71 caca_clear(); … … 64 74 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 65 75 caca_draw_line(0, 0, caca_get_width() - 1, 0, ' '); 66 print_event(0, 0, event );76 print_event(0, 0, events[0]); 67 77 68 78 /* Print previous events */ … … 70 80 for(i = 1; i < h && events[i]; i++) 71 81 print_event(0, i, events[i]); 72 73 /* q quits */74 if(event == (CACA_EVENT_KEY_PRESS | 'q'))75 break;76 82 77 83 caca_refresh(); … … 86 92 static void print_event(int x, int y, unsigned int event) 87 93 { 94 int character; 95 88 96 switch(event & 0xff000000) 89 97 { … … 92 100 break; 93 101 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 : '?'); 96 105 break; 97 106 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 : '?'); 100 110 break; 101 111 case CACA_EVENT_MOUSE_MOTION:
Note: See TracChangeset
for help on using the changeset viewer.