2020-10-30 10:23:30 +13:00
|
|
|
package room
|
2020-11-19 09:53:06 +13:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-07-14 10:58:22 +12:00
|
|
|
"github.com/demodesk/neko/pkg/types"
|
|
|
|
"github.com/demodesk/neko/pkg/utils"
|
2020-11-19 09:53:06 +13:00
|
|
|
)
|
|
|
|
|
2021-01-16 04:53:03 +13:00
|
|
|
type KeyboardMapData struct {
|
2023-09-12 02:34:57 +12:00
|
|
|
types.KeyboardMap
|
2020-11-19 09:53:06 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
type KeyboardModifiersData struct {
|
2023-09-12 02:34:57 +12:00
|
|
|
types.KeyboardModifiers
|
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 {
|
2021-01-16 04:53:03 +13:00
|
|
|
data := &KeyboardMapData{}
|
2021-09-17 10:58:50 +12:00
|
|
|
if err := utils.HttpJsonRequest(w, r, data); err != nil {
|
|
|
|
return err
|
2020-11-19 09:53:06 +13:00
|
|
|
}
|
|
|
|
|
2023-09-12 02:34:57 +12:00
|
|
|
err := h.desktop.SetKeyboardMap(data.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 {
|
2021-01-16 04:53:03 +13:00
|
|
|
data, 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
|
|
|
}
|
|
|
|
|
2021-09-17 10:58:50 +12:00
|
|
|
return utils.HttpSuccess(w, KeyboardMapData{
|
2023-09-12 02:34:57 +12:00
|
|
|
KeyboardMap: *data,
|
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 {
|
2020-11-19 09:53:06 +13:00
|
|
|
data := &KeyboardModifiersData{}
|
2021-09-17 10:58:50 +12:00
|
|
|
if err := utils.HttpJsonRequest(w, r, data); err != nil {
|
|
|
|
return err
|
2020-11-19 09:53:06 +13:00
|
|
|
}
|
|
|
|
|
2023-09-12 02:34:57 +12:00
|
|
|
h.desktop.SetKeyboardModifiers(data.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 {
|
|
|
|
return utils.HttpSuccess(w, KeyboardModifiersData{
|
2023-09-12 02:34:57 +12:00
|
|
|
KeyboardModifiers: h.desktop.GetKeyboardModifiers(),
|
2021-01-13 11:35:46 +13:00
|
|
|
})
|
|
|
|
}
|