fuzev2: prevent button light flickering when accessing µSD
[kugel-rb.git] / apps / plugins / rockboy / events.c
blobc018f7ce53610725e54c4fe3772dc15044f8966e
1 /*
2 * events.c
4 * Event queue.
5 */
8 #include "rockmacros.h"
9 #include "input.h"
11 #define MAX_EVENTS 32
13 static event_t eventqueue[MAX_EVENTS];
14 static int eventhead, eventpos;
17 int ev_postevent(event_t *ev)
19 int nextevent;
20 nextevent = (eventhead+1)%MAX_EVENTS;
21 if (nextevent == eventpos)
22 return 0;
23 eventqueue[eventhead] = *ev;
24 eventhead = nextevent;
25 return 1;
28 int ev_getevent(event_t *ev)
30 if (eventpos == eventhead)
32 ev->type = EV_NONE;
33 return 0;
35 *ev = eventqueue[eventpos];
36 eventpos = (eventpos+1)%MAX_EVENTS;
37 return 1;