diff --git a/rumcake/src/keyboard.rs b/rumcake/src/keyboard.rs index d039304..e23af88 100644 --- a/rumcake/src/keyboard.rs +++ b/rumcake/src/keyboard.rs @@ -5,7 +5,7 @@ use core::convert::Infallible; use core::fmt::Debug; -use core::ops::Range; +use core::ops::{DerefMut, Range}; use defmt::{debug, info, warn, Debug2Format}; use embassy_futures::select::{select, select_slice, Either}; @@ -96,11 +96,21 @@ pub trait KeyboardLayout { fn get_original_layout( ) -> Layers<{ Self::LAYOUT_COLS }, { Self::LAYOUT_ROWS }, { Self::LAYERS }, Keycode>; - /// Handle a [`Keycode::Custom`] event. By default this does nothing. + /// Handle a [`Keycode::User`] event. By default this does nothing. /// /// `press` is set to `true` if the event was a key press. Otherwise, it will be `false`. `id` /// corresponds to the `id` used in your keyboard layout. - fn on_custom_keycode(_id: u8, _press: bool) {} + fn on_user_keycode( + _layout: &mut KeyberonLayout< + { Self::LAYOUT_COLS }, + { Self::LAYOUT_ROWS }, + { Self::LAYERS }, + Keycode, + >, + _id: u8, + _press: bool, + ) { + } #[cfg(feature = "simple-backlight")] type SimpleBacklightDeviceType: crate::lighting::simple_backlight::private::MaybeSimpleBacklightDevice = @@ -283,9 +293,9 @@ pub fn setup_analog_keyboard_matrix {} CustomEvent::Press(keycode) => match keycode { - Keycode::Custom(id) => { - K::on_custom_keycode(id, true); + Keycode::User(id) => { + K::on_user_keycode(layout.deref_mut(), id, true); } #[cfg(feature = "media-keycodes")] Keycode::Media(keycode) => { @@ -635,8 +645,8 @@ where } }, CustomEvent::Release(keycode) => match keycode { - Keycode::Custom(id) => { - K::on_custom_keycode(id, false); + Keycode::User(id) => { + K::on_user_keycode(layout.deref_mut(), id, false); } #[cfg(feature = "media-keycodes")] Keycode::Media(keycode) => {