From 06402cadee156cea0f4a70ed83a5ee69b47d5bb3 Mon Sep 17 00:00:00 2001 From: cyber-sushi Date: Sun, 19 May 2024 05:54:09 +0200 Subject: [PATCH] Added type Hold to Event enum, and parsing support for mixed bindings --- src/config.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index a7ae7c9..df20ebf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,7 @@ use serde; pub enum Event { Axis(Axis), Key(Key), + Hold, } #[allow(non_camel_case_types)] @@ -157,7 +158,7 @@ fn parse_raw_config(raw_config: RawConfig) -> (Bindings, HashMap if let Some((mods, event)) = input.rsplit_once("-") { let str_modifiers = mods.split("-").collect::>(); let mut modifiers: Vec = Vec::new(); - for event in str_modifiers { + for event in str_modifiers.clone() { if let Ok(axis) = Axis::from_str(event) { modifiers.push(Event::Axis(axis)); } else if let Ok(key) = Key::from_str(event) { @@ -171,6 +172,10 @@ fn parse_raw_config(raw_config: RawConfig) -> (Bindings, HashMap mapped_modifiers.custom.push(modifier.clone()); } } + if str_modifiers[0] == "" { + modifiers.push(Event::Hold); + modifiers.sort(); + } if let Ok(event) = Axis::from_str(event) { if !bindings.remap.contains_key(&Event::Axis(event)) { bindings.remap.insert(Event::Axis(event), HashMap::from([(modifiers, output)])); @@ -281,3 +286,4 @@ pub fn parse_modifiers(settings: &HashMap, parameter: &str) -> V None => Vec::new(), } } +