Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usb_gadget-0.1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

usb_gadget-0.1-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page