add KeyPress func.

This commit is contained in:
Miroslav Šedivý 2022-01-30 01:22:07 +01:00
parent 5c05d1009b
commit b261217cbe
2 changed files with 19 additions and 0 deletions

View File

@ -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()
}

View File

@ -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