Skip to content

Commit 43c096f

Browse files
committed
Change to send data to blehid instead of usbhid
1 parent 150cf37 commit 43c096f

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

ble/keyboard.go

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
package keyboard
1+
package ble
22

33
import (
44
"errors"
5-
"machine"
65
"machine/usb/hid"
76
)
87

@@ -57,13 +56,6 @@ const (
5756
decodeByte3
5857
)
5958

60-
func init() {
61-
if Keyboard == nil {
62-
Keyboard = newKeyboard()
63-
hid.SetHandler(Keyboard)
64-
}
65-
}
66-
6759
// New returns the USB hid-keyboard port.
6860
// Deprecated, better to just use Port()
6961
func New() *keyboard {
@@ -81,32 +73,8 @@ func newKeyboard() *keyboard {
8173
}
8274
}
8375

84-
func (kb *keyboard) TxHandler() bool {
85-
kb.waitTxc = false
86-
if b, ok := kb.buf.Get(); ok {
87-
kb.waitTxc = true
88-
hid.SendUSBPacket(b)
89-
return true
90-
}
91-
return false
92-
}
93-
94-
func (kb *keyboard) RxHandler(b []byte) bool {
95-
if len(b) >= 2 && b[0] == 2 /* ReportID */ {
96-
kb.led = b[1]
97-
}
98-
return false
99-
}
100-
10176
func (kb *keyboard) tx(b []byte) {
102-
if machine.USBDev.InitEndpointComplete {
103-
if kb.waitTxc {
104-
kb.buf.Put(b)
105-
} else {
106-
kb.waitTxc = true
107-
hid.SendUSBPacket(b)
108-
}
109-
}
77+
sendBLEPacket(b)
11078
}
11179

11280
func (kb *keyboard) NumLockLed() bool {

ble/keycode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package keyboard
1+
package ble
22

33
// Keycode is a package-defined bitmap used to encode the value of a given key.
44
type Keycode uint16

0 commit comments

Comments
 (0)