Skip to content

Commit

Permalink
Refactor modifier key handling and update constants
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
obra committed Mar 18, 2024
1 parent 8783e40 commit 61d34c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/api/focus/keymap/db/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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"],
Expand Down
5 changes: 5 additions & 0 deletions src/api/focus/keymap/db/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const keycode_ranges = {
start: 4,
end: 255,
},
modifiers: {
start: 224,
end: 231,
},

dual_use_layer: {
start: 0xc812,
end: 0xd012,
Expand Down

0 comments on commit 61d34c9

Please sign in to comment.