mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 22:19:02 +00:00
Qt: fix mic_none and move microphone creator code
This commit is contained in:
parent
4aae9a17c1
commit
4ff69dc0cd
8 changed files with 185 additions and 82 deletions
76
rpcs3/rpcs3qt/microphone_creator.cpp
Normal file
76
rpcs3/rpcs3qt/microphone_creator.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#include "microphone_creator.h"
|
||||
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
||||
#include "3rdparty/OpenAL/include/alext.h"
|
||||
|
||||
constexpr auto qstr = QString::fromStdString;
|
||||
|
||||
microphone_creator::microphone_creator()
|
||||
{
|
||||
setObjectName("microphone_creator");
|
||||
refresh_list();
|
||||
}
|
||||
|
||||
// We need to recreate the localized string because the microphone creator is currently only created once.
|
||||
QString microphone_creator::get_none()
|
||||
{
|
||||
return tr("None", "Microphone device");
|
||||
}
|
||||
|
||||
void microphone_creator::refresh_list()
|
||||
{
|
||||
m_microphone_list.clear();
|
||||
m_microphone_list.append(get_none());
|
||||
|
||||
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE)
|
||||
{
|
||||
const char* devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
|
||||
while (*devices != 0)
|
||||
{
|
||||
m_microphone_list.append(qstr(devices));
|
||||
devices += strlen(devices) + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Without enumeration we can only use one device
|
||||
m_microphone_list.append(qstr(alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)));
|
||||
}
|
||||
}
|
||||
|
||||
QStringList microphone_creator::get_microphone_list()
|
||||
{
|
||||
return m_microphone_list;
|
||||
}
|
||||
|
||||
std::array<std::string, 4> microphone_creator::get_selection_list()
|
||||
{
|
||||
return m_sel_list;
|
||||
}
|
||||
|
||||
std::string microphone_creator::set_device(u32 num, const QString& text)
|
||||
{
|
||||
if (text == get_none())
|
||||
m_sel_list[num - 1] = "";
|
||||
else
|
||||
m_sel_list[num - 1] = text.toStdString();
|
||||
|
||||
const std::string final_list = m_sel_list[0] + "@@@" + m_sel_list[1] + "@@@" + m_sel_list[2] + "@@@" + m_sel_list[3] + "@@@";
|
||||
return final_list;
|
||||
}
|
||||
|
||||
void microphone_creator::parse_devices(const std::string& list)
|
||||
{
|
||||
for (u32 index = 0; index < 4; index++)
|
||||
{
|
||||
m_sel_list[index] = "";
|
||||
}
|
||||
|
||||
const auto devices_list = fmt::split(list, { "@@@" });
|
||||
for (u32 index = 0; index < std::min<u32>(4, ::size32(devices_list)); index++)
|
||||
{
|
||||
m_sel_list[index] = devices_list[index];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue