It shows up with name XBox360 for Windows (at least the version I have)... But at least it is starting to give some datamain
// your best effort to read chapter 4 before asking USB questions! | // your best effort to read chapter 4 before asking USB questions! | ||||
//#define USBHOST_PRINT_DEBUG | |||||
#define USBHOST_PRINT_DEBUG | |||||
//#define USBHDBGSerial Serial1 | //#define USBHDBGSerial Serial1 | ||||
#ifndef USBHDBGSerial | #ifndef USBHDBGSerial | ||||
bool setLEDs(uint8_t lr, uint8_t lg, uint8_t lb); // sets Leds, | 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 | 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) }; | 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_;} | 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... | // PS3 pair function. hack, requires that it be connect4ed by USB and we have the address of the Bluetooth dongle... |
#define println USBHost::println_//#define DEBUG_BT | #define println USBHost::println_//#define DEBUG_BT | ||||
#define DEBUG_BT | #define DEBUG_BT | ||||
#define DEBUG_BT_VERBOSE | |||||
//#define DEBUG_BT_VERBOSE | |||||
#ifndef DEBUG_BT | #ifndef DEBUG_BT | ||||
#undef DEBUG_BT_VERBOSE | #undef DEBUG_BT_VERBOSE |
// | // | ||||
// This example is in the public domain | // 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" | #include "USBHost_t36.h" | ||||
case JoystickController::XBOXONE: | case JoystickController::XBOXONE: | ||||
case JoystickController::XBOX360: | case JoystickController::XBOX360: | ||||
case JoystickController::SWITCH: | |||||
ltv = joystick.getAxis(4); | ltv = joystick.getAxis(4); | ||||
rtv = joystick.getAxis(5); | rtv = joystick.getAxis(5); | ||||
if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) { | if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) { | ||||
tft.print(top, HEX); | tft.print(top, HEX); | ||||
tft.print(") key release:"); | tft.print(") key release:"); | ||||
tft.println(key, HEX); | tft.println(key, HEX); | ||||
} | |||||
} |
JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = { | JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = { | ||||
{ 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false }, | { 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false }, | ||||
{ 0x045e, 0x0719, XBOX360, false}, | { 0x045e, 0x0719, XBOX360, false}, | ||||
{ 0x045e, 0x028E, XBOX360, false}, // Switch? | |||||
{ 0x045e, 0x028E, SWITCH, false}, // Switch? | |||||
{ 0x054C, 0x0268, PS3, true}, | { 0x054C, 0x0268, PS3, true}, | ||||
{ 0x054C, 0x042F, PS3, true}, // PS3 Navigation controller | { 0x054C, 0x042F, PS3, true}, // PS3 Navigation controller | ||||
{ 0x054C, 0x03D5, PS3_MOTION, true}, // PS3 Motion controller | { 0x054C, 0x03D5, PS3_MOTION, true}, // PS3 Motion controller | ||||
int16_t axis[4]; | int16_t axis[4]; | ||||
} xbox360data_t; | } 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}; | static const uint8_t xbox_axis_order_mapping[] = {3, 4, 0, 1, 2, 5}; | ||||
void JoystickController::rx_data(const Transfer_t *transfer) | void JoystickController::rx_data(const Transfer_t *transfer) | ||||
{ | { | ||||
#ifdef DEBUG_JOYSTICK | |||||
print("JoystickController::rx_data (", joystickType_, DEC); | print("JoystickController::rx_data (", joystickType_, DEC); | ||||
print("): "); | print("): "); | ||||
print_hexbytes((uint8_t*)transfer->buffer, transfer->length); | print_hexbytes((uint8_t*)transfer->buffer, transfer->length); | ||||
#endif | |||||
if (joystickType_ == XBOXONE) { | if (joystickType_ == XBOXONE) { | ||||
// Process XBOX One data | // Process XBOX One data | ||||
if (anychange) joystickEvent = true; | 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); | queue_Data_Transfer(rxpipe_, rxbuf_, rx_size_, this); |
PS4 LITERAL1 | PS4 LITERAL1 | ||||
XBOXONE LITERAL1 | XBOXONE LITERAL1 | ||||
XBOX360 LITERAL1 | XBOX360 LITERAL1 | ||||
SWITCH LITERAL1 | |||||
# USBSerial | # USBSerial | ||||
USBHOST_SERIAL_7E1 LITERAL1 | USBHOST_SERIAL_7E1 LITERAL1 | ||||
USBHOST_SERIAL_7O1 LITERAL1 | USBHOST_SERIAL_7O1 LITERAL1 |