mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
usb: rename callback to handler to keep consistent
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -20,35 +20,35 @@ const (
|
||||
)
|
||||
|
||||
type hidDevicer interface {
|
||||
Callback() bool
|
||||
Handler() bool
|
||||
}
|
||||
|
||||
var devices [5]hidDevicer
|
||||
var size int
|
||||
|
||||
// SetCallbackHandler sets the callback. Only the first time it is called, it
|
||||
// SetHandler sets the handler. Only the first time it is called, it
|
||||
// calls machine.EnableHID for USB configuration
|
||||
func SetCallbackHandler(d hidDevicer) {
|
||||
func SetHandler(d hidDevicer) {
|
||||
if size == 0 {
|
||||
machine.EnableHID(callback, nil, callbackSetup)
|
||||
machine.EnableHID(handler, nil, setupHandler)
|
||||
}
|
||||
|
||||
devices[size] = d
|
||||
size++
|
||||
}
|
||||
|
||||
func callback() {
|
||||
func handler() {
|
||||
for _, d := range devices {
|
||||
if d == nil {
|
||||
continue
|
||||
}
|
||||
if done := d.Callback(); done {
|
||||
if done := d.Handler(); done {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func callbackSetup(setup machine.USBSetup) bool {
|
||||
func setupHandler(setup machine.USBSetup) bool {
|
||||
ok := false
|
||||
if setup.BmRequestType == usb_SET_REPORT_TYPE && setup.BRequest == usb_SET_IDLE {
|
||||
machine.SendZlp()
|
||||
|
||||
@@ -59,7 +59,7 @@ const (
|
||||
func init() {
|
||||
if Keyboard == nil {
|
||||
Keyboard = newKeyboard()
|
||||
hid.SetCallbackHandler(Keyboard)
|
||||
hid.SetHandler(Keyboard)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func newKeyboard() *keyboard {
|
||||
}
|
||||
}
|
||||
|
||||
func (kb *keyboard) Callback() bool {
|
||||
func (kb *keyboard) Handler() bool {
|
||||
kb.waitTxc = false
|
||||
if b, ok := kb.buf.Get(); ok {
|
||||
kb.waitTxc = true
|
||||
|
||||
@@ -23,7 +23,7 @@ type mouse struct {
|
||||
func init() {
|
||||
if Mouse == nil {
|
||||
Mouse = newMouse()
|
||||
hid.SetCallbackHandler(Mouse)
|
||||
hid.SetHandler(Mouse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func newMouse() *mouse {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mouse) Callback() bool {
|
||||
func (m *mouse) Handler() bool {
|
||||
m.waitTxc = false
|
||||
if b, ok := m.buf.Get(); ok {
|
||||
m.waitTxc = true
|
||||
@@ -82,7 +82,7 @@ func (m *mouse) Move(vx, vy int) {
|
||||
})
|
||||
}
|
||||
|
||||
// Cilck clicks the mouse button.
|
||||
// Click clicks the mouse button.
|
||||
func (m *mouse) Click(btn Button) {
|
||||
m.Press(btn)
|
||||
m.Release(btn)
|
||||
|
||||
Reference in New Issue
Block a user