Microphone support (#3228)

* initial drafts

* initial implementation

* clang+reuse

* restore main

* improved AudioInInput

* fix microphone

* +

* +

* adds microphone selection to the interface

* added squidbus review fixes

* Update src/core/libraries/audio/audioin.cpp

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>

* Update src/core/libraries/audio/audioin.cpp

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>

* Increased entries in config.cpp

---------

Co-authored-by: DanielSvoboda <daniel.svoboda@hotmail.com>
Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
This commit is contained in:
georgemoralis
2025-07-23 06:54:18 +03:00
committed by GitHub
parent 16a6469b75
commit 0ad7fcb341
11 changed files with 494 additions and 75 deletions

View File

@@ -7,6 +7,7 @@
#include <QFileDialog>
#include <QHoverEvent>
#include <QMessageBox>
#include <SDL3/SDL.h>
#include <fmt/format.h>
#include "common/config.h"
@@ -28,6 +29,7 @@
#include "settings_dialog.h"
#include "ui_settings_dialog.h"
#include "video_core/renderer_vulkan/vk_instance.h"
QStringList languageNames = {"Arabic",
"Czech",
"Danish",
@@ -66,6 +68,7 @@ QMap<QString, QString> channelMap;
QMap<QString, QString> logTypeMap;
QMap<QString, QString> screenModeMap;
QMap<QString, QString> chooseHomeTabMap;
QMap<QString, QString> micMap;
int backgroundImageOpacitySlider_backup;
int bgm_volume_backup;
@@ -94,6 +97,7 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
{tr("Graphics"), "Graphics"}, {tr("User"), "User"},
{tr("Input"), "Input"}, {tr("Paths"), "Paths"},
{tr("Debug"), "Debug"}};
micMap = {{tr("None"), "None"}, {tr("Default Device"), "Default Device"}};
if (m_physical_devices.empty()) {
// Populate cache of physical devices.
@@ -125,6 +129,25 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
ui->hideCursorComboBox->addItem(tr("Idle"));
ui->hideCursorComboBox->addItem(tr("Always"));
ui->micComboBox->addItem(micMap.key("None"), "None");
ui->micComboBox->addItem(micMap.key("Default Device"), "Default Device");
SDL_InitSubSystem(SDL_INIT_AUDIO);
int count = 0;
SDL_AudioDeviceID* devices = SDL_GetAudioRecordingDevices(&count);
if (devices) {
for (int i = 0; i < count; ++i) {
SDL_AudioDeviceID devId = devices[i];
const char* name = SDL_GetAudioDeviceName(devId);
if (name) {
QString qname = QString::fromUtf8(name);
ui->micComboBox->addItem(qname, QString::number(devId));
}
}
SDL_free(devices);
} else {
qDebug() << "Erro SDL_GetAudioRecordingDevices:" << SDL_GetError();
}
InitializeEmulatorLanguages();
LoadValuesFromConfig();
@@ -453,6 +476,14 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->hideCursorComboBox->setCurrentIndex(toml::find_or<int>(data, "Input", "cursorState", 1));
OnCursorStateChanged(toml::find_or<int>(data, "Input", "cursorState", 1));
ui->idleTimeoutSpinBox->setValue(toml::find_or<int>(data, "Input", "cursorHideTimeout", 5));
QString micValue = QString::fromStdString(Config::getMicDevice());
int micIndex = ui->micComboBox->findData(micValue);
if (micIndex != -1) {
ui->micComboBox->setCurrentIndex(micIndex);
} else {
ui->micComboBox->setCurrentIndex(0);
}
// First options is auto selection -1, so gpuId on the GUI will always have to subtract 1
// when setting and add 1 when getting to select the correct gpu in Qt
ui->graphicsAdapterBox->setCurrentIndex(toml::find_or<int>(data, "Vulkan", "gpuId", -1) + 1);
@@ -771,6 +802,7 @@ void SettingsDialog::UpdateSettings() {
m_gui_settings->SetValue(gui::gl_playBackgroundMusic, ui->playBGMCheckBox->isChecked());
Config::setAllowHDR(ui->enableHDRCheckBox->isChecked());
Config::setLogType(logTypeMap.value(ui->logTypeComboBox->currentText()).toStdString());
Config::setMicDevice(ui->micComboBox->currentData().toString().toStdString());
Config::setLogFilter(ui->logFilterLineEdit->text().toStdString());
Config::setUserName(ui->userNameLineEdit->text().toStdString());
Config::setTrophyKey(ui->trophyKeyLineEdit->text().toStdString());

View File

@@ -86,7 +86,161 @@
<property name="spacing">
<number>6</number>
</property>
<item row="2" column="0">
<item row="0" column="1">
<layout class="QVBoxLayout" name="emulatorTabLayoutMiddle">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="emulatorSettingsGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Emulator</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="additionalSettingsVLayout" stretch="0">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QVBoxLayout" name="emulatorverticalLayout">
<property name="spacing">
<number>10</number>
</property>
<item>
<widget class="QCheckBox" name="showSplashCheckBox">
<property name="text">
<string>Show Splash</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="discordRPCCheckbox">
<property name="text">
<string>Enable Discord Rich Presence</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="systemTabLayoutLeft">
<property name="spacing">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="SystemSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>System</string>
</property>
<layout class="QVBoxLayout" name="emuSettingsLayout">
<property name="bottomMargin">
<number>70</number>
</property>
<item>
<widget class="QGroupBox" name="consoleLanguageGroupBox">
<property name="title">
<string>Console Language</string>
</property>
<layout class="QVBoxLayout" name="settingsLayout">
<item>
<widget class="QComboBox" name="consoleLanguageComboBox"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="emulatorLanguageGroupBox">
<property name="title">
<string>Emulator Language</string>
</property>
<layout class="QVBoxLayout" name="langSettingsLayout">
<item>
<widget class="QComboBox" name="emulatorLanguageComboBox"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
@@ -168,6 +322,32 @@
<property name="bottomMargin">
<number>80</number>
</property>
<item>
<widget class="QCheckBox" name="updateCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Check for Updates at Startup</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="changelogCheckBox">
<property name="text">
<string>Always Show Changelog</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="updaterComboBox">
<property name="sizePolicy">
@@ -255,32 +435,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="updateCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Check for Updates at Startup</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="changelogCheckBox">
<property name="text">
<string>Always Show Changelog</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -1521,7 +1675,7 @@
<item>
<layout class="QVBoxLayout" name="cursorTabLayoutLeft">
<property name="spacing">
<number>7</number>
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
@@ -1684,6 +1838,12 @@
<property name="title">
<string>Controller</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="ControllerLayout">
<property name="spacing">
<number>0</number>
@@ -1696,27 +1856,14 @@
</property>
<item>
<widget class="QCheckBox" name="motionControlsCheckBox">
<property name="text">
<string>Enable Motion Controls</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="controllerWidgetSpacer" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
<property name="text">
<string>Enable Motion Controls</string>
</property>
</widget>
</item>
@@ -1733,20 +1880,38 @@
<number>0</number>
</property>
<item>
<spacer name="emptyVerticalSpacerBottom">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<layout class="QHBoxLayout" name="micTabLayoutLeft">
<item>
<widget class="QGroupBox" name="MicGroupBox">
<property name="title">
<string>Microphone</string>
</property>
<widget class="QComboBox" name="micComboBox">
<property name="geometry">
<rect>
<x>14</x>
<y>33</y>
<width>431</width>
<height>31</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>

View File

@@ -1582,6 +1582,18 @@
<source>Hide Cursor Idle Timeout</source>
<translation>Hide Cursor Idle Timeout</translation>
</message>
<message>
<source>Microphone</source>
<translation>Microphone</translation>
</message>
<message>
<source>None</source>
<translation>None</translation>
</message>
<message>
<source>Default Device</source>
<translation>Default Device</translation>
</message>
<message>
<source>s</source>
<translation>s</translation>