Compare commits

...

4 Commits

Author SHA1 Message Date
Jack Sangdahl 746eff22db Add additional layouts for mkh_studio/bully (#26271)
* Add extra spacebar layouts

- Rename LAYOUT -> LAYOUT_all
  - Resize keys to not be 0.5u tall
- Add layout alias for the above
- Add LAYOUT_split_space
- Add LAYOUT_full_space

* Remove whitepsace
2026-06-18 15:59:10 -07:00
Joel Challis d36397fdd4 Implement Plover HID for VUSB (#26267) 2026-06-19 06:55:21 +10:00
Joel Challis 8522bb342d Enable modules to persist data (#26201) 2026-06-18 18:43:32 +01:00
precondition 721affff7b repeat_key.c: add implementation for get_last_record (#26263)
The `get_last_record` signature was present in repeat_key.h but without
any implementation in repeat_key.c which caused compilation errors for
any user of `get_last_record`.
2026-06-18 18:41:12 +01:00
18 changed files with 512 additions and 46 deletions
+8 -8
View File
@@ -187,9 +187,9 @@ include $(COMMUNITY_RULES_MK)
ifneq ($(COMMUNITY_MODULES),)
$(INTERMEDIATE_OUTPUT)/src/community_config.h: $(KEYMAP_JSON) $(DD_CONFIG_FILES)
$(INTERMEDIATE_OUTPUT)/src/community_post_config.h: $(KEYMAP_JSON) $(DD_CONFIG_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
$(eval CMD=$(QMK_BIN) generate-community-config-h -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/community_config.h $(KEYMAP_JSON))
$(eval CMD=$(QMK_BIN) generate-community-post-config-h -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/community_post_config.h $(KEYMAP_JSON))
@$(BUILD_CMD)
$(INTERMEDIATE_OUTPUT)/src/community_modules.h: $(KEYMAP_JSON) $(DD_CONFIG_FILES)
@@ -227,10 +227,10 @@ $(INTERMEDIATE_OUTPUT)/src/split_transaction_id_community_modules.inc: $(KEYMAP_
$(eval CMD=$(QMK_BIN) generate-split-transaction-id-community-modules-inc -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/split_transaction_id_community_modules.inc $(KEYMAP_JSON))
@$(BUILD_CMD)
COMMUNITY_CONFIG_H = $(INTERMEDIATE_OUTPUT)/src/community_config.h
COMMUNITY_POST_CONFIG_H = $(INTERMEDIATE_OUTPUT)/src/community_post_config.h
SRC += $(INTERMEDIATE_OUTPUT)/src/community_modules.c
generated-files: $(INTERMEDIATE_OUTPUT)/src/community_config.h $(INTERMEDIATE_OUTPUT)/src/community_modules.h $(INTERMEDIATE_OUTPUT)/src/community_modules.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h $(INTERMEDIATE_OUTPUT)/src/led_matrix_community_modules.inc $(INTERMEDIATE_OUTPUT)/src/rgb_matrix_community_modules.inc $(INTERMEDIATE_OUTPUT)/src/split_transaction_id_community_modules.inc
generated-files: $(INTERMEDIATE_OUTPUT)/src/community_post_config.h $(INTERMEDIATE_OUTPUT)/src/community_modules.h $(INTERMEDIATE_OUTPUT)/src/community_modules.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h $(INTERMEDIATE_OUTPUT)/src/led_matrix_community_modules.inc $(INTERMEDIATE_OUTPUT)/src/rgb_matrix_community_modules.inc $(INTERMEDIATE_OUTPUT)/src/split_transaction_id_community_modules.inc
endif
@@ -331,10 +331,6 @@ define config_h_community_module_appender
endef
$(foreach module,$(COMMUNITY_MODULE_PATHS),$(eval $(call config_h_community_module_appender,$(module))))
ifneq ($(COMMUNITY_CONFIG_H),)
CONFIG_H += $(COMMUNITY_CONFIG_H)
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","")
CONFIG_H += $(KEYBOARD_PATH_5)/config.h
endif
@@ -376,6 +372,10 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","")
POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h
endif
ifneq ($(COMMUNITY_POST_CONFIG_H),)
POST_CONFIG_H += $(COMMUNITY_POST_CONFIG_H)
endif
CONFIG_H += $(INTERMEDIATE_OUTPUT)/src/info_config.h
KEYBOARD_SRC += $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c
+3
View File
@@ -0,0 +1,3 @@
{
// This version exists to signify addition of eeconfig support.
}
+33 -17
View File
@@ -135,28 +135,45 @@ This file defines LED matrix effects in the same form as used with `led_matrix_k
This file defines RGB matrix effects in the same form as used with `rgb_matrix_kb.inc` and `rgb_matrix_user.inc` (see [Custom RGB Matrix Effects](rgb_matrix#custom-rgb-matrix-effects)). Effect mode names are prepended with `RGB_MATRIX_COMMUNITY_MODULE_`.
### Custom split keyboard data sync
### Additional Customization
Defines follow the convention, `SPLIT_TRANSACTION_IDS_MODULE_<MODULE>` (see [Custom data sync](split_keyboard#custom-data-sync)).
#### Split Keyboard Data Sync
Defines follow the convention, `SPLIT_TRANSACTION_IDS_MODULE_<MODULE>` (see [Custom data sync](split_keyboard#custom-data-sync)).
#### Persistent Configuration
Defines follow the convention, `EECONFIG_MODULE_<MODULE>_DATA_SIZE` and `EECONFIG_MODULE_<MODULE>_DATA_VERSION` (see [Custom Persistent Configuration](../feature_eeprom#datablock)).
When configured, the following APIs are available:
| API Format | Example (`hello_world` module) | API Version |
|--------------------------------------------|-----------------------------------------------|-------------|
| `eeconfig_is_<module>_datablock_valid` | `eeconfig_is_hello_world_datablock_valid` | `1.1.3` |
| `eeconfig_read_<module>_datablock` | `eeconfig_read_hello_world_datablock` | `1.1.3` |
| `eeconfig_update_<module>_datablock` | `eeconfig_update_hello_world_datablock` | `1.1.3` |
| `eeconfig_init_<module>_datablock` | `eeconfig_init_hello_world_datablock` | `1.1.3` |
| `eeconfig_read_<module>_datablock_field` | `eeconfig_read_hello_world_datablock_field` | `1.1.3` |
| `eeconfig_update_<module>_datablock_field` | `eeconfig_update_hello_world_datablock_field` | `1.1.3` |
### Compatible APIs
Community Modules may provide specializations for the following APIs:
| Base API | API Format | Example (`hello_world` module) | API Version |
|----------------------------------|-------------------------------------------|---------------------------------------------|-------------|
| `keyboard_pre_init` | `keyboard_pre_init_<module>` | `keyboard_pre_init_hello_world` | `0.1.0` |
| `keyboard_post_init` | `keyboard_post_init_<module>` | `keyboard_post_init_hello_world` | `0.1.0` |
| `pre_process_record` | `pre_process_record_<module>` | `pre_process_record_hello_world` | `0.1.0` |
| `process_record` | `process_record_<module>` | `process_record_hello_world` | `0.1.0` |
| `post_process_record` | `post_process_record_<module>` | `post_process_record_hello_world` | `0.1.0` |
| `housekeeping_task` | `housekeeping_task_<module>` | `housekeeping_task_hello_world` | `1.0.0` |
| `suspend_power_down` | `suspend_power_down_<module>` | `suspend_power_down_hello_world` | `1.0.0` |
| `suspend_wakeup_init` | `suspend_wakeup_init_<module>` | `suspend_wakeup_init_hello_world` | `1.0.0` |
| `shutdown` | `shutdown_<module>` | `shutdown_hello_world` | `1.0.0` |
| `process_detected_host_os` | `process_detected_host_os_<module>` | `process_detected_host_os_hello_world` | `1.0.0` |
| `default_layer_state_set` | `default_layer_state_set_<module>` | `default_layer_state_set_hello_world` | `1.1.0` |
| `layer_state_set` | `layer_state_set_<module>` | `layer_state_set_hello_world` | `1.1.0` |
| Base API | API Format | Example (`hello_world` module) | API Version |
|----------------------------------|-------------------------------------------|----------------------------------------------|-------------|
| `keyboard_pre_init` | `keyboard_pre_init_<module>` | `keyboard_pre_init_hello_world` | `0.1.0` |
| `keyboard_post_init` | `keyboard_post_init_<module>` | `keyboard_post_init_hello_world` | `0.1.0` |
| `pre_process_record` | `pre_process_record_<module>` | `pre_process_record_hello_world` | `0.1.0` |
| `process_record` | `process_record_<module>` | `process_record_hello_world` | `0.1.0` |
| `post_process_record` | `post_process_record_<module>` | `post_process_record_hello_world` | `0.1.0` |
| `housekeeping_task` | `housekeeping_task_<module>` | `housekeeping_task_hello_world` | `1.0.0` |
| `suspend_power_down` | `suspend_power_down_<module>` | `suspend_power_down_hello_world` | `1.0.0` |
| `suspend_wakeup_init` | `suspend_wakeup_init_<module>` | `suspend_wakeup_init_hello_world` | `1.0.0` |
| `shutdown` | `shutdown_<module>` | `shutdown_hello_world` | `1.0.0` |
| `process_detected_host_os` | `process_detected_host_os_<module>` | `process_detected_host_os_hello_world` | `1.0.0` |
| `default_layer_state_set` | `default_layer_state_set_<module>` | `default_layer_state_set_hello_world` | `1.1.0` |
| `layer_state_set` | `layer_state_set_<module>` | `layer_state_set_hello_world` | `1.1.0` |
| `led_matrix_indicators` | `led_matrix_indicators_<module>` | `led_matrix_indicators_hello_world` | `1.1.0` |
| `led_matrix_indicators_advanced` | `led_matrix_indicators_advanced_<module>` | `led_matrix_indicators_advanced_hello_world` | `1.1.0` |
| `rgb_matrix_indicators` | `rgb_matrix_indicators_<module>` | `rgb_matrix_indicators_hello_world` | `1.1.0` |
@@ -164,7 +181,6 @@ Community Modules may provide specializations for the following APIs:
| `pointing_device_init` | `pointing_device_init_<module>` | `pointing_device_init_hello_world` | `1.1.0` |
| `pointing_device_task` | `pointing_device_task_<module>` | `pointing_device_task_hello_world` | `1.1.0` |
::: info
An unspecified API is disregarded if a Community Module does not provide a specialization for it.
:::
@@ -0,0 +1,13 @@
// Copyright 2026 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {LAYOUT_ortho_1x1(KC_A)};
void keyboard_post_init_user(void) {
// Customise these values to desired behaviour
debug_enable = true;
debug_matrix = true;
// debug_keyboard=true;
// debug_mouse=true;
}
@@ -0,0 +1,10 @@
{
"config": {
"features": {
"console": true
}
},
"modules": [
"qmk/nvm_test"
]
}
+105 -4
View File
@@ -26,8 +26,11 @@
"resync": true
}
},
"layout_aliases": {
"LAYOUT": "LAYOUT_all"
},
"layouts": {
"LAYOUT": {
"LAYOUT_all": {
"layout": [
{"matrix": [0, 0], "w": 1.5, "x": 0, "y": 0},
{"matrix": [0, 1], "x": 1.5, "y": 0},
@@ -69,9 +72,107 @@
{"matrix": [3, 0], "w": 1.25, "x": 0, "y": 3},
{"matrix": [3, 1], "w": 1.25, "x": 1.25, "y": 3},
{"matrix": [3, 2], "w": 1.25, "x": 2.5, "y": 3},
{"matrix": [3, 3], "w": 3, "x": 3.75, "y": 3, "h": 0.5},
{"matrix": [3, 5], "w": 6, "x": 3.75, "y": 3.5, "h": 0.5},
{"matrix": [3, 6], "w": 3, "x": 6.75, "y": 3, "h": 0.5},
{"matrix": [3, 3], "w": 2.5, "x": 3.75, "y": 3},
{"matrix": [3, 5], "w": 1, "x": 6.25, "y": 3},
{"matrix": [3, 6], "w": 2.5, "x": 7.25, "y": 3},
{"matrix": [3, 8], "w": 1.25, "x": 9.75, "y": 3},
{"matrix": [3, 9], "w": 1.25, "x": 11, "y": 3},
{"matrix": [3, 10], "w": 1.25, "x": 12.25, "y": 3}
]
},
"LAYOUT_split_space": {
"layout": [
{"matrix": [0, 0], "w": 1.5, "x": 0, "y": 0},
{"matrix": [0, 1], "x": 1.5, "y": 0},
{"matrix": [0, 2], "x": 2.5, "y": 0},
{"matrix": [0, 3], "x": 3.5, "y": 0},
{"matrix": [0, 4], "x": 4.5, "y": 0},
{"matrix": [0, 5], "x": 5.5, "y": 0},
{"matrix": [0, 6], "x": 6.5, "y": 0},
{"matrix": [0, 7], "x": 7.5, "y": 0},
{"matrix": [0, 8], "x": 8.5, "y": 0},
{"matrix": [0, 9], "x": 9.5, "y": 0},
{"matrix": [0, 10], "x": 10.5, "y": 0},
{"matrix": [0, 11], "x": 11.5, "y": 0},
{"matrix": [3, 11], "x": 12.5, "y": 0},
{"matrix": [1, 0], "w": 1.75, "x": 0, "y": 1},
{"matrix": [1, 1], "x": 1.75, "y": 1},
{"matrix": [1, 2], "x": 2.75, "y": 1},
{"matrix": [1, 3], "x": 3.75, "y": 1},
{"matrix": [1, 4], "x": 4.75, "y": 1},
{"matrix": [1, 5], "x": 5.75, "y": 1},
{"matrix": [1, 6], "x": 6.75, "y": 1},
{"matrix": [1, 7], "x": 7.75, "y": 1},
{"matrix": [1, 8], "x": 8.75, "y": 1},
{"matrix": [1, 9], "x": 9.75, "y": 1},
{"matrix": [1, 10], "x": 10.75, "y": 1},
{"matrix": [1, 11], "w": 1.75, "x": 11.75, "y": 1},
{"matrix": [2, 0], "w": 2.25, "x": 0, "y": 2},
{"matrix": [2, 1], "x": 2.25, "y": 2},
{"matrix": [2, 2], "x": 3.25, "y": 2},
{"matrix": [2, 3], "x": 4.25, "y": 2},
{"matrix": [2, 4], "x": 5.25, "y": 2},
{"matrix": [2, 5], "x": 6.25, "y": 2},
{"matrix": [2, 6], "x": 7.25, "y": 2},
{"matrix": [2, 7], "x": 8.25, "y": 2},
{"matrix": [2, 8], "x": 9.25, "y": 2},
{"matrix": [2, 9], "x": 10.25, "y": 2},
{"matrix": [2, 10], "x": 11.25, "y": 2},
{"matrix": [2, 11], "w": 1.25, "x": 12.25, "y": 2},
{"matrix": [3, 0], "w": 1.25, "x": 0, "y": 3},
{"matrix": [3, 1], "w": 1.25, "x": 1.25, "y": 3},
{"matrix": [3, 2], "w": 1.25, "x": 2.5, "y": 3},
{"matrix": [3, 3], "w": 3, "x": 3.75, "y": 3},
{"matrix": [3, 6], "w": 3, "x": 6.75, "y": 3},
{"matrix": [3, 8], "w": 1.25, "x": 9.75, "y": 3},
{"matrix": [3, 9], "w": 1.25, "x": 11, "y": 3},
{"matrix": [3, 10], "w": 1.25, "x": 12.25, "y": 3}
]
},
"LAYOUT_full_space": {
"layout": [
{"matrix": [0, 0], "w": 1.5, "x": 0, "y": 0},
{"matrix": [0, 1], "x": 1.5, "y": 0},
{"matrix": [0, 2], "x": 2.5, "y": 0},
{"matrix": [0, 3], "x": 3.5, "y": 0},
{"matrix": [0, 4], "x": 4.5, "y": 0},
{"matrix": [0, 5], "x": 5.5, "y": 0},
{"matrix": [0, 6], "x": 6.5, "y": 0},
{"matrix": [0, 7], "x": 7.5, "y": 0},
{"matrix": [0, 8], "x": 8.5, "y": 0},
{"matrix": [0, 9], "x": 9.5, "y": 0},
{"matrix": [0, 10], "x": 10.5, "y": 0},
{"matrix": [0, 11], "x": 11.5, "y": 0},
{"matrix": [3, 11], "x": 12.5, "y": 0},
{"matrix": [1, 0], "w": 1.75, "x": 0, "y": 1},
{"matrix": [1, 1], "x": 1.75, "y": 1},
{"matrix": [1, 2], "x": 2.75, "y": 1},
{"matrix": [1, 3], "x": 3.75, "y": 1},
{"matrix": [1, 4], "x": 4.75, "y": 1},
{"matrix": [1, 5], "x": 5.75, "y": 1},
{"matrix": [1, 6], "x": 6.75, "y": 1},
{"matrix": [1, 7], "x": 7.75, "y": 1},
{"matrix": [1, 8], "x": 8.75, "y": 1},
{"matrix": [1, 9], "x": 9.75, "y": 1},
{"matrix": [1, 10], "x": 10.75, "y": 1},
{"matrix": [1, 11], "w": 1.75, "x": 11.75, "y": 1},
{"matrix": [2, 0], "w": 2.25, "x": 0, "y": 2},
{"matrix": [2, 1], "x": 2.25, "y": 2},
{"matrix": [2, 2], "x": 3.25, "y": 2},
{"matrix": [2, 3], "x": 4.25, "y": 2},
{"matrix": [2, 4], "x": 5.25, "y": 2},
{"matrix": [2, 5], "x": 6.25, "y": 2},
{"matrix": [2, 6], "x": 7.25, "y": 2},
{"matrix": [2, 7], "x": 8.25, "y": 2},
{"matrix": [2, 8], "x": 9.25, "y": 2},
{"matrix": [2, 9], "x": 10.25, "y": 2},
{"matrix": [2, 10], "x": 11.25, "y": 2},
{"matrix": [2, 11], "w": 1.25, "x": 12.25, "y": 2},
{"matrix": [3, 0], "w": 1.25, "x": 0, "y": 3},
{"matrix": [3, 1], "w": 1.25, "x": 1.25, "y": 3},
{"matrix": [3, 2], "w": 1.25, "x": 2.5, "y": 3},
{"matrix": [3, 5], "w": 6, "x": 3.75, "y": 3},
{"matrix": [3, 8], "w": 1.25, "x": 9.75, "y": 3},
{"matrix": [3, 9], "w": 1.25, "x": 11, "y": 3},
{"matrix": [3, 10], "w": 1.25, "x": 12.25, "y": 3}
@@ -4,19 +4,19 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
[0] = LAYOUT_all(
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, KC_BSPC,
LT(2, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
KC_LCTL, KC_LGUI, KC_LALT, LT(1, KC_SPC), KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RCTL
),
[1] = LAYOUT(
[1] = LAYOUT_all(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, QK_BOOT,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_EQL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, KC_RBRC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, LT(2, KC_SPC), KC_HOME, KC_PGDN, KC_END
),
[2] = LAYOUT(
[2] = LAYOUT_all(
KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_PGUP, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_TRNS, KC_TRNS,
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@@ -169,6 +169,139 @@ def _generate_modules_rules(keyboard, filename):
return lines
def _module_slugs(modules):
return [Path(m).name.lower() for m in modules]
def _render_eeconfig_declarations(modules):
lines = []
lines.append('')
lines.append('// nvm eeconfig')
for module_slug in _module_slugs(modules):
lines.extend([
f'#if (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
f'bool eeconfig_is_{module_slug}_datablock_valid(void);',
f'uint32_t eeconfig_read_{module_slug}_datablock(void *data, uint32_t offset, uint32_t length) __attribute__((nonnull));',
f'uint32_t eeconfig_update_{module_slug}_datablock(const void *data, uint32_t offset, uint32_t length) __attribute__((nonnull));',
f'void eeconfig_init_{module_slug}_datablock(void);',
f'# define eeconfig_read_{module_slug}_datablock_field(__object, __field) eeconfig_read_{module_slug}_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field))',
f'# define eeconfig_update_{module_slug}_datablock_field(__object, __field) eeconfig_update_{module_slug}_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field))',
'',
f'bool nvm_eeconfig_is_{module_slug}_datablock_valid(void);',
f'uint32_t nvm_eeconfig_read_{module_slug}_datablock(void *data, uint32_t offset, uint32_t length);',
f'uint32_t nvm_eeconfig_update_{module_slug}_datablock(const void *data, uint32_t offset, uint32_t length);',
f'void nvm_eeconfig_init_{module_slug}_datablock(void);',
f'#endif // (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
'',
])
lines.append('typedef struct PACKED {')
for module_slug in _module_slugs(modules):
lines.extend([
f'#if (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
f' uint32_t {module_slug}_version;',
f' uint8_t {module_slug}[EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE];',
f'#endif // (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
])
lines.append('} eeprom_modules_t;')
lines.append('')
for module_slug in _module_slugs(modules):
lines.append(f'#define EECONFIG_MODULE_{module_slug.upper()}_VERSION (uint32_t *)(EECONFIG_MODULES_DATABLOCK + (offsetof(eeprom_modules_t, {module_slug}_version)))')
lines.append(f'#define EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK (uint8_t *)(EECONFIG_MODULES_DATABLOCK + (offsetof(eeprom_modules_t, {module_slug})))')
lines.append('')
lines.append('bool eeconfig_is_modules_datablock_valid(void);')
lines.append('void eeconfig_init_modules_datablock(void);')
lines.append('')
return lines
def _render_eeconfig_implementation(modules):
lines = []
lines.append('')
lines.append('// nvm eeconfig')
lines.append('#if defined(NVM_DRIVER_EEPROM)'),
lines.append('# include "nvm_eeprom_eeconfig_internal.h"')
lines.append('# include "eeprom.h"')
lines.append('#endif // defined(NVM_DRIVER_EEPROM)'),
lines.append('')
for module_slug in _module_slugs(modules):
lines.extend([
f'#if (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
f'bool eeconfig_is_{module_slug}_datablock_valid(void) {{ return nvm_eeconfig_is_{module_slug}_datablock_valid(); }}',
f'uint32_t eeconfig_read_{module_slug}_datablock(void *data, uint32_t offset, uint32_t length) {{ return nvm_eeconfig_read_{module_slug}_datablock(data, offset, length); }}',
f'uint32_t eeconfig_update_{module_slug}_datablock(const void *data, uint32_t offset, uint32_t length) {{ return nvm_eeconfig_update_{module_slug}_datablock(data, offset, length); }}',
f'void eeconfig_init_{module_slug}_datablock(void) {{ nvm_eeconfig_init_{module_slug}_datablock(); }}',
'',
'# if defined(NVM_DRIVER_EEPROM)',
f'bool nvm_eeconfig_is_{module_slug}_datablock_valid(void) {{',
f' return eeprom_read_dword(EECONFIG_MODULE_{module_slug.upper()}_VERSION) == (EECONFIG_MODULE_{module_slug.upper()}_DATA_VERSION);',
'}',
f'uint32_t nvm_eeconfig_read_{module_slug}_datablock(void *data, uint32_t offset, uint32_t length) {{',
f' if (eeconfig_is_{module_slug}_datablock_valid()) {{',
f' void *ee_start = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK + offset);',
f' void *ee_end = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK + MIN((EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE), offset + length));',
' eeprom_read_block(data, ee_start, ee_end - ee_start);',
' return ee_end - ee_start;',
' } else {',
' memset(data, 0, length);',
' return length;',
' }',
'}',
f'uint32_t nvm_eeconfig_update_{module_slug}_datablock(const void *data, uint32_t offset, uint32_t length) {{',
f' eeprom_update_dword(EECONFIG_MODULE_{module_slug.upper()}_VERSION, (EECONFIG_MODULE_{module_slug.upper()}_DATA_VERSION));',
f' void *ee_start = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK + offset);',
f' void *ee_end = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK + MIN((EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE), offset + length));',
' eeprom_update_block(data, ee_start, ee_end - ee_start);',
' return ee_end - ee_start;',
'}',
f'void nvm_eeconfig_init_{module_slug}_datablock(void) {{',
f' eeprom_update_dword(EECONFIG_MODULE_{module_slug.upper()}_VERSION, (EECONFIG_MODULE_{module_slug.upper()}_DATA_VERSION));',
f' void *start = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK);',
f' void *end = (void *)(uintptr_t)(EECONFIG_MODULE_{module_slug.upper()}_DATABLOCK + (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE));',
' long remaining = end - start;',
' uint8_t dummy[16] = {0};',
f' for (int i = 0; i < EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE; i += sizeof(dummy)) {{',
' int this_loop = remaining < sizeof(dummy) ? remaining : sizeof(dummy);',
' eeprom_update_block(dummy, start, this_loop);',
' start += this_loop;',
' remaining -= this_loop;',
' }',
'}',
'# endif // defined(NVM_DRIVER_EEPROM)',
f'#endif // (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
'',
])
lines.append('bool eeconfig_is_modules_datablock_valid(void) {')
lines.append(' return true')
for module_slug in _module_slugs(modules):
lines.extend([
f'#if (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
f' && eeconfig_is_{module_slug}_datablock_valid()',
f'#endif // (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
])
lines.append(' ;')
lines.append('}')
lines.append('')
lines.append('void eeconfig_init_modules_datablock(void) {'),
for module_slug in _module_slugs(modules):
lines.extend([
f'#if (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
f' eeconfig_init_{module_slug}_datablock();',
f'#endif // (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE) > 0',
])
lines.append('}')
lines.append('')
return lines
@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.argument('-e', '--escape', arg_only=True, action='store_true', help="Escape spaces in quiet mode")
@@ -196,11 +329,11 @@ def generate_community_modules_rules_mk(cli):
@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate community_config.h for.')
@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate community_post_config.h for.')
@cli.argument('filename', nargs='?', type=qmk.path.FileType('r'), arg_only=True, completer=FilesCompleter('.json'), help='Configurator JSON file')
@cli.subcommand('Creates a community_config.h from a keymap.json file.')
def generate_community_config_h(cli):
"""Creates a community_config.h from a keymap.json file
@cli.subcommand('Creates a community_post_config.h from a keymap.json file.')
def generate_community_post_config_h(cli):
"""Creates a community_post_config.h from a keymap.json file
"""
if cli.args.output and cli.args.output.name == '-':
cli.args.output = None
@@ -215,14 +348,29 @@ def generate_community_config_h(cli):
modules = get_modules(cli.args.keyboard, cli.args.filename)
if len(modules) > 0:
lines.append('// Split transactions')
for module in modules:
for module_slug in _module_slugs(modules):
lines.extend([
f'#ifdef SPLIT_TRANSACTION_IDS_MODULE_{Path(module).name.upper()}',
f'#ifdef SPLIT_TRANSACTION_IDS_MODULE_{module_slug.upper()}',
'# define SPLIT_TRANSACTION_RPC',
'#endif',
])
lines.append('')
lines.append('// nvm eeconfig')
for module_slug in _module_slugs(modules):
lines.extend([
f'#ifndef EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE',
f'# define EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE 0',
'#endif',
f'#ifndef EECONFIG_MODULE_{module_slug.upper()}_DATA_VERSION',
f'# define EECONFIG_MODULE_{module_slug.upper()}_DATA_VERSION (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE)',
'#endif',
'',
])
module_size = " + ".join([f'(4 + (EECONFIG_MODULE_{module_slug.upper()}_DATA_SIZE))' for module_slug in _module_slugs(modules)])
lines.append(f'#define EECONFIG_MODULE_DATA_SIZE ({module_size})')
lines.append('')
dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True)
@@ -245,6 +393,7 @@ def generate_community_modules_h(cli):
'#pragma once',
'#include <stdint.h>',
'#include <stdbool.h>',
'#include <string.h>',
'#include <keycodes.h>',
'',
'#include "compiler_support.h"',
@@ -272,6 +421,8 @@ def generate_community_modules_h(cli):
lines.extend(_render_api_declarations(api, Path(module).name))
lines.append('')
lines.extend(_render_eeconfig_declarations(modules))
lines.append('// Core wrapper')
for api in api_list:
lines.extend(_render_api_declarations(api, 'modules', user_kb=False))
@@ -309,6 +460,8 @@ def generate_community_modules_c(cli):
for api in api_list:
lines.extend(_render_core_implementation(api, modules))
lines.extend(_render_eeconfig_implementation(modules))
dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True)
+5
View File
@@ -0,0 +1,5 @@
// Copyright 2026 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#define EECONFIG_MODULE_NVM_TEST_DATA_SIZE 4
+53
View File
@@ -0,0 +1,53 @@
// Copyright 2026 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdint.h>
#include "community_modules.h"
#include "debug.h"
#include "timer.h"
#include "eeconfig.h"
ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 1, 3);
typedef struct my_config_t {
uint32_t data;
} my_config_t;
static my_config_t config;
// Helpers required to bind to debounce helper
void eeconfig_read_my_config(my_config_t *value) {
eeconfig_read_nvm_test_datablock(value, 0, sizeof(my_config_t));
}
void eeconfig_update_my_config(my_config_t *value) {
eeconfig_update_nvm_test_datablock(value, 0, sizeof(my_config_t));
}
EECONFIG_DEBOUNCE_HELPER(my_config, config);
void keyboard_post_init_nvm_test(void) {
if (!eeconfig_is_nvm_test_datablock_valid()) {
eeconfig_init_nvm_test_datablock();
}
eeconfig_init_my_config();
}
bool process_record_nvm_test(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) {
config.data += 1;
eeconfig_flag_my_config(true);
}
return true;
}
void housekeeping_task_nvm_test(void) {
eeconfig_flush_my_config(false);
static uint32_t last_sync = 0;
if (timer_elapsed32(last_sync) > 1000) {
last_sync = timer_read32();
dprintf("Config: %ld\n", config.data);
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"module_name": "Example nvm persistence",
"maintainer": "QMK Maintainers",
"license": "GPL-2.0-or-later"
}
+8
View File
@@ -39,6 +39,10 @@
# include "connection.h"
#endif // CONNECTION_ENABLE
#ifdef COMMUNITY_MODULES_ENABLE
# include "community_modules.h"
#endif
#ifdef VIA_ENABLE
bool via_eeprom_is_valid(void);
void via_eeprom_set_valid(bool valid);
@@ -148,6 +152,10 @@ void eeconfig_init_quantum(void) {
eeconfig_init_user_datablock();
#endif // (EECONFIG_USER_DATA_SIZE) > 0
#ifdef COMMUNITY_MODULES_ENABLE
eeconfig_init_modules_datablock();
#endif // COMMUNITY_MODULES_ENABLE
#if defined(VIA_ENABLE)
// Invalidate VIA eeprom config, and then reset.
// Just in case if power is lost mid init, this makes sure that it gets
@@ -56,8 +56,14 @@ typedef struct PACKED {
#define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE))
#define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE)))
#define EECONFIG_MODULES_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)))
// Actual value is injected via the generated community_post_config.h
#ifndef EECONFIG_MODULE_DATA_SIZE
# define EECONFIG_MODULE_DATA_SIZE 0
#endif
// Size of EEPROM being used, other code can refer to this for available EEPROM
#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE))
#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE) + (EECONFIG_MODULE_DATA_SIZE))
STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect");
+4
View File
@@ -45,6 +45,10 @@ uint16_t get_last_keycode(void) {
return last_record.keycode;
}
const keyrecord_t* get_last_record(void) {
return &last_record;
}
uint8_t get_last_mods(void) {
return last_mods;
}
+1 -1
View File
@@ -26,7 +26,7 @@ void set_last_keycode(uint16_t keycode); /**< Sets the last key. */
void set_last_mods(uint8_t mods); /**< Sets the last mods. */
/** @brief Gets the record for the last key. */
keyrecord_t* get_last_record(void);
const keyrecord_t* get_last_record(void);
/** @brief Sets keycode and record info for the last key. */
void set_last_record(uint16_t keycode, keyrecord_t* record);
+6 -6
View File
@@ -481,17 +481,17 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = {
#ifdef PLOVER_HID_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = {
HID_RI_USAGE_PAGE(16, 0xff50), //
HID_RI_USAGE(16, 0x4c56), // Vendor Defined (0xff P L V)
HID_RI_USAGE_PAGE(16, 0xFF50), //
HID_RI_USAGE(16, 0x4C56), // Vendor Defined (0xff P L V)
HID_RI_COLLECTION(8, 0x01), // Application
HID_RI_REPORT_ID(8, 80),
HID_RI_REPORT_ID(8, REPORT_ID_PLOVER_HID),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_REPORT_SIZE(8, 1),
HID_RI_REPORT_COUNT(8, 64),
HID_RI_USAGE_PAGE(8, 0x0a), // Usage Page: Ordinal
HID_RI_REPORT_COUNT(8, 0x40),
HID_RI_USAGE_PAGE(8, 0x0A), // Usage Page: Ordinal
HID_RI_USAGE_MINIMUM(8, 0),
HID_RI_USAGE_MAXIMUM(8, 63),
HID_RI_USAGE_MAXIMUM(8, 0x3F),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
};
+83
View File
@@ -68,6 +68,10 @@ enum usb_interfaces {
RAW_INTERFACE,
#endif
#ifdef PLOVER_HID_ENABLE
PLOVER_HID_INTERFACE,
#endif
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
SHARED_INTERFACE,
#endif
@@ -87,6 +91,10 @@ STATIC_ASSERT(TOTAL_INTERFACES <= MAX_INTERFACES, "There are not enough availabl
# error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two.
#endif
#if defined(PLOVER_HID_ENABLE) && defined(RAW_ENABLE)
# error Plover HID shares an endpoint with Raw HID. Please disable one of the two.
#endif
static report_keyboard_t keyboard_report_sent;
static void send_report_fragment(uint8_t endpoint, void *data, size_t size) {
@@ -281,6 +289,14 @@ void send_programmable_button(report_programmable_button_t *report) {
#endif
}
#define PLOVER_HID_EPSIZE 9
void send_plover_hid(report_plover_hid_t *report) {
#ifdef PLOVER_HID_ENABLE
send_report(4, report, sizeof(report_plover_hid_t));
#endif
}
/*------------------------------------------------------------------*
* Request from host *
*------------------------------------------------------------------*/
@@ -771,6 +787,26 @@ const PROGMEM uchar raw_hid_report[] = {
};
#endif
#ifdef PLOVER_HID_ENABLE
// clang-format off
const PROGMEM uchar plover_hid_report[] = {
0x06, 0x50, 0xFF, // Usage Page (Vendor Defined)
0x0A, 0x56, 0x4C, // Usage (Vendor Defined) (0xff P L V)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_PLOVER_HID, // Report ID
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x40, // Report Count (43)
0x05, 0x0A, // Usage Page: Ordinal
0x19, 0x00, // Usage Minimum
0x29, 0x3F, // Usage Maximum (63)
0x81, 0x02, // Output (Data, Variable, Absolute)
0xC0 // End Collection
};
// clang-format on
#endif
#if defined(CONSOLE_ENABLE)
const PROGMEM uchar console_hid_report[] = {
0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
@@ -963,6 +999,46 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
},
# endif
# if defined(PLOVER_HID_ENABLE)
/*
* Plover HID
*/
.ploverInterface = {
.header = {
.bLength = sizeof(usbInterfaceDescriptor_t),
.bDescriptorType = USBDESCR_INTERFACE
},
.bInterfaceNumber = PLOVER_HID_INTERFACE,
.bAlternateSetting = 0x00,
.bNumEndpoints = 1,
.bInterfaceClass = 0x03,
.bInterfaceSubClass = 0x00,
.bInterfaceProtocol = 0x00,
.iInterface = 0x00
},
.ploverHID = {
.header = {
.bLength = sizeof(usbHIDDescriptor_t),
.bDescriptorType = USBDESCR_HID
},
.bcdHID = 0x0101,
.bCountryCode = 0x00,
.bNumDescriptors = 1,
.bDescriptorType = USBDESCR_HID_REPORT,
.wDescriptorLength = sizeof(plover_hid_report)
},
.ploverINEndpoint = {
.header = {
.bLength = sizeof(usbEndpointDescriptor_t),
.bDescriptorType = USBDESCR_ENDPOINT
},
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP4_NUMBER),
.bmAttributes = 0x03,
.wMaxPacketSize = PLOVER_HID_EPSIZE,
.bInterval = 0x01
},
# endif
# ifdef SHARED_EP_ENABLE
/*
* Shared
@@ -1140,6 +1216,13 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
break;
#endif
#if defined(PLOVER_HID_ENABLE)
case PLOVER_HID_INTERFACE:
usbMsgPtr = (usbMsgPtr_t)plover_hid_report;
len = sizeof(plover_hid_report);
break;
#endif
#ifdef SHARED_EP_ENABLE
case SHARED_INTERFACE:
usbMsgPtr = (usbMsgPtr_t)shared_hid_report;
+6
View File
@@ -104,6 +104,12 @@ typedef struct usbConfigurationDescriptor {
usbEndpointDescriptor_t rawOUTEndpoint;
#endif
#if defined(PLOVER_HID_ENABLE)
usbInterfaceDescriptor_t ploverInterface;
usbHIDDescriptor_t ploverHID;
usbEndpointDescriptor_t ploverINEndpoint;
#endif
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
usbInterfaceDescriptor_t sharedInterface;
usbHIDDescriptor_t sharedHID;