forked from hifi/xwiigun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xwiigun.h
68 lines (52 loc) · 1.47 KB
/
xwiigun.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
#include <stdint.h>
#include <time.h>
#include <xwiimote.h>
#include <poll.h>
enum {
SIDE_INVALID = -1,
SIDE_TOP = 0,
SIDE_RIGHT = 1,
SIDE_BOTTOM = 2,
SIDE_LEFT = 3,
};
struct xwiigun
{
// if polling should block or not, defaults to false
bool blocking;
// rumble when trigger is pressed
bool trigger_rumble;
// relative cursor position [0.0f - 1.0f]
double hpos, vpos;
// calculated screen aspect ratio
double ar;
// if gun is pointed outside the screen
bool offscreen;
// pressed down key data
uint8_t keys[XWII_KEY_NUM];
// time when calibration was last successful
time_t calibrated;
// adjustable IR camera center
struct xwii_event_abs center;
// IR state
struct {
// previous visible IR points for tracking
struct xwii_event_abs prev[4];
// current visible IR points
struct xwii_event_abs now[4];
// calibration "diamond", updated when all IR points are visible
struct xwii_event_abs cal[4];
// adjusted IR points from now and cal
struct xwii_event_abs adj[4];
} ir;
// current acceleration data
struct xwii_event_abs accel;
// xwiimote state
struct {
struct pollfd fds[2];
struct xwii_monitor *monitor;
struct xwii_iface *iface;
} xwii;
};
int xwiigun_open(struct xwiigun *gun);
int xwiigun_poll(struct xwiigun *gun);
int xwiigun_close(struct xwiigun *gun);