diff --git a/internal/desktop/xorg.go b/internal/desktop/xorg.go index 047068d1..ce6c28db 100644 --- a/internal/desktop/xorg.go +++ b/internal/desktop/xorg.go @@ -4,6 +4,7 @@ import ( "image" "os/exec" "regexp" + "time" "demodesk/neko/internal/desktop/xorg" "demodesk/neko/internal/types" @@ -37,6 +38,23 @@ func (manager *DesktopManagerCtx) KeyUp(code uint32) error { return xorg.KeyUp(code) } +func (manager *DesktopManagerCtx) KeyPress(codes ...uint32) error { + xorg.ResetKeys() + defer xorg.ResetKeys() + + for _, code := range codes { + if err := xorg.KeyDown(code); err != nil { + return err + } + } + + if len(codes) > 1 { + time.Sleep(10 * time.Millisecond) + } + + return nil +} + func (manager *DesktopManagerCtx) ResetKeys() { xorg.ResetKeys() } diff --git a/internal/types/desktop.go b/internal/types/desktop.go index ea724433..f55c877a 100644 --- a/internal/types/desktop.go +++ b/internal/types/desktop.go @@ -54,6 +54,7 @@ type DesktopManager interface { KeyDown(code uint32) error ButtonUp(code uint32) error KeyUp(code uint32) error + KeyPress(codes ...uint32) error ResetKeys() ScreenConfigurations() map[int]ScreenConfiguration SetScreenSize(ScreenSize) error