mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 21:09:02 +00:00
machine/usb: change to not send before endpoint initialization
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
type USBDevice struct {
|
||||
initcomplete bool
|
||||
InitEndpointComplete bool
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -215,6 +216,7 @@ func handleStandardSetup(setup usb.Setup) bool {
|
||||
}
|
||||
|
||||
usbConfiguration = setup.WValueL
|
||||
USBDev.InitEndpointComplete = true
|
||||
|
||||
SendZlp()
|
||||
return true
|
||||
|
||||
@@ -2,6 +2,7 @@ package keyboard
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"machine"
|
||||
"machine/usb/hid"
|
||||
)
|
||||
|
||||
@@ -91,6 +92,7 @@ func (kb *keyboard) Handler() bool {
|
||||
}
|
||||
|
||||
func (kb *keyboard) tx(b []byte) {
|
||||
if machine.USBDev.InitEndpointComplete {
|
||||
if kb.waitTxc {
|
||||
kb.buf.Put(b)
|
||||
} else {
|
||||
@@ -98,6 +100,7 @@ func (kb *keyboard) tx(b []byte) {
|
||||
hid.SendUSBPacket(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (kb *keyboard) ready() bool {
|
||||
return true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mouse
|
||||
|
||||
import (
|
||||
"machine"
|
||||
"machine/usb/hid"
|
||||
)
|
||||
|
||||
@@ -55,6 +56,7 @@ func (m *mouse) Handler() bool {
|
||||
}
|
||||
|
||||
func (m *mouse) tx(b []byte) {
|
||||
if machine.USBDev.InitEndpointComplete {
|
||||
if m.waitTxc {
|
||||
m.buf.Put(b)
|
||||
} else {
|
||||
@@ -62,6 +64,7 @@ func (m *mouse) tx(b []byte) {
|
||||
hid.SendUSBPacket(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move is a function that moves the mouse cursor.
|
||||
func (m *mouse) Move(vx, vy int) {
|
||||
|
||||
@@ -76,6 +76,7 @@ func (m *Joystick) rxHandler(b []byte) {
|
||||
}
|
||||
|
||||
func (m *Joystick) tx(b []byte) {
|
||||
if machine.USBDev.InitEndpointComplete {
|
||||
if m.waitTxc {
|
||||
m.buf.Put(b)
|
||||
} else {
|
||||
@@ -83,6 +84,7 @@ func (m *Joystick) tx(b []byte) {
|
||||
m.sendUSBPacket(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// to InterruptOut
|
||||
func (m *Joystick) SendReport(reportID byte, b []byte) {
|
||||
|
||||
@@ -71,6 +71,7 @@ func (m *midi) Handler() {
|
||||
}
|
||||
|
||||
func (m *midi) tx(b []byte) {
|
||||
if machine.USBDev.InitEndpointComplete {
|
||||
if m.waitTxc {
|
||||
m.buf.Put(b)
|
||||
} else {
|
||||
@@ -78,6 +79,7 @@ func (m *midi) tx(b []byte) {
|
||||
m.sendUSBPacket(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// from BulkOut
|
||||
func (m *midi) RxHandler(b []byte) {
|
||||
|
||||
Reference in New Issue
Block a user