Massive refactor largely to support Unicode on Mac

This does a bunch of crazy stuff:

- The ability to set a unicode mode (right now only Linux+ibus or
MacOS-RALT) in the keymap. This will be changeable at runtime soon, to
allow a single keyboard to be able to send table flips and whatever
other crazy stuff on any OS the board is plugged into (something that's
not currently doable on QMK, so yay us?)

- As part of the above, there is now just one user-facing macro for
unicode codepoint submission,
`kmk.common.macros.unicode.unicode_sequence`. Users should never use the
platform-specific macros, partly because they just outright won't work.
There's all sorts of fun stuff in these methods now, thank goodness
MicroPython supports the `yield from` construct.

- Keycode (these should really be renamed Keysym or something) objects
that are intended to not be pressed, or not be released. Right now these
properties are completely ignored if not part of a macro, and it's
probably sane to keep it that way. This was necessary to support MacOS's
"hold RALT while typing the codepoint characters" flow.

- Other refactor-y bits, like moving macro support to `kmk/common`
rather than sitting at the top level of the tree. One day `kmk/common`
may make sense to surface at top level `kmk/`, but that's a discussion
for another day.
This commit is contained in:
Josh Klar
2018-09-30 19:33:23 -07:00
parent 2024eb959f
commit ffa81bcf43
11 changed files with 126 additions and 58 deletions

View File

@@ -1,15 +1,17 @@
import machine
from kmk.common.consts import DiodeOrientation
from kmk.common.consts import DiodeOrientation, UnicodeModes
from kmk.common.keycodes import KC
from kmk.common.macros.simple import simple_key_sequence
from kmk.common.macros.unicode import unicode_sequence
from kmk.entrypoints.handwire.pyboard import main
from kmk.macros.simple import ibus_unicode_sequence, simple_key_sequence
p = machine.Pin.board
cols = (p.X10, p.X11, p.X12)
rows = (p.X1, p.X2, p.X3)
diode_orientation = DiodeOrientation.COLUMNS
unicode_mode = UnicodeModes.LINUX
MACRO_TEST_STRING = simple_key_sequence([
KC.LSHIFT(KC.H),
@@ -26,7 +28,7 @@ MACRO_TEST_STRING = simple_key_sequence([
KC.EXCLAIM,
])
ANGRY_TABLE_FLIP = ibus_unicode_sequence([
ANGRY_TABLE_FLIP = unicode_sequence([
"28",
"30ce",
"ca0",