It shows up with name XBox360 for Windows (at least the version I have)... But at least it is starting to give some datamain
| @@ -57,7 +57,7 @@ | |||
| // your best effort to read chapter 4 before asking USB questions! | |||
| //#define USBHOST_PRINT_DEBUG | |||
| #define USBHOST_PRINT_DEBUG | |||
| //#define USBHDBGSerial Serial1 | |||
| #ifndef USBHDBGSerial | |||
| @@ -918,7 +918,7 @@ public: | |||
| bool setLEDs(uint8_t lr, uint8_t lg, uint8_t lb); // sets Leds, | |||
| bool inline setLEDs(uint32_t leds) {return setLEDs((leds >> 16) & 0xff, (leds >> 8) & 0xff, leds & 0xff);} // sets Leds - passing one arg for all leds | |||
| enum { STANDARD_AXIS_COUNT = 10, ADDITIONAL_AXIS_COUNT = 54, TOTAL_AXIS_COUNT = (STANDARD_AXIS_COUNT+ADDITIONAL_AXIS_COUNT) }; | |||
| typedef enum { UNKNOWN=0, PS3, PS4, XBOXONE, XBOX360, PS3_MOTION, SpaceNav} joytype_t; | |||
| typedef enum { UNKNOWN=0, PS3, PS4, XBOXONE, XBOX360, PS3_MOTION, SpaceNav, SWITCH} joytype_t; | |||
| joytype_t joystickType() {return joystickType_;} | |||
| // PS3 pair function. hack, requires that it be connect4ed by USB and we have the address of the Bluetooth dongle... | |||
| @@ -31,7 +31,7 @@ | |||
| #define println USBHost::println_//#define DEBUG_BT | |||
| #define DEBUG_BT | |||
| #define DEBUG_BT_VERBOSE | |||
| //#define DEBUG_BT_VERBOSE | |||
| #ifndef DEBUG_BT | |||
| #undef DEBUG_BT_VERBOSE | |||
| @@ -17,7 +17,7 @@ | |||
| // | |||
| // This example is in the public domain | |||
| //============================================================================= | |||
| #define USE_ST77XX // define this if you wish to use one of these displays. | |||
| //#define USE_ST77XX // define this if you wish to use one of these displays. | |||
| #include "USBHost_t36.h" | |||
| @@ -489,6 +489,7 @@ void ProcessJoystickData() { | |||
| case JoystickController::XBOXONE: | |||
| case JoystickController::XBOX360: | |||
| case JoystickController::SWITCH: | |||
| ltv = joystick.getAxis(4); | |||
| rtv = joystick.getAxis(5); | |||
| if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) { | |||
| @@ -988,4 +989,4 @@ void OnHIDExtrasRelease(uint32_t top, uint16_t key) | |||
| tft.print(top, HEX); | |||
| tft.print(") key release:"); | |||
| tft.println(key, HEX); | |||
| } | |||
| } | |||
| @@ -40,7 +40,7 @@ | |||
| JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = { | |||
| { 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false }, | |||
| { 0x045e, 0x0719, XBOX360, false}, | |||
| { 0x045e, 0x028E, XBOX360, false}, // Switch? | |||
| { 0x045e, 0x028E, SWITCH, false}, // Switch? | |||
| { 0x054C, 0x0268, PS3, true}, | |||
| { 0x054C, 0x042F, PS3, true}, // PS3 Navigation controller | |||
| { 0x054C, 0x03D5, PS3_MOTION, true}, // PS3 Motion controller | |||
| @@ -648,13 +648,31 @@ typedef struct { | |||
| int16_t axis[4]; | |||
| } xbox360data_t; | |||
| typedef struct { | |||
| uint8_t state; | |||
| uint8_t id_or_type; | |||
| // From online references button order: | |||
| // sync, dummy, start, back, a, b, x, y | |||
| // dpad up, down left, right | |||
| // lb, rb, left stick, right stick | |||
| // Axis: | |||
| // lt, rt, lx, ly, rx, ry | |||
| // | |||
| uint16_t buttons; | |||
| uint8_t lt; | |||
| uint8_t rt; | |||
| int16_t axis[4]; | |||
| } switchdataUSB_t; | |||
| static const uint8_t xbox_axis_order_mapping[] = {3, 4, 0, 1, 2, 5}; | |||
| void JoystickController::rx_data(const Transfer_t *transfer) | |||
| { | |||
| #ifdef DEBUG_JOYSTICK | |||
| print("JoystickController::rx_data (", joystickType_, DEC); | |||
| print("): "); | |||
| print_hexbytes((uint8_t*)transfer->buffer, transfer->length); | |||
| #endif | |||
| if (joystickType_ == XBOXONE) { | |||
| // Process XBOX One data | |||
| @@ -733,6 +751,36 @@ void JoystickController::rx_data(const Transfer_t *transfer) | |||
| if (anychange) joystickEvent = true; | |||
| } | |||
| } else if (joystickType_ == SWITCH) { | |||
| switchdataUSB_t *switchd = (switchdataUSB_t *)transfer->buffer; | |||
| if (buttons != switchd->buttons) { | |||
| buttons = switchd->buttons; | |||
| anychange = true; | |||
| } | |||
| axis_mask_ = 0x3f; | |||
| axis_changed_mask_ = 0; // assume none for now | |||
| for (uint8_t i = 0; i < 4; i++) { | |||
| if (axis[i] != switchd->axis[i]) { | |||
| axis[i] = switchd->axis[i]; | |||
| axis_changed_mask_ |= (1 << i); | |||
| anychange = true; | |||
| } | |||
| } | |||
| // the two triggers show up as 4 and 5 | |||
| if (axis[4] != switchd->lt) { | |||
| axis[4] = switchd->lt; | |||
| axis_changed_mask_ |= (1 << 4); | |||
| anychange = true; | |||
| } | |||
| if (axis[5] != switchd->rt) { | |||
| axis[5] = switchd->rt; | |||
| axis_changed_mask_ |= (1 << 5); | |||
| anychange = true; | |||
| } | |||
| if (anychange) joystickEvent = true; | |||
| } | |||
| queue_Data_Transfer(rxpipe_, rxbuf_, rx_size_, this); | |||
| @@ -95,7 +95,7 @@ PS3_MOTION LITERAL1 | |||
| PS4 LITERAL1 | |||
| XBOXONE LITERAL1 | |||
| XBOX360 LITERAL1 | |||
| SWITCH LITERAL1 | |||
| # USBSerial | |||
| USBHOST_SERIAL_7E1 LITERAL1 | |||
| USBHOST_SERIAL_7O1 LITERAL1 | |||