7 #define XBOX360_INPUT_MAP(XX) \
8 XX(dpad_up, bool, 1, 0x01) \
9 XX(dpad_down, bool, 1, 0x01) \
10 XX(dpad_left, bool, 1, 0x01) \
11 XX(dpad_right, bool, 1, 0x01) \
12 XX(btn_start, bool, 1, 0x01) \
13 XX(btn_back, bool, 1, 0x01) \
14 XX(btn_stick_left, bool, 1, 0x01) \
15 XX(btn_stick_right, bool, 1, 0x01) \
16 XX(btn_trig_left, bool, 1, 0x01) \
17 XX(btn_trig_right, bool, 1, 0x01) \
18 XX(btn_mode, bool, 1, 0x01) \
19 XX(btn_unk1, bool, 1, 0x01) \
20 XX(btn_a, bool, 1, 0x01) \
21 XX(btn_b, bool, 1, 0x01) \
22 XX(btn_x, bool, 1, 0x01) \
23 XX(btn_y, bool, 1, 0x01) \
24 XX(trig_left, uint8_t, 8, 0xff) \
25 XX(trig_right, uint8_t, 8, 0xff) \
26 XX(stick_left_x, int16_t, 16, 0xff00) \
27 XX(stick_left_y, int16_t, 16, 0xff00) \
28 XX(stick_right_x, int16_t, 16, 0xff00) \
29 XX(stick_right_y, int16_t, 16, 0xff00)
37 #define XX(tag, ...) tag,
47 #define XX(tag, type, size, ...) type tag : size;
54 #define XX(tag, ...) \
87 bool rumble(uint8_t strong, uint8_t weak);
91 inputChangeCallback = callback;
106 bool control(tusb_request_recipient_t recipient, uint16_t value, uint16_t length);
107 void control_cb(tuh_xfer_t& xfer);
108 void process_packet();
109 bool output(
const void* data, uint8_t length);
111 static void static_control_cb(tuh_xfer_t* xfer)
113 auto self =
reinterpret_cast<Xbox*
>(xfer->user_data);
114 self->control_cb(*xfer);
117 static constexpr
size_t bufSize{64};
118 InputData inputData{};
120 uint8_t controlBuffer[20]{};
121 uint8_t dataBuffer[bufSize];
122 uint8_t outputBuffer[8];
#define XX(name, comment)
Definition: DirectoryTemplate.h:47
Manage a set of bit values using enumeration.
Definition: BitSet.h:45
Instance inst
Definition: HostInterface.h:84
Base class to use for custom devices.
Definition: VENDOR/HostDevice.h:32
static const char * getInputName(Xbox::Input input)
bool setled(LedCommand cmd)
bool begin(const Instance &inst, const Config &cfg)
const InputData & inputs() const
Definition: xbox.h:94
Delegate< void(InputMask changed)> InputChange
Definition: xbox.h:44
bool setConfig(uint8_t itf_num) override
Set active configuration.
bool transferComplete(const Transfer &txfr) override
Called when a non-control USB transfer has completed.
bool rumble(uint8_t strong, uint8_t weak)
Input
Definition: xbox.h:36
LedCommand
Definition: xbox.h:65
void onChange(InputChange callback)
Definition: xbox.h:89
Definition: Libraries/USB/src/USB/VENDOR/Device.h:26
Buffer containing list of descriptors.
Definition: Descriptors.h:78
Identifies a TinyUSB host interface.
Definition: HostInterface.h:35
Device configuration received during mount procedure.
Definition: VENDOR/HostDevice.h:37
Structure passed to 'transferComplete' method.
Definition: VENDOR/HostDevice.h:46
#define XBOX360_INPUT_MAP(XX)
Definition: xbox.h:7