30 const int8_t index = getButtonIndexSwitchPro(b);
if (index < 0)
return 0;
35 const int8_t index = getButtonIndexSwitchPro(b);
if (index < 0)
return 0;
45 return switchProData.
leftHatX - 2048;
47 return 2048 - switchProData.
leftHatY;
73 else if (
buf[0] == 0x30) {
76 Notify(
PSTR(
"\r\nReport is too short: "), 0x80);
83 if (switchProData.
btn.
val != oldButtonState.
val) {
84 buttonClickState.
val = switchProData.
btn.
val & ~oldButtonState.val;
85 oldButtonState.
val = switchProData.
btn.
val;
89 }
else if (
buf[0] == 0x21) {
91 }
else if (
buf[0] == 0x81) {
113 if (
now - rumble_on_timer > 1000) {
114 rumble_on_timer =
now;
115 sendRumbleOutputReport();
120void SwitchProParser::sendOutputCmd() {
126 buf[0x01] = output_sequence_counter++;
130 buf[0x02 + 0] = 0x28;
131 buf[0x02 + 1] = 0x88;
132 buf[0x02 + 2] = 0x60;
133 buf[0x02 + 3] = 0x61;
135 buf[0x02 + 0] = 0x00;
136 buf[0x02 + 1] = 0x01;
137 buf[0x02 + 2] = 0x40;
138 buf[0x02 + 3] = 0x40;
143 buf[0x02 + 4] = 0x28;
144 buf[0x02 + 5] = 0x88;
145 buf[0x02 + 6] = 0x60;
146 buf[0x02 + 7] = 0x61;
148 buf[0x02 + 4] = 0x00;
149 buf[0x02 + 5] = 0x01;
150 buf[0x02 + 6] = 0x40;
151 buf[0x02 + 7] = 0x40;
159 buf[0x0A + 0] = 0x30;
169 buf[0x0A + 0] = 0x38;
172 buf[0x0A + 2] = (0xF << 4) | 0x0 ;
173 buf[0x0A + 3] = (0xF << 4) | 0x0 ;
180 buf[0x0A + 0] = 0x03;
181 buf[0x0A + 1] = 0x30;
186 buf[0x0A + 0] = 0x40;
194void SwitchProParser::sendRumbleOutputReport() {
200 buf[0x01] = output_sequence_counter++;
204 buf[0x02 + 0] = 0x28;
205 buf[0x02 + 1] = 0x88;
206 buf[0x02 + 2] = 0x60;
207 buf[0x02 + 3] = 0x61;
209 buf[0x02 + 0] = 0x00;
210 buf[0x02 + 1] = 0x01;
211 buf[0x02 + 2] = 0x40;
212 buf[0x02 + 3] = 0x40;
217 buf[0x02 + 4] = 0x28;
218 buf[0x02 + 5] = 0x88;
219 buf[0x02 + 6] = 0x60;
220 buf[0x02 + 7] = 0x61;
222 buf[0x02 + 4] = 0x00;
223 buf[0x02 + 5] = 0x01;
224 buf[0x02 + 6] = 0x40;
225 buf[0x02 + 7] = 0x40;
236 switchProData.
btn.
val = 0;
237 oldButtonState.
val = 0;
238 buttonClickState.
val = 0;
240 output_sequence_counter = 0;
const uint8_t SWITCH_PRO_BUTTONS[]
virtual void sendOutputReport(uint8_t *data, uint8_t len)=0
int16_t getAnalogHat(AnalogHatEnum a)
bool getButtonClick(ButtonEnum b)
bool getButtonPress(ButtonEnum b)
virtual void disableTimeout()
virtual void sendHandshake()
void Parse(uint8_t len, uint8_t *buf)
SwitchProOutput switchProOutput
constexpr int8_t ButtonIndex(ButtonEnum key)
bool enableFullReportMode
bool ledHomeReportChanged
#define pgm_read_byte(addr)