style(detect): fix formatting
This commit is contained in:
parent
be68a1f8ff
commit
d11af8b1c2
|
@ -199,26 +199,70 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_modifier_state(&mut self, modifiers_state: &ModifiersState, modifiers_map: &HashMap<String, u32>) {
|
pub fn update_modifier_state(
|
||||||
|
&mut self,
|
||||||
|
modifiers_state: &ModifiersState,
|
||||||
|
modifiers_map: &HashMap<String, u32>,
|
||||||
|
) {
|
||||||
if modifiers_state.alt {
|
if modifiers_state.alt {
|
||||||
self.update_key(*modifiers_map.get("alt").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("alt")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if modifiers_state.ctrl {
|
if modifiers_state.ctrl {
|
||||||
self.update_key(*modifiers_map.get("ctrl").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("ctrl")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if modifiers_state.meta {
|
if modifiers_state.meta {
|
||||||
self.update_key(*modifiers_map.get("meta").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("meta")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if modifiers_state.num_lock {
|
if modifiers_state.num_lock {
|
||||||
self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), false);
|
*modifiers_map
|
||||||
|
.get("num_lock")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("num_lock")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if modifiers_state.shift {
|
if modifiers_state.shift {
|
||||||
self.update_key(*modifiers_map.get("shift").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("shift")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if modifiers_state.caps_lock {
|
if modifiers_state.caps_lock {
|
||||||
self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), true);
|
self.update_key(
|
||||||
self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), false);
|
*modifiers_map
|
||||||
|
.get("caps_lock")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
self.update_key(
|
||||||
|
*modifiers_map
|
||||||
|
.get("caps_lock")
|
||||||
|
.expect("unable to find modifiers key in map"),
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,10 +191,7 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
|
||||||
display.flush().unwrap();
|
display.flush().unwrap();
|
||||||
|
|
||||||
event_loop
|
event_loop
|
||||||
.dispatch(
|
.dispatch(Some(std::time::Duration::from_millis(10)), &mut next_action)
|
||||||
Some(std::time::Duration::from_millis(10)),
|
|
||||||
&mut next_action,
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,13 @@ use std::process::Command;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
pub fn get_active_layout() -> Option<String> {
|
pub fn get_active_layout() -> Option<String> {
|
||||||
match Command::new("setxkbmap")
|
match Command::new("setxkbmap").arg("-query").output() {
|
||||||
.arg("-query")
|
|
||||||
.output()
|
|
||||||
{
|
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
let layout_line = output_str.lines().find(|line| line.contains("layout:"))?;
|
let layout_line = output_str.lines().find(|line| line.contains("layout:"))?;
|
||||||
let layout_raw: Vec<&str> = layout_line.split("layout:").collect();
|
let layout_raw: Vec<&str> = layout_line.split("layout:").collect();
|
||||||
Some(layout_raw.get(1)?.trim().to_string())
|
Some(layout_raw.get(1)?.trim().to_string())
|
||||||
},
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
"unable to retrieve current keyboard layout with 'setxkbmap': {}",
|
"unable to retrieve current keyboard layout with 'setxkbmap': {}",
|
||||||
|
|
|
@ -94,7 +94,10 @@ impl Default for SourceCreationOptions {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn get_source(options: SourceCreationOptions) -> Result<Box<dyn Source>> {
|
pub fn get_source(options: SourceCreationOptions) -> Result<Box<dyn Source>> {
|
||||||
info!("using Win32Source");
|
info!("using Win32Source");
|
||||||
Ok(Box::new(win32::Win32Source::new(&options.hotkeys, options.win32_exclude_orphan_events)))
|
Ok(Box::new(win32::Win32Source::new(
|
||||||
|
&options.hotkeys,
|
||||||
|
options.win32_exclude_orphan_events,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user