mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add KeyPress func.
This commit is contained in:
parent
5c05d1009b
commit
b261217cbe
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user