diff options
author | sago35 <[email protected]> | 2023-05-10 19:37:25 +0900 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-05-14 12:17:01 +0200 |
commit | d1a45f2efc5e13f5a9ce52906432748830fae684 (patch) | |
tree | bf9a2d9650698b940773d1385fd0e0f70677a368 | |
parent | b56a263d0d43d258b8af7880f6eb290095b65059 (diff) | |
download | tinygo-d1a45f2efc5e13f5a9ce52906432748830fae684.tar.gz tinygo-d1a45f2efc5e13f5a9ce52906432748830fae684.zip |
machine/usb/hid: fix hidreport (2)
-rw-r--r-- | src/machine/usb/descriptor/hidreport.go | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/machine/usb/descriptor/hidreport.go b/src/machine/usb/descriptor/hidreport.go index 3176e376c..914279a51 100644 --- a/src/machine/usb/descriptor/hidreport.go +++ b/src/machine/usb/descriptor/hidreport.go @@ -1,9 +1,5 @@ package descriptor -import ( - "encoding/binary" -) - const ( hidUsagePage = 0x05 hidUsage = 0x09 @@ -134,9 +130,7 @@ func HIDReportID(id int) []byte { func HIDLogicalMinimum(min int) []byte { if min > 255 { - result := []byte{hidLogicalMinimum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(min)) - return result + return []byte{hidLogicalMinimum + 1, uint8(min), uint8(min >> 8)} } return []byte{hidLogicalMinimum, byte(min)} @@ -144,9 +138,7 @@ func HIDLogicalMinimum(min int) []byte { func HIDLogicalMaximum(max int) []byte { if max > 255 { - result := []byte{hidLogicalMaximum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(max)) - return result + return []byte{hidLogicalMaximum + 1, uint8(max), uint8(max >> 8)} } return []byte{hidLogicalMaximum, byte(max)} @@ -154,9 +146,7 @@ func HIDLogicalMaximum(max int) []byte { func HIDUsageMinimum(min int) []byte { if min > 255 { - result := []byte{hidUsageMinimum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(min)) - return result + return []byte{hidUsageMinimum + 1, uint8(min), uint8(min >> 8)} } return []byte{hidUsageMinimum, byte(min)} @@ -164,9 +154,7 @@ func HIDUsageMinimum(min int) []byte { func HIDUsageMaximum(max int) []byte { if max > 255 { - result := []byte{hidUsageMaximum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(max)) - return result + return []byte{hidUsageMaximum + 1, uint8(max), uint8(max >> 8)} } return []byte{hidUsageMaximum, byte(max)} @@ -174,9 +162,7 @@ func HIDUsageMaximum(max int) []byte { func HIDPhysicalMinimum(min int) []byte { if min > 255 { - result := []byte{hidPhysicalMinimum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(min)) - return result + return []byte{hidPhysicalMinimum + 1, uint8(min), uint8(min >> 8)} } return []byte{hidPhysicalMinimum, byte(min)} @@ -184,9 +170,7 @@ func HIDPhysicalMinimum(min int) []byte { func HIDPhysicalMaximum(max int) []byte { if max > 255 { - result := []byte{hidPhysicalMaximum + 1, 0x0, 0x0} - binary.LittleEndian.PutUint16(result[1:3], uint16(max)) - return result + return []byte{hidPhysicalMaximum + 1, uint8(max), uint8(max >> 8)} } return []byte{hidPhysicalMaximum, byte(max)} |