machine/usb/hid: add MediaKey support (#3436)

machine/usb/hid: add MediaKey support
This commit is contained in:
sago35
2023-02-18 09:27:15 +09:00
committed by GitHub
parent 4e8453167f
commit e21ab04fad
3 changed files with 35 additions and 11 deletions
+20 -10
View File
@@ -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.
+1
View File
@@ -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