This commit is contained in:
Ryan 2025-07-16 17:58:21 +10:00 committed by GitHub
commit ba58401b18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 14 deletions

View File

@ -2,11 +2,6 @@
"keyboard_name": "%KEYBOARD%", "keyboard_name": "%KEYBOARD%",
"maintainer": "%USER_NAME%", "maintainer": "%USER_NAME%",
"manufacturer": "%REAL_NAME%", "manufacturer": "%REAL_NAME%",
"diode_direction": "COL2ROW",
"matrix_pins": {
"cols": ["C2"],
"rows": ["D1"]
},
"usb": { "usb": {
"vid": "0xFEED", "vid": "0xFEED",
"pid": "0x0000", "pid": "0x0000",

View File

@ -91,16 +91,21 @@ def augment_community_info(config, src, dest):
# avoid assumptions on macro name by using the first available # avoid assumptions on macro name by using the first available
first_layout = next(iter(info["layouts"].values()))["layout"] first_layout = next(iter(info["layouts"].values()))["layout"]
# guess at width and height now its optional matrix_type = prompt_matrix_type()
width, height = (0, 0) (rows, cols) = prompt_matrix_size(len(first_layout))
for item in first_layout:
width = max(width, int(item["x"]) + 1)
height = max(height, int(item["y"]) + 1)
info["matrix_pins"] = { if matrix_type == 'direct':
"cols": ["C2"] * width, info["matrix_pins"] = {
"rows": ["D1"] * height, "direct": [
} ["C2"] * cols,
] * rows,
}
elif matrix_type in ['COL2ROW', 'ROW2COL']:
info["diode_direction"] = matrix_type
info["matrix_pins"] = {
"cols": ["C2"] * cols,
"rows": ["D1"] * rows,
}
# assume a 1:1 mapping on matrix to electrical # assume a 1:1 mapping on matrix to electrical
for item in first_layout: for item in first_layout:
@ -136,6 +141,32 @@ def prompt_heading_subheading(heading, subheading):
cli.log.info(subheading) cli.log.info(subheading)
def prompt_matrix_type():
prompt_heading_subheading("Specify Matrix Type", "")
matrix_types = ['COL2ROW', 'ROW2COL', 'direct', 'custom']
return choice("Matrix type?", matrix_types)
def prompt_matrix_size(key_count):
prompt_heading_subheading("Specify Matrix Dimensions", "The number of rows and columns in the electrical matrix")
errmsg = 'Need at least one row or column!'
ret = True
while ret:
rows = int(_question("Rows:", reprompt=errmsg, validate=lambda x: int(x) > 0))
cols = int(_question("Cols:", reprompt=errmsg, validate=lambda x: int(x) > 0))
if rows * cols >= key_count:
ret = False
else:
cli.log.error(f"Number of rows ({rows}) * number of cols ({cols}) is not sufficient for the number of keys in the selected layout ({key_count})!")
return (rows, cols)
def prompt_keyboard(): def prompt_keyboard():
prompt_heading_subheading("Name Your Keyboard Project", """For more information, see: prompt_heading_subheading("Name Your Keyboard Project", """For more information, see:
https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project""") https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project""")