wrap accepts button.Parser

This commit is contained in:
bel
2023-03-24 20:50:58 -06:00
parent b319ed7e6d
commit 896f5e9c92
3 changed files with 15 additions and 22 deletions

View File

@@ -3,7 +3,6 @@ package wrap
import (
"context"
"mayhem-party/src/device/input/button"
"mayhem-party/src/device/input/raw"
"os"
"syscall"
)
@@ -13,14 +12,9 @@ type Wrap interface {
Close()
}
func New(ctx context.Context, src raw.Raw) Wrap {
func New(ctx context.Context, src button.Parser) Wrap {
maker := func() Wrap {
return explicit{src: src}
}
if os.Getenv("WRAP_PROTOCOL") == "true" {
maker = func() Wrap {
return NewProtocol(src)
}
return src
}
if os.Getenv("WRAP_BUFFERED") == "true" {
oldMaker := maker
@@ -43,13 +37,3 @@ func New(ctx context.Context, src raw.Raw) Wrap {
}
return maker()
}
type explicit struct {
src raw.Raw
}
func (e explicit) Close() {
e.src.Close()
}
func (e explicit) Read() []button.Button {