101 goto FailUnknownDevice;
118 #ifdef DEBUG_USB_HOST
120 D_PrintHex<uint8_t > (rcode, 0x80);
126 D_PrintHex<uint8_t > (
bAddress, 0x80);
142 goto FailSetDevTblEntry;
164 goto FailSetDevTblEntry;
170 goto FailSetConfDescr;
172 #ifdef DEBUG_USB_HOST
173 Notify(
PSTR(
"\r\nXbox One Controller Connected\r\n"), 0x80);
181 rcode = XboxCommand(writeBuf, 2);
192 #ifdef DEBUG_USB_HOST
198 #ifdef DEBUG_USB_HOST
204 #ifdef DEBUG_USB_HOST
210 #ifdef DEBUG_USB_HOST
216 #ifdef DEBUG_USB_HOST
217 Notify(
PSTR(
"\r\nXbox One Init Failed, error code: "), 0x80);
230 #ifdef DEBUG_USB_HOST
231 Notify(
PSTR(
"\r\nXbox One Controller Disconnected\r\n"), 0x80);
247 #ifdef DEBUG_USB_HOST
248 else if (rcode != 0x04) {
249 Notify(
PSTR(
"\r\nXbox One Poll Failed, error code: "), 0x80);
256 void XBOXONE::readReport() {
259 if(readBuf[0] == 0x07) {
266 if(readBuf[0] != 0x20) {
269 D_PrintHex<uint8_t > (readBuf[0], 0x80);
276 ButtonState = xbox | (((uint16_t)readBuf[5] & 0xF) << 8) | (readBuf[4] & 0xF0) | (((uint16_t)readBuf[4] & 0x0C) << 10) | ((readBuf[4] & 0x01) << 3) | (((uint16_t)readBuf[5] & 0xC0) << 8) | ((readBuf[5] & 0x30) >> 4);
278 triggerValue[0] = (uint16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
279 triggerValue[1] = (uint16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
281 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
282 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
283 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]);
284 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]);
289 if(ButtonState != OldButtonState) {
290 ButtonClickState = ButtonState & ~OldButtonState;
291 OldButtonState = ButtonState;
295 if(triggerValue[0] != 0 && triggerValueOld[0] == 0)
297 triggerValueOld[0] = triggerValue[0];
298 if(triggerValue[1] != 0 && triggerValueOld[1] == 0)
300 triggerValueOld[1] = triggerValue[1];
303 void XBOXONE::printReport() {
308 D_PrintHex<uint8_t > (readBuf[i], 0x80);
317 return triggerValue[0];
319 return triggerValue[1];
320 return (
bool)(ButtonState & ((uint16_t)
pgm_read_word(&XBOX_BUTTONS[(uint8_t)b])));
338 bool click = (ButtonClickState & button);
339 ButtonClickState &= ~button;
348 uint8_t XBOXONE::XboxCommand(uint8_t* data, uint16_t nbytes) {
350 #ifdef DEBUG_USB_HOST
351 Notify(
PSTR(
"\r\nXboxCommand, Return: "), 0x80);
352 D_PrintHex<uint8_t > (rcode, 0x80);
357 void XBOXONE::onInit() {
370 XboxCommand(writeBuf, 11);
#define USB_ERROR_EPINFO_IS_NULL
#define pgm_read_word(addr)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
EpInfo epInfo[XBOX_MAX_ENDPOINTS]
#define USB_TRANSFER_TYPE_INTERRUPT
#define NotifyFailGetDevDescr(...)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
virtual void FreeAddress(uint8_t addr)=0
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailUnknownDevice(...)
#define USB_NAK_MAX_POWER
virtual uint8_t Release()
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid)
uint16_t getButtonPress(ButtonEnum b)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
bool getButtonClick(ButtonEnum b)
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
#define XBOX_MAX_ENDPOINTS
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
#define XBOX_CONTROL_PIPE
int16_t getAnalogHat(AnalogHatEnum a)
const uint16_t XBOX_BUTTONS[]
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
#define NotifyFailSetConfDescr(...)
#define XBOX_REPORT_BUFFER_SIZE
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
#define NotifyFailSetDevTblEntry(...)