Mirrored keymap-lookup


(Noseglasses) #1

When operating the mouse it would sometimes be nice to have all key-functionality available to the other (non-mouse) hand. This could of course be achieved using additional keymap layers but it seems to be a huge waste of PROGMEM.

What about adding a global boolean flag that would cause all keymap lookup to be mirrored? I would preferably like to toggle this flag via the palm key and then have the other keyboard half behave exactly as its sibling but with a mirrored layout.

In several occasions, e.g. when doing sports, it occurred to me that it is comparably easy to do the same movements with the other hand in a mirrored fashion, once you learned to perform some complex motion with one hand. It is e.g. not so hard to learn to play table tennis with the other hand once you know how to play. That’s why I imagine it not too complex a task to use (memorize) keys with the other hand in a mirrored fashion.

All this feature would require is to add some if-statements to the keymap lookup function that check for some global boolean flag to be set and in that case just to mirror the lookup (key coordinates).

Devs, what do you think about this idea?


(Gergely Nagy) #2

You don’t need any if flags. You can write your own lookup function and assign it to Layer.getKey. Your function can do the lookup in whatever way it wants, including saving the original lookup function first, and calling that with different arguments.

The EEPROMKeymap plugin uses this to implement EEPROM lookups. Nothing’s stopping you from doing mirror lookups when a flag’s toggled. :slight_smile:


(Noseglasses) #3

Good to know, thanks.
What about the LEDs? Is it equally simple there?


(Gergely Nagy) #4

No, not yet, but we’re working on it.


(Noseglasses) #5

The longer I think about it the less I am convinced that assigning to Layer.getKey is exactly what I am looking for. But it’s close.

What I would like is a global weak funktion

KeyPos messWithKeyCoordinates(KeyPos in);

that the user could override. This function would be called by the firmware core in all places immediately before key coordinate based lookup occurs, including keycode lookup (or assignment) and LED access.

The system (Hardware) could then provide convenience functions like

KeyPos mirrorKeyCoordinate(KeyPos in);
KeyPos shiftKeyCoordinate(byte xOffset, byte yOffset, bool wrapAround, KeyPos in);
...

thus not requiring the user to care too much about the dimensions of the key matrix. Those auxiliary functions could then be used in an messWithKeyCoordinates override.


(Noseglasses) #6

The point is that I don’t intend to mess with what is accessed but where.


(Noseglasses) #7

BTW, a coordinate shift could be interesting on keyboards like the Planck.


(Gergely Nagy) #8

I think there’s merit in this idea. Can you open an issue, so it doesn’t get lost?


(Noseglasses) #9