From 9f2cd9119f18deb824ef7840c69f97c635b485cd Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 22 Feb 2023 22:50:09 +0000 Subject: [PATCH] Reallocate user/kb keycode ranges (#19907) --- data/constants/keycodes/keycodes_0.0.2.hjson | 9 +++ .../keycodes/keycodes_0.0.2_user.hjson | 64 ++++++++-------- lib/python/qmk/json_schema.py | 3 + lib/python/qmk/keycodes.py | 1 + quantum/keycodes.h | 74 +++++++++---------- 5 files changed, 82 insertions(+), 69 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.2.hjson b/data/constants/keycodes/keycodes_0.0.2.hjson index 650235e647..dc789eca50 100644 --- a/data/constants/keycodes/keycodes_0.0.2.hjson +++ b/data/constants/keycodes/keycodes_0.0.2.hjson @@ -1,5 +1,14 @@ { "ranges": { + "0x7E00/0x00FF": "!delete!", + "0x7F00/0x00FF": "!delete!", + + "0x7E00/0x003F": { + "define": "QK_KB" + }, + "0x7E40/0x01BF": { + "define": "QK_USER" + }, "0x8000/0X3FFF": { "define": "QK_UNICODEMAP" }, diff --git a/data/constants/keycodes/keycodes_0.0.2_user.hjson b/data/constants/keycodes/keycodes_0.0.2_user.hjson index b41731b1be..42392dc649 100644 --- a/data/constants/keycodes/keycodes_0.0.2_user.hjson +++ b/data/constants/keycodes/keycodes_0.0.2_user.hjson @@ -1,130 +1,130 @@ { "keycodes": { - "0x7F00": { + "0x7E40": { "group": "user", "key": "QK_USER_0", }, - "0x7F01": { + "0x7E41": { "group": "user", "key": "QK_USER_1", }, - "0x7F02": { + "0x7E42": { "group": "user", "key": "QK_USER_2", }, - "0x7F03": { + "0x7E43": { "group": "user", "key": "QK_USER_3", }, - "0x7F04": { + "0x7E44": { "group": "user", "key": "QK_USER_4", }, - "0x7F05": { + "0x7E45": { "group": "user", "key": "QK_USER_5", }, - "0x7F06": { + "0x7E46": { "group": "user", "key": "QK_USER_6", }, - "0x7F07": { + "0x7E47": { "group": "user", "key": "QK_USER_7", }, - "0x7F08": { + "0x7E48": { "group": "user", "key": "QK_USER_8", }, - "0x7F09": { + "0x7E49": { "group": "user", "key": "QK_USER_9", }, - "0x7F0A": { + "0x7E4A": { "group": "user", "key": "QK_USER_10", }, - "0x7F0B": { + "0x7E4B": { "group": "user", "key": "QK_USER_11", }, - "0x7F0C": { + "0x7E4C": { "group": "user", "key": "QK_USER_12", }, - "0x7F0D": { + "0x7E4D": { "group": "user", "key": "QK_USER_13", }, - "0x7F0E": { + "0x7E4E": { "group": "user", "key": "QK_USER_14", }, - "0x7F0F": { + "0x7E4F": { "group": "user", "key": "QK_USER_15", }, - "0x7F10": { + "0x7E50": { "group": "user", "key": "QK_USER_16", }, - "0x7F11": { + "0x7E51": { "group": "user", "key": "QK_USER_17", }, - "0x7F12": { + "0x7E52": { "group": "user", "key": "QK_USER_18", }, - "0x7F13": { + "0x7E53": { "group": "user", "key": "QK_USER_19", }, - "0x7F14": { + "0x7E54": { "group": "user", "key": "QK_USER_20", }, - "0x7F15": { + "0x7E55": { "group": "user", "key": "QK_USER_21", }, - "0x7F16": { + "0x7E56": { "group": "user", "key": "QK_USER_22", }, - "0x7F17": { + "0x7E57": { "group": "user", "key": "QK_USER_23", }, - "0x7F18": { + "0x7E58": { "group": "user", "key": "QK_USER_24", }, - "0x7F19": { + "0x7E59": { "group": "user", "key": "QK_USER_25", }, - "0x7F1A": { + "0x7E5A": { "group": "user", "key": "QK_USER_26", }, - "0x7F1B": { + "0x7E5B": { "group": "user", "key": "QK_USER_27", }, - "0x7F1C": { + "0x7E5C": { "group": "user", "key": "QK_USER_28", }, - "0x7F1D": { + "0x7E5D": { "group": "user", "key": "QK_USER_29", }, - "0x7F1E": { + "0x7E5E": { "group": "user", "key": "QK_USER_30", }, - "0x7F1F": { + "0x7E5F": { "group": "user", "key": "QK_USER_31", }, diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index c886a0d868..b00df749cc 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -107,6 +107,7 @@ def deep_update(origdict, newdict): def merge_ordered_dicts(dicts): """Merges nested OrderedDict objects resulting from reading a hjson file. Later input dicts overrides earlier dicts for plain values. + If any value is "!delete!", the existing value will be removed from its parent. Arrays will be appended. If the first entry of an array is "!reset!", the contents of the array will be cleared and replaced with RHS. Dictionaries will be recursively merged. If any entry is "!reset!", the contents of the dictionary will be cleared and replaced with RHS. """ @@ -125,6 +126,8 @@ def merge_ordered_dicts(dicts): target[k] = v[1:] else: target[k] = target[k] + v + elif v == "!delete!" and isinstance(target, (OrderedDict, dict)): + del target[k] else: target[k] = v diff --git a/lib/python/qmk/keycodes.py b/lib/python/qmk/keycodes.py index d2f2492829..966930547c 100644 --- a/lib/python/qmk/keycodes.py +++ b/lib/python/qmk/keycodes.py @@ -90,6 +90,7 @@ def load_spec(version, lang=None): # Sort? spec['keycodes'] = dict(sorted(spec.get('keycodes', {}).items())) + spec['ranges'] = dict(sorted(spec.get('ranges', {}).items())) # Validate? _validate(spec) diff --git a/quantum/keycodes.h b/quantum/keycodes.h index dfebd22044..34b13c29af 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -77,13 +77,13 @@ enum qk_keycode_ranges { QK_QUANTUM = 0x7C00, QK_QUANTUM_MAX = 0x7DFF, QK_KB = 0x7E00, - QK_KB_MAX = 0x7EFF, - QK_USER = 0x7F00, + QK_KB_MAX = 0x7E3F, + QK_USER = 0x7E40, QK_USER_MAX = 0x7FFF, - QK_UNICODE = 0x8000, - QK_UNICODE_MAX = 0xFFFF, QK_UNICODEMAP = 0x8000, QK_UNICODEMAP_MAX = 0xBFFF, + QK_UNICODE = 0x8000, + QK_UNICODE_MAX = 0xFFFF, QK_UNICODEMAP_PAIR = 0xC000, QK_UNICODEMAP_PAIR_MAX = 0xFFFF, }; @@ -753,38 +753,38 @@ enum qk_keycode_defines { QK_KB_29 = 0x7E1D, QK_KB_30 = 0x7E1E, QK_KB_31 = 0x7E1F, - QK_USER_0 = 0x7F00, - QK_USER_1 = 0x7F01, - QK_USER_2 = 0x7F02, - QK_USER_3 = 0x7F03, - QK_USER_4 = 0x7F04, - QK_USER_5 = 0x7F05, - QK_USER_6 = 0x7F06, - QK_USER_7 = 0x7F07, - QK_USER_8 = 0x7F08, - QK_USER_9 = 0x7F09, - QK_USER_10 = 0x7F0A, - QK_USER_11 = 0x7F0B, - QK_USER_12 = 0x7F0C, - QK_USER_13 = 0x7F0D, - QK_USER_14 = 0x7F0E, - QK_USER_15 = 0x7F0F, - QK_USER_16 = 0x7F10, - QK_USER_17 = 0x7F11, - QK_USER_18 = 0x7F12, - QK_USER_19 = 0x7F13, - QK_USER_20 = 0x7F14, - QK_USER_21 = 0x7F15, - QK_USER_22 = 0x7F16, - QK_USER_23 = 0x7F17, - QK_USER_24 = 0x7F18, - QK_USER_25 = 0x7F19, - QK_USER_26 = 0x7F1A, - QK_USER_27 = 0x7F1B, - QK_USER_28 = 0x7F1C, - QK_USER_29 = 0x7F1D, - QK_USER_30 = 0x7F1E, - QK_USER_31 = 0x7F1F, + QK_USER_0 = 0x7E40, + QK_USER_1 = 0x7E41, + QK_USER_2 = 0x7E42, + QK_USER_3 = 0x7E43, + QK_USER_4 = 0x7E44, + QK_USER_5 = 0x7E45, + QK_USER_6 = 0x7E46, + QK_USER_7 = 0x7E47, + QK_USER_8 = 0x7E48, + QK_USER_9 = 0x7E49, + QK_USER_10 = 0x7E4A, + QK_USER_11 = 0x7E4B, + QK_USER_12 = 0x7E4C, + QK_USER_13 = 0x7E4D, + QK_USER_14 = 0x7E4E, + QK_USER_15 = 0x7E4F, + QK_USER_16 = 0x7E50, + QK_USER_17 = 0x7E51, + QK_USER_18 = 0x7E52, + QK_USER_19 = 0x7E53, + QK_USER_20 = 0x7E54, + QK_USER_21 = 0x7E55, + QK_USER_22 = 0x7E56, + QK_USER_23 = 0x7E57, + QK_USER_24 = 0x7E58, + QK_USER_25 = 0x7E59, + QK_USER_26 = 0x7E5A, + QK_USER_27 = 0x7E5B, + QK_USER_28 = 0x7E5C, + QK_USER_29 = 0x7E5D, + QK_USER_30 = 0x7E5E, + QK_USER_31 = 0x7E5F, // Alias XXXXXXX = KC_NO, @@ -1391,8 +1391,8 @@ enum qk_keycode_defines { #define IS_QK_QUANTUM(code) ((code) >= QK_QUANTUM && (code) <= QK_QUANTUM_MAX) #define IS_QK_KB(code) ((code) >= QK_KB && (code) <= QK_KB_MAX) #define IS_QK_USER(code) ((code) >= QK_USER && (code) <= QK_USER_MAX) -#define IS_QK_UNICODE(code) ((code) >= QK_UNICODE && (code) <= QK_UNICODE_MAX) #define IS_QK_UNICODEMAP(code) ((code) >= QK_UNICODEMAP && (code) <= QK_UNICODEMAP_MAX) +#define IS_QK_UNICODE(code) ((code) >= QK_UNICODE && (code) <= QK_UNICODE_MAX) #define IS_QK_UNICODEMAP_PAIR(code) ((code) >= QK_UNICODEMAP_PAIR && (code) <= QK_UNICODEMAP_PAIR_MAX) // Group Helpers