#include <stdint.h> | #include <stdint.h> | ||||
#if !defined(__MK66FX1M0__) && !defined(__IMXRT1052__) && !defined(__IMXRT1062__) | #if !defined(__MK66FX1M0__) && !defined(__IMXRT1052__) && !defined(__IMXRT1062__) | ||||
#error "USBHost_t36 only works with Teensy 3.6. Please select it in Tools > Boards" | |||||
#error "USBHost_t36 only works with Teensy 3.6 or Teensy 4.x. Please select it in Tools > Boards" | |||||
#endif | #endif | ||||
#include "utility/imxrt_usbhs.h" | #include "utility/imxrt_usbhs.h" | ||||
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} joytype_t; | |||||
typedef enum { UNKNOWN=0, PS3, PS4, XBOXONE, XBOX360, PS3_MOTION, SpaceNav} 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... |
{ 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 | ||||
{ 0x054C, 0x05C4, PS4, true}, {0x054C, 0x09CC, PS4, true } | |||||
{ 0x054C, 0x05C4, PS4, true}, {0x054C, 0x09CC, PS4, true }, | |||||
{ 0x046D, 0xC626, SpaceNav, true}, // 3d Connextion Space Navigator, 0x10008 | |||||
{ 0x046D, 0xC628, SpaceNav, true} // 3d Connextion Space Navigator, 0x10008 | |||||
}; | }; | ||||
hidclaim_t JoystickController::claim_collection(USBHIDParser *driver, Device_t *dev, uint32_t topusage) | hidclaim_t JoystickController::claim_collection(USBHIDParser *driver, Device_t *dev, uint32_t topusage) | ||||
{ | { | ||||
// only claim Desktop/Joystick and Desktop/Gamepad | // only claim Desktop/Joystick and Desktop/Gamepad | ||||
if (topusage != 0x10004 && topusage != 0x10005) return CLAIM_NO; | |||||
if (topusage != 0x10004 && topusage != 0x10005 && topusage != 0x10008) return CLAIM_NO; | |||||
// only claim from one physical device | // only claim from one physical device | ||||
if (mydevice != NULL && dev != mydevice) return CLAIM_NO; | if (mydevice != NULL && dev != mydevice) return CLAIM_NO; | ||||
void JoystickController::hid_input_data(uint32_t usage, int32_t value) | void JoystickController::hid_input_data(uint32_t usage, int32_t value) | ||||
{ | { | ||||
DBGPrintf("joystickType_=%d\n", joystickType_); | |||||
DBGPrintf("Joystick: usage=%X, value=%d\n", usage, value); | DBGPrintf("Joystick: usage=%X, value=%d\n", usage, value); | ||||
uint32_t usage_page = usage >> 16; | uint32_t usage_page = usage >> 16; | ||||
usage &= 0xFFFF; | usage &= 0xFFFF; |