mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-11 16:01:28 +03:00
defer creation of input capture / emulation (#117)
This commit is contained in:
committed by
GitHub
parent
636c5924bf
commit
77aa96e09a
@@ -5,7 +5,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
|
|
||||||
use crate::{capture, emulate};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::{ClientHandle, ClientManager},
|
client::{ClientHandle, ClientManager},
|
||||||
config::Config,
|
config::Config,
|
||||||
@@ -78,7 +77,6 @@ impl Server {
|
|||||||
return anyhow::Ok(());
|
return anyhow::Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (emulate, capture) = tokio::join!(emulate::create(), capture::create());
|
|
||||||
|
|
||||||
let (timer_tx, timer_rx) = tokio::sync::mpsc::channel(1);
|
let (timer_tx, timer_rx) = tokio::sync::mpsc::channel(1);
|
||||||
let (frontend_notify_tx, frontend_notify_rx) = tokio::sync::mpsc::channel(1);
|
let (frontend_notify_tx, frontend_notify_rx) = tokio::sync::mpsc::channel(1);
|
||||||
@@ -89,7 +87,6 @@ impl Server {
|
|||||||
|
|
||||||
// input capture
|
// input capture
|
||||||
let (mut capture_task, capture_channel) = capture_task::new(
|
let (mut capture_task, capture_channel) = capture_task::new(
|
||||||
capture,
|
|
||||||
self.clone(),
|
self.clone(),
|
||||||
sender_tx.clone(),
|
sender_tx.clone(),
|
||||||
timer_tx.clone(),
|
timer_tx.clone(),
|
||||||
@@ -98,7 +95,6 @@ impl Server {
|
|||||||
|
|
||||||
// input emulation
|
// input emulation
|
||||||
let (mut emulation_task, emulate_channel) = emulation_task::new(
|
let (mut emulation_task, emulate_channel) = emulation_task::new(
|
||||||
emulate,
|
|
||||||
self.clone(),
|
self.clone(),
|
||||||
receiver_rx,
|
receiver_rx,
|
||||||
sender_tx.clone(),
|
sender_tx.clone(),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::{collections::HashSet, net::SocketAddr};
|
|||||||
use tokio::{sync::mpsc::Sender, task::JoinHandle};
|
use tokio::{sync::mpsc::Sender, task::JoinHandle};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
capture::InputCapture,
|
capture::{self, InputCapture},
|
||||||
client::{ClientEvent, ClientHandle},
|
client::{ClientEvent, ClientHandle},
|
||||||
event::{Event, KeyboardEvent},
|
event::{Event, KeyboardEvent},
|
||||||
scancode,
|
scancode,
|
||||||
@@ -25,7 +25,6 @@ pub enum CaptureEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
mut capture: Box<dyn InputCapture>,
|
|
||||||
server: Server,
|
server: Server,
|
||||||
sender_tx: Sender<(Event, SocketAddr)>,
|
sender_tx: Sender<(Event, SocketAddr)>,
|
||||||
timer_tx: Sender<()>,
|
timer_tx: Sender<()>,
|
||||||
@@ -33,6 +32,7 @@ pub fn new(
|
|||||||
) -> (JoinHandle<Result<()>>, Sender<CaptureEvent>) {
|
) -> (JoinHandle<Result<()>>, Sender<CaptureEvent>) {
|
||||||
let (tx, mut rx) = tokio::sync::mpsc::channel(32);
|
let (tx, mut rx) = tokio::sync::mpsc::channel(32);
|
||||||
let task = tokio::task::spawn_local(async move {
|
let task = tokio::task::spawn_local(async move {
|
||||||
|
let mut capture = capture::create().await;
|
||||||
let mut pressed_keys = HashSet::new();
|
let mut pressed_keys = HashSet::new();
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use tokio::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::{ClientEvent, ClientHandle},
|
client::{ClientEvent, ClientHandle},
|
||||||
emulate::InputEmulation,
|
emulate::{self, InputEmulation},
|
||||||
event::{Event, KeyboardEvent},
|
event::{Event, KeyboardEvent},
|
||||||
scancode,
|
scancode,
|
||||||
server::State,
|
server::State,
|
||||||
@@ -27,7 +27,6 @@ pub enum EmulationEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
mut emulate: Box<dyn InputEmulation>,
|
|
||||||
server: Server,
|
server: Server,
|
||||||
mut udp_rx: Receiver<Result<(Event, SocketAddr)>>,
|
mut udp_rx: Receiver<Result<(Event, SocketAddr)>>,
|
||||||
sender_tx: Sender<(Event, SocketAddr)>,
|
sender_tx: Sender<(Event, SocketAddr)>,
|
||||||
@@ -36,6 +35,7 @@ pub fn new(
|
|||||||
) -> (JoinHandle<Result<()>>, Sender<EmulationEvent>) {
|
) -> (JoinHandle<Result<()>>, Sender<EmulationEvent>) {
|
||||||
let (tx, mut rx) = tokio::sync::mpsc::channel(32);
|
let (tx, mut rx) = tokio::sync::mpsc::channel(32);
|
||||||
let emulate_task = tokio::task::spawn_local(async move {
|
let emulate_task = tokio::task::spawn_local(async move {
|
||||||
|
let mut emulate = emulate::create().await;
|
||||||
let mut last_ignored = None;
|
let mut last_ignored = None;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
Reference in New Issue
Block a user