mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-11 19:11:29 +03:00
add option to config
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# example configuration
|
# example configuration
|
||||||
|
|
||||||
|
# capture_backend = "LayerShell"
|
||||||
|
|
||||||
# release bind
|
# release bind
|
||||||
release_bind = [ "KeyA", "KeyS", "KeyD", "KeyF" ]
|
release_bind = [ "KeyA", "KeyS", "KeyD", "KeyF" ]
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ pub async fn create(
|
|||||||
if let Some(backend) = backend {
|
if let Some(backend) = backend {
|
||||||
return match backend {
|
return match backend {
|
||||||
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
|
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
|
||||||
CaptureBackend::InputCapturePortal => Ok(Box::new(libei::LibeiInputCapture::new().await?)),
|
CaptureBackend::InputCapturePortal => {
|
||||||
|
Ok(Box::new(libei::LibeiInputCapture::new().await?))
|
||||||
|
}
|
||||||
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
||||||
CaptureBackend::LayerShell => Ok(Box::new(wayland::WaylandInputCapture::new()?)),
|
CaptureBackend::LayerShell => Ok(Box::new(wayland::WaylandInputCapture::new()?)),
|
||||||
#[cfg(all(unix, feature = "x11", not(target_os = "macos")))]
|
#[cfg(all(unix, feature = "x11", not(target_os = "macos")))]
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
use thiserror::Error;
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
||||||
|
use std::io;
|
||||||
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
backend::WaylandError,
|
backend::WaylandError,
|
||||||
globals::{BindError, GlobalError},
|
globals::{BindError, GlobalError},
|
||||||
ConnectError, DispatchError,
|
ConnectError, DispatchError,
|
||||||
};
|
};
|
||||||
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum CaptureCreationError {
|
pub enum CaptureCreationError {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::capture::error::MacOSInputCaptureCreationError;
|
||||||
use crate::capture::InputCapture;
|
use crate::capture::InputCapture;
|
||||||
use crate::client::{ClientEvent, ClientHandle};
|
use crate::client::{ClientEvent, ClientHandle};
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
@@ -5,7 +6,6 @@ use anyhow::Result;
|
|||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use std::{io, pin::Pin};
|
use std::{io, pin::Pin};
|
||||||
use crate::capture::error::MacOSInputCaptureCreationError;
|
|
||||||
|
|
||||||
pub struct MacOSInputCapture;
|
pub struct MacOSInputCapture;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ pub const DEFAULT_PORT: u16 = 4242;
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct ConfigToml {
|
pub struct ConfigToml {
|
||||||
|
pub capture_backend: Option<CaptureBackend>,
|
||||||
pub port: Option<u16>,
|
pub port: Option<u16>,
|
||||||
pub frontend: Option<String>,
|
pub frontend: Option<String>,
|
||||||
pub release_bind: Option<Vec<scancode::Linux>>,
|
pub release_bind: Option<Vec<scancode::Linux>>,
|
||||||
@@ -26,6 +27,7 @@ pub struct ConfigToml {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||||
pub struct TomlClient {
|
pub struct TomlClient {
|
||||||
|
pub capture_backend: Option<CaptureBackend>,
|
||||||
pub hostname: Option<String>,
|
pub hostname: Option<String>,
|
||||||
pub host_name: Option<String>,
|
pub host_name: Option<String>,
|
||||||
pub ips: Option<Vec<IpAddr>>,
|
pub ips: Option<Vec<IpAddr>>,
|
||||||
@@ -78,7 +80,7 @@ struct CliArgs {
|
|||||||
emulation_backend: Option<EmulationBackend>,
|
emulation_backend: Option<EmulationBackend>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, ValueEnum)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
|
||||||
pub enum CaptureBackend {
|
pub enum CaptureBackend {
|
||||||
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
|
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
|
||||||
InputCapturePortal,
|
InputCapturePortal,
|
||||||
@@ -190,6 +192,11 @@ impl Config {
|
|||||||
.and_then(|c| c.release_bind.clone())
|
.and_then(|c| c.release_bind.clone())
|
||||||
.unwrap_or(Vec::from_iter(DEFAULT_RELEASE_KEYS.iter().cloned()));
|
.unwrap_or(Vec::from_iter(DEFAULT_RELEASE_KEYS.iter().cloned()));
|
||||||
|
|
||||||
|
let capture_backend = match args.capture_backend {
|
||||||
|
Some(b) => Some(b),
|
||||||
|
None => config_toml.as_ref().and_then(|c| c.capture_backend),
|
||||||
|
};
|
||||||
|
|
||||||
let mut clients: Vec<(TomlClient, Position)> = vec![];
|
let mut clients: Vec<(TomlClient, Position)> = vec![];
|
||||||
|
|
||||||
if let Some(config_toml) = config_toml {
|
if let Some(config_toml) = config_toml {
|
||||||
@@ -210,7 +217,6 @@ impl Config {
|
|||||||
let daemon = args.daemon;
|
let daemon = args.daemon;
|
||||||
let test_capture = args.test_capture;
|
let test_capture = args.test_capture;
|
||||||
let test_emulation = args.test_emulation;
|
let test_emulation = args.test_emulation;
|
||||||
let capture_backend = args.capture_backend;
|
|
||||||
|
|
||||||
Ok(Config {
|
Ok(Config {
|
||||||
capture_backend,
|
capture_backend,
|
||||||
|
|||||||
Reference in New Issue
Block a user