neko/server/internal/api/room/keyboard.go

48 lines
1.2 KiB
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"
"github.com/demodesk/neko/pkg/types"
"github.com/demodesk/neko/pkg/utils"
2020-11-19 09:53:06 +13:00
)
2021-09-17 10:58:50 +12:00
func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) error {
keyboardMap := types.KeyboardMap{}
if err := utils.HttpJsonRequest(w, r, &keyboardMap); err != nil {
2021-09-17 10:58:50 +12:00
return err
2020-11-19 09:53:06 +13:00
}
err := h.desktop.SetKeyboardMap(keyboardMap)
2021-02-15 02:40:17 +13:00
if err != nil {
2021-09-17 10:58:50 +12:00
return utils.HttpInternalServerError().WithInternalErr(err)
2021-01-13 11:48:15 +13:00
}
2020-11-19 09:53:06 +13:00
2021-09-17 10:58:50 +12:00
return utils.HttpSuccess(w)
2020-11-19 09:53:06 +13:00
}
2021-09-17 10:58:50 +12:00
func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) error {
keyboardMap, err := h.desktop.GetKeyboardMap()
2021-02-15 02:40:17 +13:00
if err != nil {
2021-09-17 10:58:50 +12:00
return utils.HttpInternalServerError().WithInternalErr(err)
2021-01-16 04:53:03 +13:00
}
return utils.HttpSuccess(w, keyboardMap)
2021-01-16 04:53:03 +13:00
}
2021-09-17 10:58:50 +12:00
func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error {
keyboardModifiers := types.KeyboardModifiers{}
if err := utils.HttpJsonRequest(w, r, &keyboardModifiers); err != nil {
2021-09-17 10:58:50 +12:00
return err
2020-11-19 09:53:06 +13:00
}
h.desktop.SetKeyboardModifiers(keyboardModifiers)
2021-09-17 10:58:50 +12:00
return utils.HttpSuccess(w)
2020-11-19 09:53:06 +13:00
}
2021-01-13 11:35:46 +13:00
2021-09-17 10:58:50 +12:00
func (h *RoomHandler) keyboardModifiersGet(w http.ResponseWriter, r *http.Request) error {
keyboardModifiers := h.desktop.GetKeyboardModifiers()
return utils.HttpSuccess(w, keyboardModifiers)
2021-01-13 11:35:46 +13:00
}