Add support for HID Keyboard LEDs

This commit is contained in:
Unrud
2023-08-05 15:23:20 +02:00
committed by Ron Evans
parent 72270f9052
commit 0ef86e1534
4 changed files with 40 additions and 2 deletions
+12 -2
View File
@@ -26,7 +26,7 @@ var interfaceHID = [interfaceTypeLen]byte{
TypeInterface,
0x02, // InterfaceNumber
0x00, // AlternateSetting
0x01, // NumEndpoints
0x02, // NumEndpoints
0x03, // InterfaceClass
0x00, // InterfaceSubClass
0x00, // InterfaceProtocol
@@ -103,7 +103,7 @@ var classHID = [ClassHIDTypeLen]byte{
0x00, // CountryCode
0x01, // NumDescriptors
0x22, // ClassType
0x7E, // ClassLength L
0x90, // ClassLength L
0x00, // ClassLength H
}
@@ -128,6 +128,7 @@ var CDCHID = Descriptor{
InterfaceHID.Bytes(),
ClassHID.Bytes(),
EndpointEP4IN.Bytes(),
EndpointEP5OUT.Bytes(),
}),
HID: map[uint16][]byte{
2: Append([][]byte{
@@ -147,6 +148,15 @@ var CDCHID = Descriptor{
HIDReportCount(1),
HIDReportSize(8),
HIDInputConstVarAbs,
HIDReportCount(3),
HIDReportSize(1),
HIDUsagePageLED,
HIDUsageMinimum(1),
HIDUsageMaximum(3),
HIDOutputDataVarAbs,
HIDReportCount(5),
HIDReportSize(1),
HIDOutputConstVarAbs,
HIDReportCount(6),
HIDReportSize(8),
HIDLogicalMinimum(0),
+7
View File
@@ -13,6 +13,7 @@ const (
hidUnit = 0x65
hidCollection = 0xa1
hidInput = 0x81
hidOutput = 0x91
hidReportSize = 0x75
hidReportCount = 0x95
hidReportID = 0x85
@@ -121,6 +122,12 @@ var (
// Input (Data, Variable, Relative), 2 position bytes (X & Y)
HIDInputDataVarRel = []byte{hidInput, 0x06}
// Output (Data, Variable, Absolute), Modifier byte
HIDOutputDataVarAbs = []byte{hidOutput, 0x02}
// Output (Const, Variable, Absolute), Modifier byte
HIDOutputConstVarAbs = []byte{hidOutput, 0x03}
)
func HIDReportSize(size int) []byte {