Skip to content

Commit

Permalink
mic sound
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Sep 5, 2024
1 parent 4c3899e commit bce47fe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/system_ui/src/mic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn update_mic_ui(
mut pressed: Local<bool>,
input: Res<ButtonInput<KeyCode>>,
mic_images: Res<MicImages>,
mut prev_active: Local<bool>,
) {
let mic_available = mic_state.available;
let transport_available = transport
Expand All @@ -106,12 +107,17 @@ fn update_mic_ui(
}

if input.pressed(KeyCode::ControlLeft) != *pressed {
mic_state.enabled = !mic_state.enabled;
*pressed = !*pressed;
if mic_state.enabled {
mic_state.enabled = !mic_state.enabled;
}

let active = mic_available && mic_state.enabled && transport_available;
if active != *prev_active {
if active {
commands.fire_event(SystemAudio("sounds/ui/voice_chat_mic_on.wav".to_owned()));
} else {
commands.fire_event(SystemAudio("sounds/ui/voice_chat_mic_off.wav".to_owned()));
}
*prev_active = active;
}
}

0 comments on commit bce47fe

Please sign in to comment.