split src/devices/input into src/devices/input/{raw,wrap}

This commit is contained in:
bel
2023-03-24 19:51:38 -06:00
parent ab673a81f0
commit 38b00e55b0
16 changed files with 161 additions and 159 deletions

View File

@@ -0,0 +1,26 @@
package raw
import (
"context"
"os"
"strconv"
)
type Raw interface {
Read() []byte
Close()
}
func New(ctx context.Context) Raw {
if os.Getenv("RAW_KEYBOARD") == "true" {
return NewKeyboard()
}
if port, _ := strconv.Atoi(os.Getenv("RAW_UDP")); port != 0 {
return NewUDP(port)
}
generator := randomCharFromRange('a', 'g')
if p, ok := os.LookupEnv("RAW_RANDOM_WEIGHT_FILE"); ok && len(p) > 0 {
generator = randomCharFromWeightFile(p)
}
return NewRandom(generator)
}