split src/devices/input into src/devices/input/{raw,wrap}
This commit is contained in:
26
src/device/input/raw/raw.go
Normal file
26
src/device/input/raw/raw.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user