-
Notifications
You must be signed in to change notification settings - Fork 0
/
WiiExpansions.h
161 lines (127 loc) · 3.15 KB
/
WiiExpansions.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// WiiExpansions - Arduino library to control Wii Remote expansion devices.
// Copyright Julien Lebunetel 2018
// MIT License
// ensure this library description is only included once
#ifndef WiiExpansions
#define WiiExpansions
// include description files for other libraries used
// library interface description
class Button
{
// user-accessible "public" interface
public:
Button() { value = false; previousValue = false; };
void set(bool value) { this->previousValue = this->value; this->value = value; };
bool get() { return value; };
bool isPressed() { return value; };
bool isReleased() { return !value; };
bool hasChanged() { return (value != previousValue); };
bool isJustPressed() { return (hasChanged() && isPressed()); };
bool isJustReleased() { return (hasChanged() && isReleased()); };
// library-accessible "private" interface
protected:
bool value;
bool previousValue;
};
class Potentiometer
{
// user-accessible "public" interface
public:
Potentiometer() { value = 0; previousValue = 0; };
void set(uint16_t value) { this->previousValue = this->value; this->value = value; };
uint16_t get() { return value; };
bool hasChanged() { return (value != previousValue); };
// library-accessible "private" interface
protected:
uint16_t value;
uint16_t previousValue;
};
class WiiExpansion
{
// user-accessible "public" interface
public:
WiiExpansion();
void init();
void read();
// library-accessible "protected" interface
protected:
byte data[6];
};
class WiiNunchuk : public WiiExpansion
{
// user-accessible "public" interface
public:
// WiiNunchuk();
void init();
void read();
void print();
Button C;
Button Z;
Potentiometer stick_X;
Potentiometer stick_Y;
Potentiometer accelerometer_X;
Potentiometer accelerometer_Y;
Potentiometer accelerometer_Z;
};
class WiiClassicController : public WiiExpansion
{
// user-accessible "public" interface
public:
//WiiClassicController();
void init();
void read();
void print();
Button L;
Button R;
Button select;
Button home;
Button start;
Button X;
Button Y;
Button A;
Button B;
Button ZL;
Button ZR;
Button pad_L;
Button pad_R;
Button pad_U;
Button pad_D;
Potentiometer stick_LX;
Potentiometer stick_LY;
Potentiometer stick_RX;
Potentiometer stick_RY;
Potentiometer bumper_L;
Potentiometer bumper_R;
};
class WiiGuitar : public WiiExpansion
{
// user-accessible "public" interface
public:
// WiiGuitar();
void init();
void read();
void print();
Button strum_bar_down;
Button strum_bar_up;
Button bridge;
Button plus_button;
Button green;
Button red;
Button yellow;
Button blue;
Button orange;
Potentiometer stick_X;
Potentiometer stick_Y;
Potentiometer touch_bar;
Potentiometer whammy_bar;
Button touch_bar_0;
Button touch_bar_1;
Button touch_bar_2;
Button touch_bar_3;
Button touch_bar_4;
Button touch_bar_5;
Button touch_bar_6;
Button touch_bar_7;
Button touch_bar_8;
};
#endif