"borrow your laptop?"

I can envision a number of ways to trigger switching layer combinations, from a dedicated keys, through MagicCombos, to sending a command through Focus. But the more interesting part is how to switch all layers? You don’t want to replace the existing ones (so that the operation remains reversible). You don’t want to over-complicate the keymap, either.

So here’s an easy thing to do: take the factory keymap, paste it after your own, and adjust the layers in the factory keymap, then you can create a macro that toggles your layers off, and enables FACTORY (or does the opposite).

In other words:

enum { DVORAK, FN, FACTORY_QWERTY, FACTORY_FN, FACTORY_NUMPAD };
const Key keymaps[][ROWS][COLS] PROGMEM = {
  [DVORAK] = KEYMAP_STACKED(...),
  [FN] = KEYMAP_STACKED(...),
  [FACTORY_QWERTY] = ...,
  ...
};

On the FACTORY_* layers you’d just use ShiftToLayer(FACTORY_FN) instead of ShiftToLayer(FN), and so on, and you’d have a macro on - say, Prog - that does something along these lines:

static void toggleFactoryLayout(uint8_t keyState) {
  if (!keyToggledOn(keyState))
    return;

  if (Layer.isOn(DVORAK)) {
    Layer.move(FACTORY_QWERTY);
  } else {
    Layer.move(DVORAK);
  }
}

Adapting this to use MagicCombos, TapDance, or any other method is left as an exercise for the reader.

The downside of this is that this increases the firmware size considerably (128 bytes / layer, for a total of 384 bytes for the factory layers), so if you have a lot of stuff in your firmware, this isn’t an option. One could also play tricks with having the factory firmware in PROGMEM, and your own in EEPROM, and a macro that toggles where keys are looked up from. The downside of that would be that it is slightly more complicated, but uses less PROGMEM, at the cost of EEPROM, but if you ever want to use Chrysalis or similar tools, you’ll need your keymap in EEPROM anyway.

Right. Lots of words, little sense. Let me know if further explanation is helpful. I’ll go and get some caffeine into my system.

3 Likes