From 61d34c91cd514f37732245efa44944ea0251d659 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Mar 2024 12:10:29 -0700 Subject: [PATCH] Refactor modifier key handling and update constants - Refactored the handling of modifier keys in `src/api/focus/keymap/db/base.js` to use a new range defined in `constants.js`, improving code clarity and maintainability. - Updated `constants.js` to include a new range for modifier keys, enhancing the structure and readability of key definitions. - These changes ensure that the handling of modifier keys is more aligned with the updated constants, facilitating future updates and maintenance. --- src/api/focus/keymap/db/base.js | 30 ++++++++++++++++++++-------- src/api/focus/keymap/db/constants.js | 5 +++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/api/focus/keymap/db/base.js b/src/api/focus/keymap/db/base.js index c89e73d0d..05f8a486d 100644 --- a/src/api/focus/keymap/db/base.js +++ b/src/api/focus/keymap/db/base.js @@ -445,18 +445,31 @@ const lang_intl = assignKeysToCategory( { code: 143, label: { base: { full: "Intl9" } } }, ] ); + const modifiers = withModifiers( assignKeysToCategory( ["modifier"], [ - { code: 224, label: { base: { full: "Control", "1u": "Ctrl" } }, location: "left" }, - { code: 225, label: { base: "Shift" }, location: "left" }, - { code: 226, label: { base: "Alt" }, location: "left" }, - { code: 227, label: { base: GuiLabel }, location: "left" }, - { code: 228, label: { base: { full: "Control", "1u": "Ctrl" } }, location: "right" }, - { code: 229, label: { base: "Shift" }, location: "right" }, - { code: 230, label: { base: { full: "AltGr", "1u": "AGr" } }, location: "right" }, - { code: 231, label: { base: GuiLabel }, location: "right" }, + { + code: constants.ranges.modifiers.start + 0, + label: { base: { full: "Control", "1u": "Ctrl" } }, + location: "left", + }, + { code: constants.ranges.modifiers.start + 1, label: { base: "Shift" }, location: "left" }, + { code: constants.ranges.modifiers.start + 2, label: { base: "Alt" }, location: "left" }, + { code: constants.ranges.modifiers.start + 3, label: { base: GuiLabel }, location: "left" }, + { + code: constants.ranges.modifiers.start + 4, + label: { base: { full: "Control", "1u": "Ctrl" } }, + location: "right", + }, + { code: constants.ranges.modifiers.start + 5, label: { base: "Shift" }, location: "right" }, + { + code: constants.ranges.modifiers.start + 6, + label: { base: { full: "AltGr", "1u": "AGr" } }, + location: "right", + }, + { code: constants.ranges.modifiers.start + 7, label: { base: GuiLabel }, location: "right" }, ] ) ).concat([ @@ -466,6 +479,7 @@ const modifiers = withModifiers( ]); const oneshot_modifier = (index, mod) => ({ code: constants.ranges.oneshot_modifier.start + index, + baseCode: constants.ranges.modifiers.start + index, label: { hint: { full: "OneShot", "1u": "OSM" }, base: mod }, rangeStart: constants.ranges.oneshot_modifier.start, categories: ["oneshot", "modifier"], diff --git a/src/api/focus/keymap/db/constants.js b/src/api/focus/keymap/db/constants.js index 8672ab429..23e041572 100644 --- a/src/api/focus/keymap/db/constants.js +++ b/src/api/focus/keymap/db/constants.js @@ -19,6 +19,11 @@ const keycode_ranges = { start: 4, end: 255, }, + modifiers: { + start: 224, + end: 231, + }, + dual_use_layer: { start: 0xc812, end: 0xd012,