Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | TUD_HID_REPORT_DESC_GAMEPAD_SWADGE(...) |
HID Gamepad Report Descriptor Template with 32 buttons, 2 joysticks and 1 hat/dpad with following layout | X | Y | Z | Rz | Rx | Ry (1 byte each) | hat/DPAD (1 byte) | Button Map (4 bytes) |. | |
Functions | |
void | initUsb (fnSetSwadgeMode _setSwadgeMode, fnAdvancedUsbHandler _advancedUsbHandler, bool redirectPrintf) |
Initialize USB HID device. | |
void | initTusb (const tinyusb_config_t *tusb_cfg, const uint8_t *descriptor) |
Initialize TinyUSB. | |
void | deinitUsb (void) |
Deinitialize USB HID device Note, this does nothing as tinyusb_driver_uninstall() doesn't exist. | |
void | sendUsbGamepadReport (hid_gamepad_report_t *report) |
Send a USB gamepad report to the system. | |
bool | tud_hid_gamepad_report_ns (uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons) |
Send a USB gamepad report to a Switch. | |
uint8_t const * | tud_hid_descriptor_report_cb (uint8_t instance) |
uint16_t | tud_hid_get_report_cb (uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqLen) |
void | tud_hid_set_report_cb (uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) |
void | usbSetSwadgeMode (void *newMode) |
Set the Swadge mode to the given pointer. | |
#define TUD_HID_REPORT_DESC_GAMEPAD_SWADGE | ( | ... | ) |
HID Gamepad Report Descriptor Template with 32 buttons, 2 joysticks and 1 hat/dpad with following layout | X | Y | Z | Rz | Rx | Ry (1 byte each) | hat/DPAD (1 byte) | Button Map (4 bytes) |.
void initUsb | ( | fnSetSwadgeMode | _setSwadgeMode, |
fnAdvancedUsbHandler | _advancedUsbHandler, | ||
bool | redirectPrintf ) |
Initialize USB HID device.
_setSwadgeMode | A function that can be called from this component to set the Swadge mode |
_advancedUsbHandler | A function that can be called from this component to handle USB commands |
redirectPrintf | true to redirect printf() to USB, false to leave it over UART |
void initTusb | ( | const tinyusb_config_t * | tusb_cfg, |
const uint8_t * | descriptor ) |
Initialize TinyUSB.
tusb_cfg | The TinyUSB configuration |
descriptor | The descriptor to use for this configuration |
void deinitUsb | ( | void | ) |
Deinitialize USB HID device Note, this does nothing as tinyusb_driver_uninstall() doesn't exist.
void sendUsbGamepadReport | ( | hid_gamepad_report_t * | report | ) |
Send a USB gamepad report to the system.
report | The report to send, the current state of all gamepad inputs |
bool tud_hid_gamepad_report_ns | ( | uint8_t | report_id, |
int8_t | x, | ||
int8_t | y, | ||
int8_t | z, | ||
int8_t | rz, | ||
int8_t | rx, | ||
int8_t | ry, | ||
uint8_t | hat, | ||
uint16_t | buttons ) |
Send a USB gamepad report to a Switch.
report_id | Should be HID_ITF_PROTOCOL_NONE |
x | Unsure |
y | Unsure |
z | Unsure |
rz | Unsure |
rx | Unsure |
ry | Unsure |
hat | A bitmask of hid_gamepad_ns_hat_t |
buttons | A bitmask of hid_gamepad_ns_button_bm_t |
uint8_t const * tud_hid_descriptor_report_cb | ( | uint8_t | instance | ) |
Invoked when received GET HID REPORT DESCRIPTOR request Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
instance | The index to get a descriptor report for |
uint16_t tud_hid_get_report_cb | ( | uint8_t | instance, |
uint8_t | report_id, | ||
hid_report_type_t | report_type, | ||
uint8_t * | buffer, | ||
uint16_t | reqLen ) |
Invoked when received GET_REPORT control request Application must fill buffer report's content and return its length. Return zero will cause the stack to STALL request
instance | The endpoint index to handle a GET_REPORT |
report_id | The report ID |
report_type | Unused |
buffer | Pointer to a feature get request for the command set. |
reqLen | Number of bytes host is requesting from us. |
void tud_hid_set_report_cb | ( | uint8_t | instance, |
uint8_t | report_id, | ||
hid_report_type_t | report_type, | ||
uint8_t const * | buffer, | ||
uint16_t | bufsize ) |
Invoked when received SET_REPORT control request or received data on OUT endpoint ( Report ID = 0, Type = 0 )
instance | The endpoint index to handle a SET_REPORT request |
report_id | The report ID |
report_type | unused |
buffer | Pointer to full command |
bufsize | Total length of the buffer (command ID included) |
void usbSetSwadgeMode | ( | void * | newMode | ) |
Set the Swadge mode to the given pointer.
newMode | A pointer to the new mode to set |