From 9ded702c411430870873a278ae4beac12026176b Mon Sep 17 00:00:00 2001 From: sago35 Date: Tue, 24 Dec 2024 08:38:59 +0900 Subject: [PATCH] Fix index-out-of-range --- keyboard.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/keyboard.go b/keyboard.go index 705f884..398ce24 100644 --- a/keyboard.go +++ b/keyboard.go @@ -350,10 +350,12 @@ func (d *Device) Tick() error { for _, xx := range noneToPress { kbidx, layer, index := decKey(xx) - x := d.kb[kbidx].Key(layer, index) - switch x & keycodes.QuantumMask { - case keycodes.TypeLxxxT, keycodes.TypeRxxxT: - d.tapOrHold[xx] = time.Now().Add(200 * time.Millisecond) + if kbidx < len(d.kb) { + x := d.kb[kbidx].Key(layer, index) + switch x & keycodes.QuantumMask { + case keycodes.TypeLxxxT, keycodes.TypeRxxxT: + d.tapOrHold[xx] = time.Now().Add(200 * time.Millisecond) + } } }