split wrap protocol parsing into input.button

This commit is contained in:
bel
2023-03-24 20:25:15 -06:00
parent 9990273b19
commit b319ed7e6d
8 changed files with 72 additions and 27 deletions

View File

@@ -2,13 +2,14 @@ package wrap
import (
"context"
"mayhem-party/src/device/input/button"
"mayhem-party/src/device/input/raw"
"os"
"syscall"
)
type Wrap interface {
Read() []Button
Read() []button.Button
Close()
}
@@ -51,19 +52,4 @@ func (e explicit) Close() {
e.src.Close()
}
func (e explicit) Read() []Button {
b := e.src.Read()
buttons := make([]Button, 0, len(b))
down := true
for i := range b {
if b[i] == '!' {
down = false
} else {
if b[i] != '\n' {
buttons = append(buttons, Button{Char: b[i], Down: down})
}
down = true
}
}
return buttons
}
func (e explicit) Read() []button.Button {