-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlaywidget.cpp
227 lines (170 loc) · 8.56 KB
/
overlaywidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#include "overlaywidget.h"
#include "ui_overlaywidget.h"
#include "AudioFunctions.h"
#include "audiostatecontroller.h"
#include <QDebug>
OverlayWidget::OverlayWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::OverlayWidget)
{
ui->setupUi(this);
/////////////////////////////////////////////////////
const auto outputList = GetAudioDeviceList(AudioDeviceDirection::OUTPUT);
const auto inputList = GetAudioDeviceList(AudioDeviceDirection::INPUT);
qDebug() << "-----";
qDebug() << "Found Output devices:";
for (const auto& kv : outputList) {
// List only connected or present devices
if(kv.second.state != AudioDeviceState::CONNECTED && kv.second.state != AudioDeviceState::DEVICE_PRESENT_NO_CONNECTION){
continue;
}
outputDevices.append(kv.second);
qDebug() << kv.first.data();
qDebug() << kv.second.id.data();
qDebug() << kv.second.interfaceName.data();
qDebug() << kv.second.endpointName.data();
qDebug() << kv.second.displayName.data();
std::string stateString;
if(kv.second.state == AudioDeviceState::CONNECTED){
stateString = "CONNECTED";
} else if(kv.second.state == AudioDeviceState::DEVICE_NOT_PRESENT){
stateString = "DEVICE_NOT_PRESENT";
} else if(kv.second.state == AudioDeviceState::DEVICE_DISABLED){
stateString = "DEVICE_DISABLED";
} else if(kv.second.state == AudioDeviceState::DEVICE_PRESENT_NO_CONNECTION){
stateString = "DEVICE_PRESENT_NO_CONNECTION";
} else {
qCritical() << "Error AudioDeviceState";
}
qDebug() << stateString.data();
qDebug() << "---";
}
qDebug() << "-----";
qDebug() << "-----";
qDebug() << "Found Input devices:";
for (const auto& kv : inputList) {
// List only connected or present devices
if(kv.second.state != AudioDeviceState::CONNECTED && kv.second.state != AudioDeviceState::DEVICE_PRESENT_NO_CONNECTION){
continue;
}
inputDevices.append(kv.second);
qDebug() << kv.first.data();
qDebug() << kv.second.id.data();
qDebug() << kv.second.interfaceName.data();
qDebug() << kv.second.endpointName.data();
qDebug() << kv.second.displayName.data();
std::string stateString;
if(kv.second.state == AudioDeviceState::CONNECTED){
stateString = "CONNECTED";
} else if(kv.second.state == AudioDeviceState::DEVICE_NOT_PRESENT){
stateString = "DEVICE_NOT_PRESENT";
} else if(kv.second.state == AudioDeviceState::DEVICE_DISABLED){
stateString = "DEVICE_DISABLED";
} else if(kv.second.state == AudioDeviceState::DEVICE_PRESENT_NO_CONNECTION){
stateString = "DEVICE_PRESENT_NO_CONNECTION";
} else {
qCritical() << "Error AudioDeviceState";
}
qDebug() << stateString.data();
qDebug() << "---";
}
qDebug() << "-----";
std::string default_output_default = GetDefaultAudioDeviceID(AudioDeviceDirection::OUTPUT, AudioDeviceRole::DEFAULT);
std::string default_output_communication = GetDefaultAudioDeviceID(AudioDeviceDirection::OUTPUT, AudioDeviceRole::COMMUNICATION);
qDebug() << "default output default: " << default_output_default.data();
qDebug() << "default output communication: " << default_output_communication.data();
qDebug() << "-----";
std::string default_input_default = GetDefaultAudioDeviceID(AudioDeviceDirection::INPUT, AudioDeviceRole::DEFAULT);
std::string default_input_communication = GetDefaultAudioDeviceID(AudioDeviceDirection::INPUT, AudioDeviceRole::COMMUNICATION);
qDebug() << "default input default: " << default_input_default.data();
qDebug() << "default input communication: " << default_input_communication.data();
qDebug() << "-----";
//AudioStateController::SharedInstance()->m_prefs.default_output_default = QString::fromStdString(default_output_default);
//AudioStateController::SharedInstance()->m_prefs.default_output_communication = QString::fromStdString(default_output_communication);
//AudioStateController::SharedInstance()->saveSettings();
// 0 is None so we start at 1
int index_output = 1;
for (const auto& kv : outputDevices) {
ui->comboBox_output_wearinghmd->addItem(QString::fromStdString(kv.displayName));
ui->comboBox_output_notwearinghmd->addItem(QString::fromStdString(kv.displayName));
if(AudioStateController::SharedInstance()->m_prefs.output_wearinghmd == QString::fromStdString(kv.id)){
qDebug() << "Found saved output_wearinghmd " << QString::fromStdString(kv.id) << " at " << index_output;
ui->comboBox_output_wearinghmd->setCurrentIndex(index_output);
}
if(AudioStateController::SharedInstance()->m_prefs.output_notwearinghmd == QString::fromStdString(kv.id)){
qDebug() << "Found saved output_notwearinghmd " << QString::fromStdString(kv.id) << " at " << index_output;
ui->comboBox_output_notwearinghmd->setCurrentIndex(index_output);
}
index_output++;
}
// 0 is None so we start at 1
int index_input = 1;
for (const auto& kv : inputDevices) {
ui->comboBox_input_wearinghmd->addItem(QString::fromStdString(kv.displayName));
ui->comboBox_input_notwearinghmd->addItem(QString::fromStdString(kv.displayName));
if(AudioStateController::SharedInstance()->m_prefs.input_wearinghmd == QString::fromStdString(kv.id)){
qDebug() << "Found saved input_wearinghmd " << QString::fromStdString(kv.id) << " at " << index_input;
ui->comboBox_input_wearinghmd->setCurrentIndex(index_input);
}
if(AudioStateController::SharedInstance()->m_prefs.input_notwearinghmd == QString::fromStdString(kv.id)){
qDebug() << "Found saved input_notwearinghmd " << QString::fromStdString(kv.id) << " at " << index_input;
ui->comboBox_input_notwearinghmd->setCurrentIndex(index_input);
}
index_input++;
}
}
OverlayWidget::~OverlayWidget()
{
delete ui;
}
void OverlayWidget::on_pushButton_quit_clicked()
{
QApplication::quit();
}
void OverlayWidget::on_pushButton_save_clicked()
{
AudioStateController::SharedInstance()->saveSettings();
}
void OverlayWidget::on_pushButton_refresh_clicked()
{
const auto outputList = GetAudioDeviceList(AudioDeviceDirection::OUTPUT);
//const auto inputList = GetAudioDeviceList(AudioDeviceDirection::INPUT);
qDebug() << "-----";
qDebug() << "Found Output devices:";
for (const auto& kv : outputList) {
qDebug() << kv.first.data();
}
qDebug() << "-----";
}
void OverlayWidget::on_comboBox_output_wearinghmd_currentIndexChanged(int index)
{
QString selectedDeviceID = QString::fromStdString(outputDevices.at(index - 1).id);
qDebug() << "Selected comboBox_output_wearinghmd entry with Index " << index << " and DeviceID " << selectedDeviceID;
AudioStateController::SharedInstance()->m_prefs.output_wearinghmd = selectedDeviceID;
AudioStateController::SharedInstance()->saveSettings();
}
void OverlayWidget::on_comboBox_output_notwearinghmd_currentIndexChanged(int index)
{
QString selectedDeviceID = QString::fromStdString(outputDevices.at(index - 1).id);
qDebug() << "Selected comboBox_output_notwearinghmd entry with Index " << index << " and DeviceID " << selectedDeviceID;
AudioStateController::SharedInstance()->m_prefs.output_notwearinghmd = selectedDeviceID;
AudioStateController::SharedInstance()->saveSettings();
}
void OverlayWidget::on_comboBox_input_wearinghmd_currentIndexChanged(int index)
{
QString selectedDeviceID = QString::fromStdString(inputDevices.at(index - 1).id);
qDebug() << "Selected comboBox_input_wearinghmd entry with Index " << index << " and DeviceID " << selectedDeviceID;
AudioStateController::SharedInstance()->m_prefs.input_wearinghmd = selectedDeviceID;
AudioStateController::SharedInstance()->saveSettings();
}
void OverlayWidget::on_comboBox_input_notwearinghmd_currentIndexChanged(int index)
{
QString selectedDeviceID = QString::fromStdString(inputDevices.at(index - 1).id);
qDebug() << "Selected comboBox_input_notwearinghmd entry with Index " << index << " and DeviceID " << selectedDeviceID;
AudioStateController::SharedInstance()->m_prefs.input_notwearinghmd = selectedDeviceID;
AudioStateController::SharedInstance()->saveSettings();
}
void OverlayWidget::on_pushButton_clear_settings_clicked()
{
AudioStateController::SharedInstance()->clearSettings();
}