fork/GramFirmware

git clone https://git.julia.blue/fork/GramFirmware

CarVacrebase to configurator818d962

gram
3.3 KiB146 linesraw
1#ifndef _CORE_STATE_HPP
2#define _CORE_STATE_HPP
3
4#include "stdlib.hpp"
5
6#include <config.pb.h>
7
8typedef struct _InputState {
9    // Rectangle inputs.
10    union {
11        uint64_t buttons = 0;
12
13        struct {
14            bool lf1 : 1;
15            bool lf2 : 1;
16            bool lf3 : 1;
17            bool lf4 : 1;
18            bool lf5 : 1;
19            bool lf6 : 1;
20            bool lf7 : 1;
21            bool lf8 : 1;
22            bool lf9 : 1;
23            bool lf10 : 1;
24            bool lf11 : 1;
25            bool lf12 : 1;
26            bool lf13 : 1;
27            bool lf14 : 1;
28            bool lf15 : 1;
29            bool lf16 : 1;
30            bool rf1 : 1;
31            bool rf2 : 1;
32            bool rf3 : 1;
33            bool rf4 : 1;
34            bool rf5 : 1;
35            bool rf6 : 1;
36            bool rf7 : 1;
37            bool rf8 : 1;
38            bool rf9 : 1;
39            bool rf10 : 1;
40            bool rf11 : 1;
41            bool rf12 : 1;
42            bool rf13 : 1;
43            bool rf14 : 1;
44            bool rf15 : 1;
45            bool rf16 : 1;
46            bool lt1 : 1;
47            bool lt2 : 1;
48            bool lt3 : 1;
49            bool lt4 : 1;
50            bool lt5 : 1;
51            bool lt6 : 1;
52            bool lt7 : 1;
53            bool lt8 : 1;
54            bool rt1 : 1;
55            bool rt2 : 1;
56            bool rt3 : 1;
57            bool rt4 : 1;
58            bool rt5 : 1;
59            bool rt6 : 1;
60            bool rt7 : 1;
61            bool rt8 : 1;
62            bool mb1 : 1;
63            bool mb2 : 1;
64            bool mb3 : 1;
65            bool mb4 : 1;
66            bool mb5 : 1;
67            bool mb6 : 1;
68            bool mb7 : 1;
69            bool mb8 : 1;
70            bool mb9 : 1;
71            bool mb10 : 1;
72            bool mb11 : 1;
73            bool mb12 : 1;
74        };
75    };
76
77    // Nunchuk inputs.
78    union {
79        uint8_t nunchuk_buttons = 0;
80
81        struct {
82            bool nunchuk_connected : 1;
83            bool nunchuk_c : 1;
84            bool nunchuk_z : 1;
85        };
86    };
87
88    int8_t nunchuk_x = 0;
89    int8_t nunchuk_y = 0;
90} InputState;
91
92// State describing stick direction at the quadrant level.
93typedef struct {
94    bool horizontal;
95    bool vertical;
96    bool diagonal;
97    int8_t x;
98    int8_t y;
99    int8_t cx;
100    int8_t cy;
101} StickDirections;
102
103// Output state.
104typedef struct _OutputState {
105    // Digital outputs.
106    union {
107        uint32_t buttons = 0;
108
109        struct {
110            bool a : 1;
111            bool b : 1;
112            bool x : 1;
113            bool y : 1;
114            bool buttonL : 1;
115            bool buttonR : 1;
116            bool triggerLDigital : 1;
117            bool triggerRDigital : 1;
118            bool start : 1;
119            bool select : 1;
120            bool home : 1;
121            bool capture : 1;
122            bool dpadUp : 1;
123            bool dpadDown : 1;
124            bool dpadLeft : 1;
125            bool dpadRight : 1;
126            bool leftStickClick : 1;
127            bool rightStickClick : 1;
128        };
129    };
130
131    // Analog outputs.
132    union {
133        uint8_t analog_axes[6] = { 128, 128, 128, 128, 0, 0 };
134
135        struct {
136            uint8_t leftStickX;
137            uint8_t leftStickY;
138            uint8_t rightStickX;
139            uint8_t rightStickY;
140            uint8_t triggerLAnalog;
141            uint8_t triggerRAnalog;
142        };
143    };
144} OutputState;
145
146#endif