File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ var interfaceHID = [interfaceTypeLen]byte{
26
26
TypeInterface ,
27
27
0x02 , // InterfaceNumber
28
28
0x00 , // AlternateSetting
29
- 0x01 , // NumEndpoints
29
+ 0x02 , // NumEndpoints
30
30
0x03 , // InterfaceClass
31
31
0x00 , // InterfaceSubClass
32
32
0x00 , // InterfaceProtocol
@@ -103,7 +103,7 @@ var classHID = [ClassHIDTypeLen]byte{
103
103
0x00 , // CountryCode
104
104
0x01 , // NumDescriptors
105
105
0x22 , // ClassType
106
- 0x7E , // ClassLength L
106
+ 0x90 , // ClassLength L
107
107
0x00 , // ClassLength H
108
108
}
109
109
@@ -128,6 +128,7 @@ var CDCHID = Descriptor{
128
128
InterfaceHID .Bytes (),
129
129
ClassHID .Bytes (),
130
130
EndpointEP4IN .Bytes (),
131
+ EndpointEP5OUT .Bytes (),
131
132
}),
132
133
HID : map [uint16 ][]byte {
133
134
2 : Append ([][]byte {
@@ -147,6 +148,15 @@ var CDCHID = Descriptor{
147
148
HIDReportCount (1 ),
148
149
HIDReportSize (8 ),
149
150
HIDInputConstVarAbs ,
151
+ HIDReportCount (3 ),
152
+ HIDReportSize (1 ),
153
+ HIDUsagePageLED ,
154
+ HIDUsageMinimum (1 ),
155
+ HIDUsageMaximum (3 ),
156
+ HIDOutputDataVarAbs ,
157
+ HIDReportCount (5 ),
158
+ HIDReportSize (1 ),
159
+ HIDOutputConstVarAbs ,
150
160
HIDReportCount (6 ),
151
161
HIDReportSize (8 ),
152
162
HIDLogicalMinimum (0 ),
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const (
13
13
hidUnit = 0x65
14
14
hidCollection = 0xa1
15
15
hidInput = 0x81
16
+ hidOutput = 0x91
16
17
hidReportSize = 0x75
17
18
hidReportCount = 0x95
18
19
hidReportID = 0x85
@@ -121,6 +122,12 @@ var (
121
122
122
123
// Input (Data, Variable, Relative), 2 position bytes (X & Y)
123
124
HIDInputDataVarRel = []byte {hidInput , 0x06 }
125
+
126
+ // Output (Data, Variable, Absolute), Modifier byte
127
+ HIDOutputDataVarAbs = []byte {hidOutput , 0x02 }
128
+
129
+ // Output (Const, Variable, Absolute), Modifier byte
130
+ HIDOutputConstVarAbs = []byte {hidOutput , 0x03 }
124
131
)
125
132
126
133
func HIDReportSize (size int ) []byte {
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ func SetHandler(d hidDevicer) {
36
36
if size == 0 {
37
37
machine .ConfigureUSBEndpoint (descriptor .CDCHID ,
38
38
[]usb.EndpointConfig {
39
+ {
40
+ Index : usb .HID_ENDPOINT_OUT ,
41
+ IsIn : false ,
42
+ Type : usb .ENDPOINT_TYPE_INTERRUPT ,
43
+ RxHandler : rxHandler ,
44
+ },
39
45
{
40
46
Index : usb .HID_ENDPOINT_IN ,
41
47
IsIn : true ,
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ func (kb *keyboard) TxHandler() bool {
92
92
}
93
93
94
94
func (kb * keyboard ) RxHandler (b []byte ) bool {
95
+ if len (b ) >= 2 && b [0 ] == 2 /* ReportID */ {
96
+ kb .led = b [1 ]
97
+ }
95
98
return false
96
99
}
97
100
@@ -106,6 +109,18 @@ func (kb *keyboard) tx(b []byte) {
106
109
}
107
110
}
108
111
112
+ func (kb * keyboard ) NumLockLed () bool {
113
+ return kb .led & 1 != 0
114
+ }
115
+
116
+ func (kb * keyboard ) CapsLockLed () bool {
117
+ return kb .led & 2 != 0
118
+ }
119
+
120
+ func (kb * keyboard ) ScrollLockLed () bool {
121
+ return kb .led & 4 != 0
122
+ }
123
+
109
124
func (kb * keyboard ) ready () bool {
110
125
return true
111
126
}
You can’t perform that action at this time.
0 commit comments