mirror of
https://codeberg.org/Fl1tzi/microdeck.git
synced 2024-05-08 14:40:44 +00:00
fmt
This commit is contained in:
parent
7edb88192c
commit
df8b668a0a
|
@ -1,15 +1,10 @@
|
|||
use crate::{
|
||||
modules::{retrieve_module_from_name, start_module, HostEvent},
|
||||
Button, ConfigError, DeviceConfig,
|
||||
skip_if_none, unwrap_or_error
|
||||
skip_if_none, unwrap_or_error, Button, ConfigError, DeviceConfig,
|
||||
};
|
||||
use deck_driver as streamdeck;
|
||||
use hidapi::HidApi;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::Display,
|
||||
sync::Arc,
|
||||
};
|
||||
use std::{collections::HashMap, fmt::Display, sync::Arc};
|
||||
use streamdeck::{
|
||||
asynchronous::{AsyncStreamDeck, ButtonStateUpdate},
|
||||
info::Kind,
|
||||
|
@ -17,8 +12,8 @@ use streamdeck::{
|
|||
};
|
||||
use tokio::{
|
||||
process::Command,
|
||||
sync::mpsc::{self, error::TrySendError},
|
||||
runtime::Runtime,
|
||||
sync::mpsc::{self, error::TrySendError},
|
||||
};
|
||||
use tracing::{debug, error, info_span, trace};
|
||||
|
||||
|
@ -93,11 +88,13 @@ impl Device {
|
|||
let button = self.config.buttons.get(i).unwrap().to_owned();
|
||||
unwrap_or_error!(self._create_module(button).await);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async fn _create_module(&mut self, btn: Arc<Button>) -> Result<(), DeviceError> {
|
||||
let runtime = self.modules_runtime.as_ref().expect("Runtime has to be created before module can be spawned");
|
||||
let runtime = self
|
||||
.modules_runtime
|
||||
.as_ref()
|
||||
.expect("Runtime has to be created before module can be spawned");
|
||||
let (button_sender, button_receiver) = mpsc::channel(4);
|
||||
if let Some(module) = retrieve_module_from_name(&btn.module) {
|
||||
{
|
||||
|
@ -109,8 +106,7 @@ impl Device {
|
|||
start_module(ser, b, module, dev, Box::new(button_receiver)).await
|
||||
});
|
||||
}
|
||||
self.modules
|
||||
.insert(btn.index, (btn.clone(), button_sender));
|
||||
self.modules.insert(btn.index, (btn.clone(), button_sender));
|
||||
return Ok(());
|
||||
} else {
|
||||
return Err(DeviceError::Config(ConfigError::ModuleDoesNotExist(
|
||||
|
|
|
@ -10,8 +10,8 @@ use std::{
|
|||
io::ErrorKind,
|
||||
path::PathBuf,
|
||||
process::exit,
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
sync::Arc
|
||||
};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing_subscriber::{
|
||||
|
@ -41,7 +41,7 @@ macro_rules! unwrap_or_error {
|
|||
($res:expr) => {
|
||||
match $res {
|
||||
Ok(v) => v,
|
||||
Err(e) => error!("{}", e)
|
||||
Err(e) => error!("{}", e),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -143,7 +143,8 @@ pub async fn start(config: Config, mut hid: HidApi) {
|
|||
config.device.iter().find(|d| d.serial == hw_device.1)
|
||||
{
|
||||
// start the device and its listener
|
||||
if let Some(device) = start_device(hw_device, &hid, device_config.clone()).await
|
||||
if let Some(device) =
|
||||
start_device(hw_device, &hid, device_config.clone()).await
|
||||
{
|
||||
devices.insert(device.serial(), device);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ pub async fn start_module(
|
|||
button: Arc<Button>,
|
||||
module_function: ModuleFunction,
|
||||
device: Arc<AsyncStreamDeck>,
|
||||
br: ChannelReceiver
|
||||
br: ChannelReceiver,
|
||||
) {
|
||||
debug!("STARTED");
|
||||
let da = DeviceAccess::new(device, button.index).await;
|
||||
|
|
Loading…
Reference in a new issue