keyberon icon indicating copy to clipboard operation
keyberon copied to clipboard

Why the move to "fully const layouts"?

Open riskable opened this issue 2 years ago • 1 comments

This change has been a nightmare for me so I'm curious what benefit it provides? My code used to be able to take simple arguments like:

pub fn event_scanner(
    config: &mut Config,
    layout: &mut Layout<CustomActions>,
    states: &mut PeripheralStates,
    now: Instant<u64, 1, 1000000>,
) { do_stuff_here() }

Now I have to change all my functions that deal with layout to be like this:

pub fn event_scanner<const C: usize, const R: usize, const L: usize>(
    config: &mut Config,
    layout: &mut Layout<C, R, L, CustomActions>,
    states: &mut PeripheralStates,
    now: Instant<u64, 1, 1000000>,
) { do_stuff_here() }

Also, whenever an end user implementing my firmware for a specific board wants to call one of these functions they have to make a complicated call like this:

action.execute::<16, 3, 4>(config, layout, states, now);

...and know ahead of time (somehow) how many layers their end users will have configured (they'll know how many rows/columns since that'll be specific to their hardware). It's super unergonomic and rather inflexible.

riskable avatar May 11 '22 15:05 riskable

@Skelebot ?

For reference, the corresponding PR: https://github.com/TeXitoi/keyberon/pull/67

TeXitoi avatar May 11 '22 16:05 TeXitoi