From 5cfcb4324b9242be7da434efe42cfb7403446953 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sat, 6 Jul 2019 17:03:35 -0700 Subject: [PATCH] Don't crash when seven keys are pressed. --- menelaus.scm | 4 ++-- test.rkt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/menelaus.scm b/menelaus.scm index 3415b3b..1579a1f 100644 --- a/menelaus.scm +++ b/menelaus.scm @@ -154,8 +154,8 @@ (define (press-normal-key keycode key) (let ((slot (find keycodes-down 0))) - (vector-set! keycodes-down slot keycode) - (vector-set! keys-for-frame slot key))) + (and slot (vector-set! keycodes-down slot keycode)) + (and slot (vector-set! keys-for-frame slot key)))) (define (press-key key) (let ((keycode (lookup key))) diff --git a/test.rkt b/test.rkt index eb95943..57bf4b9 100644 --- a/test.rkt +++ b/test.rkt @@ -92,6 +92,8 @@ ((40) . (())) ;; base layer key ((2) . (() ,key-e)) + ;; seven keys down + ((1 2 3 4 7 8 9) . (() ,key-e ,key-w ,key-r ,key-t ,key-u ,key-i)) ;; shift combo and shift key simultaneously ((40) . (())) ((40 1 36) . ((shift) ,key-2))