refactor hotkeys example.

This commit is contained in:
onyx-and-iris 2022-09-18 05:35:53 +01:00
parent a87c11099c
commit 1284c92680

View File

@ -10,18 +10,13 @@ import (
func main() { func main() {
if err := keyboard.Open(); err != nil { if err := keyboard.Open(); err != nil {
panic(err) log.Fatal(err)
} }
defer func() { defer func() {
_ = keyboard.Close() _ = keyboard.Close()
}() }()
vm, err := voicemeeter.NewRemote("potato", 0) vm, err := vmConnect()
if err != nil {
log.Fatal(err)
}
err = vm.Login()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -55,3 +50,17 @@ Loop:
} }
} }
} }
func vmConnect() (*voicemeeter.Remote, error) {
vm, err := voicemeeter.NewRemote("potato", 0)
if err != nil {
return nil, err
}
err = vm.Login()
if err != nil {
return nil, err
}
return vm, nil
}