aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsago35 <[email protected]>2023-05-10 19:37:25 +0900
committerRon Evans <[email protected]>2023-05-14 12:17:01 +0200
commitd1a45f2efc5e13f5a9ce52906432748830fae684 (patch)
treebf9a2d9650698b940773d1385fd0e0f70677a368
parentb56a263d0d43d258b8af7880f6eb290095b65059 (diff)
downloadtinygo-d1a45f2efc5e13f5a9ce52906432748830fae684.tar.gz
tinygo-d1a45f2efc5e13f5a9ce52906432748830fae684.zip
machine/usb/hid: fix hidreport (2)
-rw-r--r--src/machine/usb/descriptor/hidreport.go28
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)}