neko/internal/websocket/handler/keyboard.go

33 lines
776 B
Go
Raw Normal View History

2020-12-01 05:45:53 +13:00
package handler
import (
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/message"
)
2021-01-16 04:53:03 +13:00
func (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {
2020-12-01 05:45:53 +13:00
if !session.IsHost() {
h.logger.Debug().Str("id", session.ID()).Msg("is not the host")
return nil
}
2021-01-16 04:53:03 +13:00
return h.desktop.SetKeyboardMap(types.KeyboardMap{
Layout: payload.Layout,
Variant: payload.Variant,
})
2020-12-01 05:45:53 +13:00
}
func (h *MessageHandlerCtx) keyboardModifiers(session types.Session, payload *message.KeyboardModifiers) error {
if !session.IsHost() {
h.logger.Debug().Str("id", session.ID()).Msg("is not the host")
return nil
}
2021-01-13 10:54:13 +13:00
h.desktop.SetKeyboardModifiers(types.KeyboardModifiers{
NumLock: payload.NumLock,
CapsLock: payload.CapsLock,
})
2020-12-01 05:45:53 +13:00
return nil
}