RKTK API Docs RKTK Home Repo

kmsm_rktk/
lib.rs

1#![no_std]
2
3use kmsm::keycode::prelude::*;
4
5macro_rules! gen_rktk_keys {
6    ($($name:ident = $value:literal),* $(,)?) => {
7        /// Custom key id of kmsm which is specific to rktk.
8        /// It must be used with `Custom1` variant of [`kmsm::keycode::KeyCode`]
9        ///
10        /// Custom2 and Custom3 can be used by user.
11        #[derive(
12            Debug, Clone, Copy, PartialEq, Eq, strum::EnumIter, strum::IntoStaticStr, strum::FromRepr,
13        )]
14        #[repr(u8)]
15        pub enum RktkKeys {
16            $(
17                $name = $value,
18            )*
19        }
20
21        paste::paste! {
22            $(pub const [<$name:snake:upper>] : KeyAction = KeyAction::Normal(KeyCode::Custom1($value));)*
23        }
24    };
25    }
26
27gen_rktk_keys! {
28    FlashClear = 0,
29    OutputBle = 1,
30    OutputUsb = 2,
31    BleBondClear = 3,
32    Bootloader = 4,
33    PowerOff = 5,
34    RgbOff = 6,
35    RgbBrightnessUp = 7,
36    RgbBrightnessDown = 8,
37    RgbPatternRainbow = 9,
38}
39
40use core::fmt::{self, Display, Formatter};
41impl Display for RktkKeys {
42    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
43        let s: &'static str = self.into();
44        write!(f, "{s}")
45    }
46}