80 return xboxButtonState;
97 }
else if (b ==
XBOX) {
98 bool click = xboxbuttonClickState;
99 xboxbuttonClickState = 0;
103 bool click = buttonClickState.
val & mask;
104 buttonClickState.
val &= ~mask;
109 return xboxOneSData.
hatValue[(uint8_t)a] - 32768;
113 if (len > 1 && buf) {
116 for (uint8_t i = 0; i < len; i++) {
117 D_PrintHex<uint8_t > (buf[i], 0x80);
123 memcpy(&xboxOneSData, buf + 1, min((uint8_t)(len - 1),
MFK_CASTUINT8T sizeof(xboxOneSData)));
124 else if (buf[0] == 0x02) {
125 xboxButtonState = buf[1];
126 if(xboxButtonState != xboxOldButtonState) {
127 xboxbuttonClickState = xboxButtonState & ~xboxOldButtonState;
128 xboxOldButtonState = xboxButtonState;
131 }
else if (buf[0] == 0x04)
134 #ifdef DEBUG_USB_HOST 135 Notify(
PSTR(
"\r\nUnknown report id: "), 0x80);
136 D_PrintHex<uint8_t > (buf[0], 0x80);
141 if (xboxOneSData.
btn.
val != oldButtonState.
val) {
142 buttonClickState.
val = xboxOneSData.
btn.
val & ~oldButtonState.
val;
143 oldButtonState.
val = xboxOneSData.
btn.
val;
149 if (checkDpad(
RIGHT))
150 newDpad |= 1 <<
RIGHT;
152 newDpad |= 1 <<
DOWN;
154 newDpad |= 1 <<
LEFT;
155 if (newDpad != oldDpad) {
156 buttonClickState.
dpad = newDpad & ~oldDpad;
162 if(xboxOneSData.
trigger[0] != 0 && triggerOld[0] == 0)
164 triggerOld[0] = xboxOneSData.
trigger[0];
165 if(xboxOneSData.
trigger[1] != 0 && triggerOld[1] == 0)
167 triggerOld[1] = xboxOneSData.
trigger[1];
173 for (i = 0; i <
sizeof(xboxOneSData.
hatValue) /
sizeof(xboxOneSData.
hatValue[0]); i++)
176 oldButtonState.
val = 0;
177 for (i = 0; i <
sizeof(xboxOneSData.
trigger) /
sizeof(xboxOneSData.
trigger[0]); i++)
182 buttonClickState.
dpad = 0;
187 void XBOXONESParser::setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor) {
191 buf[1] = leftTrigger;
192 buf[2] = rightTrigger;
198 sendOutputReport(buf,
sizeof(buf));
bool getButtonClick(ButtonEnum b)
int16_t getAnalogHat(AnalogHatEnum a)
#define pgm_read_byte(addr)
uint16_t getButtonPress(ButtonEnum b)
void Parse(uint8_t len, uint8_t *buf)
const uint8_t XBOX_ONE_S_BUTTONS[]