Skip to content

Commit

Permalink
Configurable Purple laser modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Anon-11487 committed Nov 2, 2024
1 parent a78d11d commit ff51b49
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
40 changes: 29 additions & 11 deletions src/overlays/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -330,6 +335,7 @@ fn test_highlight(

struct KeyboardData {
modifiers: KeyModifier,
alt_modifier: KeyModifier,
processes: Vec<Child>,
}

Expand Down Expand Up @@ -368,12 +374,24 @@ static LAYOUT: Lazy<Layout> = Lazy::new(Layout::load_from_disk);
static MACRO_REGEX: Lazy<Regex> =
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<Vec<f32>>,
main_layout: Vec<Vec<Option<String>>>,
alt_modifier: AltModifier,
exec_commands: HashMap<String, Vec<String>>,
macros: HashMap<String, Vec<String>>,
labels: HashMap<String, Vec<String>>,
Expand Down
9 changes: 9 additions & 0 deletions src/res/keyboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ff51b49

Please sign in to comment.