blob: b686ebaba727c9f64d66c76b89b1841c04b53830 (
plain) (
blame)
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
|
#ifndef PERIPHERAL_H
#define PERIPHERAL_H
#include <pad.h>
#include <keyboard.h>
#include <mouse.h>
#include <util.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
enum peripheral_type
{
PERIPHERAL_TYPE_PAD,
PERIPHERAL_TYPE_TOUCH,
PERIPHERAL_TYPE_KEYBOARD_MOUSE
};
union peripheral
{
struct peripheral_common
{
enum peripheral_type type;
bool exit;
} common;
struct peripheral_pad
{
struct peripheral_common common;
struct pad pad;
} pad;
struct peripheral_kbm
{
struct peripheral_common common;
struct mouse mouse;
struct keyboard keyboard;
bool long_press;
unsigned lp_t;
} kbm;
};
struct peripheral_cfg
{
enum peripheral_type type;
int padn;
};
UTIL_STATIC_ASSERT(!offsetof(struct peripheral_pad, common),
"unexpected offsetof for struct peripheral_pad");
UTIL_STATIC_ASSERT(!offsetof(struct peripheral_kbm, common),
"unexpected offsetof for struct peripheral_kbm");
int peripheral_get_default(struct peripheral_cfg *cfg);
void peripheral_init(const struct peripheral_cfg *cfg, union peripheral *p);
void peripheral_input_set(union peripheral *p, void (*cb)(char, void *));
void peripheral_update(union peripheral *p);
#ifdef __cplusplus
}
#endif
#endif /* PERIPHERAL_H */
|