A python library for creating and interfacing with USB Gadgets on Linux through libcomposite
Project description
USBGadget
A python library for creating and interfacing with USB Gadgets on Linux through libcomposite.
This library assumes the ConfigFS gadget directory to be
/sys/kernel/config/usb_gadget
.
If this is not the case, specify the correct directory in the call to USBGadget(name, path).
Creating a gadget
Any gadget type that libcomposite supports can be created.
import usb_gadget
gadget = usb_gadget.USBGadget('my_test_gadget')
# ... set up gadget parameters, functions and configurations
gadget.activate()
Interfacing with a gadget
This library has an interface for HID gadgets. Specifically, keyboard, mouse and game controller.
import usb_gadget
gadget = usb_gadget.USBGadget('my_test_gadget')
function = usb_gadget.HIDFunction(gadget, 'keyboard0')
keyboard = usb_gadget.KeyboardGadget(function.device)
keyboard.press_and_release('a')
See also example.py
for a full keyboard setup
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file usb_gadget-0.1.tar.gz
.
File metadata
- Download URL: usb_gadget-0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0d142ee95d3afdf6256cbf126a83ba4c628819680144dda12d4f86b57fa7a42 |
|
MD5 | 3564f2a00787947d6afdec74aac32af4 |
|
BLAKE2b-256 | 54cfe29f0812ae232af511330acba869520ca51fd94ce2f5b6f0f63906b33228 |
File details
Details for the file usb_gadget-0.1-py3-none-any.whl
.
File metadata
- Download URL: usb_gadget-0.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64fdb09305a3c8c07847fa5ba6abbf227f928b21284626e2948f8e423184a192 |
|
MD5 | 6582bb5207c1b7f88cc4348396a0f067 |
|
BLAKE2b-256 | 598b235e948aacba4db5e32a4bca8bff078cc7c3c5e335e75575cfb692a96697 |