KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.45k stars 486 forks source link

Refactor key types #988

Closed xs5871 closed 5 months ago

xs5871 commented 5 months ago

Here's the beginning of something I wanted to do for a long time: Use pythons typing system to distinguish key types, i.e. use actual classes instead the self-made type system that compares fake key codes against FIRST_KMK_INTERNAL_KEY. Also gone: secretly changing the meaning of keys with the has_modifiers attribute. Modified keys are now their own class, they work for any key (including for example mouse and media), not just keyboard HID -- a limitation that was never documented in the first place. Shifted keys are handled by the ModifiedKeys handlers and are no longer a special case deep inside hid.py, which will make resolving issues like #642 easier.

Coming soon: getting rid of key.meta, aka: "we already use classes for key types, but only sometimes, and we hide it behind a layer of indirection".