Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2024-11-02 19:13:59 +00:00 committed by GitHub
parent a89a1be619
commit e1caa580f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 273 additions and 271 deletions

View file

@ -265,10 +265,15 @@ impl EventReader {
let switcher: Key = self.settings.layout_switcher;
let mut stream = self.stream.lock().await;
let mut pen_events: Vec<InputEvent> = Vec::new();
let is_tablet: bool =
stream.device().properties().contains(evdev::PropType::POINTER)
&& stream.device().supported_keys()
.unwrap_or(&evdev::AttributeSet::new()).contains(evdev::Key::BTN_TOOL_PEN);
let is_tablet: bool = stream
.device()
.properties()
.contains(evdev::PropType::POINTER)
&& stream
.device()
.supported_keys()
.unwrap_or(&evdev::AttributeSet::new())
.contains(evdev::Key::BTN_TOOL_PEN);
let mut max_abs_wheel = 0;
if let Ok(abs_state) = stream.device().get_abs_state() {
for state in abs_state {
@ -293,7 +298,10 @@ impl EventReader {
| Key::BTN_TOOL_AIRBRUSH
| Key::BTN_TOOL_MOUSE
| Key::BTN_TOOL_LENS
if is_tablet => pen_events.push(event),
if is_tablet =>
{
pen_events.push(event)
}
key if key == switcher && event.value() == 1 => {
self.change_active_layout().await
}
@ -348,9 +356,7 @@ impl EventReader {
abs_wheel_position = 0
}
}
(EventType::ABSOLUTE, _, _, true) => {
pen_events.push(event)
}
(EventType::ABSOLUTE, _, _, true) => pen_events.push(event),
(_, _, AbsoluteAxisType::ABS_HAT0X, _) => {
match event.value() {
-1 => {
@ -433,9 +439,8 @@ impl EventReader {
EventType::ABSOLUTE,
_,
AbsoluteAxisType::ABS_X | AbsoluteAxisType::ABS_Y,
false
) => {
match self.settings.lstick.function.as_str() {
false,
) => match self.settings.lstick.function.as_str() {
"cursor" | "scroll" => {
let axis_value = self
.get_axis_value(&event, &self.settings.lstick.deadzone)
@ -559,15 +564,13 @@ impl EventReader {
}
}
_ => {}
}
}
},
(
EventType::ABSOLUTE,
_,
AbsoluteAxisType::ABS_RX | AbsoluteAxisType::ABS_RY,
false
) => {
match self.settings.rstick.function.as_str() {
false,
) => match self.settings.rstick.function.as_str() {
"cursor" | "scroll" => {
let axis_value = self
.get_axis_value(&event, &self.settings.rstick.deadzone)
@ -695,8 +698,7 @@ impl EventReader {
}
}
_ => {}
}
}
},
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_Z, false) => {
match (event.value(), triggers_values.0) {
(0, 1) => {
@ -728,7 +730,11 @@ impl EventReader {
}
}
(EventType::MISC, _, _, true) => {
if !stream.device().properties().contains(evdev::PropType::POINTER) {
if !stream
.device()
.properties()
.contains(evdev::PropType::POINTER)
{
self.emit_default_event(event).await;
} else if evdev::MiscType(event.code()) == evdev::MiscType::MSC_SERIAL {
pen_events.push(event);

View file

@ -1,7 +1,7 @@
use crate::config::{Associations, Event};
use crate::event_reader::EventReader;
use crate::Config;
use crate::virtual_devices::VirtualDevices;
use crate::Config;
use evdev::{Device, EventStream};
use std::{env, path::Path, process::Command, sync::Arc};
use tokio::sync::Mutex;
@ -165,9 +165,7 @@ pub async fn start_reader(reader: EventReader) {
fn set_environment() -> Environment {
match env::var("DBUS_SESSION_BUS_ADDRESS") {
Ok(_) => {
copy_variables()
}
Ok(_) => copy_variables(),
Err(_) => {
let uid = Command::new("sh").arg("-c").arg("id -u").output().unwrap();
let uid_number = std::str::from_utf8(uid.stdout.as_slice()).unwrap().trim();

View file

@ -29,14 +29,12 @@ impl VirtualDevices {
info.maximum,
info.fuzz,
info.flat,
info.resolution
info.resolution,
);
tablet_abs_capabilities.push(
evdev::UinputAbsSetup::new(
tablet_abs_capabilities.push(evdev::UinputAbsSetup::new(
evdev::AbsoluteAxisType(axis_type.try_into().unwrap()),
new_absinfo
)
)
new_absinfo,
))
}
}
}
@ -77,7 +75,7 @@ impl VirtualDevices {
.input_id(device.input_id());
for abs_setup in tablet_abs_capabilities {
abs_builder = abs_builder.with_absolute_axis(&abs_setup).unwrap();
};
}
let virtual_device_keys = keys_builder.build().unwrap();
let virtual_device_axis = axis_builder.build().unwrap();
let virtual_device_abs = abs_builder.build().unwrap();