Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Caps Word #196

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/main/python/keycodes/keycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Keycode:
recorder_alias_to_keycode = dict()
qmk_id_to_keycode = dict()
protocol = 0
min_protocol = 0

def __init__(self, qmk_id, label, tooltip=None, masked=False, printable=None, recorder_alias=None, alias=None):
def __init__(self, qmk_id, label, tooltip=None, masked=False, printable=None, recorder_alias=None, alias=None, min_protocol=0):
self.qmk_id = qmk_id
self.qmk_id_to_keycode[qmk_id] = self
self.label = label
self.min_protocol = min_protocol
# we cannot embed full CJK fonts due to large size, workaround like this for now
if sys.platform == "emscripten" and not label.isascii() and qmk_id != "KC_TRNS":
self.label = qmk_id.replace("KC_", "")
Expand Down Expand Up @@ -583,8 +585,9 @@ def resolve(cls, qmk_constant):
K("KC_RAPC", "RA\n)", "Right Alt when held, ) when tapped"),
K("KC_SFTENT", "RS\nEnter", "Right Shift when held, Enter when tapped"),
]

KEYCODES_QUANTUM = [
]
KEYCODES_QUANTUM_ALL = [
K("MAGIC_SWAP_CONTROL_CAPSLOCK", "Swap\nCtrl\nCaps", "Swap Caps Lock and Left Control", alias=["CL_SWAP"]),
K("MAGIC_UNSWAP_CONTROL_CAPSLOCK", "Unswap\nCtrl\nCaps", "Unswap Caps Lock and Left Control", alias=["CL_NORM"]),
K("MAGIC_CAPSLOCK_TO_CONTROL", "Caps\nto\nCtrl", "Treat Caps Lock as Control", alias=["CL_CTRL"]),
Expand Down Expand Up @@ -653,6 +656,7 @@ def resolve(cls, qmk_constant):
K("CMB_ON", "Combo\nOn", "Turns on Combo feature"),
K("CMB_OFF", "Combo\nOff", "Turns off Combo feature"),
K("CMB_TOG", "Combo\nToggle", "Toggles Combo feature on and off"),
K("FN_CAPSWORD", "Caps\nWord\nToggle", "Toggles Caps Word on and off", min_protocol=6),
]

KEYCODES_BACKLIGHT = [
Expand Down Expand Up @@ -946,10 +950,15 @@ def resolve(cls, qmk_constant):
K = None


def recreate_keycodes():
def recreate_keycodes(min_protocol=0):
""" Regenerates global KEYCODES array """

KEYCODES.clear()
KEYCODES_QUANTUM.clear()
if min_protocol > 0:
for keycode in KEYCODES_QUANTUM_ALL:
if min_protocol >= keycode.min_protocol:
KEYCODES_QUANTUM.append(keycode)
KEYCODES.extend(KEYCODES_SPECIAL + KEYCODES_BASIC + KEYCODES_SHIFTED + KEYCODES_ISO + KEYCODES_LAYERS +
KEYCODES_BOOT + KEYCODES_MODIFIERS + KEYCODES_QUANTUM + KEYCODES_BACKLIGHT + KEYCODES_MEDIA +
KEYCODES_TAP_DANCE + KEYCODES_MACRO + KEYCODES_USER + KEYCODES_HIDDEN + KEYCODES_MIDI)
Expand Down Expand Up @@ -1059,7 +1068,5 @@ def generate_keycodes_for_mask(label, description):

create_midi_keycodes(keyboard.midi)

recreate_keycodes()

recreate_keycodes(keyboard.vial_protocol)

recreate_keycodes()
2 changes: 2 additions & 0 deletions src/main/python/keycodes/keycodes_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ class keycodes_v6:

"RESET": 0x7C00,

"FN_CAPSWORD": 0x7C73,

"FN_MO13": 0x7C77,
"FN_MO23": 0x7C78,

Expand Down
7 changes: 4 additions & 3 deletions src/main/python/tabbed_keycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def __init__(self, parent=None, keycode_filter=keycode_filter_any):
(None, KEYCODES_ISO),
], prefix_buttons=[("Any", -1)]),
SimpleTab(self, "Layers", KEYCODES_LAYERS),
Tab(self, "Quantum", [(mods, (KEYCODES_BOOT + KEYCODES_QUANTUM)),
(mods_narrow, (KEYCODES_BOOT + KEYCODES_QUANTUM)),
(None, (KEYCODES_BOOT + KEYCODES_MODIFIERS + KEYCODES_QUANTUM))]),
Tab(self, "Modifiers", [(mods, KEYCODES_BOOT),
(mods_narrow, KEYCODES_BOOT),
(None, KEYCODES_BOOT + KEYCODES_MODIFIERS)]),
SimpleTab(self, "Quantum", KEYCODES_QUANTUM),
SimpleTab(self, "Backlight", KEYCODES_BACKLIGHT),
SimpleTab(self, "App, Media and Mouse", KEYCODES_MEDIA),
SimpleTab(self, "MIDI", KEYCODES_MIDI),
Expand Down