aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/machine/usb
diff options
context:
space:
mode:
authorsago35 <[email protected]>2023-01-08 11:59:26 +0900
committerRon Evans <[email protected]>2023-01-08 08:44:27 +0100
commit5f3534fe72bf6631b4a2ac5fce8bd93fce6c79f2 (patch)
tree7814832cb890cad2fda9dde770d01886e6cd3967 /src/machine/usb
parenta7ff2731b91a83767a72da5f8ad196b45bc4c5de (diff)
downloadtinygo-5f3534fe72bf6631b4a2ac5fce8bd93fce6c79f2.tar.gz
tinygo-5f3534fe72bf6631b4a2ac5fce8bd93fce6c79f2.zip
machine/usb: change to not send before endpoint initialization
Diffstat (limited to 'src/machine/usb')
-rw-r--r--src/machine/usb/hid/keyboard/keyboard.go13
-rw-r--r--src/machine/usb/hid/mouse/mouse.go13
-rw-r--r--src/machine/usb/joystick/joystick.go12
-rw-r--r--src/machine/usb/midi/midi.go12
4 files changed, 30 insertions, 20 deletions
diff --git a/src/machine/usb/hid/keyboard/keyboard.go b/src/machine/usb/hid/keyboard/keyboard.go
index 2dc36e68e..ce6993998 100644
--- a/src/machine/usb/hid/keyboard/keyboard.go
+++ b/src/machine/usb/hid/keyboard/keyboard.go
@@ -2,6 +2,7 @@ package keyboard
import (
"errors"
+ "machine"
"machine/usb/hid"
)
@@ -91,11 +92,13 @@ func (kb *keyboard) Handler() bool {
}
func (kb *keyboard) tx(b []byte) {
- if kb.waitTxc {
- kb.buf.Put(b)
- } else {
- kb.waitTxc = true
- hid.SendUSBPacket(b)
+ if machine.USBDev.InitEndpointComplete {
+ if kb.waitTxc {
+ kb.buf.Put(b)
+ } else {
+ kb.waitTxc = true
+ hid.SendUSBPacket(b)
+ }
}
}
diff --git a/src/machine/usb/hid/mouse/mouse.go b/src/machine/usb/hid/mouse/mouse.go
index 4d80add4b..baf9efb65 100644
--- a/src/machine/usb/hid/mouse/mouse.go
+++ b/src/machine/usb/hid/mouse/mouse.go
@@ -1,6 +1,7 @@
package mouse
import (
+ "machine"
"machine/usb/hid"
)
@@ -55,11 +56,13 @@ func (m *mouse) Handler() bool {
}
func (m *mouse) tx(b []byte) {
- if m.waitTxc {
- m.buf.Put(b)
- } else {
- m.waitTxc = true
- hid.SendUSBPacket(b)
+ if machine.USBDev.InitEndpointComplete {
+ if m.waitTxc {
+ m.buf.Put(b)
+ } else {
+ m.waitTxc = true
+ hid.SendUSBPacket(b)
+ }
}
}
diff --git a/src/machine/usb/joystick/joystick.go b/src/machine/usb/joystick/joystick.go
index 9c12997b9..d672cbcef 100644
--- a/src/machine/usb/joystick/joystick.go
+++ b/src/machine/usb/joystick/joystick.go
@@ -76,11 +76,13 @@ func (m *Joystick) rxHandler(b []byte) {
}
func (m *Joystick) tx(b []byte) {
- if m.waitTxc {
- m.buf.Put(b)
- } else {
- m.waitTxc = true
- m.sendUSBPacket(b)
+ if machine.USBDev.InitEndpointComplete {
+ if m.waitTxc {
+ m.buf.Put(b)
+ } else {
+ m.waitTxc = true
+ m.sendUSBPacket(b)
+ }
}
}
diff --git a/src/machine/usb/midi/midi.go b/src/machine/usb/midi/midi.go
index c0796be49..2697866f3 100644
--- a/src/machine/usb/midi/midi.go
+++ b/src/machine/usb/midi/midi.go
@@ -71,11 +71,13 @@ func (m *midi) Handler() {
}
func (m *midi) tx(b []byte) {
- if m.waitTxc {
- m.buf.Put(b)
- } else {
- m.waitTxc = true
- m.sendUSBPacket(b)
+ if machine.USBDev.InitEndpointComplete {
+ if m.waitTxc {
+ m.buf.Put(b)
+ } else {
+ m.waitTxc = true
+ m.sendUSBPacket(b)
+ }
}
}