-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.h
86 lines (68 loc) · 1.32 KB
/
core.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef THUNDER_CORE_H
#define THUNDER_CORE_H
#include <stdbool.h>
#include <stdint.h>
/*
* time utils
*/
uint64_t now();
/*
* control event
*/
typedef enum {
MOVE_UP,
MOVE_DOWN,
MOVE_LEFT,
MOVE_RIGHT,
MOVE_NONE,
} Movement;
/*
* consider a contract rework where the controller and the sentry behavior are both just drivers of the
* same port, with the exception that the controller is capable of enabling/disabling sentry behavior
*/
typedef enum {
CONTROL_TYPE_MODE_TOGGLE,
CONTROL_TYPE_RELOAD,
// manual controls
CONTROL_TYPE_LED_TOGGLE,
CONTROL_TYPE_FIRE_BEGIN,
CONTROL_TYPE_FIRE_END,
CONTROL_TYPE_MOVEMENT,
// sentry controls
CONTROL_TYPE_SENTRY_MODE_TOGGLE, // passive, armed
} ControlType;
typedef struct {
ControlType type;
union {
Movement movement;
};
} ControlEvent;
/*
* face event
*/
typedef struct CapturedFace {
int x, y, width, height;
} CapturedFace;
#define CAPTURE_MAX_FACES 10
typedef struct {
uint16_t numFaces;
CapturedFace faces[CAPTURE_MAX_FACES];
} FaceEvent;
/*
* sending events
*/
typedef enum {
E_CONTROL,
E_FACE,
} EventType;
typedef struct {
EventType type;
uint64_t whenOccurred;
union {
ControlEvent control;
FaceEvent face;
};
} Event;
typedef struct Core* Core_t;
bool send(Core_t core, Event e);
#endif //THUNDER_CORE_H