diff --git a/src/api/focus/keymap/db/constants.js b/src/api/focus/keymap/db/constants.js index dd9fed62d..9961fed93 100644 --- a/src/api/focus/keymap/db/constants.js +++ b/src/api/focus/keymap/db/constants.js @@ -69,6 +69,12 @@ const keycode_ranges = { turbo: { start: 0xd15b, end: 0xd15b }, }; export const constants = { + limits: { + // Using a secondary action for layer shifts is limited to 8 layers due to + // technical reasons in Kaleidoscope. We overflow the key range assigned to + // secondary actions if we got beyond layer 7. (Layer 0 is the first layer.) + secondaryActionLayerLimit: 7, + }, codes: { // Keycodes ESCAPE: 41, diff --git a/src/renderer/screens/Editor/Sidebar/LayerKeys.js b/src/renderer/screens/Editor/Sidebar/LayerKeys.js index e9655c319..f5ff190df 100644 --- a/src/renderer/screens/Editor/Sidebar/LayerKeys.js +++ b/src/renderer/screens/Editor/Sidebar/LayerKeys.js @@ -48,8 +48,8 @@ const LayerKeys = (props) => { if (db.isInCategory(key.code, "layer") && key.categories.includes("dualuse")) { const code = key.baseCode || key.code; - if (target < 0) target = getMaxLayer(); - if (target > getMaxLayer()) target = 0; + if (target < 0) target = db.constants.limits.secondaryActionLayerLimit; + if (target > db.constants.limits.secondaryActionLayerLimit) target = 0; props.onKeyChange(addDualUseLayer(db.lookup(code), target).code); } else { @@ -120,7 +120,7 @@ const LayerKeys = (props) => { > {[...Array(getMaxLayer())].map((x, i) => ( - + db.constants.limits.secondaryActionLayerLimit}> {props.layerNames?.names[i]} ))} diff --git a/src/renderer/screens/Editor/Sidebar/SecondaryFunction.js b/src/renderer/screens/Editor/Sidebar/SecondaryFunction.js index 501d3b980..01396b0bf 100644 --- a/src/renderer/screens/Editor/Sidebar/SecondaryFunction.js +++ b/src/renderer/screens/Editor/Sidebar/SecondaryFunction.js @@ -78,10 +78,6 @@ const SecondaryFunction = (props) => { const { currentKey: key, keymap } = props; const maxLayer = keymap.custom.length; - // Using a secondary action for layer shifts is limited to 8 layers due to - // technical reasons in Kaleidoscope. We overflow the key range assigned to - // secondary actions if we got beyond layer 7. (Layer 0 is the first layer.) - const secondaryActionLayerLimit = 7; let type = "none", targetLayer = -1, @@ -131,9 +127,9 @@ const SecondaryFunction = (props) => { targetLayer = key.target; let layerLimitText = ""; - if (maxLayer > secondaryActionLayerLimit) { + if (maxLayer > db.constants.limits.secondaryActionLayerLimit) { layerLimitText = t("editor.sidebar.secondary.help-layerLimit", { - layer7: props.layerNames?.names[secondaryActionLayerLimit], + layer7: props.layerNames?.names[db.constants.limits.secondaryActionLayerLimit], }); } @@ -142,7 +138,7 @@ const SecondaryFunction = (props) => { {t("editor.sidebar.secondary.targetLayer")}{" "} - secondaryActionLayerLimit && layerLimitText}> + db.constants.limits.secondaryActionLayerLimit && layerLimitText}>