#[component] pub fn App() -> impl IntoView { let devices = RwSignal::new(Vec::::new()); let selected_path = RwSignal::new(String::new()); let selected_profile = RwSignal::new("direct".to_string()); let device_state = RwSignal::new(None::); let active_tab = RwSignal::new("basic".to_string()); let status = RwSignal::new("Scanning for a supported Basilisk mouse.".to_string()); let busy = RwSignal::new(false); let connect_path = move |path: String| { if path.is_empty() { status.set("Select a device path before connecting.".to_string()); return; } busy.set(true); status.set(format!("Connecting to {path}...")); spawn_local(async move { let args = ConnectArgs { path }; match invoke::("connect_device", &args).await { Ok(snapshot) => { selected_profile.set(snapshot.basic.profile.clone()); status.set(format!("Connected to {}.", snapshot.device.supported_name)); device_state.set(Some(snapshot)); } Err(error) => status.set(error), } busy.set(false); }); }; let scan = move || { busy.set(true); status.set("Scanning /sys/class/hidraw for Basilisk V3 devices...".to_string()); spawn_local(async move { match invoke_no_args::>("list_supported_devices").await { Ok(found) => { if let Some(first) = found.first() { let path = first.path.clone(); selected_path.set(path.clone()); devices.set(found); status.set(format!("Found supported device. Connecting to {path}...")); match invoke::("connect_device", &ConnectArgs { path }).await { Ok(snapshot) => { selected_profile.set(snapshot.basic.profile.clone()); status.set(format!("Connected to {}.", snapshot.device.supported_name)); device_state.set(Some(snapshot)); } Err(error) => status.set(error), } } else { selected_path.set(String::new()); devices.set(found); status.set("No supported Razer hidraw devices found.".to_string()); } } Err(error) => status.set(error), } busy.set(false); }); }; Effect::new(move |_| scan()); let connect = move |_| { let path = selected_path.get_untracked(); connect_path(path); }; let refresh_profile = move |profile: String| { selected_profile.set(profile.clone()); busy.set(true); status.set(format!("Loading {profile} profile...")); spawn_local(async move { let args = ProfileArgs { profile }; match invoke::("refresh_device_state", &args).await { Ok(snapshot) => { status.set("Profile settings loaded.".to_string()); device_state.set(Some(snapshot)); } Err(error) => status.set(error), } busy.set(false); }); }; view! {

"Linux desktop configuration"

{move || device_state.get().map(|state| state.device.supported_name).unwrap_or_else(|| "No device connected".to_string())}

{move || status.get()}
{move || match device_state.get() { Some(snapshot) => view! { }.into_any(), None => view! {

"Connect to a Basilisk V3 or V3 Pro"

"This app uses Linux hidraw feature reports through the Tauri backend instead of WebHID and Pyodide."

"If your mouse is connected but does not appear, check that the current user can read and write the matching /dev/hidraw node."

}.into_any() }}
} } #[component] fn ConnectedView( snapshot: DeviceState, active_tab: RwSignal, selected_profile: RwSignal, refresh_profile: impl Fn(String) + Copy + 'static, set_snapshot: WriteSignal>, set_status: WriteSignal, set_busy: WriteSignal, ) -> impl IntoView { view! {
"Profile"
{snapshot.profiles.iter().map(|profile| { let profile_name = profile.clone(); let profile_for_click = profile.clone(); view! { } }).collect_view()}
{move || match active_tab.get().as_str() { "basic" => view! { }.into_any(), "info" => view! { }.into_any(), "profile" => view! { }.into_any(), "led" => view! { }.into_any(), "button" => view! { }.into_any(), "macro" => view! { }.into_any(), "sensor" => view! { }.into_any(), _ => view! { }.into_any(), }} } }