split wrap protocol parsing into input.button
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user