HaoboGu / rmk

A Rust keyboard firmware with layers, online keymap editing and BLE wireless support for nRF52/ESP32
https://github.com/HaoboGu/rmk
Apache License 2.0
275 stars 19 forks source link

Macropad (RP2040) 'matrix-less' switch support? #39

Open erdii opened 1 month ago

erdii commented 1 month ago

Heya :wave:

I was wondering: does this firmware support the "matrix-less" inputs on the Adafruit Macropad [1]? The macropad has 12 keyboard switches, each connected to it's own GPIO pin.

Cheers, Josh

[1] https://www.adafruit.com/product/5128

HaoboGu commented 1 month ago

Hi!

Direct pin is not supported right now, but adding this feature isn't hard imo. If you really want it, I can add it in next weeks, or you can do a PR and I'm happy to review it :D

erdii commented 1 month ago

Ah that's a bummer.

I haven't written any rust actively and my experience only revolves around gargabe-collected languages so far, so I'm not sure if my rust-foo is good enough to contribute without getting overwhelmed by the steep learning curves of rust, cross-compiling rust for embedded and embassy but I'll dabble a few more hours to try and find out. :)

Thanks for creating this project and being a maintainer of it and I'd like to acknowledge that I don't have any entitlement to ask you for adding this feature (in the next weeks or at all).

That said, If you'd like to share any pointers on where to start, I'd happily take them. I'd also happily download a version of rmk that includes the feature.

Cheers! :)

HaoboGu commented 1 month ago

You can follow the first two sections of user guide to setup Rust and RMK environment.

If you're not familiar with Rust nor Rust embedded, the official Rust book and the Rust embedded book are the good start points of your Rust journey.

Happy coding! :D

HaoboGu commented 3 weeks ago

I just did some investigation. Current matrix.rs implementation is limited to traditional keyboard matrix, but it can be abstracted easily to a trait which is used in keyboard.rs:

pub(crate) trait KeyboardMatrix {
    fn new() -> Self;
    fn get_key_state(&mut self, row: usize, col: usize) -> KeyState;
    fn update_timer(&mut self, row: usize, col: usize);
    async fn scan(&mut self);
    #[cfg(feature = "async_matrix")]
    async fn wait_for_key(&mut self); 
}

Then the direct pin matrix can be implemented with very little effort. I currently just doesn't have enough time to implement it. But if anyone want to do, I'd happy to give suggestions & guidance about it.