From 2024eb959f4a494f6de2144bf931355c6b979a0f Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sun, 30 Sep 2018 18:20:18 -0700 Subject: [PATCH] Support the real reason we're all here: unicode key sequences (Linux only). Basically takes the same output style as klardotsh/qmk_emote_macro_generator outputs --- kmk/macros/simple.py | 15 +++++++++++++++ .../klardotsh/threethree_matrix_pyboard.py | 18 ++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/kmk/macros/simple.py b/kmk/macros/simple.py index 62c3cff..324b556 100644 --- a/kmk/macros/simple.py +++ b/kmk/macros/simple.py @@ -1,5 +1,6 @@ from kmk.common.event_defs import (hid_report_event, keycode_down_event, keycode_up_event) +from kmk.common.keycodes import Common, Modifiers from kmk.macros import KMKMacro @@ -12,3 +13,17 @@ def simple_key_sequence(seq): yield hid_report_event() return KMKMacro(keydown=_simple_key_sequence) + + +def ibus_unicode_sequence(codepoints): + seq = [] + + for codepoint in codepoints: + seq.append(Modifiers.KC_LCTRL(Modifiers.KC_LSHIFT(Common.KC_U))) + + for codepoint_fragment in codepoint: + seq.append(getattr(Common, 'KC_{}'.format(codepoint_fragment.upper()))) + + seq.append(Common.KC_ENTER) + + return simple_key_sequence(seq) diff --git a/user_keymaps/klardotsh/threethree_matrix_pyboard.py b/user_keymaps/klardotsh/threethree_matrix_pyboard.py index dd62898..9498a82 100644 --- a/user_keymaps/klardotsh/threethree_matrix_pyboard.py +++ b/user_keymaps/klardotsh/threethree_matrix_pyboard.py @@ -3,7 +3,7 @@ import machine from kmk.common.consts import DiodeOrientation from kmk.common.keycodes import KC from kmk.entrypoints.handwire.pyboard import main -from kmk.macros.simple import simple_key_sequence +from kmk.macros.simple import ibus_unicode_sequence, simple_key_sequence p = machine.Pin.board cols = (p.X10, p.X11, p.X12) @@ -26,6 +26,20 @@ MACRO_TEST_STRING = simple_key_sequence([ KC.EXCLAIM, ]) +ANGRY_TABLE_FLIP = ibus_unicode_sequence([ + "28", + "30ce", + "ca0", + "75ca", + "ca0", + "29", + "30ce", + "5f61", + "253b", + "2501", + "253b", +]) + keymap = [ [ [KC.MO(1), KC.GESC, KC.RESET], @@ -38,7 +52,7 @@ keymap = [ [KC.F, KC.G, KC.H], ], [ - [KC.VOLU, KC.MUTE, KC.Z], + [KC.VOLU, KC.MUTE, ANGRY_TABLE_FLIP], [KC.TRNS, KC.PIPE, KC.MEDIA_PLAY_PAUSE], [KC.VOLD, KC.P, MACRO_TEST_STRING], ],