forked from mirrors/qmk_firmware
Allow community layouts to be specified in info.json (#14682)
* move the community layout detection to python * fixup tests
This commit is contained in:
parent
f72b2ad720
commit
20f81af98a
4 changed files with 21 additions and 31 deletions
31
Makefile
31
Makefile
|
@ -303,37 +303,8 @@ define PARSE_KEYBOARD
|
||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
|
||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
|
||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
|
||||||
# this might be needed, but in a different form
|
|
||||||
#KEYMAPS := $$(sort $$(filter-out $$(KEYBOARD_FOLDER_1) $$(KEYBOARD_FOLDER_2) \
|
|
||||||
$$(KEYBOARD_FOLDER_3) $$(KEYBOARD_FOLDER_4) $$(KEYBOARD_FOLDER_5), $$(KEYMAPS)))
|
|
||||||
|
|
||||||
KEYBOARD_LAYOUTS :=
|
|
||||||
ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk)","")
|
|
||||||
LAYOUTS :=
|
|
||||||
$$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk)
|
|
||||||
KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
|
|
||||||
endif
|
|
||||||
ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk)","")
|
|
||||||
LAYOUTS :=
|
|
||||||
$$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk)
|
|
||||||
KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
|
|
||||||
endif
|
|
||||||
ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk)","")
|
|
||||||
LAYOUTS :=
|
|
||||||
$$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk)
|
|
||||||
KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
|
|
||||||
endif
|
|
||||||
ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk)","")
|
|
||||||
LAYOUTS :=
|
|
||||||
$$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk)
|
|
||||||
KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
|
|
||||||
endif
|
|
||||||
ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk)","")
|
|
||||||
LAYOUTS :=
|
|
||||||
$$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk)
|
|
||||||
KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
KEYBOARD_LAYOUTS := $(shell $(QMK_BIN) list-layouts --keyboard $1)
|
||||||
LAYOUT_KEYMAPS :=
|
LAYOUT_KEYMAPS :=
|
||||||
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
|
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ subcommands = [
|
||||||
'qmk.cli.lint',
|
'qmk.cli.lint',
|
||||||
'qmk.cli.list.keyboards',
|
'qmk.cli.list.keyboards',
|
||||||
'qmk.cli.list.keymaps',
|
'qmk.cli.list.keymaps',
|
||||||
|
'qmk.cli.list.layouts',
|
||||||
'qmk.cli.kle2json',
|
'qmk.cli.kle2json',
|
||||||
'qmk.cli.multibuild',
|
'qmk.cli.multibuild',
|
||||||
'qmk.cli.new.keyboard',
|
'qmk.cli.new.keyboard',
|
||||||
|
|
|
@ -26,7 +26,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if key_type == 'array':
|
if key_type in ['array', 'list']:
|
||||||
return f'{rules_key} ?= {" ".join(rules_value)}'
|
return f'{rules_key} ?= {" ".join(rules_value)}'
|
||||||
elif key_type == 'bool':
|
elif key_type == 'bool':
|
||||||
return f'{rules_key} ?= {"on" if rules_value else "off"}'
|
return f'{rules_key} ?= {"on" if rules_value else "off"}'
|
||||||
|
|
18
lib/python/qmk/cli/list/layouts.py
Normal file
18
lib/python/qmk/cli/list/layouts.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
"""List the keymaps for a specific keyboard
|
||||||
|
"""
|
||||||
|
from milc import cli
|
||||||
|
|
||||||
|
from qmk.decorators import automagic_keyboard
|
||||||
|
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||||
|
from qmk.info import info_json
|
||||||
|
|
||||||
|
|
||||||
|
@cli.argument("-kb", "--keyboard", type=keyboard_folder, completer=keyboard_completer, help="Specify keyboard name. Example: monarch")
|
||||||
|
@cli.subcommand("List the layouts for a specific keyboard")
|
||||||
|
@automagic_keyboard
|
||||||
|
def list_layouts(cli):
|
||||||
|
"""List the layouts for a specific keyboard
|
||||||
|
"""
|
||||||
|
info_data = info_json(cli.config.list_layouts.keyboard)
|
||||||
|
for name in sorted(info_data.get('community_layouts', [])):
|
||||||
|
print(name)
|
Loading…
Reference in a new issue