neko/internal/api/room/keyboard.go

42 lines
821 B
Go
Raw Normal View History

2020-10-30 10:23:30 +13:00
package room
2020-11-19 09:53:06 +13:00
import (
"net/http"
"demodesk/neko/internal/utils"
2021-01-13 10:54:13 +13:00
"demodesk/neko/internal/types"
2020-11-19 09:53:06 +13:00
)
type KeyboardLayoutData struct {
Layout string `json:"layout"`
}
type KeyboardModifiersData struct {
2021-01-13 10:54:13 +13:00
NumLock *bool `json:"numlock"`
CapsLock *bool `json:"capslock"`
2020-11-19 09:53:06 +13:00
}
2020-11-19 10:35:50 +13:00
func (h *RoomHandler) keyboardLayoutSet(w http.ResponseWriter, r *http.Request) {
2020-11-19 09:53:06 +13:00
data := &KeyboardLayoutData{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
h.desktop.SetKeyboardLayout(data.Layout)
utils.HttpSuccess(w)
}
2020-11-19 10:35:50 +13:00
func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) {
2020-11-19 09:53:06 +13:00
data := &KeyboardModifiersData{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
2021-01-13 10:54:13 +13:00
h.desktop.SetKeyboardModifiers(types.KeyboardModifiers{
NumLock: data.NumLock,
CapsLock: data.CapsLock,
})
2020-11-19 09:53:06 +13:00
utils.HttpSuccess(w)
}