rumcake
rumcake::keyboard

Trait KeyboardMatrix

Source
pub trait KeyboardMatrix {
    type Layout: MaybeKeyboardLayout = EmptyKeyboardLayout;
    type PeripheralDeviceType: MaybePeripheralDevice = EmptyPeripheralDevice;

    const MATRIX_COLS: usize;
    const MATRIX_ROWS: usize;
    const DEBOUNCE_MS: u16 = 5u16;

    // Required method
    fn get_matrix() -> &'static PollableMatrix<impl Pollable>;

    // Provided method
    fn remap_to_layout(row: u8, col: u8) -> (u8, u8) { ... }
}
Expand description

A trait that must be implemented for any device that needs to poll a switch matrix.

Required Associated Constants§

Source

const MATRIX_COLS: usize

Number of matrix columns.

It is recommended to use one of the build_*_matrix macros to set this constant.

Source

const MATRIX_ROWS: usize

Number of matrix rows.

It is recommended to use one of the build_*_matrix macros to set this constant.

Provided Associated Constants§

Source

const DEBOUNCE_MS: u16 = 5u16

Debounce setting.

Provided Associated Types§

Source

type Layout: MaybeKeyboardLayout = EmptyKeyboardLayout

The layout to send matrix events to.

Source

type PeripheralDeviceType: MaybePeripheralDevice = EmptyPeripheralDevice

The peripheral device in a split keyboard setup to send matrix events to.

Required Methods§

Source

fn get_matrix() -> &'static PollableMatrix<impl Pollable>

Create the keyboard matrix by initializing a set of GPIO pins to use for columns and rows.

It is recommended to use one of the build_*_matrix macros to set this constant.

Provided Methods§

Source

fn remap_to_layout(row: u8, col: u8) -> (u8, u8)

Optional function to remap a matrix position to a position on the keyboard layout defined by KeyboardLayout::get_layout.

This is useful in split keyboard setups, where all peripherals have a matrix, but only one of the devices stores the overall keyboard layout.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§