mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Documentation: new doc on Storage module and JS cleanup (#4161)
- Add new doc on Storage module - Improve formatting in the JS section for better readability
This commit is contained in:
@@ -4,16 +4,17 @@
|
||||
let badusb = require("badusb");
|
||||
```
|
||||
# Methods
|
||||
## setup
|
||||
## setup()
|
||||
Start USB HID with optional parameters. Should be called before all other methods.
|
||||
|
||||
### Parameters
|
||||
Configuration object (optional):
|
||||
**Parameters**
|
||||
|
||||
Configuration object *(optional)*:
|
||||
- vid, pid (number): VID and PID values, both are mandatory
|
||||
- mfr_name (string): Manufacturer name (32 ASCII characters max), optional
|
||||
- prod_name (string): Product name (32 ASCII characters max), optional
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
// Start USB HID with default parameters
|
||||
badusb.setup();
|
||||
@@ -23,10 +24,12 @@ badusb.setup({ vid: 0xAAAA, pid: 0xBBBB });
|
||||
badusb.setup({ vid: 0xAAAA, pid: 0xBBBB, mfr_name: "Flipper Devices", prod_name: "Flipper Zero" });
|
||||
```
|
||||
|
||||
## isConnected
|
||||
<br>
|
||||
|
||||
## isConnected()
|
||||
Returns USB connection state.
|
||||
|
||||
### Example:
|
||||
**Example**
|
||||
```js
|
||||
if (badusb.isConnected()) {
|
||||
// Do something
|
||||
@@ -35,15 +38,18 @@ if (badusb.isConnected()) {
|
||||
}
|
||||
```
|
||||
|
||||
## press
|
||||
<br>
|
||||
|
||||
## press()
|
||||
Press and release a key.
|
||||
|
||||
### Parameters
|
||||
**Parameters**
|
||||
|
||||
Key or modifier name, key code.
|
||||
|
||||
See a list of key names below.
|
||||
See a [list of key names below](#js_badusb_keynames).
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
badusb.press("a"); // Press "a" key
|
||||
badusb.press("A"); // SHIFT + "a"
|
||||
@@ -53,58 +59,70 @@ badusb.press(98); // Press key with HID code (dec) 98 (Numpad 0 / Insert)
|
||||
badusb.press(0x47); // Press key with HID code (hex) 0x47 (Scroll lock)
|
||||
```
|
||||
|
||||
## hold
|
||||
<br>
|
||||
|
||||
## hold()
|
||||
Hold a key. Up to 5 keys (excluding modifiers) can be held simultaneously.
|
||||
|
||||
### Parameters
|
||||
**Parameters**
|
||||
|
||||
Same as `press`.
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
badusb.hold("a"); // Press and hold "a" key
|
||||
badusb.hold("CTRL", "v"); // Press and hold CTRL + "v" combo
|
||||
```
|
||||
|
||||
## release
|
||||
<br>
|
||||
|
||||
## release()
|
||||
Release a previously held key.
|
||||
|
||||
### Parameters
|
||||
**Parameters**
|
||||
|
||||
Same as `press`.
|
||||
|
||||
Release all keys if called without parameters.
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
badusb.release(); // Release all keys
|
||||
badusb.release("a"); // Release "a" key
|
||||
```
|
||||
|
||||
## print
|
||||
<br>
|
||||
|
||||
## print()
|
||||
Print a string.
|
||||
|
||||
### Parameters
|
||||
**Parameters**
|
||||
|
||||
- A string to print
|
||||
- *(optional)* Delay between key presses
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
badusb.print("Hello, world!"); // print "Hello, world!"
|
||||
badusb.print("Hello, world!", 100); // Add 100ms delay between key presses
|
||||
```
|
||||
<br>
|
||||
|
||||
## println
|
||||
## println()
|
||||
Same as `print` but ended with "ENTER" press.
|
||||
|
||||
### Parameters
|
||||
**Parameters**
|
||||
|
||||
- A string to print
|
||||
- *(optional)* Delay between key presses
|
||||
|
||||
### Examples:
|
||||
**Examples**
|
||||
```js
|
||||
badusb.println("Hello, world!"); // print "Hello, world!" and press "ENTER"
|
||||
```
|
||||
<br>
|
||||
|
||||
# Key names list
|
||||
# Key names list {#js_badusb_keynames}
|
||||
|
||||
## Modifier keys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user