# Different Layouts for two persons

**URL:** <https://community.keyboard.io/t/different-layouts-for-two-persons/3107>\
**Category:** Programming\
**Created:** [August 12, 2019, 10:47pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107 "2019-08-12T22:47:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxG](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@MaxG](https://community.keyboard.io/u/MaxG)\
**Post date:** [August 12, 2019, 10:47pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/1 "2019-08-12T22:47:27Z")

</div>

Hi everyone.

I want to change the firmware of my keyboard such that I have two customised layouts in it. This means, I would have layers PRIMARY\_A and PRIMARY\_B, but also FUNCTION\_A and FUNCTION\_B, NumPad\_A and NumPad\_B and maybe WEIRD\_STUFF\_A. Basically, two unrelated groups of layouts.

I now wonder what the best way to change between them would be. I thought I would dedicate a key somehow (e.g. FN+Prog) to change the currently active layout group. Unfortunately, I cannot figure out how the firmware keeps track of which firmware it is in, currently. I suspect that LockLayer is not the right tool. I would have LockLayer in each group too, e.g. to reach NumPad.

Can anyone help me out here?

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [August 13, 2019, 12:13pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/2 "2019-08-13T12:13:47Z")

</div>

`LockLayer` will be the tool you want. The easiest way would be to structure the layers like `PRIMARY_A`, `FUNCTION_A`, `NumPad_A`, `WEIRD_STUFF_A`, `PRIMARY_B`, `FUNCTION_B`, `NumPad_B`.

On `FUNCTION_A`, you’d have the `Prog` key do `LockLayer(PRIMARY_B)`, so when you press `Fn+Prog`, it would lock to `PRIMARY_B`. On `FUNCTION_B`, you’d have `UnlockLayer(PRIMARY_B)`, and voila! To reach numpad, `PRIMARY_A` would have `LockLayer(NumPad_A)`, and `PRIMARY_B` would `LockLayer(NumPad_B)`.

Imagine that layers are like stacks of foil: when you lock to or switch to one, the layers below stay active too, the higher ones merely shadow the lower ones. So as soon as you turn a higher layer off, the layers below will be used again. This way, you can shadow all the `_A` layers with `_B`.

Let me know if you need further help, or explanation!

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [August 13, 2019, 12:24pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/3 "2019-08-13T12:24:32Z")

</div>

One more thing: Your `PRIMARY_B` layer shouldn’t have any `Key_Transparent` (`___`) entries, to prevent getting semi-random behaviour depending on which `*_A` layers are active.

---

<div class="post-metadata">

**Author:** ![MaxG](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@MaxG](https://community.keyboard.io/u/MaxG)\
**Post date:** [August 14, 2019, 4:02pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/4 "2019-08-14T16:02:15Z")

</div>

Thank you both very very much. That helped a lot and I was able to setup the layouts as I want them to.

I have one follow-up question. I would like to have an LED to indicate the layer the keyboard is locked to. However, with your answers I learned nothing about how the system keeps track about which layer it is in.

I currently see only the option of using a macro that accepts a layer, sets the colour and returns the right key. However, I would prefer to query some state in the loop() function instead of making the layout more complex.

How could that be done?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [August 14, 2019, 7:16pm UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/5 "2019-08-14T19:16:33Z")

</div>

You can query the highest layer with `Layer.top()`, and compare that to the layer, like:

```auto
if (Layer.top() == PRIMARY_A) {
  LEDControl.setAllCrgbTo(CRGB(255, 0, 0)));
}

```

Mind you, this is _very_ inefficient, because it runs every cycle, even if the layers did not change. It’s far less resource intensive to write a plugin that changes colors when layers do change. Thankfully, you don’t have to do that, as two such plugins already exist: the [Colormap](https://github.com/keyboardio/Kaleidoscope/blob/master/doc/plugin/Colormap.md) and [ActiveLayerColor](https://github.com/keyboardio/Kaleidoscope/blob/master/doc/plugin/LED-ActiveLayerColor.md) plugins. If you want all keys to be the same color, the latter plugin is probably the most efficient.

FWIW, the firmware stores the active layers as a 32-bit bitmap, with one bit for each active layer. You can also query _all_ the active layers with `Layer.getLayerState()`, which will return you said bitmap.

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [August 15, 2019, 1:24am UTC](https://community.keyboard.io/t/different-layouts-for-two-persons/3107/6 "2019-08-15T01:24:35Z")

</div>

> [@MaxG](#):
>
> I would like to have an LED to indicate the layer the keyboard is locked to. However, with your answers I learned nothing about how the system keeps track about which layer it is in.

Your question implies a common misconception about Kaleidoscope’s layer system — that there is only one layer active at a time. A `LockLayer(N)` key _toggles_ the state of layer `N`, but doesn’t affect any other layers. It’s entirely possible to have all layers active (turned on) at the same time; the value looked up when a key is pressed comes from the highest active layer with a non-transparent entry for that key.
