mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +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.
|
||||
|
||||
@@ -77,6 +77,7 @@ const (
|
||||
KeyModifierRightAlt Keycode = 0x40 | 0xE000
|
||||
KeyModifierRightGUI Keycode = 0x80 | 0xE000
|
||||
|
||||
// KeySystemXXX is not supported now
|
||||
KeySystemPowerDown Keycode = 0x81 | 0xE200
|
||||
KeySystemSleep Keycode = 0x82 | 0xE200
|
||||
KeySystemWakeUp Keycode = 0x83 | 0xE200
|
||||
|
||||
Reference in New Issue
Block a user