Commands count as key activations

This commit is contained in:
cyber-sushi 2024-04-19 09:40:00 +02:00
parent 4d5c00200a
commit 0dcc72882d

View file

@ -262,14 +262,14 @@ impl EventReader {
}
} else if let Some(command_hashmap) = path.combinations.keys_sh.get(&Key(event.code())) {
if let Some(command_list) = command_hashmap.get(&modifiers) {
spawn_subprocess(command_list).await;
self.spawn_subprocess(command_list).await;
return
}
}
if let Some(event_list) = path.bindings.keys.get(&Key(event.code())) {
self.emit_event(event_list, event.value()).await;
} else if let Some(command_list) = path.bindings.keys_sh.get(&Key(event.code())) {
spawn_subprocess(command_list).await;
self.spawn_subprocess(command_list).await;
} else {
self.emit_default_event(event).await;
}
@ -288,7 +288,7 @@ impl EventReader {
}
} else if let Some(command_hashmap) = path.combinations.axis_sh.get(event_string) {
if let Some(command_list) = command_hashmap.get(&modifiers) {
spawn_subprocess(command_list).await;
self.spawn_subprocess(command_list).await;
return
}
}
@ -298,7 +298,7 @@ impl EventReader {
self.emit_event_without_modifiers(event_list, &modifiers, 0).await;
}
} else if let Some(command_list) = path.bindings.axis_sh.get(event_string) {
spawn_subprocess(command_list).await;
self.spawn_subprocess(command_list).await;
} else {
self.emit_default_event(event).await;
}
@ -399,6 +399,18 @@ impl EventReader {
}
}
async fn spawn_subprocess(&self, command_list: &Vec<String>) {
let mut modifier_was_activated = self.modifier_was_activated.lock().await;
*modifier_was_activated = true;
for command in command_list {
Command::new("sh")
.arg("-c")
.arg(command)
.spawn()
.expect("Failed to run command.");
}
}
async fn get_axis_value(&self, event: &InputEvent, deadzone: &i32) -> i32 {
let distance_from_center: i32 = match self.settings.axis_16_bit {
false => (event.value() as i32 - 128) * 200,
@ -510,15 +522,3 @@ impl EventReader {
}
}
async fn spawn_subprocess(command_list: &Vec<String>) {
for command in command_list {
Command::new("sh")
.arg("-c")
.arg(command)
.spawn()
.expect("Failed to run command.");
}
}