aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorsago35 <[email protected]>2023-07-03 22:54:14 +0900
committerRon Evans <[email protected]>2023-08-04 09:43:53 +0200
commitc51f5cea0bd4a8c3d7b80544dc6577ddacf947b6 (patch)
tree61568d44a3c80ffb9b95905efc3f6cc770c0572f /src
parent395ee2d338d323d0b9225d7522dc419ac40aaaf4 (diff)
downloadtinygo-c51f5cea0bd4a8c3d7b80544dc6577ddacf947b6.tar.gz
tinygo-c51f5cea0bd4a8c3d7b80544dc6577ddacf947b6.zip
machine/usb/hid: add RxHandler interface
Diffstat (limited to 'src')
-rw-r--r--src/machine/usb/hid/hid.go12
-rw-r--r--src/machine/usb/hid/keyboard/keyboard.go4
-rw-r--r--src/machine/usb/hid/mouse/mouse.go4
3 files changed, 20 insertions, 0 deletions
diff --git a/src/machine/usb/hid/hid.go b/src/machine/usb/hid/hid.go
index e73c7a4a2..e3948dc41 100644
--- a/src/machine/usb/hid/hid.go
+++ b/src/machine/usb/hid/hid.go
@@ -24,6 +24,7 @@ const (
type hidDevicer interface {
Handler() bool
+ RxHandler([]byte) bool
}
var devices [5]hidDevicer
@@ -65,6 +66,17 @@ func handler() {
}
}
+func rxHandler(b []byte) {
+ for _, d := range devices {
+ if d == nil {
+ continue
+ }
+ if done := d.RxHandler(b); done {
+ return
+ }
+ }
+}
+
var DefaultSetupHandler = setupHandler
func setupHandler(setup usb.Setup) bool {
diff --git a/src/machine/usb/hid/keyboard/keyboard.go b/src/machine/usb/hid/keyboard/keyboard.go
index 6a5bad647..d39321410 100644
--- a/src/machine/usb/hid/keyboard/keyboard.go
+++ b/src/machine/usb/hid/keyboard/keyboard.go
@@ -91,6 +91,10 @@ func (kb *keyboard) Handler() bool {
return false
}
+func (kb *keyboard) RxHandler(b []byte) bool {
+ return false
+}
+
func (kb *keyboard) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if kb.waitTxc {
diff --git a/src/machine/usb/hid/mouse/mouse.go b/src/machine/usb/hid/mouse/mouse.go
index d778fd201..024c1e9c3 100644
--- a/src/machine/usb/hid/mouse/mouse.go
+++ b/src/machine/usb/hid/mouse/mouse.go
@@ -57,6 +57,10 @@ func (m *mouse) Handler() bool {
return false
}
+func (m *mouse) RxHandler(b []byte) bool {
+ return false
+}
+
func (m *mouse) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc {