mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
feat: sync keyboard led status (#502)
This commit is contained in:
15
usb.go
15
usb.go
@@ -24,6 +24,17 @@ func initUsbGadget() {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}()
|
||||
|
||||
gadget.SetOnKeyboardStateChange(func(state usbgadget.KeyboardState) {
|
||||
if currentSession != nil {
|
||||
writeJSONRPCEvent("keyboardLedState", state, currentSession)
|
||||
}
|
||||
})
|
||||
|
||||
// open the keyboard hid file to listen for keyboard events
|
||||
if err := gadget.OpenKeyboardHidFile(); err != nil {
|
||||
usbLogger.Error().Err(err).Msg("failed to open keyboard hid file")
|
||||
}
|
||||
}
|
||||
|
||||
func rpcKeyboardReport(modifier uint8, keys []uint8) error {
|
||||
@@ -42,6 +53,10 @@ func rpcWheelReport(wheelY int8) error {
|
||||
return gadget.AbsMouseWheelReport(wheelY)
|
||||
}
|
||||
|
||||
func rpcGetKeyboardLedState() (state usbgadget.KeyboardState) {
|
||||
return gadget.GetKeyboardState()
|
||||
}
|
||||
|
||||
var usbState = "unknown"
|
||||
|
||||
func rpcGetUSBState() (state string) {
|
||||
|
||||
Reference in New Issue
Block a user