Compare commits

...

40 Commits

Author SHA1 Message Date
Set
1403818892
Merge ef00c5b044 into 9bea332a21 2024-11-20 22:22:13 -08:00
Ryan
9bea332a21
qmk via2json: Improve macro parsing (#24345) 2024-11-21 17:20:05 +11:00
Ryan
8cbcdcac62
qmk new-keymap: validate keymap name (#23420) 2024-11-21 17:18:51 +11:00
Stanislav
ef00c5b044 Macropad 2x5 2024-10-22 11:42:20 +03:00
Set
3565b16ff5
Merge branch 'qmk:master' into set_st-keyboards 2024-10-22 11:29:50 +03:00
Set
0b9ee47596
Rename info.json to keyboard.json 2024-10-22 11:12:21 +03:00
Set
6d25dfa99e
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:06:21 +03:00
Set
790c55c5d7
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:05:59 +03:00
Set
33c3090cb2
Update keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:05:27 +03:00
Set
98d49afc1f
Update keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:05:16 +03:00
Set
ed2b0d04f7
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:04:58 +03:00
Set
d5d4f67e0f
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:04:49 +03:00
Set
e5b92f5dc7
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:04:33 +03:00
Set
de20db2fc3
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:04:03 +03:00
Set
e4068abe6f
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:03:47 +03:00
Set
cd9fbbc21e
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:03:11 +03:00
Set
60375da441
Update keyboards/handwired/set_st/rp2040/extra.h
Co-authored-by: Drashna Jaelre <drashna@live.com>
2024-10-22 11:02:55 +03:00
Set
b5af9041e2
Merge branch 'qmk:master' into set_st-keyboards 2024-05-28 16:22:12 +03:00
Stanislav
503049cdae change structure, because functions in rp2040.c did not works properly. i was need access to keymap array. 2024-04-12 16:21:26 +03:00
Stanislav
ec67d265f2 some updates, move code in rp2040.c 2024-04-12 14:09:10 +03:00
Stanislav
8254e20e22 some updates, move code in rp2040.c 2024-04-12 13:34:05 +03:00
Stanislav
2d52271935 some updates, move code in rp2040.c 2024-04-12 13:31:48 +03:00
Stanislav
a056a1748c some updates, move code in rp2040.c 2024-04-12 13:27:16 +03:00
Set
d7b8f7e4a7
Merge branch 'master' into set_st-keyboards 2024-03-22 13:17:18 +02:00
Set
24b46006db
Merge branch 'master' into set_st-keyboards 2024-03-15 14:35:24 +02:00
Set
9ec6975d30
Merge branch 'master' into set_st-keyboards 2024-03-14 13:07:45 +02:00
Set
fbc0592526
Merge branch 'master' into set_st-keyboards 2024-03-13 14:37:39 +02:00
Set
cd8ed6d131
Merge branch 'master' into set_st-keyboards 2024-03-11 11:48:15 +02:00
Set
d65468ab7f
Merge branch 'master' into set_st-keyboards 2024-03-10 16:45:47 +02:00
Set
1bf81c6bf1
Merge branch 'master' into set_st-keyboards 2024-03-08 15:27:22 +02:00
Set
91df014311
Merge branch 'master' into set_st-keyboards 2024-03-06 12:47:44 +02:00
Stanislav
9cdbdca043 remove comments 2024-03-05 12:32:39 +02:00
Set
a28b3079c7
Merge branch 'master' into set_st-keyboards 2024-03-05 11:06:10 +02:00
Set
315cd4abb5
Merge branch 'master' into set_st-keyboards 2024-03-04 12:11:53 +02:00
Set
00fed3acaa
Update keyboards/handwired/set_st/rp2040/config.h
Co-authored-by: Joel Challis <git@zvecr.com>
2024-02-28 22:02:33 +02:00
Set
9558934a68
Update keyboards/handwired/set_st/rp2040/config.h
Co-authored-by: Joel Challis <git@zvecr.com>
2024-02-28 22:02:27 +02:00
Set
6416ca2752
Update keyboards/handwired/set_st/rp2040/config.h
Co-authored-by: Joel Challis <git@zvecr.com>
2024-02-28 22:02:14 +02:00
Set
c0167e72a7
Update keyboards/handwired/set_st/rp2040/halconf.h
Co-authored-by: jack <0x6a73@protonmail.com>
2024-02-28 21:56:14 +02:00
Set
4bf09490e3
Merge branch 'qmk:master' into set_st-keyboards 2024-02-28 21:27:26 +02:00
Stanislav
0e5c79d99e Macropad 2x5 2024-02-28 21:23:29 +02:00
2 changed files with 37 additions and 9 deletions

View File

@ -1,5 +1,6 @@
"""This script automates the copying of the default keymap into your own keymap.
"""
import re
import shutil
from milc import cli
@ -13,6 +14,13 @@ from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.userspace import UserspaceDefs
def validate_keymap_name(name):
"""Returns True if the given keymap name contains only a-z, 0-9 and underscore characters.
"""
regex = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_]+$')
return bool(regex.match(name))
def prompt_keyboard():
prompt = """{fg_yellow}Select Keyboard{style_reset_all}
If you`re unsure you can view a full list of supported keyboards with {fg_yellow}qmk list-keyboards{style_reset_all}.
@ -60,6 +68,10 @@ def new_keymap(cli):
cli.log.error(f'Default keymap {{fg_cyan}}{keymap_path_default}{{fg_reset}} does not exist!')
return False
if not validate_keymap_name(user_name):
cli.log.error('Keymap names must contain only {fg_cyan}a-z{fg_reset}, {fg_cyan}0-9{fg_reset} and {fg_cyan}_{fg_reset}! Please choose a different name.')
return False
if keymap_path_new.exists():
cli.log.error(f'Keymap {{fg_cyan}}{user_name}{{fg_reset}} already exists! Please choose a different name.')
return False

View File

@ -29,6 +29,7 @@ def _convert_macros(via_macros):
if len(via_macros) == 0:
return list()
split_regex = re.compile(r'(}\,)|(\,{)')
macro_group_regex = re.compile(r'({.+?})')
macros = list()
for via_macro in via_macros:
# Split VIA macro to its elements
@ -38,13 +39,28 @@ def _convert_macros(via_macros):
macro_data = list()
for m in macro:
if '{' in m or '}' in m:
# Found keycode(s)
keycodes = m.split(',')
# Remove whitespaces and curly braces from around keycodes
keycodes = list(map(lambda s: s.strip(' {}'), keycodes))
# Remove the KC prefix
keycodes = list(map(lambda s: s.replace('KC_', ''), keycodes))
macro_data.append({"action": "tap", "keycodes": keycodes})
# Split macro groups
macro_groups = macro_group_regex.findall(m)
for macro_group in macro_groups:
# Remove whitespaces and curly braces from around group
macro_group = macro_group.strip(' {}')
macro_action = 'tap'
macro_keycodes = []
if macro_group[0] == '+':
macro_action = 'down'
macro_keycodes.append(macro_group[1:])
elif macro_group[0] == '-':
macro_action = 'up'
macro_keycodes.append(macro_group[1:])
else:
macro_keycodes.extend(macro_group.split(',') if ',' in macro_group else [macro_group])
# Remove the KC prefixes
macro_keycodes = list(map(lambda s: s.replace('KC_', ''), macro_keycodes))
macro_data.append({"action": macro_action, "keycodes": macro_keycodes})
else:
# Found text
macro_data.append(m)
@ -54,13 +70,13 @@ def _convert_macros(via_macros):
def _fix_macro_keys(keymap_data):
macro_no = re.compile(r'MACRO0?([0-9]{1,2})')
macro_no = re.compile(r'MACRO0?\(([0-9]{1,2})\)')
for i in range(0, len(keymap_data)):
for j in range(0, len(keymap_data[i])):
kc = keymap_data[i][j]
m = macro_no.match(kc)
if m:
keymap_data[i][j] = f'MACRO_{m.group(1)}'
keymap_data[i][j] = f'MC_{m.group(1)}'
return keymap_data