Resolve issue 285 in parsing logic, KC.NO was being parsed has an alpha, swapped the control flow treating the special case KC.NO and KC.XXXXX before alphas and nimbers
-Fix linting error on last PR
This commit is contained in:
parent
e1300ba767
commit
5fcd31b97c
30
kmk/keys.py
30
kmk/keys.py
@ -75,27 +75,14 @@ class KeyAttrDict(AttrDict):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Basic ASCII letters/numbers don't need anything fancy, so check those
|
# Try all the other weird special cases to get them out of our way:
|
||||||
# in the laziest way
|
# This need to be done before or ALPHAS because NO will be parsed as alpha
|
||||||
if key in ALL_ALPHAS:
|
|
||||||
make_key(code=4 + ALL_ALPHAS.index(key), names=(key,))
|
|
||||||
elif key in ALL_NUMBERS or key in ALL_NUMBER_ALIASES:
|
|
||||||
try:
|
|
||||||
offset = ALL_NUMBERS.index(key)
|
|
||||||
except ValueError:
|
|
||||||
offset = ALL_NUMBER_ALIASES.index(key)
|
|
||||||
|
|
||||||
names = (ALL_NUMBERS[offset], ALL_NUMBER_ALIASES[offset])
|
|
||||||
make_key(code=30 + offset, names=names)
|
|
||||||
|
|
||||||
# Now try all the other weird special cases to get them out of our way:
|
|
||||||
|
|
||||||
# Internal, diagnostic, or auxiliary/enhanced keys
|
# Internal, diagnostic, or auxiliary/enhanced keys
|
||||||
|
|
||||||
# NO and TRNS are functionally identical in how they (don't) mutate
|
# NO and TRNS are functionally identical in how they (don't) mutate
|
||||||
# the state, but are tracked semantically separately, so create
|
# the state, but are tracked semantically separately, so create
|
||||||
# two keys with the exact same functionality
|
# two keys with the exact same functionality
|
||||||
elif key in ('NO', 'XXXXXXX'):
|
if key in ('NO', 'XXXXXXX'):
|
||||||
make_key(
|
make_key(
|
||||||
names=('NO', 'XXXXXXX'),
|
names=('NO', 'XXXXXXX'),
|
||||||
on_press=handlers.passthrough,
|
on_press=handlers.passthrough,
|
||||||
@ -107,7 +94,18 @@ class KeyAttrDict(AttrDict):
|
|||||||
on_press=handlers.passthrough,
|
on_press=handlers.passthrough,
|
||||||
on_release=handlers.passthrough,
|
on_release=handlers.passthrough,
|
||||||
)
|
)
|
||||||
|
# Basic ASCII letters/numbers don't need anything fancy, so check those
|
||||||
|
# in the laziest way
|
||||||
|
elif key in ALL_ALPHAS:
|
||||||
|
make_key(code=4 + ALL_ALPHAS.index(key), names=(key,))
|
||||||
|
elif key in ALL_NUMBERS or key in ALL_NUMBER_ALIASES:
|
||||||
|
try:
|
||||||
|
offset = ALL_NUMBERS.index(key)
|
||||||
|
except ValueError:
|
||||||
|
offset = ALL_NUMBER_ALIASES.index(key)
|
||||||
|
|
||||||
|
names = (ALL_NUMBERS[offset], ALL_NUMBER_ALIASES[offset])
|
||||||
|
make_key(code=30 + offset, names=names)
|
||||||
elif key in ('RESET',):
|
elif key in ('RESET',):
|
||||||
make_key(names=('RESET',), on_press=handlers.reset)
|
make_key(names=('RESET',), on_press=handlers.reset)
|
||||||
elif key in ('BOOTLOADER',):
|
elif key in ('BOOTLOADER',):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user