Adds more macros

This commit is contained in:
Dandaedre 2024-02-29 22:01:48 +01:00
parent 5aaa461f2d
commit 33c6b21e31
3 changed files with 41 additions and 26 deletions

View File

@ -15,8 +15,7 @@
//! ```
use crate::{
kb_macro::{M_A2, M_A3, M_A4},
keysend::{send_keypress, send_macro},
keysend::send_keypress,
layout::{A1, B1, C1},
ChannelType,
};
@ -25,30 +24,29 @@ use portable_atomic::Ordering;
use crate::{keyboard::KeyCode, layout::KeypadKey};
pub(crate) async fn keydispatch_press(pressed_key: &KeypadKey, sender: &ChannelType) {
macro_rules! mk {
($x:ident) => {
$crate::keysend::send_macro($crate::kb_macro::$x, sender).await
};
}
// Big switchcase
// let m1 = ActionsTypes::from(Key { key: KeyCode::A });
// let void = ActionsTypes::from(NoOp {});
match (
A1.load(Ordering::Relaxed),
B1.load(Ordering::Relaxed),
C1.load(Ordering::Relaxed),
&pressed_key,
) {
(_, _, _, &KeypadKey::A1) => Key { key: KeyCode::A }.launch(sender).await,
(_, _, _, &KeypadKey::A2) => Key { key: KeyCode::B }.launch(sender).await,
(_, _, _, &KeypadKey::A3) => Key { key: KeyCode::C }.launch(sender).await,
(_, _, _, &KeypadKey::A4) => Key { key: KeyCode::D }.launch(sender).await,
(_, _, _, &KeypadKey::B1) => Key { key: KeyCode::E }.launch(sender).await,
(_, _, _, &KeypadKey::B2) => Key { key: KeyCode::F }.launch(sender).await,
(_, _, _, &KeypadKey::B3) => Key { key: KeyCode::G }.launch(sender).await,
(_, _, _, &KeypadKey::B4) => Key { key: KeyCode::H }.launch(sender).await,
(_, _, _, &KeypadKey::C1) => Key { key: KeyCode::I }.launch(sender).await,
// (_, _, _, &KeypadKey::C2) => Key { key: KeyCode::J }.launch(sender).await,
// (_, _, _, &KeypadKey::C3) => Key { key: KeyCode::K }.launch(sender).await,
// (_, _, _, &KeypadKey::C4) => Key { key: KeyCode::L }.launch(sender).await,
(_, _, _, &KeypadKey::C2) => send_macro(M_A4, sender).await,
(_, _, _, &KeypadKey::C3) => send_macro(M_A3, sender).await,
(_, _, _, &KeypadKey::C4) => send_macro(M_A2, sender).await,
(true, false, false, &KeypadKey::A2) => mk!(M_BTE),
(true, false, false, &KeypadKey::A3) => mk!(M_BLLY),
(false, false, false, &KeypadKey::A3) => mk!(M_UP),
(false, false, false, &KeypadKey::B3) => mk!(M_DOWN),
(false, false, false, &KeypadKey::B2) => mk!(M_LEFT),
(false, false, false, &KeypadKey::B4) => mk!(M_RIGHT),
(false, false, true, &KeypadKey::A3) => mk!(M_BIGUP),
(false, false, true, &KeypadKey::B3) => mk!(M_BIGDOWN),
(false, false, true, &KeypadKey::B2) => mk!(M_BIGLEFT),
(false, false, true, &KeypadKey::B4) => mk!(M_BIGRIGHT),
(_, _, _, _) => (),
}
// Return
}

View File

@ -17,8 +17,23 @@ macro_rules! KBM {
const M_A1: KBMacro = KBMacro {
keys: &[layout::translate(&layout::Layout::a)],
};
pub(crate) const M_A2: KBMacro =
KBM!(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
pub(crate) const M_A3: KBMacro =
KBM!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z);
pub(crate) const M_A4: KBMacro = KBM!(nb1, nb2, nb3, nb4, nb5, nb6, nb7, nb8, nb9, nb0);
// pub(crate) const M_A2: KBMacro =
// KBM!(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
// pub(crate) const M_A3: KBMacro =
// KBM!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z);
// pub(crate) const M_A4: KBMacro = KBM!(nb1, nb2, nb3, nb4, nb5, nb6, nb7, nb8, nb9, nb0);
pub const M_BTE: KBMacro = KBM!(b, i, t, e);
pub const M_BLLY: KBMacro = KBM!(b, i, l, no, l, y);
// pub const M_ERROR: KBMacro = KBM!(e, r, no, r, o, r);
pub const M_BIGUP: KBMacro = KBM!(nb8, k);
pub const M_BIGDOWN: KBMacro = KBM!(nb8, j);
pub const M_BIGLEFT: KBMacro = KBM!(nb8, h);
pub const M_BIGRIGHT: KBMacro = KBM!(nb8, l);
pub const M_UP: KBMacro = KBM!(k);
pub const M_DOWN: KBMacro = KBM!(j);
pub const M_LEFT: KBMacro = KBM!(h);
pub const M_RIGHT: KBMacro = KBM!(l);
// pub const M_NO: KBMacro = KBM!(no);
// pub const M_BTE: KBMacro = KBM!(b, i, t, e);
// pub const M_BLLY: KBMacro = KBM!(b, i, l, no, l, y);

View File

@ -146,10 +146,11 @@ pub(crate) const fn translate(symbol: &Layout) -> KeyboardReport {
Layout::agrave => todo!(),
Layout::rparenth => todo!(),
Layout::equals => todo!(),
Layout::lessthan => todo!(),
Layout::morethan => todo!(),
Layout::lessthan => KR!(KeyCode::Bslash,0,0,0,0,0; KeyMods::LShift),
Layout::morethan => KR!(KeyCode::Bslash,0,0,0,0,0; 0),
Layout::pow => todo!(),
Layout::star => todo!(),
Layout::no => KR!(0,0,0,0,0,0;0),
}
}
@ -233,4 +234,5 @@ pub(crate) enum Layout {
morethan,
pow,
star,
no,
}