Added option for proximity sensor to mute/unmute the microphone.
This commit is contained in:
@@ -79,18 +79,18 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content: ColumnLayout {
|
content: ColumnLayout {
|
||||||
spacing: 68
|
spacing: 24
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
MyText {
|
MyText {
|
||||||
text: "Playback Device: "
|
text: "Playback Device: "
|
||||||
Layout.preferredWidth: 210
|
Layout.preferredWidth: 260
|
||||||
}
|
}
|
||||||
MyComboBox {
|
MyComboBox {
|
||||||
id: audioPlaybackNameCombo
|
id: audioPlaybackNameCombo
|
||||||
Layout.maximumWidth: 900
|
Layout.maximumWidth: 850
|
||||||
Layout.minimumWidth: 900
|
Layout.minimumWidth: 850
|
||||||
Layout.preferredWidth: 900
|
Layout.preferredWidth: 850
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (componentCompleted) {
|
if (componentCompleted) {
|
||||||
AudioTabController.setPlaybackDeviceIndex(currentIndex)
|
AudioTabController.setPlaybackDeviceIndex(currentIndex)
|
||||||
@@ -104,13 +104,13 @@ MyStackViewPage {
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
MyText {
|
MyText {
|
||||||
text: "Mirror Device: "
|
text: "Mirror Device: "
|
||||||
Layout.preferredWidth: 210
|
Layout.preferredWidth: 260
|
||||||
}
|
}
|
||||||
MyComboBox {
|
MyComboBox {
|
||||||
id: audioMirrorNameCombo
|
id: audioMirrorNameCombo
|
||||||
Layout.maximumWidth: 900
|
Layout.maximumWidth: 850
|
||||||
Layout.minimumWidth: 900
|
Layout.minimumWidth: 850
|
||||||
Layout.preferredWidth: 900
|
Layout.preferredWidth: 850
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (componentCompleted) {
|
if (componentCompleted) {
|
||||||
AudioTabController.setMirrorDeviceIndex(currentIndex - 1)
|
AudioTabController.setMirrorDeviceIndex(currentIndex - 1)
|
||||||
@@ -120,8 +120,8 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
MyText {
|
MyText {
|
||||||
text: "Volume:"
|
text: "Mirror Volume:"
|
||||||
Layout.preferredWidth: 120
|
Layout.preferredWidth: 260
|
||||||
}
|
}
|
||||||
|
|
||||||
MyPushButton2 {
|
MyPushButton2 {
|
||||||
@@ -187,13 +187,13 @@ MyStackViewPage {
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
MyText {
|
MyText {
|
||||||
text: "Microphone: "
|
text: "Microphone: "
|
||||||
Layout.preferredWidth: 210
|
Layout.preferredWidth: 260
|
||||||
}
|
}
|
||||||
MyComboBox {
|
MyComboBox {
|
||||||
id: audioMicNameCombo
|
id: audioMicNameCombo
|
||||||
Layout.maximumWidth: 900
|
Layout.maximumWidth: 850
|
||||||
Layout.minimumWidth: 900
|
Layout.minimumWidth: 850
|
||||||
Layout.preferredWidth: 900
|
Layout.preferredWidth: 850
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (componentCompleted) {
|
if (componentCompleted) {
|
||||||
AudioTabController.setMicDeviceIndex(currentIndex)
|
AudioTabController.setMicDeviceIndex(currentIndex)
|
||||||
@@ -203,8 +203,8 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
MyText {
|
MyText {
|
||||||
text: "Volume:"
|
text: "Microphone Volume:"
|
||||||
Layout.preferredWidth: 120
|
Layout.preferredWidth: 260
|
||||||
}
|
}
|
||||||
|
|
||||||
MyPushButton2 {
|
MyPushButton2 {
|
||||||
@@ -263,6 +263,14 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MyToggleButton {
|
||||||
|
id: audioMuteProximitySensorToggle
|
||||||
|
Layout.preferredWidth: 600
|
||||||
|
text: "Proximity Sensor Mutes/Unmutes Microphone"
|
||||||
|
onClicked: {
|
||||||
|
AudioTabController.setMicProximitySensorCanMute(checked, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
MyToggleButton {
|
MyToggleButton {
|
||||||
id: audioPttEnabledToggle
|
id: audioPttEnabledToggle
|
||||||
@@ -413,13 +421,16 @@ MyStackViewPage {
|
|||||||
audioMicVolumeSlider.enabled = false
|
audioMicVolumeSlider.enabled = false
|
||||||
audioMicVolumePlusButton.enabled = false
|
audioMicVolumePlusButton.enabled = false
|
||||||
audioMicMuteToggle.enabled = false
|
audioMicMuteToggle.enabled = false
|
||||||
|
audioMuteProximitySensorToggle.enabled = false
|
||||||
} else {
|
} else {
|
||||||
audioMicVolumeMinusButton.enabled = true
|
audioMicVolumeMinusButton.enabled = true
|
||||||
audioMicVolumeSlider.enabled = true
|
audioMicVolumeSlider.enabled = true
|
||||||
audioMicVolumePlusButton.enabled = true
|
audioMicVolumePlusButton.enabled = true
|
||||||
audioMicMuteToggle.enabled = true
|
audioMicMuteToggle.enabled = true
|
||||||
|
audioMuteProximitySensorToggle.enabled = true
|
||||||
audioMicVolumeSlider.value = AudioTabController.micVolume
|
audioMicVolumeSlider.value = AudioTabController.micVolume
|
||||||
audioMicMuteToggle.checked = AudioTabController.micMuted
|
audioMicMuteToggle.checked = AudioTabController.micMuted
|
||||||
|
audioMuteProximitySensorToggle.checked = AudioTabController.micProximitySensorCanMute
|
||||||
audioMicNameCombo.currentIndex = AudioTabController.micDeviceIndex
|
audioMicNameCombo.currentIndex = AudioTabController.micDeviceIndex
|
||||||
}
|
}
|
||||||
reloadPttProfiles()
|
reloadPttProfiles()
|
||||||
@@ -477,6 +488,9 @@ MyStackViewPage {
|
|||||||
onMicMutedChanged: {
|
onMicMutedChanged: {
|
||||||
audioMicMuteToggle.checked = AudioTabController.micMuted
|
audioMicMuteToggle.checked = AudioTabController.micMuted
|
||||||
}
|
}
|
||||||
|
onMicProximitySensorCanMuteChanged: {
|
||||||
|
audioMuteProximitySensorToggle.checked = AudioTabController.micProximitySensorCanMute
|
||||||
|
}
|
||||||
onPttEnabledChanged: {
|
onPttEnabledChanged: {
|
||||||
audioPttEnabledToggle.checked = AudioTabController.pttEnabled
|
audioPttEnabledToggle.checked = AudioTabController.pttEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace advsettings {
|
|||||||
m_micMuted = audioManager->getMicMuted();
|
m_micMuted = audioManager->getMicMuted();
|
||||||
reloadPttProfiles();
|
reloadPttProfiles();
|
||||||
reloadPttConfig();
|
reloadPttConfig();
|
||||||
|
reloadAudioSettings();
|
||||||
eventLoopTick();
|
eventLoopTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,22 @@ namespace advsettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioTabController::reloadAudioSettings() {
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(eventLoopMutex);
|
||||||
|
auto settings = OverlayController::appSettings();
|
||||||
|
settings->beginGroup(getSettingsName());
|
||||||
|
setMicProximitySensorCanMute(settings->value("micProximitySensorCanMute", false).toBool(), false);
|
||||||
|
settings->endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioTabController::saveAudioSettings() {
|
||||||
|
auto settings = OverlayController::appSettings();
|
||||||
|
settings->beginGroup(getSettingsName());
|
||||||
|
settings->setValue("micProximitySensorCanMute", micProximitySensorCanMute());
|
||||||
|
settings->endGroup();
|
||||||
|
settings->sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float AudioTabController::mirrorVolume() const {
|
float AudioTabController::mirrorVolume() const {
|
||||||
return m_mirrorVolume;
|
return m_mirrorVolume;
|
||||||
@@ -79,11 +96,33 @@ namespace advsettings {
|
|||||||
return m_micMuted;
|
return m_micMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioTabController::micProximitySensorCanMute() const {
|
||||||
|
return m_micProximitySensorCanMute;
|
||||||
|
}
|
||||||
|
|
||||||
void AudioTabController::eventLoopTick() {
|
void AudioTabController::eventLoopTick() {
|
||||||
if (!eventLoopMutex.try_lock()) {
|
if (!eventLoopMutex.try_lock()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settingsUpdateCounter >= 50) {
|
if (settingsUpdateCounter >= 50) {
|
||||||
|
if (m_micProximitySensorCanMute) {
|
||||||
|
vr::VRControllerState_t controllerState;
|
||||||
|
if (vr::VRSystem()->GetControllerState(vr::k_unTrackedDeviceIndex_Hmd, &controllerState, sizeof(vr::VRControllerState_t))) {
|
||||||
|
if ((controllerState.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_ProximitySensor)) == 0) {
|
||||||
|
if (!m_micMuted) {
|
||||||
|
setMicMuted(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_micMuted) {
|
||||||
|
setMicMuted(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!parent->isDashboardVisible()) {
|
||||||
|
LOG(ERROR) << "Could not read proximity sensor!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
vr::EVRSettingsError vrSettingsError;
|
vr::EVRSettingsError vrSettingsError;
|
||||||
char mirrorDeviceId[1024];
|
char mirrorDeviceId[1024];
|
||||||
vr::VRSettings()->GetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, mirrorDeviceId, 1024, &vrSettingsError);
|
vr::VRSettings()->GetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, mirrorDeviceId, 1024, &vrSettingsError);
|
||||||
@@ -183,6 +222,17 @@ namespace advsettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioTabController::setMicProximitySensorCanMute(bool value, bool notify) {
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(eventLoopMutex);
|
||||||
|
if (value != m_micProximitySensorCanMute) {
|
||||||
|
m_micProximitySensorCanMute = value;
|
||||||
|
saveAudioSettings();
|
||||||
|
if (notify) {
|
||||||
|
emit micProximitySensorCanMuteChanged(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudioTabController::onNewRecordingDevice() {
|
void AudioTabController::onNewRecordingDevice() {
|
||||||
findMicDeviceIndex(audioManager->getMicDevId());
|
findMicDeviceIndex(audioManager->getMicDevId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace advsettings {
|
|||||||
//Q_PROPERTY(QString micDevName READ micDevName NOTIFY micDevNameChanged)
|
//Q_PROPERTY(QString micDevName READ micDevName NOTIFY micDevNameChanged)
|
||||||
Q_PROPERTY(float micVolume READ micVolume WRITE setMicVolume NOTIFY micVolumeChanged)
|
Q_PROPERTY(float micVolume READ micVolume WRITE setMicVolume NOTIFY micVolumeChanged)
|
||||||
Q_PROPERTY(bool micMuted READ micMuted WRITE setMicMuted NOTIFY micMutedChanged)
|
Q_PROPERTY(bool micMuted READ micMuted WRITE setMicMuted NOTIFY micMutedChanged)
|
||||||
|
Q_PROPERTY(bool micProximitySensorCanMute READ micProximitySensorCanMute WRITE setMicProximitySensorCanMute NOTIFY micProximitySensorCanMuteChanged)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -42,6 +43,7 @@ namespace advsettings {
|
|||||||
int m_recordingDeviceIndex = -1;
|
int m_recordingDeviceIndex = -1;
|
||||||
float m_micVolume = 1.0;
|
float m_micVolume = 1.0;
|
||||||
bool m_micMuted = false;
|
bool m_micMuted = false;
|
||||||
|
bool m_micProximitySensorCanMute = false;
|
||||||
|
|
||||||
unsigned settingsUpdateCounter = 0;
|
unsigned settingsUpdateCounter = 0;
|
||||||
|
|
||||||
@@ -66,6 +68,9 @@ namespace advsettings {
|
|||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2(OverlayController* parent, QQuickWindow* widget);
|
void initStage2(OverlayController* parent, QQuickWindow* widget);
|
||||||
|
|
||||||
|
void reloadAudioSettings();
|
||||||
|
void saveAudioSettings();
|
||||||
|
|
||||||
void eventLoopTick();
|
void eventLoopTick();
|
||||||
|
|
||||||
int playbackDeviceIndex() const;
|
int playbackDeviceIndex() const;
|
||||||
@@ -77,6 +82,7 @@ namespace advsettings {
|
|||||||
int micDeviceIndex() const;
|
int micDeviceIndex() const;
|
||||||
float micVolume() const;
|
float micVolume() const;
|
||||||
bool micMuted() const;
|
bool micMuted() const;
|
||||||
|
bool micProximitySensorCanMute() const;
|
||||||
|
|
||||||
Q_INVOKABLE int getPlaybackDeviceCount();
|
Q_INVOKABLE int getPlaybackDeviceCount();
|
||||||
Q_INVOKABLE QString getPlaybackDeviceName(int index);
|
Q_INVOKABLE QString getPlaybackDeviceName(int index);
|
||||||
@@ -95,6 +101,7 @@ namespace advsettings {
|
|||||||
|
|
||||||
void setMicVolume(float value, bool notify = true);
|
void setMicVolume(float value, bool notify = true);
|
||||||
void setMicMuted(bool value, bool notify = true);
|
void setMicMuted(bool value, bool notify = true);
|
||||||
|
void setMicProximitySensorCanMute(bool value, bool notify = true);
|
||||||
|
|
||||||
void setPlaybackDeviceIndex(int value, bool notify = true);
|
void setPlaybackDeviceIndex(int value, bool notify = true);
|
||||||
void setMirrorDeviceIndex(int value, bool notify = true);
|
void setMirrorDeviceIndex(int value, bool notify = true);
|
||||||
@@ -110,6 +117,7 @@ namespace advsettings {
|
|||||||
void micDeviceIndexChanged(int index);
|
void micDeviceIndexChanged(int index);
|
||||||
void micVolumeChanged(float value);
|
void micVolumeChanged(float value);
|
||||||
void micMutedChanged(bool value);
|
void micMutedChanged(bool value);
|
||||||
|
void micProximitySensorCanMuteChanged(bool value);
|
||||||
|
|
||||||
void playbackDeviceListChanged();
|
void playbackDeviceListChanged();
|
||||||
void recordingDeviceListChanged();
|
void recordingDeviceListChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user