mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 04:49:04 +00:00
machine/usb/hid: add MediaKey support (#3436)
machine/usb/hid: add MediaKey support
This commit is contained in:
@@ -238,16 +238,26 @@ func (kb *keyboard) sendKey(consumer bool, b []byte) bool {
|
||||
|
||||
func (kb *keyboard) keyboardSendKeys(consumer bool) bool {
|
||||
var b [9]byte
|
||||
b[0] = 0x02
|
||||
b[1] = kb.mod
|
||||
b[2] = 0x02
|
||||
b[3] = kb.key[0]
|
||||
b[4] = kb.key[1]
|
||||
b[5] = kb.key[2]
|
||||
b[6] = kb.key[3]
|
||||
b[7] = kb.key[4]
|
||||
b[8] = kb.key[5]
|
||||
return kb.sendKey(consumer, b[:])
|
||||
|
||||
if !consumer {
|
||||
b[0] = 0x02 // REPORT_ID
|
||||
b[1] = kb.mod
|
||||
b[2] = 0x02
|
||||
b[3] = kb.key[0]
|
||||
b[4] = kb.key[1]
|
||||
b[5] = kb.key[2]
|
||||
b[6] = kb.key[3]
|
||||
b[7] = kb.key[4]
|
||||
b[8] = kb.key[5]
|
||||
return kb.sendKey(consumer, b[:])
|
||||
|
||||
} else {
|
||||
b[0] = 0x03 // REPORT_ID
|
||||
b[1] = uint8(kb.con[0])
|
||||
b[2] = uint8((kb.con[0] & 0x0300) >> 8)
|
||||
|
||||
return kb.sendKey(consumer, b[:3])
|
||||
}
|
||||
}
|
||||
|
||||
// Down transmits a key-down event for the given Keycode.
|
||||
|
||||
Reference in New Issue
Block a user