- Recent kernel with configfs support 4.0 or higher recommended
- libcomposite module loaded
- A supported device with a OTG port
- CHIP (Requires building a kernel with USB gadgets set to use configfs)
- Pi Zero
- Pi4
- Any SoC with OTG and a recent kernel supporting configfs
npm install -g ags131/node-gadget
npm install ags131/node-gadget
Usage: gadget <options> args
libcomposite module MUST be loaded.
sudo modprobe libcomposite
Options:
-h --help this help
-c --create jsonfile create gadget
-r --remove id remove gadget
-e --enable id <udc> enable gadget
-d --disable id disable gadget
Types:
jsonfile file containing gadget config
id id of gadget
udc name of udc device (Automatic if omitted)
const { Gadget } = require('node-gadget')
config is a JSON object. See Examples for example jsons
Creates the gadget on the system Does not enable the gadget
Removes the gadget
enables the gadget with the provided udc udc can be left undefined to automatically select the default udc
Disables the gadget This does not remove it from the system
Creates the gadget on the system from the config Does not enable the gadget
Removes the gadget
enables the gadget using the provided udc udc can be left undefined to automatically select the default udc
Disables the gadget This does not remove it from the system
returns a Duplex stream for the HID Device. NOTE: this assumes linux creates the /dev/hidg* devices in the right order, more than one HID device may screw with this.