Since kmk/modules/combos.py#L59 (__repr__ - creates string representation, p.e. for debugging)
accesses the code attribute of matching keys unconditionally, it
results in an AttributeError: 'HoldTapKey' object has no attribute 'code'.
To Reproduce
Steps to reproduce the behavior:
Use the current main branch
Use this minimal example as main.py:
from kmk.keys import KC
from kmk.modules.combos import Combos, Chord, Sequence
from kmk.modules.holdtap import HoldTap
keyboard = KMKKeyboard()
* Input: Press the two keys that are configured in the combo (hold or tap doesn't matter)
**Expected behavior**
Output should be the result of the combo: PLUS on tap, R on hold
**Debug output**
755828 kmk.keyboard: <Event: key_number 11 pressed>: HoldTapKey
755832 kmk.keyboard: coordkeys_pressed={11: None}
755854 kmk.keyboard: <Event: key_number 17 pressed>: HoldTapKey
755858 kmk.modules.combos: activate755860 kmk.modules.combos: process_key: AttributeError: 'HoldTapKey' object has no attribute 'code'
755861 kmk.keyboard: coordkeys_pressed={17: HoldTapKey, 11: None}
755903 kmk.modules.combos: activateTraceback (most recent call last):
File "kmk/kmk_keyboard.py", line 454, in go
File "kmk/kmk_keyboard.py", line 528, in _main_loop
File "kmk/kmk_keyboard.py", line 267, in _process_timeouts
File "kmk/modules/combos.py", line 191, in
File "kmk/modules/combos.py", line 286, in on_timeout
File "kmk/modules/combos.py", line 306, in activate
File "kmk/utils.py", line 31, in call
File "kmk/modules/combos.py", line 59, in repr
File "kmk/modules/combos.py", line 59, in
AttributeError: 'HoldTapKey' object has no attribute 'code'
755912 kmk.keyboard: cleaning up...
755916 kmk.keyboard: ...done
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
Describe the bug When using a HoldTapKey in a Combo and activating the debug mode, the firmware will crash, display a stacktrace and abort running.
Since the refactoring Add KeyboardKey class to distinguish from internal Keys, internal keys like HoldTapKey don't have a
code
attribute anymore and trying to access it must fail.Since kmk/modules/combos.py#L59 (
__repr__
- creates string representation, p.e. for debugging) accesses thecode
attribute of matching keys unconditionally, it results in anAttributeError: 'HoldTapKey' object has no attribute 'code'
.To Reproduce Steps to reproduce the behavior:
keyboard.modules.append(HoldTap())
S_A = KC.HT(KC.S, KC.A) T_M = KC.HT(KC.T, KC.M)
combos = Combos() combos.combos = [ Chord((S_A, T_M), KC.HT(KC.PLUS, KC.R)), ] keyboard.modules.append(combos)
from kmk.keys import KC keyboard.keymap = [[S_A, T_M]] keyboard.debug_enabled = True
if name == 'main': keyboard.go()
755828 kmk.keyboard: <Event: key_number 11 pressed>: HoldTapKey 755832 kmk.keyboard: coordkeys_pressed={11: None} 755854 kmk.keyboard: <Event: key_number 17 pressed>: HoldTapKey 755858 kmk.modules.combos: activate755860 kmk.modules.combos: process_key: AttributeError: 'HoldTapKey' object has no attribute 'code' 755861 kmk.keyboard: coordkeys_pressed={17: HoldTapKey, 11: None} 755903 kmk.modules.combos: activateTraceback (most recent call last): File "kmk/kmk_keyboard.py", line 454, in go File "kmk/kmk_keyboard.py", line 528, in _main_loop File "kmk/kmk_keyboard.py", line 267, in _process_timeouts File "kmk/modules/combos.py", line 191, in
File "kmk/modules/combos.py", line 286, in on_timeout
File "kmk/modules/combos.py", line 306, in activate
File "kmk/utils.py", line 31, in call
File "kmk/modules/combos.py", line 59, in repr
File "kmk/modules/combos.py", line 59, in
AttributeError: 'HoldTapKey' object has no attribute 'code'
755912 kmk.keyboard: cleaning up...
755916 kmk.keyboard: ...done
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.