mirror of
https://github.com/joleuger/vuinputd.git
synced 2026-07-17 16:36:03 +00:00
Refactor: move stuff that actually does something into input_realizer. Action is now the entry point for cli-actions. Maybe I should rename it in the future, too.
This commit is contained in:
parent
6bde733b09
commit
350a80644a
12 changed files with 28 additions and 15 deletions
|
|
@ -23,6 +23,7 @@ Error messages may change over time; error codes do not.
|
|||
| Code | Area | Summary |
|
||||
|------|------|--------|
|
||||
| VUI-UDEV-001 | udev | udev control socket not reachable |
|
||||
| VUI-UDEV-002 | udev | could not write into /run/vuinputd/... |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -60,3 +61,5 @@ When reporting an issue, please include:
|
|||
* Full command-line invocation
|
||||
* Execution environment (host, container, systemd)
|
||||
* Relevant debug logs (see [DEBUG.md](DEBUG.md))
|
||||
|
||||
### VUI-UDEV-002 - could not write into /run/vuinputd/...
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
// Author: Johannes Leupolz <dev@leupolz.eu>
|
||||
|
||||
use super::action::Action;
|
||||
use super::input_device;
|
||||
use super::netlink_message;
|
||||
use super::runtime_data;
|
||||
use crate::input_realizer::input_device;
|
||||
use crate::input_realizer::netlink_message;
|
||||
use crate::input_realizer::runtime_data;
|
||||
|
||||
pub fn handle_cli_action(json: String) -> i32 {
|
||||
let action: Action = serde_json::from_str(&json).expect("invalid action JSON");
|
||||
|
|
|
|||
|
|
@ -4,6 +4,3 @@
|
|||
|
||||
pub mod action;
|
||||
pub mod handle_action;
|
||||
pub mod input_device;
|
||||
pub mod netlink_message;
|
||||
pub mod runtime_data;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub enum DevicePolicy {
|
|||
StrictGamepad,
|
||||
}
|
||||
/// Where to create runtime artifacts (device nodes + udev data)
|
||||
#[derive(Debug, Clone, ValueEnum, Default)]
|
||||
#[derive(Debug, Clone, ValueEnum, Default, PartialEq, Eq)]
|
||||
pub enum Placement {
|
||||
#[default]
|
||||
/// Create inside the container
|
||||
|
|
|
|||
7
vuinputd/src/input_realizer/mod.rs
Normal file
7
vuinputd/src/input_realizer/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// Author: Johannes Leupolz <dev@leupolz.eu>
|
||||
|
||||
pub mod input_device;
|
||||
pub mod netlink_message;
|
||||
pub mod runtime_data;
|
||||
|
|
@ -14,12 +14,9 @@ use async_io::Timer;
|
|||
use log::debug;
|
||||
|
||||
use crate::{
|
||||
actions::{
|
||||
self,
|
||||
action::Action,
|
||||
runtime_data::{self, read_udev_data},
|
||||
},
|
||||
actions::{self, action::Action},
|
||||
global_config::{self, get_placement, Placement},
|
||||
input_realizer::runtime_data,
|
||||
job_engine::job::{Job, JobTarget},
|
||||
jobs::monitor_udev_job::EVENT_STORE,
|
||||
process_tools::{self, await_process, Pid, RequestingProcess},
|
||||
|
|
@ -128,7 +125,7 @@ impl EmitUdevEventJob {
|
|||
};
|
||||
}
|
||||
if runtime_data.is_none() {
|
||||
runtime_data = read_udev_data(self.major, self.minor).ok();
|
||||
runtime_data = runtime_data::read_udev_data(self.major, self.minor).ok();
|
||||
}
|
||||
|
||||
number_of_attempt += 1;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
actions::{action::Action, input_device},
|
||||
actions::action::Action,
|
||||
global_config::{self, Placement},
|
||||
input_realizer::input_device,
|
||||
job_engine::job::{Job, JobTarget},
|
||||
process_tools::{self, await_process, Pid, RequestingProcess},
|
||||
};
|
||||
|
||||
use crate::actions::runtime_data::write_udev_data;
|
||||
use crate::input_realizer::runtime_data::write_udev_data;
|
||||
|
||||
#[derive(Clone, Debug, Copy, PartialOrd, PartialEq)]
|
||||
pub enum State {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use log::debug;
|
|||
use crate::{
|
||||
actions::action::Action,
|
||||
global_config::{self, Placement},
|
||||
input_realizer::{input_device, runtime_data},
|
||||
job_engine::job::{Job, JobTarget},
|
||||
jobs::monitor_udev_job::EVENT_STORE,
|
||||
process_tools::{self, await_process, Pid, RequestingProcess},
|
||||
|
|
@ -154,6 +155,8 @@ impl RemoveDeviceJob {
|
|||
}
|
||||
Placement::OnHost => {
|
||||
todo!();
|
||||
//input_device::remove_input_device(path, major.into(), minor.into())?;
|
||||
//runtime_data::delete_udev_data("/run",major.into(), minor.into())?;
|
||||
}
|
||||
Placement::None => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ use crate::job_engine::{job::*, JOB_DISPATCHER};
|
|||
use crate::process_tools::*;
|
||||
|
||||
pub mod actions;
|
||||
pub mod input_realizer;
|
||||
|
||||
pub mod global_config;
|
||||
pub mod jobs;
|
||||
|
|
@ -218,6 +219,10 @@ fn main() -> std::io::Result<()> {
|
|||
None => "vuinput",
|
||||
Some(devname) => devname,
|
||||
};
|
||||
if args.placement==Placement::OnHost {
|
||||
todo!("ensure structure and writablity of dev-input")
|
||||
}
|
||||
|
||||
let vuinput_devicename = CString::new(format!("DEVNAME={}", vuinput_devicename)).unwrap();
|
||||
|
||||
let mut dev_info_argv: Vec<*const c_char> = vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue