Skip to content

Commit 9c76065

Browse files
authored
Merge pull request #2 from qmk/develop
Develop
2 parents 240745d + 621b4b7 commit 9c76065

File tree

22 files changed

+62
-84
lines changed

22 files changed

+62
-84
lines changed

.github/workflows/api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }}
3636
AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }}
3737
AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
38-
SOURCE_DIR: 'api_data'
38+
SOURCE_DIR: '.build/api_data'

.github/workflows/develop_api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }}
3636
AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }}
3737
AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
38-
SOURCE_DIR: 'api_data'
38+
SOURCE_DIR: '.build/api_data'

api_data/_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

data/mappings/info_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
# Format:
55
# <config.h key>: {"info_key": <info.json key>, ["value_type": <value_type>], ["to_json": <true/false>], ["to_c": <true/false>]}
6-
# value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping"
6+
# value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping", "str", "raw"
77
# to_json: Default `true`. Set to `false` to exclude this mapping from info.json
88
# to_c: Default `true`. Set to `false` to exclude this mapping from config.h
99
# warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
@@ -17,7 +17,7 @@
1717
"DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"},
1818
# TODO: Replace ^^^ with vvv
1919
#"DEVICE_VER": {"info_key": "usb.device_version", "value_type": "bcd_version"},
20-
"DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false},
20+
"DESCRIPTION": {"info_key": "keyboard_folder", "value_type": "str", "to_json": false},
2121
"DIODE_DIRECTION": {"info_key": "diode_direction"},
2222
"FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"},
2323
"DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"},

data/mappings/info_rules.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
# Format:
55
# <rules.mk key>: {"info_key": <info.json key>, ["value_type": <value_type>], ["to_json": <true/false>], ["to_c": <true/false>]}
6-
# value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping"
6+
# value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping", "str", "raw"
77
# to_json: Default `true`. Set to `false` to exclude this mapping from info.json
88
# to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk
99
# warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
@@ -20,6 +20,6 @@
2020
"MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"},
2121
"NO_USB_STARTUP_CHECK": {"info_key": "usb.no_startup_check", "value_type": "bool"},
2222
"SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"},
23-
"SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false},
23+
"SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "to_c": false},
2424
"WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"}
2525
}
File renamed without changes.

docs/data_driven_config.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ In other cases you should group like options together in an `object`. This is pa
4444
In most cases you can add a simple mapping. These are maintained as JSON files in `data/mappings/info_config.json` and `data/mappings/info_rules.json`, and control mapping for `config.h` and `rules.mk`, respectively. Each mapping is keyed by the `config.h` or `rules.mk` variable, and the value is a hash with the following keys:
4545

4646
* `info_key`: (required) The location within `info.json` for this value. See below.
47-
* `value_type`: (optional) Default `str`. The format for this variable's value. See below.
47+
* `value_type`: (optional) Default `raw`. The format for this variable's value. See below.
4848
* `to_json`: (optional) Default `true`. Set to `false` to exclude this mapping from info.json
4949
* `to_c`: (optional) Default `true`. Set to `false` to exclude this mapping from config.h
5050
* `warn_duplicate`: (optional) Default `true`. Set to `false` to turn off warning when a value exists in both places
@@ -57,14 +57,15 @@ Under the hood we use [Dotty Dict](https://dotty-dict.readthedocs.io/en/latest/)
5757

5858
#### Value Types
5959

60-
By default we treat all values as simple strings. If your value is more complex you can use one of these types to intelligently parse the data:
60+
By default we treat all values as unquoted "raw" data. If your value is more complex you can use one of these types to intelligently parse the data:
6161

6262
* `array`: A comma separated array of strings
6363
* `array.int`: A comma separated array of integers
6464
* `int`: An integer
6565
* `hex`: A number formatted as hex
6666
* `list`: A space separate array of strings
6767
* `mapping`: A hash of key/value pairs
68+
* `str`: A quoted string literal
6869

6970
### Add code to extract it
7071

docs/feature_unicode.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,6 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
230230

231231
Example uses include sending Unicode strings when a key is pressed, as described in [Macros](feature_macros.md).
232232

233-
### `send_unicode_hex_string()` (Deprecated)
234-
235-
Similar to `send_unicode_string()`, but the characters are represented by their Unicode code points, written in hexadecimal and separated by spaces. For example, the table flip above would be achieved with:
236-
237-
```c
238-
send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
239-
```
240-
241-
An easy way to convert your Unicode string to this format is to use [this site](https://r12a.github.io/app-conversion/) and take the result in the "Hex/UTF-32" section.
242-
243-
244233
## Additional Language Support
245234

246235
In `quantum/keymap_extras`, you'll see various language files — these work the same way as the ones for alternative layouts such as Colemak or BÉPO. When you include one of these language headers, you gain access to keycodes specific to that language / national layout. Such keycodes are defined by a 2-letter country/language code, followed by an underscore and a 4-letter abbreviation of the character to which the key corresponds. For example, including `keymap_french.h` and using `FR_UGRV` in your keymap will output `ù` when typed on a system with a native French AZERTY layout.

docs/ja/feature_unicode.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,6 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
233233

234234
使用例には、[Macros](ja/feature_macros.md) で説明されているように、キーが押された時に Unicode 文字列を送信することが含まれます。
235235

236-
### `send_unicode_hex_string()`
237-
238-
`send_unicode_string()` に似ていますが、文字は Unicode コードポイントで表され、16進数で記述され、空白で区切られています。例えば、上記のちゃぶ台返しは以下で表されます:
239-
240-
```c
241-
send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
242-
```
243-
244-
[このサイト](https://r12a.github.io/app-conversion/)で結果を "Hex/UTF-32" で受け取ることで、Unicode 文字列をこの形式に簡単に変換できます。
245-
246-
247236
## 追加の言語サポート
248237

249238
`quantum/keymap_extras` には、様々な言語ファイルがあります — これらは Colemak または BÉPO のような代替レイアウトのファイルと同じように動作します。これらの言語ヘッダのいずれかを `#include` すると、その言語/国のレイアウトに固有のキーコードにアクセスできます。このようなキーコードは、2文字の国/言語コードの後に、アンダースコアとキーが対応する4文字の略語が続くことで定義されます。例えば、キーマップに `keymap_french.h` を含め、`FR_UGRV` を使うと、ネイティブのフランス語 AZERTY レイアウトを使うシステムで入力すると、`ù` が出力されます。

keyboards/sowbug/68keys/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#define DEVICE_VER 0x0001
2727
#define MANUFACTURER github.com/sowbug
2828
#define PRODUCT 68-key keyboard
29-
#define DESCRIPTION A 68-key keyboard based on 68keys.io
3029

3130
// key matrix size
3231
#define MATRIX_ROWS 5

keyboards/sowbug/ansi_tkl/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#define DEVICE_VER 0x0001
2727
#define MANUFACTURER github.com/sowbug
2828
#define PRODUCT ANSI TKL
29-
#define DESCRIPTION A tenkeyless ANSI-layout keyboard
3029

3130
// key matrix size
3231
#define MATRIX_ROWS 6

keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#define DEVICE_VER 0x0001
2424
#define MANUFACTURER Unicomp/Purdea Andrei
2525
#define PRODUCT Unicomp Spacesaver M
26-
#define DESCRIPTION QMK firmware for the Unicomp Spacesaver M keyboard with a replacement Overnumpad controller
2726
#define SERIAL_NUMBER "purdea.ro:overnumpad_controller"
2827

2928
/* key matrix size */

keyboards/xelus/ninjin/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define DEVICE_VER 0x0001
2323
#define MANUFACTURER Xelus
2424
#define PRODUCT Ninjin
25-
#define DESCRIPTION Ninjin
2625

2726
/* key matrix size */
2827
#define MATRIX_ROWS 6

lib/python/qmk/cli/generate/api.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This script automates the generation of the QMK API data.
22
"""
33
from pathlib import Path
4-
from shutil import copyfile
4+
import shutil
55
import json
66

77
from milc import cli
@@ -12,28 +12,42 @@
1212
from qmk.json_schema import json_load
1313
from qmk.keyboard import find_readme, list_keyboards
1414

15+
TEMPLATE_PATH = Path('data/templates/api/')
16+
BUILD_API_PATH = Path('.build/api_data/')
17+
1518

1619
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.")
20+
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on partial name matches the supplied value. May be passed multiple times.")
1721
@cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True)
1822
def generate_api(cli):
1923
"""Generates the QMK API data.
2024
"""
21-
api_data_dir = Path('api_data')
22-
v1_dir = api_data_dir / 'v1'
25+
if BUILD_API_PATH.exists():
26+
shutil.rmtree(BUILD_API_PATH)
27+
28+
shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH)
29+
30+
v1_dir = BUILD_API_PATH / 'v1'
2331
keyboard_all_file = v1_dir / 'keyboards.json' # A massive JSON containing everything
2432
keyboard_list_file = v1_dir / 'keyboard_list.json' # A simple list of keyboard targets
2533
keyboard_aliases_file = v1_dir / 'keyboard_aliases.json' # A list of historical keyboard names and their new name
2634
keyboard_metadata_file = v1_dir / 'keyboard_metadata.json' # All the data configurator/via needs for initialization
2735
usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target
2836

29-
if not api_data_dir.exists():
30-
api_data_dir.mkdir()
37+
# Filter down when required
38+
keyboard_list = list_keyboards()
39+
if cli.args.filter:
40+
kb_list = []
41+
for keyboard_name in keyboard_list:
42+
if any(i in keyboard_name for i in cli.args.filter):
43+
kb_list.append(keyboard_name)
44+
keyboard_list = kb_list
3145

3246
kb_all = {}
3347
usb_list = {}
3448

3549
# Generate and write keyboard specific JSON files
36-
for keyboard_name in list_keyboards():
50+
for keyboard_name in keyboard_list:
3751
kb_all[keyboard_name] = info_json(keyboard_name)
3852
keyboard_dir = v1_dir / 'keyboards' / keyboard_name
3953
keyboard_info = keyboard_dir / 'info.json'
@@ -47,7 +61,7 @@ def generate_api(cli):
4761
cli.log.debug('Wrote file %s', keyboard_info)
4862

4963
if keyboard_readme_src:
50-
copyfile(keyboard_readme_src, keyboard_readme)
64+
shutil.copyfile(keyboard_readme_src, keyboard_readme)
5165
cli.log.debug('Copied %s -> %s', keyboard_readme_src, keyboard_readme)
5266

5367
if 'usb' in kb_all[keyboard_name]:

lib/python/qmk/cli/generate/config_h.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def generate_config_items(kb_info_json, config_h_lines):
8282

8383
for config_key, info_dict in info_config_map.items():
8484
info_key = info_dict['info_key']
85-
key_type = info_dict.get('value_type', 'str')
85+
key_type = info_dict.get('value_type', 'raw')
8686
to_config = info_dict.get('to_config', True)
8787

8888
if not to_config:
@@ -110,6 +110,11 @@ def generate_config_items(kb_info_json, config_h_lines):
110110
config_h_lines.append(f'#ifndef {key}')
111111
config_h_lines.append(f'# define {key} {value}')
112112
config_h_lines.append(f'#endif // {key}')
113+
elif key_type == 'str':
114+
config_h_lines.append('')
115+
config_h_lines.append(f'#ifndef {config_key}')
116+
config_h_lines.append(f'# define {config_key} "{config_value}"')
117+
config_h_lines.append(f'#endif // {config_key}')
113118
elif key_type == 'bcd_version':
114119
(major, minor, revision) = config_value.split('.')
115120
config_h_lines.append('')
@@ -200,7 +205,7 @@ def generate_config_h(cli):
200205
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
201206
if cli.args.output.exists():
202207
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
203-
cli.args.output.write_text(config_h)
208+
cli.args.output.write_text(config_h, encoding='utf-8')
204209

205210
if not cli.args.quiet:
206211
cli.log.info('Wrote info_config.h to %s.', cli.args.output)

lib/python/qmk/cli/generate/rules_mk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
1919
return None
2020

2121
info_key = info_dict['info_key']
22-
key_type = info_dict.get('value_type', 'str')
22+
key_type = info_dict.get('value_type', 'raw')
2323

2424
try:
2525
rules_value = kb_info_json[info_key]
@@ -32,6 +32,8 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
3232
return f'{rules_key} ?= {"yes" if rules_value else "no"}'
3333
elif key_type == 'mapping':
3434
return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()])
35+
elif key_type == 'str':
36+
return f'{rules_key} ?= "{rules_value}"'
3537

3638
return f'{rules_key} ?= {rules_value}'
3739

lib/python/qmk/info.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def _extract_config_h(info_data):
411411

412412
for config_key, info_dict in info_config_map.items():
413413
info_key = info_dict['info_key']
414-
key_type = info_dict.get('value_type', 'str')
414+
key_type = info_dict.get('value_type', 'raw')
415415

416416
try:
417417
if config_key in config_c and info_dict.get('to_json', True):
@@ -443,6 +443,9 @@ def _extract_config_h(info_data):
443443
elif key_type == 'int':
444444
dotty_info[info_key] = int(config_c[config_key])
445445

446+
elif key_type == 'str':
447+
dotty_info[info_key] = config_c[config_key].strip('"')
448+
446449
elif key_type == 'bcd_version':
447450
major = int(config_c[config_key][2:4])
448451
minor = int(config_c[config_key][4])
@@ -491,7 +494,7 @@ def _extract_rules_mk(info_data):
491494

492495
for rules_key, info_dict in info_rules_map.items():
493496
info_key = info_dict['info_key']
494-
key_type = info_dict.get('value_type', 'str')
497+
key_type = info_dict.get('value_type', 'raw')
495498

496499
try:
497500
if rules_key in rules and info_dict.get('to_json', True):
@@ -523,6 +526,9 @@ def _extract_rules_mk(info_data):
523526
elif key_type == 'int':
524527
dotty_info[info_key] = int(rules[rules_key])
525528

529+
elif key_type == 'str':
530+
dotty_info[info_key] = rules[rules_key].strip('"')
531+
526532
else:
527533
dotty_info[info_key] = rules[rules_key]
528534

lib/python/qmk/tests/test_cli_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def test_clean():
244244

245245

246246
def test_generate_api():
247-
result = check_subcommand('generate-api', '--dry-run')
247+
result = check_subcommand('generate-api', '--dry-run', '--filter', 'handwired/pytest')
248248
check_returncode(result)
249249

250250

@@ -259,7 +259,7 @@ def test_generate_config_h():
259259
result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic')
260260
check_returncode(result)
261261
assert '# define DEVICE_VER 0x0001' in result.stdout
262-
assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout
262+
assert '# define DESCRIPTION "handwired/pytest/basic"' in result.stdout
263263
assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
264264
assert '# define MANUFACTURER none' in result.stdout
265265
assert '# define PRODUCT pytest' in result.stdout

platforms/avr/platform.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ COMPILEFLAGS += -ffunction-sections
1818
COMPILEFLAGS += -fdata-sections
1919
COMPILEFLAGS += -fpack-struct
2020
COMPILEFLAGS += -fshort-enums
21+
COMPILEFLAGS += -mcall-prologues
22+
23+
# Linker relaxation is only possible if
24+
# link time optimizations are not enabled.
25+
ifeq ($(strip $(LTO_ENABLE)), no)
26+
COMPILEFLAGS += -mrelax
27+
endif
2128

2229
ASFLAGS += $(AVR_ASFLAGS)
2330

@@ -28,7 +35,7 @@ CFLAGS += -fno-strict-aliasing
2835
CXXFLAGS += $(COMPILEFLAGS)
2936
CXXFLAGS += -fno-exceptions -std=c++11
3037

31-
LDFLAGS +=-Wl,--gc-sections
38+
LDFLAGS += -Wl,--gc-sections
3239

3340
OPT_DEFS += -DF_CPU=$(F_CPU)UL
3441

quantum/process_keycode/process_unicode_common.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#include "process_unicode_common.h"
1818
#include "eeprom.h"
19-
#include <ctype.h>
20-
#include <string.h>
2119

2220
unicode_config_t unicode_config;
2321
uint8_t unicode_saved_mods;
@@ -231,37 +229,6 @@ void register_unicode(uint32_t code_point) {
231229
unicode_input_finish();
232230
}
233231

234-
// clang-format off
235-
236-
void send_unicode_hex_string(const char *str) {
237-
if (!str) {
238-
return;
239-
}
240-
241-
while (*str) {
242-
// Find the next code point (token) in the string
243-
for (; *str == ' '; str++); // Skip leading spaces
244-
size_t n = strcspn(str, " "); // Length of the current token
245-
char code_point[n+1];
246-
strncpy(code_point, str, n); // Copy token into buffer
247-
code_point[n] = '\0'; // Make sure it's null-terminated
248-
249-
// Normalize the code point: make all hex digits lowercase
250-
for (char *p = code_point; *p; p++) {
251-
*p = tolower((unsigned char)*p);
252-
}
253-
254-
// Send the code point as a Unicode input string
255-
unicode_input_start();
256-
send_string(code_point);
257-
unicode_input_finish();
258-
259-
str += n; // Move to the first ' ' (or '\0') after the current token
260-
}
261-
}
262-
263-
// clang-format on
264-
265232
// Borrowed from https://nullprogram.com/blog/2017/10/06/
266233
static const char *decode_utf8(const char *str, int32_t *code_point) {
267234
const char *next;

quantum/process_keycode/process_unicode_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ void register_hex(uint16_t hex);
9090
void register_hex32(uint32_t hex);
9191
void register_unicode(uint32_t code_point);
9292

93-
void send_unicode_hex_string(const char *str);
9493
void send_unicode_string(const char *str);
9594

9695
bool process_unicode_common(uint16_t keycode, keyrecord_t *record);

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This is the `develop` branch!
2+
3+
See the [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) document for more information.
4+
15
# Quantum Mechanical Keyboard Firmware
26

37
[![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags)

0 commit comments

Comments
 (0)