mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-10-28 08:20:49 +08:00
feat: 新增 Linux 绝对鼠标兼容模式 #266;新增 CH9329 描述符设置
This commit is contained in:
@@ -98,6 +98,7 @@ use std::time::Duration;
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::config::{Ch9329DescriptorConfig, Ch9329DescriptorState};
|
||||
use crate::error::{AppError, Result};
|
||||
use crate::events::EventBus;
|
||||
#[cfg(unix)]
|
||||
@@ -287,6 +288,36 @@ impl HidController {
|
||||
self.runtime_state.read().await.clone()
|
||||
}
|
||||
|
||||
async fn ch9329_backend(&self) -> Result<Arc<dyn HidBackend>> {
|
||||
if !matches!(
|
||||
*self.backend_type.read().await,
|
||||
HidBackendType::Ch9329 { .. }
|
||||
) {
|
||||
return Err(AppError::BadRequest(
|
||||
"Current HID backend is not CH9329".to_string(),
|
||||
));
|
||||
}
|
||||
self.backend
|
||||
.read()
|
||||
.await
|
||||
.clone()
|
||||
.ok_or_else(|| AppError::BadRequest("CH9329 backend not available".to_string()))
|
||||
}
|
||||
|
||||
pub async fn apply_ch9329_descriptor(
|
||||
&self,
|
||||
descriptor: &Ch9329DescriptorConfig,
|
||||
) -> Result<Ch9329DescriptorState> {
|
||||
self.ch9329_backend()
|
||||
.await?
|
||||
.apply_ch9329_descriptor(descriptor)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn read_ch9329_descriptor(&self) -> Result<Ch9329DescriptorState> {
|
||||
self.ch9329_backend().await?.read_ch9329_descriptor().await
|
||||
}
|
||||
|
||||
pub async fn reload(&self, new_backend_type: HidBackendType) -> Result<()> {
|
||||
info!("Reloading HID backend: {:?}", new_backend_type);
|
||||
self.backend_available.store(false, Ordering::Release);
|
||||
|
||||
Reference in New Issue
Block a user