From 41ff1edf1b9fc518053228182ce5edfc758a1eca Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 22 Feb 2023 04:28:54 +0000 Subject: [PATCH 1/2] Reallocate user/kb keycode ranges --- data/constants/keycodes/keycodes_0.0.2.hjson | 9 +++++++++ lib/python/qmk/json_schema.py | 3 +++ lib/python/qmk/keycodes.py | 1 + quantum/keycodes.h | 10 +++++----- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.2.hjson b/data/constants/keycodes/keycodes_0.0.2.hjson index 650235e6471b..dc789eca50b4 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/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index c886a0d86816..b901cd50fd1f 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -109,6 +109,7 @@ def merge_ordered_dicts(dicts): Later input dicts overrides earlier dicts for plain values. 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. + If any value is "!delete!", the dictionary will be removed from its parent. """ result = OrderedDict() @@ -125,6 +126,8 @@ def add_entry(target, k, v): target[k] = v[1:] else: target[k] = target[k] + v + elif v == "!delete!" and isinstance(target[k], (OrderedDict, dict)): + del target[k] else: target[k] = v diff --git a/lib/python/qmk/keycodes.py b/lib/python/qmk/keycodes.py index d2f24928290a..966930547c75 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 dfebd22044b1..d8891ce53401 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, }; @@ -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 From bdb96c0b9864e1b1ab8f2aa61dbfd8d57885f979 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 22 Feb 2023 04:56:57 +0000 Subject: [PATCH 2/2] Reallocate user/kb keycode ranges --- .../keycodes/keycodes_0.0.2_user.hjson | 64 +++++++++---------- lib/python/qmk/json_schema.py | 4 +- quantum/keycodes.h | 64 +++++++++---------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.2_user.hjson b/data/constants/keycodes/keycodes_0.0.2_user.hjson index b41731b1be4f..42392dc64935 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 b901cd50fd1f..b00df749ccfa 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -107,9 +107,9 @@ 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. - If any value is "!delete!", the dictionary will be removed from its parent. """ result = OrderedDict() @@ -126,7 +126,7 @@ def add_entry(target, k, v): target[k] = v[1:] else: target[k] = target[k] + v - elif v == "!delete!" and isinstance(target[k], (OrderedDict, dict)): + elif v == "!delete!" and isinstance(target, (OrderedDict, dict)): del target[k] else: target[k] = v diff --git a/quantum/keycodes.h b/quantum/keycodes.h index d8891ce53401..34b13c29af52 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -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,