RKTK API Docs RKTK Home Repo

rktk_keymanager/keycode/
layer.rs

1//! Layer operation keys
2
3#![allow(non_snake_case)]
4
5use macro_rules_attribute::apply;
6
7use super::{KeyAction, KeyCode};
8use crate::macros::common_derive;
9
10/// Keycode for layer operations.
11#[apply(common_derive)]
12#[derive(Copy, strum::EnumIter, strum::IntoStaticStr)]
13pub enum LayerOp {
14    /// Momentary activates the specified layer.
15    Momentary(u8),
16    /// Toggles the state of the specified layer.
17    Toggle(u8),
18}
19
20pub const fn MO(n: u8) -> KeyAction {
21    KeyAction::Normal(KeyCode::Layer(LayerOp::Momentary(n)))
22}
23
24pub const fn TG(n: u8) -> KeyAction {
25    KeyAction::Normal(KeyCode::Layer(LayerOp::Toggle(n)))
26}