Configurable Purple laser modifier
This commit is contained in:
@@ -75,6 +75,14 @@ where
|
|||||||
|
|
||||||
let data = KeyboardData {
|
let data = KeyboardData {
|
||||||
modifiers: 0,
|
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![],
|
processes: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -225,17 +233,14 @@ fn key_press(
|
|||||||
Some(KeyButtonData::Key { vk, pressed }) => {
|
Some(KeyButtonData::Key { vk, pressed }) => {
|
||||||
data.key_click(app);
|
data.key_click(app);
|
||||||
|
|
||||||
match mode {
|
data.modifiers |= match mode {
|
||||||
PointerMode::Right => {
|
PointerMode::Right => SHIFT,
|
||||||
data.modifiers |= SHIFT;
|
PointerMode::Middle => data.alt_modifier,
|
||||||
|
_ => 0,
|
||||||
|
};
|
||||||
|
|
||||||
app.hid_provider.set_modifiers(data.modifiers);
|
app.hid_provider.set_modifiers(data.modifiers);
|
||||||
},
|
|
||||||
PointerMode::Middle => {
|
|
||||||
data.modifiers |= CTRL;
|
|
||||||
app.hid_provider.set_modifiers(data.modifiers);
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
send_key(app, *vk, true);
|
send_key(app, *vk, true);
|
||||||
*pressed = true;
|
*pressed = true;
|
||||||
@@ -330,6 +335,7 @@ fn test_highlight(
|
|||||||
|
|
||||||
struct KeyboardData {
|
struct KeyboardData {
|
||||||
modifiers: KeyModifier,
|
modifiers: KeyModifier,
|
||||||
|
alt_modifier: KeyModifier,
|
||||||
processes: Vec<Child>,
|
processes: Vec<Child>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,12 +374,24 @@ static LAYOUT: Lazy<Layout> = Lazy::new(Layout::load_from_disk);
|
|||||||
static MACRO_REGEX: Lazy<Regex> =
|
static MACRO_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^([A-Za-z0-9_-]+)(?: +(UP|DOWN))?$").unwrap()); // want panic
|
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)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
name: String,
|
name: String,
|
||||||
row_size: f32,
|
row_size: f32,
|
||||||
key_sizes: Vec<Vec<f32>>,
|
key_sizes: Vec<Vec<f32>>,
|
||||||
main_layout: Vec<Vec<Option<String>>>,
|
main_layout: Vec<Vec<Option<String>>>,
|
||||||
|
alt_modifier: AltModifier,
|
||||||
exec_commands: HashMap<String, Vec<String>>,
|
exec_commands: HashMap<String, Vec<String>>,
|
||||||
macros: HashMap<String, Vec<String>>,
|
macros: HashMap<String, Vec<String>>,
|
||||||
labels: HashMap<String, Vec<String>>,
|
labels: HashMap<String, Vec<String>>,
|
||||||
|
|||||||
@@ -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"]
|
- ["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", ~]
|
- ["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.
|
# Shell commands to be used in a layout.
|
||||||
# Value is an array of string arguments.
|
# Value is an array of string arguments.
|
||||||
exec_commands:
|
exec_commands:
|
||||||
|
|||||||
Reference in New Issue
Block a user