From 8e92c9a6d6e5fbdb2b79942821b5b58ee03421c9 Mon Sep 17 00:00:00 2001 From: bel Date: Thu, 23 Mar 2023 20:39:57 -0600 Subject: [PATCH] keyboard supports !a to indicate release a --- src/device/input/buffered.go | 2 ++ src/device/input/keyboard.go | 8 ++++++-- todo.yaml | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 todo.yaml diff --git a/src/device/input/buffered.go b/src/device/input/buffered.go index 6ad5bda..2f10b8a 100644 --- a/src/device/input/buffered.go +++ b/src/device/input/buffered.go @@ -44,6 +44,8 @@ func (b *Buffered) listen() { for i := range buttons { if buttons[i].Down { b.keys[buttons[i].Char] = time.Now().UnixNano() + } else { + b.keys[buttons[i].Char] = 0 } } b.lock.Unlock() diff --git a/src/device/input/keyboard.go b/src/device/input/keyboard.go index d9babb8..d6b3c1f 100644 --- a/src/device/input/keyboard.go +++ b/src/device/input/keyboard.go @@ -50,10 +50,14 @@ func (kb Keyboard) Read() []Button { panic(err) } + down := true result := make([]Button, 0, n) for i := 0; i < n; i++ { - if b[i] != '\n' { - result = append(result, Button{Char: b[i], Down: true}) + if b[i] == '!' { + down = false + } else if b[i] != '\n' { + result = append(result, Button{Char: b[i], Down: down}) + down = true } } return result diff --git a/todo.yaml b/todo.yaml new file mode 100755 index 0000000..8a28f1c --- /dev/null +++ b/todo.yaml @@ -0,0 +1,4 @@ +todo: +- sticky keyboard input mode for enable/disable explicitly +scheduled: [] +done: []