Merge pull request #48 from KMKfw/topic-emotes-as-strings
Ability to create emote/emoji macros from strings directly, on-board.
This commit is contained in:
commit
c0b78fe3f2
@ -3,6 +3,7 @@ from kmk.common.event_defs import (hid_report_event, keycode_down_event,
|
|||||||
keycode_up_event)
|
keycode_up_event)
|
||||||
from kmk.common.keycodes import Common, Macro, Modifiers
|
from kmk.common.keycodes import Common, Macro, Modifiers
|
||||||
from kmk.common.macros.simple import simple_key_sequence
|
from kmk.common.macros.simple import simple_key_sequence
|
||||||
|
from kmk.common.util import get_wide_ordinal
|
||||||
|
|
||||||
IBUS_KEY_COMBO = Modifiers.KC_LCTRL(Modifiers.KC_LSHIFT(Common.KC_U))
|
IBUS_KEY_COMBO = Modifiers.KC_LCTRL(Modifiers.KC_LSHIFT(Common.KC_U))
|
||||||
|
|
||||||
@ -24,7 +25,18 @@ def generate_codepoint_keysym_seq(codepoint):
|
|||||||
return seq
|
return seq
|
||||||
|
|
||||||
|
|
||||||
def unicode_sequence(codepoints):
|
def unicode_string_sequence(unistring):
|
||||||
|
'''
|
||||||
|
Allows sending things like (╯°□°)╯︵ ┻━┻ directly, without
|
||||||
|
manual conversion to Unicode codepoints.
|
||||||
|
'''
|
||||||
|
return unicode_codepoint_sequence([
|
||||||
|
hex(get_wide_ordinal(s))[2:]
|
||||||
|
for s in unistring
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def unicode_codepoint_sequence(codepoints):
|
||||||
def _unicode_sequence(state):
|
def _unicode_sequence(state):
|
||||||
if state.unicode_mode == UnicodeModes.IBUS:
|
if state.unicode_mode == UnicodeModes.IBUS:
|
||||||
yield from _ibus_unicode_sequence(codepoints, state)
|
yield from _ibus_unicode_sequence(codepoints, state)
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
def get_wide_ordinal(char):
|
||||||
|
if len(char) != 2:
|
||||||
|
return ord(char)
|
||||||
|
|
||||||
|
return 0x10000 + (ord(char[0]) - 0xD800) * 0x400 + (ord(char[1]) - 0xDC00)
|
||||||
|
|
||||||
|
|
||||||
def flatten_dict(d):
|
def flatten_dict(d):
|
||||||
items = {}
|
items = {}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from kmk.common.consts import DiodeOrientation, LeaderMode, UnicodeModes
|
from kmk.common.consts import DiodeOrientation, LeaderMode, UnicodeModes
|
||||||
from kmk.common.keycodes import KC
|
from kmk.common.keycodes import KC
|
||||||
from kmk.common.macros.unicode import unicode_sequence
|
from kmk.common.macros.unicode import unicode_codepoint_sequence
|
||||||
from kmk.common.pins import Pin as P
|
from kmk.common.pins import Pin as P
|
||||||
from kmk.entrypoints.handwire.pyboard import main
|
from kmk.entrypoints.handwire.pyboard import main
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ leader_timeout = 2000
|
|||||||
DEBUG_ENABLE = True
|
DEBUG_ENABLE = True
|
||||||
|
|
||||||
# -------------------------------Macros -----------------------------------------------
|
# -------------------------------Macros -----------------------------------------------
|
||||||
FLIP = unicode_sequence([
|
FLIP = unicode_codepoint_sequence([
|
||||||
"28",
|
"28",
|
||||||
"30ce",
|
"30ce",
|
||||||
"ca0",
|
"ca0",
|
||||||
@ -35,7 +35,7 @@ FLIP = unicode_sequence([
|
|||||||
|
|
||||||
LEADER_DICTIONARY = {
|
LEADER_DICTIONARY = {
|
||||||
(KC.F, KC.L, KC.I, KC.P):
|
(KC.F, KC.L, KC.I, KC.P):
|
||||||
unicode_sequence([
|
unicode_codepoint_sequence([
|
||||||
"28",
|
"28",
|
||||||
"30ce",
|
"30ce",
|
||||||
"ca0",
|
"ca0",
|
||||||
@ -49,7 +49,7 @@ LEADER_DICTIONARY = {
|
|||||||
"253b",
|
"253b",
|
||||||
]),
|
]),
|
||||||
(KC.C, KC.H, KC.E, KC.E, KC.R):
|
(KC.C, KC.H, KC.E, KC.E, KC.R):
|
||||||
unicode_sequence([
|
unicode_codepoint_sequence([
|
||||||
'002B',
|
'002B',
|
||||||
'FF61',
|
'FF61',
|
||||||
'003A',
|
'003A',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
||||||
from kmk.common.keycodes import KC
|
from kmk.common.keycodes import KC
|
||||||
from kmk.common.macros.simple import send_string, simple_key_sequence
|
from kmk.common.macros.simple import send_string, simple_key_sequence
|
||||||
from kmk.common.macros.unicode import unicode_sequence
|
from kmk.common.macros.unicode import unicode_codepoint_sequence
|
||||||
from kmk.common.pins import Pin as P
|
from kmk.common.pins import Pin as P
|
||||||
from kmk.entrypoints.handwire.feather_m4_express import main
|
from kmk.entrypoints.handwire.feather_m4_express import main
|
||||||
from kmk.firmware import Firmware
|
from kmk.firmware import Firmware
|
||||||
@ -31,7 +31,7 @@ MACRO_TEST_SIMPLE = simple_key_sequence([
|
|||||||
|
|
||||||
MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]")
|
MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]")
|
||||||
|
|
||||||
ANGRY_TABLE_FLIP = unicode_sequence([
|
ANGRY_TABLE_FLIP = unicode_codepoint_sequence([
|
||||||
"28",
|
"28",
|
||||||
"30ce",
|
"30ce",
|
||||||
"ca0",
|
"ca0",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
||||||
from kmk.common.keycodes import KC
|
from kmk.common.keycodes import KC
|
||||||
from kmk.common.macros.simple import send_string, simple_key_sequence
|
from kmk.common.macros.simple import send_string, simple_key_sequence
|
||||||
from kmk.common.macros.unicode import unicode_sequence
|
from kmk.common.macros.unicode import unicode_string_sequence
|
||||||
from kmk.common.pins import Pin as P
|
from kmk.common.pins import Pin as P
|
||||||
|
from kmk.common.types import AttrDict
|
||||||
from kmk.entrypoints.handwire.itsybitsy_m4_express import main
|
from kmk.entrypoints.handwire.itsybitsy_m4_express import main
|
||||||
from kmk.firmware import Firmware
|
from kmk.firmware import Firmware
|
||||||
|
|
||||||
@ -12,7 +13,40 @@ rows = (P.D12, P.D11, P.D10)
|
|||||||
diode_orientation = DiodeOrientation.COLUMNS
|
diode_orientation = DiodeOrientation.COLUMNS
|
||||||
unicode_mode = UnicodeModes.LINUX
|
unicode_mode = UnicodeModes.LINUX
|
||||||
|
|
||||||
MACRO_TEST_SIMPLE = simple_key_sequence([
|
emoticons = AttrDict({
|
||||||
|
# Emojis
|
||||||
|
'BEER': r'🍺',
|
||||||
|
'BEER_TOAST': r'🍻',
|
||||||
|
'FACE_CUTE_SMILE': r'😊',
|
||||||
|
'FACE_HEART_EYES': r'😍',
|
||||||
|
'FACE_JOY': r'😂',
|
||||||
|
'FACE_SWEAT_SMILE': r'😅',
|
||||||
|
'FACE_THINKING': r'🤔',
|
||||||
|
'FIRE': r'🔥',
|
||||||
|
'FLAG_CA': r'🇨🇦',
|
||||||
|
'FLAG_US': r'🇺🇸',
|
||||||
|
'HAND_CLAP': r'👏',
|
||||||
|
'HAND_HORNS': r'🤘',
|
||||||
|
'HAND_OK': r'👌',
|
||||||
|
'HAND_THUMB_DOWN': r'👎',
|
||||||
|
'HAND_THUMB_UP': r'👍',
|
||||||
|
'HAND_WAVE': r'👋',
|
||||||
|
'HEART': r'❤️',
|
||||||
|
'MAPLE_LEAF': r'🍁',
|
||||||
|
'POOP': r'💩',
|
||||||
|
'TADA': r'🎉',
|
||||||
|
|
||||||
|
# Emoticons, but fancier
|
||||||
|
'ANGRY_TABLE_FLIP': r'(ノಠ痊ಠ)ノ彡┻━┻',
|
||||||
|
'CELEBRATORY_GLITTER': r'+。:.゚ヽ(´∀。)ノ゚.:。+゚゚+。:.゚ヽ(*´∀)ノ゚.:。+゚',
|
||||||
|
'SHRUGGIE': r'¯\_(ツ)_/¯',
|
||||||
|
'TABLE_FLIP': r'(╯°□°)╯︵ ┻━┻',
|
||||||
|
})
|
||||||
|
|
||||||
|
for k, v in emoticons.items():
|
||||||
|
emoticons[k] = unicode_string_sequence(v)
|
||||||
|
|
||||||
|
MACRO_HELLO_WORLD = simple_key_sequence([
|
||||||
KC.LSHIFT(KC.H),
|
KC.LSHIFT(KC.H),
|
||||||
KC.E,
|
KC.E,
|
||||||
KC.L,
|
KC.L,
|
||||||
@ -29,22 +63,6 @@ MACRO_TEST_SIMPLE = simple_key_sequence([
|
|||||||
KC.EXCLAIM,
|
KC.EXCLAIM,
|
||||||
])
|
])
|
||||||
|
|
||||||
MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]")
|
|
||||||
|
|
||||||
ANGRY_TABLE_FLIP = unicode_sequence([
|
|
||||||
"28",
|
|
||||||
"30ce",
|
|
||||||
"ca0",
|
|
||||||
"75ca",
|
|
||||||
"ca0",
|
|
||||||
"29",
|
|
||||||
"30ce",
|
|
||||||
"5f61",
|
|
||||||
"253b",
|
|
||||||
"2501",
|
|
||||||
"253b",
|
|
||||||
])
|
|
||||||
|
|
||||||
keymap = [
|
keymap = [
|
||||||
[
|
[
|
||||||
[KC.GESC, KC.A, KC.RESET],
|
[KC.GESC, KC.A, KC.RESET],
|
||||||
@ -57,8 +75,8 @@ keymap = [
|
|||||||
[KC.F, KC.G, KC.H],
|
[KC.F, KC.G, KC.H],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[KC.VOLU, KC.MUTE, ANGRY_TABLE_FLIP],
|
[emoticons.CELEBRATORY_GLITTER, emoticons.SHRUGGIE, emoticons.ANGRY_TABLE_FLIP],
|
||||||
[KC.NO, KC.PIPE, MACRO_TEST_SIMPLE],
|
[emoticons.BEER, emoticons.FLAG_CA, emoticons.FLAG_US],
|
||||||
[KC.TRNS, KC.P, MACRO_TEST_STRING],
|
[KC.TRNS, KC.P, MACRO_HELLO_WORLD],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
from kmk.common.consts import DiodeOrientation, UnicodeModes
|
||||||
from kmk.common.keycodes import KC
|
from kmk.common.keycodes import KC
|
||||||
from kmk.common.macros.simple import send_string, simple_key_sequence
|
from kmk.common.macros.simple import send_string, simple_key_sequence
|
||||||
from kmk.common.macros.unicode import unicode_sequence
|
from kmk.common.macros.unicode import unicode_codepoint_sequence
|
||||||
from kmk.common.pins import Pin as P
|
from kmk.common.pins import Pin as P
|
||||||
from kmk.entrypoints.handwire.pyboard import main
|
from kmk.entrypoints.handwire.pyboard import main
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ MACRO_TEST_SIMPLE = simple_key_sequence([
|
|||||||
|
|
||||||
MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]")
|
MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]")
|
||||||
|
|
||||||
ANGRY_TABLE_FLIP = unicode_sequence([
|
ANGRY_TABLE_FLIP = unicode_codepoint_sequence([
|
||||||
"28",
|
"28",
|
||||||
"30ce",
|
"30ce",
|
||||||
"ca0",
|
"ca0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user