neko/internal/websocket/handler/keyboard.go

33 lines
735 B
Go
Raw Normal View History

2020-12-01 05:45:53 +13:00
package handler
import (
2021-09-02 09:10:18 +12:00
"errors"
2022-03-20 23:43:00 +13:00
"gitlab.com/demodesk/neko/server/pkg/types"
"gitlab.com/demodesk/neko/server/pkg/types/message"
2020-12-01 05:45:53 +13:00
)
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() {
2021-09-02 09:10:18 +12:00
return errors.New("is not the host")
2020-12-01 05:45:53 +13:00
}
2021-01-16 04:53:03 +13:00
return h.desktop.SetKeyboardMap(types.KeyboardMap{
2021-02-15 02:40:17 +13:00
Layout: payload.Layout,
2021-01-16 04:53:03 +13:00
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() {
2021-09-02 09:10:18 +12:00
return errors.New("is not the host")
2020-12-01 05:45:53 +13:00
}
2021-01-13 10:54:13 +13:00
h.desktop.SetKeyboardModifiers(types.KeyboardModifiers{
2021-02-15 02:40:17 +13:00
NumLock: payload.NumLock,
2021-01-13 10:54:13 +13:00
CapsLock: payload.CapsLock,
})
2021-03-16 22:53:03 +13:00
2020-12-01 05:45:53 +13:00
return nil
}