Ratelimit keypresses
This commit is contained in:
parent
d5cbe21b67
commit
fc22882dc4
15
main.py
15
main.py
|
@ -196,6 +196,18 @@ text_line = 0
|
||||||
|
|
||||||
logging.info('Starting main loop...')
|
logging.info('Starting main loop...')
|
||||||
|
|
||||||
|
|
||||||
|
last_key = time.time()
|
||||||
|
def ratelimit_key():
|
||||||
|
global last_key
|
||||||
|
|
||||||
|
if think_to_send or sign_to_send or time.time() > last_key + 1:
|
||||||
|
last_key = time.time()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if current_screen != 'debug':
|
if current_screen != 'debug':
|
||||||
c = 0
|
c = 0
|
||||||
|
@ -473,6 +485,8 @@ while True:
|
||||||
if skip_input:
|
if skip_input:
|
||||||
skip_input = False
|
skip_input = False
|
||||||
else:
|
else:
|
||||||
|
curses.flushinp()
|
||||||
|
if ratelimit_key(): continue
|
||||||
try:
|
try:
|
||||||
c = stdscr.getch()
|
c = stdscr.getch()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -489,6 +503,7 @@ while True:
|
||||||
if c and time.time() - highlight_debounce > 0.6:
|
if c and time.time() - highlight_debounce > 0.6:
|
||||||
highlight_debounce = time.time()
|
highlight_debounce = time.time()
|
||||||
highlight_keys = True
|
highlight_keys = True
|
||||||
|
curses.beep()
|
||||||
|
|
||||||
if current_screen == 'home':
|
if current_screen == 'home':
|
||||||
if button == 's':
|
if button == 's':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user