-
Notifications
You must be signed in to change notification settings - Fork 34
6) Adding support for more data types
This section describes how to add more datatypes to UNFLoader and the USB library.
Simply add a new datatype to usb.h through a #define, making sure to not use a number value that is already being used by another datatype.
Simply add the new datatype to the USBDataType enum in UNFLoader's device.h, making sure to use the exact same number used in the N64 usb.h header. Afterwards, go to debug.cpp and, in the debug_decidedata function, add your new datatype to the switch statement. In order to keep the code clean, it is recommended that you create a separate function and do all the handling of the USB data in there, as opposed to doing it in the switch statement itself.
The debug_decidedata function provides some useful variables for you, which are recommended to be passed to your helper function as arguments:
-
uint32_t size- The total size of the incoming data. -
byte* buffer- The buffer containing said data.
If your datatype relies on a value returned from a DATATYPE_HEADER call, you can use the debug_headerdata global variable to access said values. This global variable is a 16 integer array. For more information on how to use the DATATYPE_HEADER datatype, check out the Communication Protocol chapter of section 1) How UNFLoader Works. For a practical example, check out the debug_handle_screenshot function.