Verbesserte Rotor-Sprites.
[hackover2013-badge-firmware.git] / badge / ui / event.h
1 #ifndef INCLUDED_BADGE2013_BADGE_UI_EVENT_H
2 #define INCLUDED_BADGE2013_BADGE_UI_EVENT_H
3
4 #include <stdint.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 enum {
11 BADGE_EVENT_USER_INPUT,
12 BADGE_EVENT_GAME_TICK,
13 };
14
15 enum {
16 BADGE_EVENT_KEY_UP = 1,
17 BADGE_EVENT_KEY_LEFT = 2,
18 BADGE_EVENT_KEY_DOWN = 4,
19 BADGE_EVENT_KEY_RIGHT = 8,
20 BADGE_EVENT_KEY_CENTER = 16,
21 BADGE_EVENT_KEY_BTN_A = 32,
22 BADGE_EVENT_KEY_BTN_B = 64
23 };
24
25 typedef uint16_t badge_event_t;
26
27 static inline uint8_t badge_event_type (badge_event_t event) { return (uint8_t) (event & 0x03); }
28 static inline uint8_t badge_event_old_input_state(badge_event_t event) { return (uint8_t) (event >> 2 & 0x7f); }
29 static inline uint8_t badge_event_new_input_state(badge_event_t event) { return (uint8_t) (event >> 9 ); }
30
31 uint8_t badge_input_raw(void);
32 uint8_t badge_event_current_input_state(void);
33
34 static inline badge_event_t badge_event_new(uint8_t type, uint8_t old_input_state, uint8_t new_input_state) {
35 return (badge_event_t) ((type & 0x3) | ((badge_event_t) (old_input_state & 0x7f) << 2) | ((badge_event_t) (new_input_state & 0x7f) << 9));
36 }
37
38 badge_event_t badge_event_wait(void);
39 void badge_event_start(void);
40
41 #ifdef __cplusplus
42 }
43 #endif
44
45 #endif
This page took 0.041631 seconds and 5 git commands to generate.