diff --git a/kmk/common/consts.py b/kmk/common/consts.py index 29fddd9..ae681b5 100644 --- a/kmk/common/consts.py +++ b/kmk/common/consts.py @@ -119,3 +119,4 @@ class UnicodeModes: NOOP = 0 LINUX = IBUS = 1 MACOS = OSX = RALT = 2 + WINC = 3 diff --git a/kmk/common/keycodes.py b/kmk/common/keycodes.py index 3ba5e1a..498801b 100644 --- a/kmk/common/keycodes.py +++ b/kmk/common/keycodes.py @@ -453,6 +453,7 @@ class KMK(KeycodeCategory): KC_UC_MODE_MACOS = KC_UC_MODE_OSX = KC_UC_MODE_RALT = UnicodeModeKeycode.from_mode_const( UnicodeModes.RALT, ) + KC_UC_MODE_WINC = UnicodeModeKeycode.from_mode_const(UnicodeModes.WINC) class Layers(KeycodeCategory): diff --git a/kmk/common/macros/unicode.py b/kmk/common/macros/unicode.py index 2a6f090..11c465f 100644 --- a/kmk/common/macros/unicode.py +++ b/kmk/common/macros/unicode.py @@ -21,6 +21,8 @@ def unicode_sequence(codepoints): yield from _ibus_unicode_sequence(codepoints, state) elif state.unicode_mode == UnicodeModes.RALT: yield from _ralt_unicode_sequence(codepoints, state) + elif state.unicode_mode == UnicodeModes.WINC: + yield from _winc_unicode_sequence(codepoints, state) return KMKMacro(keydown=_unicode_sequence) @@ -43,3 +45,16 @@ def _ibus_unicode_sequence(codepoints, state): seq.append(Common.KC_ENTER) yield from simple_key_sequence(seq).keydown(state) + + +def _winc_unicode_sequence(codepoints, state): + ''' + Send unicode sequence using WinCompose: + + http://wincompose.info/ + https://github.com/SamHocevar/wincompose + ''' + for codepoint in codepoints: + yield keycode_down_event(Modifiers.RALT()) + yield keycode_down_event(Common.KC_U()) + yield from simple_key_sequence(generate_codepoint_keysym_seq(codepoint)).keydown(state)