mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
4da7869e70
* implement additional modifiers to xorg. * xorg modifiers to API. * update modifiers api & add ws. * scroll pos rename to delta and add ctrl key.
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package room
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/demodesk/neko/pkg/types"
|
|
"github.com/demodesk/neko/pkg/utils"
|
|
)
|
|
|
|
type KeyboardMapData struct {
|
|
types.KeyboardMap
|
|
}
|
|
|
|
type KeyboardModifiersData struct {
|
|
types.KeyboardModifiers
|
|
}
|
|
|
|
func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) error {
|
|
data := &KeyboardMapData{}
|
|
if err := utils.HttpJsonRequest(w, r, data); err != nil {
|
|
return err
|
|
}
|
|
|
|
err := h.desktop.SetKeyboardMap(data.KeyboardMap)
|
|
if err != nil {
|
|
return utils.HttpInternalServerError().WithInternalErr(err)
|
|
}
|
|
|
|
return utils.HttpSuccess(w)
|
|
}
|
|
|
|
func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) error {
|
|
data, err := h.desktop.GetKeyboardMap()
|
|
if err != nil {
|
|
return utils.HttpInternalServerError().WithInternalErr(err)
|
|
}
|
|
|
|
return utils.HttpSuccess(w, KeyboardMapData{
|
|
KeyboardMap: *data,
|
|
})
|
|
}
|
|
|
|
func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error {
|
|
data := &KeyboardModifiersData{}
|
|
if err := utils.HttpJsonRequest(w, r, data); err != nil {
|
|
return err
|
|
}
|
|
|
|
h.desktop.SetKeyboardModifiers(data.KeyboardModifiers)
|
|
return utils.HttpSuccess(w)
|
|
}
|
|
|
|
func (h *RoomHandler) keyboardModifiersGet(w http.ResponseWriter, r *http.Request) error {
|
|
return utils.HttpSuccess(w, KeyboardModifiersData{
|
|
KeyboardModifiers: h.desktop.GetKeyboardModifiers(),
|
|
})
|
|
}
|