fix KC.LM

This commit is contained in:
xs5871 2022-05-26 11:29:41 +00:00 committed by Kyle Brown
parent 4a29530ad5
commit 08d3386643
3 changed files with 32 additions and 3 deletions

View File

@ -5,7 +5,7 @@ def key_seq_sleep_validator(ms):
return KeySeqSleepMeta(ms)
def layer_key_validator(layer):
def layer_key_validator(layer, kc=None):
'''
Validates the syntax (but not semantics) of a layer key call. We won't
have access to the keymap here, so we can't verify much of anything useful
@ -13,7 +13,7 @@ def layer_key_validator(layer):
existing is mostly that Python will catch extraneous args/kwargs and error
out.
'''
return LayerKeyMeta(layer)
return LayerKeyMeta(layer, kc)
def mod_tap_validator(

View File

@ -28,8 +28,9 @@ class HoldTapKeyMeta:
class LayerKeyMeta:
def __init__(self, layer):
def __init__(self, layer, kc=None):
self.layer = layer
self.kc = kc
class ModTapKeyMeta(HoldTapKeyMeta):

28
tests/test_layers.py Normal file
View File

@ -0,0 +1,28 @@
import unittest
from kmk.keys import KC
from kmk.modules.layers import Layers
from tests.keyboard_test import KeyboardTest
class TestLayers(unittest.TestCase):
def setUp(self):
self.kb = KeyboardTest(
[Layers()],
[
[KC.N0, KC.LM(1, KC.LCTL)],
[KC.A, KC.B],
],
debug_enabled=False,
)
def test_layermod(self):
self.kb.test(
'Layer + Mod',
[(1, True), (0, True), (1, False), (0, False)],
[{KC.LCTL}, {KC.LCTL, KC.A}, {KC.A}, {}],
)
if __name__ == '__main__':
unittest.main()