mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
kbd modifiers - server side
This commit is contained in:
parent
e01ab240f1
commit
8c8df119ad
@ -47,8 +47,11 @@ type Clipboard struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Keyboard struct {
|
type Keyboard struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Layout string `json:"layout"`
|
Layout *string `json:"layout,omitempty"`
|
||||||
|
CapsLock *bool `json:"capsLock,omitempty"`
|
||||||
|
NumLock *bool `json:"numLock,omitempty"`
|
||||||
|
ScrollLock *bool `json:"scrollLock,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Control struct {
|
type Control struct {
|
||||||
|
@ -116,6 +116,11 @@ func (h *MessageHandler) controlClipboard(id string, session types.Session, payl
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor
|
||||||
|
var CapsLock = false
|
||||||
|
var NumLock = false
|
||||||
|
var ScrollLock = false
|
||||||
|
|
||||||
func (h *MessageHandler) controlKeyboard(id string, session types.Session, payload *message.Keyboard) error {
|
func (h *MessageHandler) controlKeyboard(id string, session types.Session, payload *message.Keyboard) error {
|
||||||
// check if session is host
|
// check if session is host
|
||||||
if !h.sessions.IsHost(id) {
|
if !h.sessions.IsHost(id) {
|
||||||
@ -123,6 +128,34 @@ func (h *MessageHandler) controlKeyboard(id string, session types.Session, paylo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
h.remote.SetKeyboard(payload.Layout)
|
// change layout
|
||||||
|
if payload.Layout != nil {
|
||||||
|
h.remote.SetKeyboard(*payload.Layout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set caps lock
|
||||||
|
if payload.CapsLock != nil && *payload.CapsLock != CapsLock {
|
||||||
|
h.remote.KeyDown(0xffe5)
|
||||||
|
h.remote.KeyUp(0xffe5)
|
||||||
|
|
||||||
|
CapsLock = *payload.CapsLock
|
||||||
|
}
|
||||||
|
|
||||||
|
// set num lock
|
||||||
|
if payload.NumLock != nil && *payload.NumLock != NumLock {
|
||||||
|
h.remote.KeyDown(0xff7f)
|
||||||
|
h.remote.KeyUp(0xff7f)
|
||||||
|
|
||||||
|
NumLock = *payload.NumLock
|
||||||
|
}
|
||||||
|
|
||||||
|
// set scroll lock
|
||||||
|
if payload.ScrollLock != nil && *payload.ScrollLock != ScrollLock {
|
||||||
|
h.remote.KeyDown(0xff14)
|
||||||
|
h.remote.KeyUp(0xff14)
|
||||||
|
|
||||||
|
ScrollLock = *payload.ScrollLock
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user