Home (original) (raw)

Waratah is a HID descriptor composition tool. It offers a high-level of abstraction, eliminates common errors (by design), and optimizes the descriptor to reduce byte size. It implements the HID 1.11 specification so developers don't have to.

It is expected to be used by device firmware authors during device bring-up.

Waratah uses a TOML-like hierarchical language of sections and keys to represent a HID Report Descriptor (Note: There is currently no support for HID Physical Descriptors). This can then be compiled to to either a simple plain-text format, or a C++ header file suitable for ingestion into device firmware.

Waratah is NOT a direct dt.exe replacement. dt.exe permits the use of specialized items (e.g. Push/Pop) and non-optimal practices (e.g. ReportSize larger than LogicalMinimum/Maximum). There are also known bugs in dt.exe, that have not been replicated in Waratah. It is reasonable to think of Waratah as high-level compiler like C and dt.exe as an assembler. No further development of dt.exe is planned.

Features

Example

Simple mouse with 3 buttons.

[[applicationCollection]] usage = ['Generic Desktop', 'Mouse']

[[applicationCollection.inputReport]]

    [[applicationCollection.inputReport.physicalCollection]]
    usage = ['Generic Desktop', 'Pointer']

        [[applicationCollection.inputReport.physicalCollection.variableItem]]
        usage = ['Generic Desktop', 'X']
        sizeInBits = 8
        logicalValueRange = 'maxSignedSizeRange'
        reportFlags = ['relative']

        [[applicationCollection.inputReport.physicalCollection.variableItem]]
        usage = ['Generic Desktop', 'Y']
        sizeInBits = 8
        logicalValueRange = 'maxSignedSizeRange'
        reportFlags = ['relative']

        [[applicationCollection.inputReport.physicalCollection.variableItem]]
        usageRange = ['Button', 'Button 1', 'Button 3']
        logicalValueRange = [0, 1]

C++ output

#pragma once

// AUTO-GENERATED by WaratahCmd.exe (https://github.com/microsoft/hidtools)

// HID Usage Tables: 1.6.0 // Descriptor size: 50 (bytes) // +----------+-------+-------------------+ // | ReportId | Kind | ReportSizeInBytes | // +----------+-------+-------------------+ // | 1 | Input | 3 | // +----------+-------+-------------------+ static const uint8_t hidReportDescriptor[] = { 0x05, 0x01, // UsagePage(Generic Desktop[0x0001]) 0x09, 0x02, // UsageId(Mouse[0x0002]) 0xA1, 0x01, // Collection(Application) 0x85, 0x01, // ReportId(1) 0x09, 0x01, // UsageId(Pointer[0x0001]) 0xA1, 0x00, // Collection(Physical) 0x09, 0x30, // UsageId(X[0x0030]) 0x09, 0x31, // UsageId(Y[0x0031]) 0x15, 0x80, // LogicalMinimum(-128) 0x25, 0x7F, // LogicalMaximum(127) 0x95, 0x02, // ReportCount(2) 0x75, 0x08, // ReportSize(8) 0x81, 0x06, // Input(Data, Variable, Relative, NoWrap, Linear, PreferredState, NoNullPosition, BitField) 0x05, 0x09, // UsagePage(Button[0x0009]) 0x19, 0x01, // UsageIdMin(Button 1[0x0001]) 0x29, 0x03, // UsageIdMax(Button 3[0x0003]) 0x15, 0x00, // LogicalMinimum(0) 0x25, 0x01, // LogicalMaximum(1) 0x95, 0x03, // ReportCount(3) 0x75, 0x01, // ReportSize(1) 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) 0xC0, // EndCollection() 0x95, 0x01, // ReportCount(1) 0x75, 0x05, // ReportSize(5) 0x81, 0x03, // Input(Constant, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) 0xC0, // EndCollection() };

#pragma pack(push,1)

#define HID_REPORT_INPUT1_ID (1) struct HidReportInput1 { uint8_t ReportId = HID_REPORT_INPUT1_ID; uint8_t Payload[3]; };

#pragma pack(pop)

Unsupported Features

Currently unsupported (but desirable features).