dash-frontend: Detect and switch to WiVRn speakers
[skip ci]
This commit is contained in:
169
dash-frontend/assets/dashboard/wivrn_head_symbolic.svg
Normal file
169
dash-frontend/assets/dashboard/wivrn_head_symbolic.svg
Normal file
@@ -0,0 +1,169 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="180"
|
||||
height="180"
|
||||
viewBox="0 0 180 180"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="wivrn_head_symbolic.svg"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#000000"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="true"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="3.3305556"
|
||||
inkscape:cx="62.602168"
|
||||
inkscape:cy="88.27356"
|
||||
inkscape:window-width="1969"
|
||||
inkscape:window-height="1165"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" /><title
|
||||
id="title1">WiVRn Wyvern yippe</title><defs
|
||||
id="defs1"><linearGradient
|
||||
id="linearGradient19"><stop
|
||||
style="stop-color:#e6aa00;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop19" /><stop
|
||||
style="stop-color:#eae69a;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop20" /></linearGradient><linearGradient
|
||||
id="linearGradient17"><stop
|
||||
style="stop-color:#e6aa00;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop17" /><stop
|
||||
style="stop-color:#eae69a;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop18" /></linearGradient><linearGradient
|
||||
id="linearGradient12"><stop
|
||||
style="stop-color:#e09100;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop12" /><stop
|
||||
style="stop-color:#eae69a;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop15" /></linearGradient><linearGradient
|
||||
id="linearGradient4"><stop
|
||||
style="stop-color:#001b42;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4" /><stop
|
||||
style="stop-color:#000308;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop5" /></linearGradient><linearGradient
|
||||
xlink:href="#linearGradient4"
|
||||
id="linearGradient3"
|
||||
x1="-9.9182129e-05"
|
||||
y1="255.99979"
|
||||
x2="512.00006"
|
||||
y2="255.99979"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-2.1362305e-4,-511.99978)" /><linearGradient
|
||||
xlink:href="#linearGradient4"
|
||||
id="linearGradient5"
|
||||
x1="-9.9182129e-05"
|
||||
y1="255.99979"
|
||||
x2="512.00006"
|
||||
y2="255.99979"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-2.1362305e-4,-511.99978)" /><linearGradient
|
||||
xlink:href="#linearGradient12"
|
||||
id="linearGradient15"
|
||||
x1="231.79434"
|
||||
y1="216.66031"
|
||||
x2="-107.19677"
|
||||
y2="-122.3308"
|
||||
gradientUnits="userSpaceOnUse" /><linearGradient
|
||||
xlink:href="#linearGradient17"
|
||||
id="linearGradient18"
|
||||
x1="287.30957"
|
||||
y1="58.948975"
|
||||
x2="239.39442"
|
||||
y2="11.033832"
|
||||
gradientUnits="userSpaceOnUse" /><linearGradient
|
||||
xlink:href="#linearGradient19"
|
||||
id="linearGradient20"
|
||||
x1="96.295563"
|
||||
y1="279.51785"
|
||||
x2="18.726246"
|
||||
y2="200.55717"
|
||||
gradientUnits="userSpaceOnUse" /><linearGradient
|
||||
xlink:href="#linearGradient19"
|
||||
id="linearGradient22"
|
||||
x1="513.62122"
|
||||
y1="177.14229"
|
||||
x2="399.88248"
|
||||
y2="79.645096"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.1063376,0.29644226,-0.29644226,1.1063376,-31.100051,-154.59176)" /></defs><g
|
||||
id="night-sky"
|
||||
style="display:none"
|
||||
transform="matrix(0.35156237,0,0,0.35156237,6.6787018e-5,-2.0283465e-4)"><rect
|
||||
style="opacity:1;fill:url(#linearGradient5);stroke:url(#linearGradient3);stroke-width:109.387;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="rect1"
|
||||
width="402.61319"
|
||||
height="402.61276"
|
||||
x="54.693188"
|
||||
y="-457.30637"
|
||||
transform="rotate(90)" /><path
|
||||
style="opacity:1;fill:url(#linearGradient15);fill-opacity:1;stroke:#000000;stroke-width:25.2217;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path12"
|
||||
d="M 219.20311,114.5513 107.70982,111.45267 41.950025,201.54153 10.443676,94.547585 -95.556813,59.845289 -3.5355221,-3.181977 -3.2876299,-114.71803 85.091005,-46.67708 191.2447,-80.907857 153.84441,24.171031 Z"
|
||||
transform="matrix(0.35683517,0,0,0.35683517,53.99049,62.985431)" /><path
|
||||
style="opacity:1;fill:url(#linearGradient20);fill-opacity:1;stroke:#000000;stroke-width:9;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path16"
|
||||
d="m 91.923883,258.09397 -24.559389,-2.01745 -15.585017,19.08772 -5.670558,-23.98079 -22.969535,-8.92381 21.054792,-12.80349 1.389064,-24.60293 18.683135,16.0678 23.828023,-6.28165 -9.50798,22.73394 z" /><path
|
||||
style="opacity:1;fill:url(#linearGradient18);fill-opacity:1;stroke:#000000;stroke-width:9;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path17"
|
||||
d="m 282.84271,38.890874 -13.87372,2.657982 -5.67564,12.935685 -6.8151,-12.373325 -14.05644,-1.400506 9.66175,-10.305117 -3.01172,-13.801245 12.7864,6.004413 12.19509,-7.129133 -1.75932,14.016048 z" /><path
|
||||
style="opacity:1;fill:url(#linearGradient22);fill-opacity:1;stroke:#000000;stroke-width:9;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 380.70776,184.75225 c -6.12682,2.5958 78.08431,26.29978 99.99397,-55.46822 21.04184,-78.529228 -65.63535,-99.651425 -59.9966,-93.381543 23.8872,26.560922 27.24809,55.867376 20.10618,82.193633 -7.64406,28.1771 -28.65811,53.33337 -60.10355,66.65613 z"
|
||||
id="path20" /></g><g
|
||||
id="wivrn"
|
||||
transform="matrix(0.35156237,0,0,0.35156237,6.6787018e-5,-2.0283465e-4)"
|
||||
style="display:inline"><g
|
||||
id="layer1"
|
||||
transform="matrix(2.8444455,0,0,2.8444455,-189.84471,-30.499434)"
|
||||
style="stroke-width:14.99999998;stroke-dasharray:none"><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 92.534742,122.93881 c -2.905994,7.38008 -4.746438,21.30199 8.633538,32.72739 7.57609,6.46936 20.38912,11.86588 32.48415,13.44224 9.58171,1.24879 26.70701,1.21338 32.90963,0.63191 11.80031,-1.10625 34.50568,-10.07679 44.543,-20.83318"
|
||||
id="path14-7" /><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 188.46876,110.26038 -5.21956,9.63246 -22.58647,-0.33215 c -6.90616,-0.0316 -7.30738,-7.07013 -13.85556,-7.07013 l -25.10134,0.80665 c -4.79251,0.18981 -5.81439,7.39991 -11.05598,7.96931 l -18.885326,1.4259 -12.960463,-22.50447 C 76.839174,95.928995 77.695768,91.866643 80.139132,87.863715 L 95.797837,62.429456 c 2.039918,-2.678813 4.159493,-5.023837 8.321053,-5.435523 l 74.41968,-3.237827 c 5.0906,-0.295214 8.73208,1.737803 11.00526,5.250985 l 11.20838,18.604622 -0.009,-0.01397"
|
||||
id="path18-6" /><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 134.47003,55.383809 c 4.67387,-5.765243 7.35483,-13.381057 7.35483,-13.381057 0,0 3.55879,6.714253 4.17565,12.147342"
|
||||
id="path42-8" /><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 188.84836,57.969864 c 7.2018,-9.344387 17.89541,-13.953904 27.09427,-16.702596 8.57089,-2.561049 14.57571,-4.987318 19.50218,-12.716749 3.16826,13.836148 -0.44802,26.39734 -3.84686,34.544005 -3.23674,7.758106 -11.52712,19.359828 -19.83097,24.294686"
|
||||
id="path43-8" /><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 200.75221,77.611713 c 9.05609,7.170997 12.00082,10.65054 15.89737,19.107608"
|
||||
id="path44-5" /><path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:14.99999998;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 211.10506,148.90717 c 18.09388,-17.60049 9.68681,-45.03368 5.54452,-52.187849 -5.07761,-8.122981 -5.86539,-15.251314 -17.01296,-19.574554 l -10.98381,32.405743 v 0 c 10.01156,2.93429 24.20554,12.33526 29.85215,19.21559"
|
||||
id="path45-0" /></g></g><metadata
|
||||
id="metadata1"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:title>WiVRn Wyvern yippe</dc:title><dc:date>1/25/25</dc:date><dc:creator><cc:Agent><dc:title>Yaya, y.a.y.a on Discord.</dc:title></cc:Agent></dc:creator><cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" /></cc:Work><cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/"><cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" /><cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" /><cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /><cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" /></cc:License></rdf:RDF></metadata></svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -40,8 +40,7 @@
|
||||
"NO_VR_MICROPHONE_SWITCH_MANUALLY": "Kein VR-Mikrofon gefunden. Schalten Sie es manuell um.",
|
||||
"FAILED_TO_SWITCH_MICROPHONE": "Fehler beim Wechseln des Mikrofons",
|
||||
"MICROPHONE_SET_SUCCESSFULLY": "Mikrofon erfolgreich umgeschaltet",
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "Lautsprecher erfolgreich umgeschaltet",
|
||||
"DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED": "Gerät gefunden und initialisiert, aber nicht umgeschaltet"
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "Lautsprecher erfolgreich umgeschaltet"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"RECENTER_PLAYSPACE": "Playspace neu zentrieren"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"AUDIO": {
|
||||
"AUTO_SWITCH_TO_VR_AUDIO": "Auto-switch to VR audio",
|
||||
"CARDS": "Cards",
|
||||
"DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED": "Device found and initialized, but not switched",
|
||||
"FAILED_TO_SWITCH_MICROPHONE": "Failed to switch microphone",
|
||||
"MICROPHONE_SET_SUCCESSFULLY": "Microphone set successfully",
|
||||
"MICROPHONES": "Microphones",
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
"NO_VR_MICROPHONE_SWITCH_MANUALLY": "No se encontró micrófono VR. Actívelo manualmente.",
|
||||
"FAILED_TO_SWITCH_MICROPHONE": "No se pudo cambiar el micrófono",
|
||||
"MICROPHONE_SET_SUCCESSFULLY": "Micrófono configurado correctamente",
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "Altavoces configurados correctamente",
|
||||
"DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED": "Dispositivo encontrado e inicializado, pero no cambiado"
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "Altavoces configurados correctamente"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"RECENTER_PLAYSPACE": "Re-centrar espacio de juego"
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
"NO_VR_MICROPHONE_SWITCH_MANUALLY": "VRマイクが見つかりませんでした。手動で切り替えてください。",
|
||||
"FAILED_TO_SWITCH_MICROPHONE": "マイクの切り替えに失敗しました",
|
||||
"MICROPHONE_SET_SUCCESSFULLY": "マイクの設定が完了しました",
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "スピーカーを設定しました",
|
||||
"DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED": "デバイスが見つかり、初期化されましたが、切り替えられていません"
|
||||
"SPEAKERS_SET_SUCCESSFULLY": "スピーカーを設定しました"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"RECENTER_PLAYSPACE": "プレイスペースを再中央"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"AUDIO": {
|
||||
"AUTO_SWITCH_TO_VR_AUDIO": "Automatyczne przełączanie na dźwięk VR",
|
||||
"CARDS": "Karty",
|
||||
"DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED": "Urządzenie znalezione i zainicjalizowane, ale nie przełączone",
|
||||
"FAILED_TO_SWITCH_MICROPHONE": "Nie udało się przełączyć mikrofon",
|
||||
"MICROPHONE_SET_SUCCESSFULLY": "Mikrofon ustawiono pomyślnie",
|
||||
"MICROPHONES": "Mikrofony",
|
||||
|
||||
@@ -18,7 +18,7 @@ use wgui::{
|
||||
|
||||
use crate::{
|
||||
frontend::{FrontendTask, FrontendTasks},
|
||||
util::pactl_wrapper,
|
||||
util::pactl_wrapper::{self},
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -172,7 +172,8 @@ fn does_string_mention_hmd_sink(input: &str) -> bool {
|
||||
lwr.contains("index") || // Valve hardware
|
||||
lwr.contains("oculus") || // Oculus
|
||||
lwr.contains("rift") || // Also Oculus
|
||||
lwr.contains("beyond") // Bigscreen Beyond
|
||||
lwr.contains("beyond") || // Bigscreen Beyond
|
||||
lwr.contains("wivrn") // WiVRn
|
||||
}
|
||||
|
||||
fn does_string_mention_hmd_source(input: &str) -> bool {
|
||||
@@ -180,7 +181,8 @@ fn does_string_mention_hmd_source(input: &str) -> bool {
|
||||
lwr.contains("hmd") || // generic hmd name detected
|
||||
lwr.contains("valve") || // Valve hardware
|
||||
lwr.contains("oculus") || // Oculus
|
||||
lwr.contains("beyond") // Bigscreen Beyond
|
||||
lwr.contains("beyond") || // Bigscreen Beyond
|
||||
lwr.contains("wivrn") // WiVRn
|
||||
}
|
||||
|
||||
fn is_card_mentioning_hmd(card: &pactl_wrapper::Card) -> bool {
|
||||
@@ -401,7 +403,30 @@ struct MountDeviceSliderParams<'a> {
|
||||
alt_desc: String,
|
||||
}
|
||||
|
||||
fn push_popup_speakers_set_successfully(globals: &WguiGlobals, frontend_tasks: &FrontendTasks, name: &str) {
|
||||
frontend_tasks.push(FrontendTask::PushToast(Translation::from_translation_key(
|
||||
format!(
|
||||
"{}: {}",
|
||||
globals.i18n().translate("AUDIO.SPEAKERS_SET_SUCCESSFULLY"),
|
||||
name
|
||||
)
|
||||
.as_str(),
|
||||
)));
|
||||
}
|
||||
|
||||
fn push_popup_microphone_set_successfully(globals: &WguiGlobals, frontend_tasks: &FrontendTasks, name: &str) {
|
||||
frontend_tasks.push(FrontendTask::PushToast(Translation::from_translation_key(
|
||||
format!(
|
||||
"{}: {}",
|
||||
globals.i18n().translate("AUDIO.MICROPHONE_SET_SUCCESSFULLY"),
|
||||
name
|
||||
)
|
||||
.as_str(),
|
||||
)));
|
||||
}
|
||||
|
||||
fn switch_sink_card(
|
||||
globals: &WguiGlobals,
|
||||
frontend_tasks: &FrontendTasks,
|
||||
card: &pactl_wrapper::Card,
|
||||
profile_name: &str,
|
||||
@@ -424,32 +449,32 @@ fn switch_sink_card(
|
||||
}
|
||||
|
||||
if sink_found {
|
||||
frontend_tasks.push(FrontendTask::PushToast(Translation::from_translation_key(
|
||||
format!("[AUDIO.SPEAKERS_SET_SUCCESSFULLY]: {}", name.name).as_str(),
|
||||
)));
|
||||
push_popup_speakers_set_successfully(globals, frontend_tasks, &name.name);
|
||||
} else {
|
||||
frontend_tasks.push(FrontendTask::PushToast(Translation::from_translation_key(
|
||||
format!("[AUDIO.DEVICE_FOUND_AND_INITIALIZED_BUT_NOT_SWITCHED]: {}", name.name).as_str(),
|
||||
format!("Card found ({}), but no matching speakers found", name.name).as_str(),
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn switch_source(frontend_tasks: &FrontendTasks, source: &pactl_wrapper::Source) -> anyhow::Result<()> {
|
||||
fn switch_source(
|
||||
globals: &WguiGlobals,
|
||||
frontend_tasks: &FrontendTasks,
|
||||
source: &pactl_wrapper::Source,
|
||||
) -> anyhow::Result<()> {
|
||||
match pactl_wrapper::set_default_source(source.index) {
|
||||
Ok(()) => {
|
||||
frontend_tasks.push(FrontendTask::PushToast(Translation::from_translation_key(
|
||||
format!(
|
||||
"[AUDIO.MICROPHONE_SET_SUCCESSFULLY]: {}",
|
||||
push_popup_microphone_set_successfully(
|
||||
globals,
|
||||
frontend_tasks,
|
||||
if let Some(card_name) = &source.properties.card_name {
|
||||
card_name
|
||||
} else {
|
||||
&source.description
|
||||
}
|
||||
)
|
||||
.as_str(),
|
||||
)));
|
||||
},
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -459,13 +484,13 @@ fn switch_source(frontend_tasks: &FrontendTasks, source: &pactl_wrapper::Source)
|
||||
}
|
||||
}
|
||||
|
||||
fn switch_to_vr_microphone(frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
fn switch_to_vr_microphone(globals: &WguiGlobals, frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
let sources = pactl_wrapper::list_sources()?;
|
||||
let mut switched = false;
|
||||
|
||||
for source in &sources {
|
||||
if is_source_mentioning_hmd(source) {
|
||||
switch_source(frontend_tasks, source)?;
|
||||
switch_source(globals, frontend_tasks, source)?;
|
||||
switched = true;
|
||||
break;
|
||||
}
|
||||
@@ -529,10 +554,20 @@ fn get_best_profile_from_array<'a>(arr: &[CardPriorityResult<'a>]) -> Option<Car
|
||||
res
|
||||
}
|
||||
|
||||
fn switch_to_vr_speakers(frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
fn switch_to_vr_speakers(globals: &WguiGlobals, frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
let cards = pactl_wrapper::list_cards()?;
|
||||
let sinks = pactl_wrapper::list_sinks()?;
|
||||
let mut best_profiles = Vec::new();
|
||||
|
||||
// Check for WiVRn presence
|
||||
for sink in sinks {
|
||||
if sink.name.contains("wivrn") {
|
||||
pactl_wrapper::set_default_sink(sink.index)?;
|
||||
push_popup_speakers_set_successfully(globals, frontend_tasks, "WiVRn");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
for card in &cards {
|
||||
if !is_card_mentioning_hmd(card) {
|
||||
continue;
|
||||
@@ -545,7 +580,7 @@ fn switch_to_vr_speakers(frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
if !best_profiles.is_empty() {
|
||||
let best_profile = get_best_profile_from_array(&best_profiles).unwrap();
|
||||
let name = get_profile_display_name(&best_profile.name, best_profile.card);
|
||||
switch_sink_card(frontend_tasks, best_profile.card, &best_profile.name, &name)?;
|
||||
switch_sink_card(globals, frontend_tasks, best_profile.card, &best_profile.name, &name)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -556,7 +591,7 @@ fn switch_to_vr_speakers(frontend_tasks: &FrontendTasks) -> anyhow::Result<()> {
|
||||
if !name.is_vr {
|
||||
continue;
|
||||
}
|
||||
switch_sink_card(frontend_tasks, card, profile_name, &name)?;
|
||||
switch_sink_card(globals, frontend_tasks, card, profile_name, &name)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@@ -684,8 +719,8 @@ impl View {
|
||||
pactl_wrapper::set_card_profile(c.card.index, &c.profile_name)?;
|
||||
}
|
||||
ViewTask::AutoSwitch => {
|
||||
switch_to_vr_microphone(&self.frontend_tasks)?;
|
||||
switch_to_vr_speakers(&self.frontend_tasks)?;
|
||||
switch_to_vr_speakers(&self.globals, &self.frontend_tasks)?;
|
||||
switch_to_vr_microphone(&self.globals, &self.frontend_tasks)?;
|
||||
self.tasks.push(ViewTask::Remount);
|
||||
}
|
||||
}
|
||||
@@ -745,8 +780,14 @@ impl View {
|
||||
par.insert("device_name".into(), disp.name.as_str().into());
|
||||
par.insert("device_icon".into(), disp.icon_path.into());
|
||||
} else {
|
||||
let icon_path = if params.alt_desc.contains("WiVRn") {
|
||||
"dashboard/wivrn_head_symbolic.svg"
|
||||
} else {
|
||||
"dashboard/binary.svg"
|
||||
};
|
||||
|
||||
par.insert("device_name".into(), params.alt_desc.into());
|
||||
par.insert("device_icon".into(), "dashboard/binary.svg".into());
|
||||
par.insert("device_icon".into(), icon_path.into());
|
||||
}
|
||||
|
||||
par.insert(
|
||||
|
||||
Reference in New Issue
Block a user