From 24096b7b5acde0f507b39c590188298a71f182e6 Mon Sep 17 00:00:00 2001 From: Anon_11487 <154088073+Anon-11487@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:36:22 -0500 Subject: [PATCH] Configurable Purple laser modifier --- src/overlays/keyboard.rs | 40 +++++++++++++++++++++++++++++----------- src/res/keyboard.yaml | 9 +++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/overlays/keyboard.rs b/src/overlays/keyboard.rs index c862af6..e1eb769 100644 --- a/src/overlays/keyboard.rs +++ b/src/overlays/keyboard.rs @@ -75,6 +75,14 @@ where let data = KeyboardData { modifiers: 0, + alt_modifier: match LAYOUT.alt_modifier { + AltModifier::Shift => SHIFT, + AltModifier::Ctrl => CTRL, + AltModifier::Alt => ALT, + AltModifier::Super => SUPER, + AltModifier::Meta => META, + _ => 0, + }, processes: vec![], }; @@ -225,17 +233,14 @@ fn key_press( Some(KeyButtonData::Key { vk, pressed }) => { data.key_click(app); - match mode { - PointerMode::Right => { - data.modifiers |= SHIFT; - app.hid_provider.set_modifiers(data.modifiers); - }, - PointerMode::Middle => { - data.modifiers |= CTRL; - app.hid_provider.set_modifiers(data.modifiers); - }, - _ => {}, - } + data.modifiers |= match mode { + PointerMode::Right => SHIFT, + PointerMode::Middle => data.alt_modifier, + _ => 0, + }; + + app.hid_provider.set_modifiers(data.modifiers); + send_key(app, *vk, true); *pressed = true; @@ -330,6 +335,7 @@ fn test_highlight( struct KeyboardData { modifiers: KeyModifier, + alt_modifier: KeyModifier, processes: Vec, } @@ -368,12 +374,24 @@ static LAYOUT: Lazy = Lazy::new(Layout::load_from_disk); static MACRO_REGEX: Lazy = Lazy::new(|| Regex::new(r"^([A-Za-z0-9_-]+)(?: +(UP|DOWN))?$").unwrap()); // want panic +#[derive(Debug, Clone, Copy, Deserialize, Serialize)] +#[repr(usize)] +pub enum AltModifier { + None, + Shift, + Ctrl, + Alt, + Super, + Meta, +} + #[derive(Debug, Deserialize, Serialize)] pub struct Layout { name: String, row_size: f32, key_sizes: Vec>, main_layout: Vec>>, + alt_modifier: AltModifier, exec_commands: HashMap>, macros: HashMap>, labels: HashMap>, diff --git a/src/res/keyboard.yaml b/src/res/keyboard.yaml index 80e27e3..b75c4e6 100644 --- a/src/res/keyboard.yaml +++ b/src/res/keyboard.yaml @@ -43,6 +43,15 @@ main_layout: - ["LShift", "Oem102", "Z", "X", "C", "V", "B", "N", "M", "Comma", "Period", "Oem2", "RShift", ~, "Up", ~, "KP_1", "KP_2", "KP_3", "KP_Enter"] - ["LCtrl", "LSuper", "LAlt", "Space", "Meta", "RSuper", "Menu", "RCtrl", ~, "Left", "Down", "Right", ~, "KP_0", "KP_Decimal", ~] +# When using the purple pointer... +# None - No special functionality when using purple pointer (Default) +# Shift - Use same functionality as the orange pointer +# Ctrl - Use Main layout with Ctrl modifier +# Alt - Use Main layout with Alt modifier +# Super - Use Main layout with Super (WinKey) modifier +# Meta - Use Main layout with Meta (AltGr) modifier +alt_modifier: None + # Shell commands to be used in a layout. # Value is an array of string arguments. exec_commands: