Brandon Fosdick


USB::HID - USB HID Descriptor generation tools


A set of classes and methods for generating USB HID descriptor sets.

    use USB::HID;

    my $device = USB::HID::Descriptor( product => 'My First Device' );
    $device->configurations( [ USB::Descriptor::Configuration->new() ] );


USB::HID provides a means of specifying a USB Human Interface Device's descriptors and then generating descriptor structures suitable for use in the device's firmware. However, USB::HID::Descriptor only generates the bytes that comprise the structures, it does not handle generation of valid source code.

The easiest way to create a new HID descriptor set is to use the USB::HID::Descriptor() factory method. It accepts a hash of arguments that happens to be the same hash expected by USB::Descriptor::Device and returns a reference to a new USB::Descriptor::Device object. Any interface specifications provided to the method will be automatically converted into USB::HID::Descriptor::Interface objects

    use USB::HID;

    my $device = USB::HID::Descriptor(
        'usb_version'       => '2.0.0',         # Default
        'max_packet_size'   => 64,              # Full speed device
        'vendorID'          => 0x1234,
        'productID'         => 0x5678,
        'manufacturer'      => 'Acme, Inc.',
        'product'           => 'Giant Catapult',
        'serial_number'     => '007',
        'configurations'    => [{
            'description'   => 'Configuration 0',
            'remote_wakeup'     => 1,
            'max_current'       => 100,   # mA
            'interfaces'        => [{
                'description'       => 'Interface 0',
                'endpoints'         => [{
                    'direction'         => 'in',
                    'number'            => 1,
                    'max_packet_size'   => 42,


$device = USB::HID::Descriptor(vendorID=>$vendorID, ...);

Constructs and returns a new USB::Descriptor::Device object using the passed options. Each option key is the name of an accessor method of USB::Descriptor::Device. Interface specifications are automatically converted to USB::HID::Descriptor::Interface.


Brandon Fosdick, <bfoz at>


Please report any bugs or feature requests to bug-usb-hid at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc USB::HID

You can also look for information at:



Copyright 2011 Brandon Fosdick.

This program is released under the terms of the BSD License.