neko/internal/websocket/handler/keyboard.go
2021-02-14 14:40:17 +01:00

32 lines
777 B
Go

package handler
import (
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/message"
)
func (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {
if !session.IsHost() {
h.logger.Debug().Str("id", session.ID()).Msg("is not the host")
return nil
}
return h.desktop.SetKeyboardMap(types.KeyboardMap{
Layout: payload.Layout,
Variant: payload.Variant,
})
}
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
}
h.desktop.SetKeyboardModifiers(types.KeyboardModifiers{
NumLock: payload.NumLock,
CapsLock: payload.CapsLock,
})
return nil
}