mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-10-28 16:30:48 +08:00
feat: 初步增加 Windows 支持
This commit is contained in:
53
src/web/handlers/hid_api.rs
Normal file
53
src/web/handlers/hid_api.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct HidStatus {
|
||||
pub available: bool,
|
||||
pub backend: String,
|
||||
pub initialized: bool,
|
||||
pub online: bool,
|
||||
pub supports_absolute_mouse: bool,
|
||||
pub keyboard_leds_enabled: bool,
|
||||
pub led_state: crate::hid::LedState,
|
||||
pub screen_resolution: Option<(u32, u32)>,
|
||||
pub device: Option<String>,
|
||||
pub error: Option<String>,
|
||||
pub error_code: Option<String>,
|
||||
}
|
||||
|
||||
/// OTG self-check status for troubleshooting USB gadget issues
|
||||
#[cfg(unix)]
|
||||
pub async fn hid_otg_self_check(
|
||||
State(state): State<Arc<AppState>>,
|
||||
) -> Json<crate::otg::self_check::OtgSelfCheckResponse> {
|
||||
let config = state.config.get();
|
||||
Json(crate::otg::self_check::run(config.as_ref()))
|
||||
}
|
||||
|
||||
/// Get HID status
|
||||
pub async fn hid_status(State(state): State<Arc<AppState>>) -> Json<HidStatus> {
|
||||
let hid = state.hid.snapshot().await;
|
||||
Json(HidStatus {
|
||||
available: hid.available,
|
||||
backend: hid.backend,
|
||||
initialized: hid.initialized,
|
||||
online: hid.online,
|
||||
supports_absolute_mouse: hid.supports_absolute_mouse,
|
||||
keyboard_leds_enabled: hid.keyboard_leds_enabled,
|
||||
led_state: hid.led_state,
|
||||
screen_resolution: hid.screen_resolution,
|
||||
device: hid.device,
|
||||
error: hid.error,
|
||||
error_code: hid.error_code,
|
||||
})
|
||||
}
|
||||
|
||||
/// Reset HID state
|
||||
pub async fn hid_reset(State(state): State<Arc<AppState>>) -> Result<Json<LoginResponse>> {
|
||||
state.hid.reset().await?;
|
||||
|
||||
Ok(Json(LoginResponse {
|
||||
success: true,
|
||||
message: Some("HID state reset".to_string()),
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user