Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Optionally decouple layout matrix and pin matrix via transform function #121

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ben-PH
Copy link

@Ben-PH Ben-PH commented Jul 24, 2023

The Project I am working on doesn't conform to the assumptions in keyberon about input/output pins being rows/columns. This PR does two things:

  • In the matrix file, renames variables and types from "row"-and-friends to "outs"-and-friend, and changes "column"-and-friends to "ins"-and-friends
  • the debounce-events takes an Option<fn...>, which allows the caller to define a matrix transformation

when the transformation is None, the behavior is unchanged: output pins are still assumed to correspond to rows, and similarly for input puns.

If one passes in Some<transpose>, rowout-pins are now column pins and colin-pins are now row-pins. One can also define their own transpose function of the signature fn(u8, u8) -> (u8, u8), and wire up their key-matrix arbitrarily, and then being able to write out their layout ergonomically.

This means that one can wire up their matrix to maximise pin-use, then independently choose how to define their layouts, and if the kb-matrix and layout are mismatched, it should be a simple matter of writing a transform to re-align the two.

For my project, specifically, this PR means that Instead of writing this (note the vertical qwerty):

static LAYOUT: Layers<4, 6, 1> = [[
    [k(No),     k(No), k(A), k(Z)],
    [k(No),     k(Q), k(S), k(X)],
    [k(Escape), k(W), k(D), k(C)],
    [k(LCtrl),  k(E), k(F), k(V)],
    [k(LAlt),   k(R), k(G), k(B)],
    [k(No),     k(T), k(Q), k(R)],
]];

I can write it out like so, so long as I call Debouncer::events with Some(transpose):

static LAYOUT: Layers<6, 4, 1> = [[
    [k(No), k(No), k(Escape), k(LCtrl), k(LAlt), k(No)],
    [k(No), k(Q),  k(W),      k(E),     k(R),    k(T)],
    [k(A),  k(S),  k(D),      k(F),     k(G),    k(Q)],
    [k(Z),  k(X),  k(C),      k(V),     k(B),    k(R)],
]];

ETA: I think it would be better to add the function as described. When a minor-version bump arrives, we can then go with just having events with the optional transformation provided

Due to the addition of an argument in the public API, I've also bumped the minor version. To migrate to the minor version, users only have to add None to their events calls.

alternatively, we could add events_transposed, and events just calls that with None, and leave events unchanged. That would preclude a version bump.

@TeXitoi
Copy link
Owner

TeXitoi commented Dec 24, 2024

First, sorry to the very late review.

I don’t understand why you don’t just do a map to transform the event between the debounce and the layout. Something like https://github.com/TeXitoi/keyseebee/blob/master/firmware/src/main.rs#L231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants