1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-24 02:58:06 +11:00

ti/kbd: improve debouncing

Previously, on real hardware (emulator behaved fine), we would routinely
get repeat keys unless pressing the button very fast. This commit solves that.
This commit is contained in:
Virgil Dupras 2019-11-09 13:22:01 -05:00
parent 418af5f626
commit 9c37471780

View File

@ -126,13 +126,20 @@ kbdGetC:
ret
.debounce:
; wait until all keys are de-pressed
; To avoid repeat keys, we require 64 subsequent polls to indicate all
; depressed keys
push af ; --> lvl 1
push bc ; --> lvl 2
.pressed:
ld b, 64
.wait:
xor a
call .get
inc a ; if a was 0xff, will become 0 (nz test)
jr nz, .wait ; non-zero? something is pressed
jr nz, .pressed ; non-zero? something is pressed
djnz .wait
pop bc ; <-- lvl 2
pop af ; <-- lvl 1
ret