Add layer_dismiss module: a key that drops the layer that delivered it - #9
Add layer_dismiss module: a key that drops the layer that delivered it#9dscarpetti wants to merge 1 commit into
Conversation
|
Use surfaced something worth mentioning, there is a hold-and-release behavior that comes along for free. Tap dismisses as designed. What I had not planned is what a hold does when composed with automouse. While the key is held, automouse counts it as layer activity and keeps refreshing its timer, so the layer stays open indefinitely through any pause. Release then drops it instantly. The dismiss key is thereby also a sustain key: rest a finger on it and pointer mode persists, lift it and you are typing again. My layout previously dedicated an entire second held layer to exactly that persistence job, and this made the layer deletable. This falls out of dropping on release rather than press, which the PR justified for rollover safety. One important ordering note is that the sustain behavior requires automouse to be listed before layer_dismiss in the keymap's modules list, so that automouse sees the held key's press before layer_dismiss consumes it. Otherwise, tap-to-dismiss still works but a hold no longer counts as activity. I'm now running with a short automouse idle timeout, which gives me time for double clicks. When doing sustained mousing, I hold down a dismiss key to keep the mouse live and then I pop directly back into typing mode when I release it. |
KC_LAYER_DISMISS (alias LY_DSMS) is the lowering half of a toggle: on release it turns off whichever layer resolved the keypress, and emits nothing of its own. TG() raises and lowers one hardcoded layer. Layer Lock holds the current layer on. This is the missing third primitive, letting the current layer go from any position it is bound on. On the base layer the key is a deliberate no-op: the root cannot be dismissed. Motivating use: automouse layers. Neither timeout-based deactivation nor exit-on-any-keypress fits users who want mouse keys to keep the layer and chosen positions to dismiss it. Binding KC_LAYER_DISMISS across a mouse layer's unused positions makes each of them a consumed tap-to-wake exit: the layer drops, nothing types, and the next keystroke lands on the layout below. Dropping on release keeps rollover safe: a fast second keystroke still resolves through the layer's transparency. The keycode is generic: any transient layer can carry dismiss positions, and per-position policy lives in the keymap rather than in firmware configuration.
ef0c3c3 to
4ca22b0
Compare
What
KC_LAYER_DISMISS(aliasLY_DSMS) is an assignable key that, on release, turns off whichever layer resolved the keypress, and emits nothing of its own.It is the missing third layer primitive.
TG()raises and lowers one hardcoded layer. Layer Lock holds the current layer on.TO(0)exits but tears down every other active layer with it. There was no way to bind "let this layer go", the lowering half of a toggle, aimed at the layer the key came from, so a single binding works on any layer it is placed on. On the base layer the key is a deliberate no-op so the root cannot be dismissed.Why (the automouse case)
Automouse currently offers timeout-based deactivation or oneshot tap-to-exit, and neither fits a common want: mouse keys should keep the layer alive, while chosen positions dismiss it. With this keycode that policy moves into the keymap. Bind
KC_LAYER_DISMISSon whichever automouse-layer positions should exit, and each becomes a consumed tap-to-wake: the layer drops, nothing types, and the next keystroke lands on the layout below. The automouse module needs no changes, it already tolerates its layer being turned off externally and re-raises on the next motion.Dropping on release keeps rollover safe. A fast second keystroke arrives while the layer is still up and resolves through its transparency to the layout below, so nothing is lost when typing immediately after a wake tap.
Scope
Tiny footprint, large possibility space, predictable behavior: one keycode, one hook, about 30 lines including comments. Generic by construction: any transient layer can carry dismiss positions, and per-position policy lives in keymap data rather than firmware configuration.
Tested on a Voyager with
navigator_trackball+automouse(three dismiss positions on the mouse layer, built against firmware25 with this module added)