You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/input/console_buttons.hpp
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,58 @@ enum JOYCON {
131
131
static_assert(BIT(JOYCON_B) == KEY_B);
132
132
static_assert(BIT(JOYCON_SELECT) == KEY_SELECT);
133
133
134
+
#elif defined(__WII__)
135
+
136
+
137
+
// some wii buttons, from (lib)wut, but since SDL doesn't handle inputs as flags, like (lib)wut), the have to be reversed and reversing 1 << x = log_2(x), this is done constexpr
138
+
139
+
140
+
namespace {
141
+
// this is rounding down since >> 1 throws away the least significant bit, but if its a power of two it is spot on
142
+
constexprunsignedintBIT_REVERSE(unsignedint x) {
143
+
return x == 1 ? 0 : 1 + BIT_REVERSE(x >> 1);
144
+
}
145
+
}; // namespace
146
+
147
+
148
+
#include<wut.h>
149
+
#include<padscore/wpad.h>
150
+
151
+
152
+
//using C enum (not enum class) on purpose
153
+
enum JOYCON {
154
+
155
+
// see /opt/devkitpro/wut/include/padscore/wpad.h
156
+
157
+
JOYCON_LEFT = BIT_REVERSE(WPAD_BUTTON_LEFT), ///! The left button of the D-pad.
158
+
JOYCON_RIGHT = BIT_REVERSE(WPAD_BUTTON_RIGHT), ///! The right button of the D-pad.
159
+
JOYCON_DOWN = BIT_REVERSE(WPAD_BUTTON_DOWN), ///! The down button of the D-pad.
160
+
JOYCON_UP = BIT_REVERSE(WPAD_BUTTON_UP), ///! The up button of the D-pad.
161
+
162
+
JOYCON_PLUS = BIT_REVERSE(WPAD_BUTTON_PLUS), ///! The + button.
163
+
JOYCON_MINUS = BIT_REVERSE(WPAD_BUTTON_MINUS), ///! The - button.
164
+
165
+
JOYCON_1 = BIT_REVERSE(WPAD_BUTTON_1), ///! The 1 button.
166
+
JOYCON_2 = BIT_REVERSE(WPAD_BUTTON_2), ///! The 2 button.
167
+
168
+
JOYCON_A = BIT_REVERSE(WPAD_BUTTON_A), ///! The A button.
169
+
JOYCON_B = BIT_REVERSE(WPAD_BUTTON_B), ///! The B button.
170
+
171
+
JOYCON_C = BIT_REVERSE(WPAD_BUTTON_C), ///! The C button on the Nunchuk extension.
172
+
JOYCON_Z = BIT_REVERSE(WPAD_BUTTON_Z), ///! The Z button on the Nunchuk extension.
173
+
174
+
JOYCON_HOME = BIT_REVERSE(WPAD_BUTTON_HOME), ///! The HOME button.
175
+
};
176
+
177
+
/// Creates a bitmask from a bit number.
178
+
#defineBIT(n) (1U<<(n))
179
+
180
+
// some static asserts to check if BIT_REVERSE works as expected
0 commit comments