hid-desc
- NodeJS HID Descriptors Library
hid-desc
is a lightweight JavaScript library for working with HID (Human Interface Device) Descriptors. This library provides all symbols that are defined within the standard. Whether you're building custom HID devices or working with existing ones, hid-desc
should simplifythe process of handling and understanding HID Descriptors.
Installation
You can install hid-desc
via npm:
npm install hid-desc
Alternatively, you can include it directly in your HTML file using a script tag:
<script src="path/to/hid-desc.js"></script>
Usage
To use hid-desc
, simply include the library in your project and access the provided symbols. This library does not require any additional dependencies, making it easy to integrate into your existing codebase.
Here's a quick example of how you can use hid-desc
:
import { CollectionType, FieldDesc, HIDDesc, UsagePages } from 'hid-desc';
const desc = new HIDDesc()
.UsagePage( UsagePages.GenericDesktop )
.Usage( UsagePages.GenericDesktop.Mouse )
.Collection( CollectionType.Application )
.Usage( UsagePages.GenericDesktop.Pointer )
.Collection( CollectionType.Physical )
.UsagePage( UsagePages.Button )
.UsageMinimum( 1 )
.UsageMaximum( 3 )
.LogicalMinimum( 0 )
.LogicalMaximum( 1 )
.ReportCount( 3 )
.ReportSize( 1 )
.Input( FieldDesc.Data | FieldDesc.Variable | FieldDesc.Absolute )
.ReportCount( 1 )
.ReportSize( 5 )
.Input( FieldDesc.Constant | FieldDesc.Variable | FieldDesc.Absolute )
.UsagePage( UsagePages.GenericDesktop )
.Usage( UsagePages.GenericDesktop.X )
.Usage( UsagePages.GenericDesktop.Y )
.LogicalMinimum( -127 )
.LogicalMaximum( 127 )
.ReportSize( 8 )
.ReportCount( 2 )
.Input( FieldDesc.Data | FieldDesc.Variable | FieldDesc.Relative )
.EndCollection()
.EndCollection();
Documentation
https://onesandzer0s.github.io/hid-desc/
Resources
TODO