From fc22882dc482735836c28d59cd955571e4b2dd6e Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 18 Sep 2022 19:23:26 -0600 Subject: [PATCH] Ratelimit keypresses --- main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.py b/main.py index bc4c1bc..27fa747 100755 --- a/main.py +++ b/main.py @@ -196,6 +196,18 @@ text_line = 0 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: if current_screen != 'debug': c = 0 @@ -473,6 +485,8 @@ while True: if skip_input: skip_input = False else: + curses.flushinp() + if ratelimit_key(): continue try: c = stdscr.getch() except KeyboardInterrupt: @@ -489,6 +503,7 @@ while True: if c and time.time() - highlight_debounce > 0.6: highlight_debounce = time.time() highlight_keys = True + curses.beep() if current_screen == 'home': if button == 's':