keyboard supports !a to indicate release a

master
bel 2023-03-23 20:39:57 -06:00
parent 1fc6d71db6
commit 8e92c9a6d6
3 changed files with 12 additions and 2 deletions

View File

@ -44,6 +44,8 @@ func (b *Buffered) listen() {
for i := range buttons { for i := range buttons {
if buttons[i].Down { if buttons[i].Down {
b.keys[buttons[i].Char] = time.Now().UnixNano() b.keys[buttons[i].Char] = time.Now().UnixNano()
} else {
b.keys[buttons[i].Char] = 0
} }
} }
b.lock.Unlock() b.lock.Unlock()

View File

@ -50,10 +50,14 @@ func (kb Keyboard) Read() []Button {
panic(err) panic(err)
} }
down := true
result := make([]Button, 0, n) result := make([]Button, 0, n)
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if b[i] != '\n' { if b[i] == '!' {
result = append(result, Button{Char: b[i], Down: true}) down = false
} else if b[i] != '\n' {
result = append(result, Button{Char: b[i], Down: down})
down = true
} }
} }
return result return result

4
todo.yaml Executable file
View File

@ -0,0 +1,4 @@
todo:
- sticky keyboard input mode for enable/disable explicitly
scheduled: []
done: []