|
whiskers 0.4.0
RP2350 BadUSB Tool
|
High-level code for setting up the USB stack.
This code is meant to setup all the USB stack functions in a high-level way. Typically, these are just wrappers for the underlying HAL functions.
Note that with the implementation of Lua being on a seperate core, flags will have to be set so that all of the USB stuff is setup on the same core to prevent memory corruption.
Go to the source code of this file.
Macros | |
| #define | whiskers_usb_task() |
| Wrapper for HAL usb_loop(). | |
| #define | whiskers_send_report(x) |
| Wrapper for HAL usb_keyboard_send_report(). | |
| #define | whiskers_msc_setup(x, y, z) |
| Wrapper for HAL usb_setup_msc(). | |
Functions | |
| bool | whiskers_usb_started () |
| Checks if USB has been started or not. | |
| bool | whiskers_usb_enabled () |
| Checks if USB is enabled or not. | |
| void | whiskers_enable_usb (w_usb_mods *mods) |
| Enables USB. Called by Lua typically. | |
| void | whiskers_start_usb () |
| Starts the USB stack with default values (being the descriptors). | |
| void | whiskers_send_reset_report () |
| Sends a HID reset report (all 8 bytes being zero). | |
| void | whiskers_send_ascii_string (char *str, size_t len) |
| Sends a ascii string via USB. | |
| uint8_t | whiskers_char_to_scancode (char key) |
| Converts a character into it's corresponding key. | |
| uint8_t | whiskers_ascii_to_modbyte (char *mods, size_t len) |
| Converts a string of modifier words into a single modbyte. | |
| uint8_t | whiskers_ascii_to_special_key (char *key, size_t len) |
| Converts a special key string (ie. ENTER, ESCAPE, PRINTSCRN) into it's respective opcode. | |
| #define whiskers_msc_setup | ( | x, | |
| y, | |||
| z ) |
Wrapper for HAL usb_setup_msc().
| #define whiskers_send_report | ( | x | ) |
Wrapper for HAL usb_keyboard_send_report().
| #define whiskers_usb_task | ( | ) |
Wrapper for HAL usb_loop().
| uint8_t whiskers_ascii_to_modbyte | ( | char * | mods, |
| size_t | len ) |
Converts a string of modifier words into a single modbyte.
| mods | String containing modifier words like LSHIFT and LALT. |
| len | Length of modifier string. |
Acceptable modifier words are: LCTRL, LSHIFT, LALT, LWIN, RCTRL, RSHIFT, RALT, RWIN.
For combining multiple into one modifier byte add a '+' between each word like: LALT+LSHIFT.
| uint8_t whiskers_ascii_to_special_key | ( | char * | key, |
| size_t | len ) |
Converts a special key string (ie. ENTER, ESCAPE, PRINTSCRN) into it's respective opcode.
| *key | String containing the special key. |
| len | Length of the key string. |
Accepted keys are:
ENTER, ESCAPE, BACKSPACE, TAB, CAPSLOCK, F1-24, NUMLOCK, END, DOWNARROW, PAGEDN, LEFTARROW, RIGHTARROW, HOME, UPARROW, PAGEUP, INSERT, DELETE.
The modifier keys can be used to but instead of the standard modifier bit mask it will return the literal scancode for those keys. The list for those is:
LCTRL, LSHIFT, LALT, LWIN, RCTRL, RSHIFT, RALT, RWIN.
I understand that there are a whole list of other special keys out there. If you want to use them, I recommend sending the raw scancodes instead as the more I add to the list above the longer and worse the resulting code gets.
| uint8_t whiskers_char_to_scancode | ( | char | key | ) |
Converts a character into it's corresponding key.
| key | A single character. |
| void whiskers_enable_usb | ( | w_usb_mods * | mods | ) |
Enables USB. Called by Lua typically.
| *mods | USB mods to be applied. Set to NULL for default configuration. |
| void whiskers_send_ascii_string | ( | char * | str, |
| size_t | len ) |
Sends a ascii string via USB.
| str | String to an ascii string. |
| len | Length of the ascii string. |
Note that this will only send over standard letters, numbers, and symbols in the ascii table. It will not parse things such as F-keys or keys like escape or enter. However, it treats newlines or carriage returns as sending the enter key. It will recognize capitalized characters and send them accordingly.
Once finished a null report is sent to cap off the series of reports.
| bool whiskers_usb_enabled | ( | ) |
Checks if USB is enabled or not.
| bool whiskers_usb_started | ( | ) |
Checks if USB has been started or not.