machine/usb: change to not send before endpoint initialization

Этот коммит содержится в:
sago35 2023-01-08 11:59:26 +09:00 коммит произвёл Ron Evans
родитель a7ff2731b9
коммит 5f3534fe72
5 изменённых файлов: 33 добавлений и 21 удалений

Просмотреть файл

@ -11,6 +11,7 @@ import (
type USBDevice struct { type USBDevice struct {
initcomplete bool initcomplete bool
InitEndpointComplete bool
} }
var ( var (
@ -215,6 +216,7 @@ func handleStandardSetup(setup usb.Setup) bool {
} }
usbConfiguration = setup.WValueL usbConfiguration = setup.WValueL
USBDev.InitEndpointComplete = true
SendZlp() SendZlp()
return true return true

Просмотреть файл

@ -2,6 +2,7 @@ package keyboard
import ( import (
"errors" "errors"
"machine"
"machine/usb/hid" "machine/usb/hid"
) )
@ -91,6 +92,7 @@ func (kb *keyboard) Handler() bool {
} }
func (kb *keyboard) tx(b []byte) { func (kb *keyboard) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if kb.waitTxc { if kb.waitTxc {
kb.buf.Put(b) kb.buf.Put(b)
} else { } else {
@ -98,6 +100,7 @@ func (kb *keyboard) tx(b []byte) {
hid.SendUSBPacket(b) hid.SendUSBPacket(b)
} }
} }
}
func (kb *keyboard) ready() bool { func (kb *keyboard) ready() bool {
return true return true

Просмотреть файл

@ -1,6 +1,7 @@
package mouse package mouse
import ( import (
"machine"
"machine/usb/hid" "machine/usb/hid"
) )
@ -55,6 +56,7 @@ func (m *mouse) Handler() bool {
} }
func (m *mouse) tx(b []byte) { func (m *mouse) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc { if m.waitTxc {
m.buf.Put(b) m.buf.Put(b)
} else { } else {
@ -62,6 +64,7 @@ func (m *mouse) tx(b []byte) {
hid.SendUSBPacket(b) hid.SendUSBPacket(b)
} }
} }
}
// Move is a function that moves the mouse cursor. // Move is a function that moves the mouse cursor.
func (m *mouse) Move(vx, vy int) { func (m *mouse) Move(vx, vy int) {

Просмотреть файл

@ -76,6 +76,7 @@ func (m *Joystick) rxHandler(b []byte) {
} }
func (m *Joystick) tx(b []byte) { func (m *Joystick) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc { if m.waitTxc {
m.buf.Put(b) m.buf.Put(b)
} else { } else {
@ -83,6 +84,7 @@ func (m *Joystick) tx(b []byte) {
m.sendUSBPacket(b) m.sendUSBPacket(b)
} }
} }
}
// to InterruptOut // to InterruptOut
func (m *Joystick) SendReport(reportID byte, b []byte) { func (m *Joystick) SendReport(reportID byte, b []byte) {

Просмотреть файл

@ -71,6 +71,7 @@ func (m *midi) Handler() {
} }
func (m *midi) tx(b []byte) { func (m *midi) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc { if m.waitTxc {
m.buf.Put(b) m.buf.Put(b)
} else { } else {
@ -78,6 +79,7 @@ func (m *midi) tx(b []byte) {
m.sendUSBPacket(b) m.sendUSBPacket(b)
} }
} }
}
// from BulkOut // from BulkOut
func (m *midi) RxHandler(b []byte) { func (m *midi) RxHandler(b []byte) {