Skip to content

Commit 2d487b0

Browse files
committed
fix(dashboard): 🐛 Set pipewire devices in the setup wizard
1 parent 0b0d044 commit 2d487b0

File tree

8 files changed

+85
-87
lines changed

8 files changed

+85
-87
lines changed

alvr/dashboard/src/dashboard/components/connections.rs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::dashboard::{basic_components, ServerRequest};
1+
use crate::dashboard::ServerRequest;
22
use alvr_common::ConnectionState;
33
use alvr_gui_common::theme::{self, log_colors};
44
use alvr_packets::ClientListAction;
@@ -8,7 +8,6 @@ use eframe::{
88
emath::{Align, Align2},
99
epaint::Color32,
1010
};
11-
use std::net::{IpAddr, Ipv4Addr};
1211

1312
struct EditPopupState {
1413
new_client: bool,
@@ -214,12 +213,7 @@ fn trusted_clients_section(
214213
.num_columns(2)
215214
.spacing(egui::vec2(8.0, 8.0))
216215
.show(ui, |ui| {
217-
ui.label(format!(
218-
"{hostname}: {} ({})",
219-
data.current_ip
220-
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
221-
data.display_name
222-
));
216+
ui.label(&data.display_name);
223217
ui.horizontal(|ui| {
224218
ui.with_layout(
225219
Layout::right_to_left(Align::Center),
@@ -248,23 +242,12 @@ fn trusted_clients_section(
248242

249243
ui.end_row();
250244

251-
ui.horizontal(|ui| {
252-
ui.hyperlink_to(
253-
"Use Cable:",
254-
format!(
255-
"https://github.com/alvr-org/ALVR/wiki/{}#{}",
256-
"ALVR-wired-setup-(ALVR-over-USB)",
257-
"letting-your-pc-communicate-with-your-hmd"
258-
),
259-
);
260-
if basic_components::switch(ui, &mut data.cabled).changed()
261-
{
262-
request = Some(ServerRequest::UpdateClientList {
263-
hostname: hostname.clone(),
264-
action: ClientListAction::SetCabled(data.cabled),
265-
});
266-
}
267-
});
245+
ui.label(format!(
246+
"{hostname}: {}",
247+
data.current_ip
248+
.map(|ip| ip.to_string())
249+
.unwrap_or_else(|| "Unknown IP".into()),
250+
));
268251
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
269252
if ui.button("Remove").clicked() {
270253
request = Some(ServerRequest::UpdateClientList {

alvr/dashboard/src/dashboard/components/settings_controls/help.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

alvr/dashboard/src/dashboard/components/settings_controls/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub mod boolean;
33
pub mod choice;
44
pub mod collapsible;
55
pub mod dictionary;
6-
pub mod help;
76
pub mod notice;
87
pub mod number;
98
pub mod optional;

alvr/dashboard/src/dashboard/components/settings_controls/presets/builtin_schema.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ pub fn microphone_schema(devices: Vec<String>) -> PresetSchemaNode {
239239
string_modifier(&format!("{PREFIX}.variant"), "Custom"),
240240
string_modifier(&format!("{PREFIX}.Custom.sink.variant"), "NameSubstring"),
241241
string_modifier(&format!("{PREFIX}.Custom.sink.NameSubstring"), &name),
242-
// string_modifier(&format!("{PREFIX}.Custom.source.variant"), "NameSubstring"),
243-
// string_modifier(&format!("{PREFIX}.Custom.source.NameSubstring"), ""),
244242
],
245243
content: None,
246244
})

alvr/dashboard/src/dashboard/components/setup_wizard.rs

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,82 @@ Script is not 100% stable and might cause some instability issues with pipewire,
135135

136136
#[cfg(target_os = "linux")]
137137
if ui
138-
.button("Download and set 'On connect/On disconnect' script")
138+
.button(format!(
139+
"Download and set 'On connect/On disconnect' script, {}",
140+
"set Pipewire audio"
141+
))
139142
.clicked()
140143
{
141144
match download_and_prepare_audio_script() {
142145
Ok(audio_script_path) => {
143-
let path_json = serde_json::Value::String(
144-
audio_script_path.to_string_lossy().to_string(),
145-
);
146+
fn bool_path_value_pair(
147+
session_path: &str,
148+
value: bool,
149+
) -> PathValuePair {
150+
PathValuePair {
151+
path: alvr_packets::parse_path(session_path),
152+
value: serde_json::Value::Bool(value),
153+
}
154+
}
155+
fn string_path_value_pair(
156+
session_path: &str,
157+
value: &str,
158+
) -> PathValuePair {
159+
PathValuePair {
160+
path: alvr_packets::parse_path(session_path),
161+
value: serde_json::Value::String(value.to_owned()),
162+
}
163+
}
164+
165+
const GAME_AUDIO_PREFIX: &str =
166+
"session_settings.audio.game_audio.content.device";
167+
const MIC_PREFIX: &str =
168+
"session_settings.audio.microphone.content.devices";
146169
request = Some(SetupWizardRequest::ServerRequest(
147170
ServerRequest::SetValues(vec![
148-
PathValuePair {
149-
path: alvr_packets::parse_path(
150-
"session_settings.connection.on_connect_script",
151-
),
152-
value: path_json.clone(),
153-
},
154-
PathValuePair {
155-
path: alvr_packets::parse_path(
156-
"session_settings.connection.on_disconnect_script",
157-
),
158-
value: path_json,
159-
},
171+
// scripts
172+
string_path_value_pair(
173+
"session_settings.connection.on_connect_script",
174+
&audio_script_path.to_string_lossy().to_string(),
175+
),
176+
string_path_value_pair(
177+
"session_settings.connection.on_disconnect_script",
178+
&audio_script_path.to_string_lossy().to_string(),
179+
),
180+
// game audio
181+
bool_path_value_pair(
182+
"session_settings.audio.game_audio.enabled",
183+
true,
184+
),
185+
bool_path_value_pair(
186+
&format!("{GAME_AUDIO_PREFIX}.set"),
187+
true,
188+
),
189+
string_path_value_pair(
190+
&format!("{GAME_AUDIO_PREFIX}.content.variant"),
191+
"NameSubstring",
192+
),
193+
string_path_value_pair(
194+
&format!("{GAME_AUDIO_PREFIX}.content.NameSubstring"),
195+
"pipewire",
196+
),
197+
// microphone
198+
bool_path_value_pair(
199+
"session_settings.audio.microphone.enabled",
200+
true,
201+
),
202+
string_path_value_pair(
203+
&format!("{MIC_PREFIX}.variant"),
204+
"Custom",
205+
),
206+
string_path_value_pair(
207+
&format!("{MIC_PREFIX}.Custom.sink.variant"),
208+
"NameSubstring",
209+
),
210+
string_path_value_pair(
211+
&format!("{MIC_PREFIX}.Custom.sink.NameSubstring"),
212+
"pipewire",
213+
),
160214
]),
161215
));
162216
alvr_common::info!("Successfully downloaded and set On connect / On disconnect script")
@@ -166,6 +220,7 @@ Script is not 100% stable and might cause some instability issues with pipewire,
166220
}
167221
},
168222
),
223+
169224
Page::HandGestures => page_content(
170225
ui,
171226
"Hand Gestures",
@@ -176,9 +231,10 @@ By default, controller button emulation is set to prevent accidental clicks. You
176231
if basic_components::switch(ui, &mut self.only_touch).changed() {
177232
request = Some(SetupWizardRequest::ServerRequest(
178233
ServerRequest::SetValues(vec![PathValuePair {
179-
path: alvr_packets::parse_path(
180-
"session_settings.headset.controllers.content.gestures.content.only_touch",
181-
),
234+
path: alvr_packets::parse_path(&format!(
235+
"session_settings.headset.controllers.content.{}",
236+
"gestures.content.only_touch"
237+
)),
182238
value: serde_json::Value::Bool(self.only_touch),
183239
}]),
184240
));

alvr/packets/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ pub enum ClientListAction {
188188
RemoveEntry,
189189
UpdateCurrentIp(Option<IpAddr>),
190190
SetConnectionState(ConnectionState),
191-
SetCabled(bool),
192191
}
193192

194193
#[derive(Serialize, Deserialize, Default, Clone)]

alvr/server/src/web_server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ async fn http_api(
238238

239239
reply(StatusCode::OK)?
240240
}
241-
// Latency in ms
242-
"/api/average-video-latency" => {
241+
"/api/average-video-latency-ms" => {
243242
let latency = if let Some(manager) = &*STATISTICS_MANAGER.lock() {
244243
manager.video_pipeline_latency_average().as_millis()
245244
} else {

alvr/server_io/src/lib.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ use alvr_common::{
1212
};
1313
use alvr_events::EventType;
1414
use alvr_packets::{AudioDevicesList, ClientListAction, PathSegment, PathValuePair};
15-
use alvr_session::{ClientConnectionConfig, SessionConfig, Settings, SocketProtocolDefaultVariant};
15+
use alvr_session::{ClientConnectionConfig, SessionConfig, Settings};
1616
use cpal::traits::{DeviceTrait, HostTrait};
1717
use serde_json as json;
1818
use std::{
1919
collections::{hash_map::Entry, HashMap},
2020
fs,
21-
net::{IpAddr, Ipv4Addr},
2221
ops::{Deref, DerefMut},
2322
path::{Path, PathBuf},
2423
};
@@ -257,40 +256,6 @@ impl ServerDataManager {
257256
}
258257
}
259258
}
260-
ClientListAction::SetCabled(state) => {
261-
if let Entry::Occupied(mut entry) = maybe_client_entry {
262-
entry.get_mut().cabled = state;
263-
264-
if entry.get().cabled {
265-
entry
266-
.get_mut()
267-
.manual_ips
268-
.insert(IpAddr::V4(Ipv4Addr::LOCALHOST));
269-
self.session
270-
.session_settings
271-
.connection
272-
.client_discovery
273-
.enabled = false;
274-
self.session
275-
.session_settings
276-
.connection
277-
.stream_protocol
278-
.variant = SocketProtocolDefaultVariant::Tcp;
279-
} else {
280-
entry
281-
.get_mut()
282-
.manual_ips
283-
.remove(&IpAddr::V4(Ipv4Addr::LOCALHOST));
284-
self.session
285-
.session_settings
286-
.connection
287-
.client_discovery
288-
.enabled = true;
289-
}
290-
291-
updated = true;
292-
}
293-
}
294259
}
295260

296261
if updated {

0 commit comments

Comments
 (0)