diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/aoc/aoc_u.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/cmif_serialization.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.cpp | 45 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.h | 5 | ||||
| -rw-r--r-- | src/hid_core/hid_types.h | 5 | ||||
| -rw-r--r-- | src/hid_core/resources/npad/npad.cpp | 11 | ||||
| -rw-r--r-- | src/hid_core/resources/npad/npad.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_audio.cpp | 117 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_audio.h | 7 |
10 files changed, 155 insertions, 57 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index 16749ab68..f1b1add56 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -134,12 +134,12 @@ struct Values { | |||
| 134 | Linkage linkage{}; | 134 | Linkage linkage{}; |
| 135 | 135 | ||
| 136 | // Audio | 136 | // Audio |
| 137 | Setting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio, | 137 | SwitchableSetting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine", |
| 138 | Specialization::RuntimeList}; | 138 | Category::Audio, Specialization::RuntimeList}; |
| 139 | Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio, | 139 | SwitchableSetting<std::string> audio_output_device_id{ |
| 140 | Specialization::RuntimeList}; | 140 | linkage, "auto", "output_device", Category::Audio, Specialization::RuntimeList}; |
| 141 | Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio, | 141 | SwitchableSetting<std::string> audio_input_device_id{ |
| 142 | Specialization::RuntimeList}; | 142 | linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList}; |
| 143 | SwitchableSetting<AudioMode, true> sound_index{ | 143 | SwitchableSetting<AudioMode, true> sound_index{ |
| 144 | linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, | 144 | linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, |
| 145 | "sound_index", Category::SystemAudio, Specialization::Default, true, | 145 | "sound_index", Category::SystemAudio, Specialization::Default, true, |
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 7075ab800..486719cc0 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -202,7 +202,7 @@ void AOC_U::ListAddOnContent(HLERequestContext& ctx) { | |||
| 202 | LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, | 202 | LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, |
| 203 | process_id); | 203 | process_id); |
| 204 | 204 | ||
| 205 | const auto current = system.GetApplicationProcessProgramID(); | 205 | const auto current = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID()); |
| 206 | 206 | ||
| 207 | std::vector<u32> out; | 207 | std::vector<u32> out; |
| 208 | const auto& disabled = Settings::values.disabled_addons[current]; | 208 | const auto& disabled = Settings::values.disabled_addons[current]; |
diff --git a/src/core/hle/service/cmif_serialization.h b/src/core/hle/service/cmif_serialization.h index 5eabf51fe..315475e71 100644 --- a/src/core/hle/service/cmif_serialization.h +++ b/src/core/hle/service/cmif_serialization.h | |||
| @@ -283,7 +283,7 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE | |||
| 283 | 283 | ||
| 284 | return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex + 1, InBufferIndex, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); | 284 | return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex + 1, InBufferIndex, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); |
| 285 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InLargeData) { | 285 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InLargeData) { |
| 286 | constexpr size_t BufferSize = sizeof(ArgType); | 286 | constexpr size_t BufferSize = sizeof(typename ArgType::Type); |
| 287 | 287 | ||
| 288 | // Clear the existing data. | 288 | // Clear the existing data. |
| 289 | std::memset(&std::get<ArgIndex>(args), 0, BufferSize); | 289 | std::memset(&std::get<ArgIndex>(args), 0, BufferSize); |
| @@ -324,7 +324,7 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE | |||
| 324 | 324 | ||
| 325 | return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex + 1, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); | 325 | return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex + 1, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); |
| 326 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) { | 326 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) { |
| 327 | constexpr size_t BufferSize = sizeof(ArgType); | 327 | constexpr size_t BufferSize = sizeof(typename ArgType::Type); |
| 328 | 328 | ||
| 329 | // Clear the existing data. | 329 | // Clear the existing data. |
| 330 | std::memset(&std::get<ArgIndex>(args).raw, 0, BufferSize); | 330 | std::memset(&std::get<ArgIndex>(args).raw, 0, BufferSize); |
| @@ -394,7 +394,7 @@ void WriteOutArgument(bool is_domain, CallArguments& args, u8* raw_data, HLERequ | |||
| 394 | 394 | ||
| 395 | return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); | 395 | return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp); |
| 396 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) { | 396 | } else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) { |
| 397 | constexpr size_t BufferSize = sizeof(ArgType); | 397 | constexpr size_t BufferSize = sizeof(typename ArgType::Type); |
| 398 | 398 | ||
| 399 | ASSERT(ctx.CanWriteBuffer(OutBufferIndex)); | 399 | ASSERT(ctx.CanWriteBuffer(OutBufferIndex)); |
| 400 | if constexpr (ArgType::Attr & BufferAttr_HipcAutoSelect) { | 400 | if constexpr (ArgType::Attr & BufferAttr_HipcAutoSelect) { |
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 09c47b5e3..938b93451 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "core/hle/kernel/k_shared_memory.h" | 8 | #include "core/hle/kernel/k_shared_memory.h" |
| 9 | #include "core/hle/kernel/k_transfer_memory.h" | 9 | #include "core/hle/kernel/k_transfer_memory.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/service/cmif_serialization.h" | ||
| 11 | #include "core/hle/service/hid/hid_server.h" | 12 | #include "core/hle/service/hid/hid_server.h" |
| 12 | #include "core/hle/service/ipc_helpers.h" | 13 | #include "core/hle/service/ipc_helpers.h" |
| 13 | #include "core/memory.h" | 14 | #include "core/memory.h" |
| @@ -153,7 +154,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r | |||
| 153 | {104, &IHidServer::DeactivateNpad, "DeactivateNpad"}, | 154 | {104, &IHidServer::DeactivateNpad, "DeactivateNpad"}, |
| 154 | {106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, | 155 | {106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, |
| 155 | {107, &IHidServer::DisconnectNpad, "DisconnectNpad"}, | 156 | {107, &IHidServer::DisconnectNpad, "DisconnectNpad"}, |
| 156 | {108, &IHidServer::GetPlayerLedPattern, "GetPlayerLedPattern"}, | 157 | {108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"}, |
| 157 | {109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, | 158 | {109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, |
| 158 | {120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, | 159 | {120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, |
| 159 | {121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, | 160 | {121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, |
| @@ -1136,19 +1137,39 @@ void IHidServer::DisconnectNpad(HLERequestContext& ctx) { | |||
| 1136 | rb.Push(ResultSuccess); | 1137 | rb.Push(ResultSuccess); |
| 1137 | } | 1138 | } |
| 1138 | 1139 | ||
| 1139 | void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) { | 1140 | Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, |
| 1140 | IPC::RequestParser rp{ctx}; | 1141 | Core::HID::NpadIdType npad_id) { |
| 1141 | const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; | ||
| 1142 | |||
| 1143 | Core::HID::LedPattern pattern{0, 0, 0, 0}; | ||
| 1144 | auto controller = GetResourceManager()->GetNpad(); | ||
| 1145 | const auto result = controller->GetLedPattern(npad_id, pattern); | ||
| 1146 | |||
| 1147 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); | 1142 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); |
| 1148 | 1143 | ||
| 1149 | IPC::ResponseBuilder rb{ctx, 4}; | 1144 | switch (npad_id) { |
| 1150 | rb.Push(result); | 1145 | case Core::HID::NpadIdType::Player1: |
| 1151 | rb.Push(pattern.raw); | 1146 | *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 0}; |
| 1147 | R_SUCCEED(); | ||
| 1148 | case Core::HID::NpadIdType::Player2: | ||
| 1149 | *out_led_pattern = Core::HID::LedPattern{1, 1, 0, 0}; | ||
| 1150 | R_SUCCEED(); | ||
| 1151 | case Core::HID::NpadIdType::Player3: | ||
| 1152 | *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 0}; | ||
| 1153 | R_SUCCEED(); | ||
| 1154 | case Core::HID::NpadIdType::Player4: | ||
| 1155 | *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 1}; | ||
| 1156 | R_SUCCEED(); | ||
| 1157 | case Core::HID::NpadIdType::Player5: | ||
| 1158 | *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 1}; | ||
| 1159 | R_SUCCEED(); | ||
| 1160 | case Core::HID::NpadIdType::Player6: | ||
| 1161 | *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 0}; | ||
| 1162 | R_SUCCEED(); | ||
| 1163 | case Core::HID::NpadIdType::Player7: | ||
| 1164 | *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 1}; | ||
| 1165 | R_SUCCEED(); | ||
| 1166 | case Core::HID::NpadIdType::Player8: | ||
| 1167 | *out_led_pattern = Core::HID::LedPattern{0, 1, 1, 0}; | ||
| 1168 | R_SUCCEED(); | ||
| 1169 | default: | ||
| 1170 | *out_led_pattern = Core::HID::LedPattern{0, 0, 0, 0}; | ||
| 1171 | R_SUCCEED(); | ||
| 1172 | } | ||
| 1152 | } | 1173 | } |
| 1153 | 1174 | ||
| 1154 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | 1175 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index 3a2e0a230..faf775689 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | #include "hid_core/hid_types.h" | ||
| 7 | 9 | ||
| 8 | namespace Core { | 10 | namespace Core { |
| 9 | class System; | 11 | class System; |
| @@ -66,7 +68,8 @@ private: | |||
| 66 | void DeactivateNpad(HLERequestContext& ctx); | 68 | void DeactivateNpad(HLERequestContext& ctx); |
| 67 | void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); | 69 | void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); |
| 68 | void DisconnectNpad(HLERequestContext& ctx); | 70 | void DisconnectNpad(HLERequestContext& ctx); |
| 69 | void GetPlayerLedPattern(HLERequestContext& ctx); | 71 | Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, |
| 72 | Core::HID::NpadIdType npad_id); | ||
| 70 | void ActivateNpadWithRevision(HLERequestContext& ctx); | 73 | void ActivateNpadWithRevision(HLERequestContext& ctx); |
| 71 | void SetNpadJoyHoldType(HLERequestContext& ctx); | 74 | void SetNpadJoyHoldType(HLERequestContext& ctx); |
| 72 | void GetNpadJoyHoldType(HLERequestContext& ctx); | 75 | void GetNpadJoyHoldType(HLERequestContext& ctx); |
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h index b310ab72d..ffb5f1926 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h | |||
| @@ -422,7 +422,10 @@ struct NpadPowerInfo { | |||
| 422 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); | 422 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); |
| 423 | 423 | ||
| 424 | struct LedPattern { | 424 | struct LedPattern { |
| 425 | explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { | 425 | LedPattern() { |
| 426 | raw = 0; | ||
| 427 | } | ||
| 428 | LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { | ||
| 426 | position1.Assign(light1); | 429 | position1.Assign(light1); |
| 427 | position2.Assign(light2); | 430 | position2.Assign(light2); |
| 428 | position3.Assign(light3); | 431 | position3.Assign(light3); |
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index cde84b1bb..2823be348 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp | |||
| @@ -956,17 +956,6 @@ Result NPad::SwapNpadAssignment(u64 aruid, Core::HID::NpadIdType npad_id_1, | |||
| 956 | return ResultSuccess; | 956 | return ResultSuccess; |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const { | ||
| 960 | if (!IsNpadIdValid(npad_id)) { | ||
| 961 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
| 962 | return ResultInvalidNpadId; | ||
| 963 | } | ||
| 964 | const auto aruid = applet_resource_holder.applet_resource->GetActiveAruid(); | ||
| 965 | const auto& controller = GetControllerFromNpadIdType(aruid, npad_id).device; | ||
| 966 | pattern = controller->GetLedPattern(); | ||
| 967 | return ResultSuccess; | ||
| 968 | } | ||
| 969 | |||
| 970 | Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, | 959 | Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, |
| 971 | Core::HID::NpadIdType npad_id) const { | 960 | Core::HID::NpadIdType npad_id) const { |
| 972 | std::scoped_lock lock{mutex}; | 961 | std::scoped_lock lock{mutex}; |
diff --git a/src/hid_core/resources/npad/npad.h b/src/hid_core/resources/npad/npad.h index 502cb9b55..3b1a69e7f 100644 --- a/src/hid_core/resources/npad/npad.h +++ b/src/hid_core/resources/npad/npad.h | |||
| @@ -97,8 +97,6 @@ public: | |||
| 97 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( | 97 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( |
| 98 | u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle); | 98 | u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle); |
| 99 | 99 | ||
| 100 | Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; | ||
| 101 | |||
| 102 | Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, | 100 | Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, |
| 103 | Core::HID::NpadIdType npad_id) const; | 101 | Core::HID::NpadIdType npad_id) const; |
| 104 | Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id, | 102 | Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id, |
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 9b6ef47a7..c235b0fca 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include <QComboBox> | 7 | #include <QComboBox> |
| 8 | #include <QPushButton> | ||
| 8 | 9 | ||
| 9 | #include "audio_core/sink/sink.h" | 10 | #include "audio_core/sink/sink.h" |
| 10 | #include "audio_core/sink/sink_details.h" | 11 | #include "audio_core/sink/sink_details.h" |
| @@ -67,19 +68,99 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { | |||
| 67 | 68 | ||
| 68 | hold.emplace(std::pair{setting->Id(), widget}); | 69 | hold.emplace(std::pair{setting->Id(), widget}); |
| 69 | 70 | ||
| 71 | auto global_sink_match = [this] { | ||
| 72 | return static_cast<Settings::AudioEngine>(sink_combo_box->currentIndex()) == | ||
| 73 | Settings::values.sink_id.GetValue(true); | ||
| 74 | }; | ||
| 70 | if (setting->Id() == Settings::values.sink_id.Id()) { | 75 | if (setting->Id() == Settings::values.sink_id.Id()) { |
| 71 | // TODO (lat9nq): Let the system manage sink_id | 76 | // TODO (lat9nq): Let the system manage sink_id |
| 72 | sink_combo_box = widget->combobox; | 77 | sink_combo_box = widget->combobox; |
| 73 | InitializeAudioSinkComboBox(); | 78 | InitializeAudioSinkComboBox(); |
| 74 | 79 | ||
| 75 | connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, | 80 | if (Settings::IsConfiguringGlobal()) { |
| 76 | &ConfigureAudio::UpdateAudioDevices); | 81 | connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, |
| 82 | &ConfigureAudio::UpdateAudioDevices); | ||
| 83 | } else { | ||
| 84 | restore_sink_button = ConfigurationShared::Widget::CreateRestoreGlobalButton( | ||
| 85 | Settings::values.sink_id.UsingGlobal(), widget); | ||
| 86 | widget->layout()->addWidget(restore_sink_button); | ||
| 87 | connect(restore_sink_button, &QAbstractButton::clicked, [this](bool) { | ||
| 88 | Settings::values.sink_id.SetGlobal(true); | ||
| 89 | const int sink_index = static_cast<int>(Settings::values.sink_id.GetValue()); | ||
| 90 | sink_combo_box->setCurrentIndex(sink_index); | ||
| 91 | ConfigureAudio::UpdateAudioDevices(sink_index); | ||
| 92 | Settings::values.audio_output_device_id.SetGlobal(true); | ||
| 93 | Settings::values.audio_input_device_id.SetGlobal(true); | ||
| 94 | restore_sink_button->setVisible(false); | ||
| 95 | }); | ||
| 96 | connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), | ||
| 97 | [this, global_sink_match](const int slot) { | ||
| 98 | Settings::values.sink_id.SetGlobal(false); | ||
| 99 | Settings::values.audio_output_device_id.SetGlobal(false); | ||
| 100 | Settings::values.audio_input_device_id.SetGlobal(false); | ||
| 101 | |||
| 102 | restore_sink_button->setVisible(true); | ||
| 103 | restore_sink_button->setEnabled(true); | ||
| 104 | output_device_combo_box->setCurrentIndex(0); | ||
| 105 | restore_output_device_button->setVisible(true); | ||
| 106 | restore_output_device_button->setEnabled(global_sink_match()); | ||
| 107 | input_device_combo_box->setCurrentIndex(0); | ||
| 108 | restore_input_device_button->setVisible(true); | ||
| 109 | restore_input_device_button->setEnabled(global_sink_match()); | ||
| 110 | ConfigureAudio::UpdateAudioDevices(slot); | ||
| 111 | }); | ||
| 112 | } | ||
| 77 | } else if (setting->Id() == Settings::values.audio_output_device_id.Id()) { | 113 | } else if (setting->Id() == Settings::values.audio_output_device_id.Id()) { |
| 78 | // Keep track of output (and input) device comboboxes to populate them with system | 114 | // Keep track of output (and input) device comboboxes to populate them with system |
| 79 | // devices, which are determined at run time | 115 | // devices, which are determined at run time |
| 80 | output_device_combo_box = widget->combobox; | 116 | output_device_combo_box = widget->combobox; |
| 117 | |||
| 118 | if (!Settings::IsConfiguringGlobal()) { | ||
| 119 | restore_output_device_button = | ||
| 120 | ConfigurationShared::Widget::CreateRestoreGlobalButton( | ||
| 121 | Settings::values.audio_output_device_id.UsingGlobal(), widget); | ||
| 122 | restore_output_device_button->setEnabled(global_sink_match()); | ||
| 123 | restore_output_device_button->setVisible( | ||
| 124 | !Settings::values.audio_output_device_id.UsingGlobal()); | ||
| 125 | widget->layout()->addWidget(restore_output_device_button); | ||
| 126 | connect(restore_output_device_button, &QAbstractButton::clicked, [this](bool) { | ||
| 127 | Settings::values.audio_output_device_id.SetGlobal(true); | ||
| 128 | SetOutputDevicesFromDeviceID(); | ||
| 129 | restore_output_device_button->setVisible(false); | ||
| 130 | }); | ||
| 131 | connect(output_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), | ||
| 132 | [this, global_sink_match](int) { | ||
| 133 | if (updating_devices) { | ||
| 134 | return; | ||
| 135 | } | ||
| 136 | Settings::values.audio_output_device_id.SetGlobal(false); | ||
| 137 | restore_output_device_button->setVisible(true); | ||
| 138 | restore_output_device_button->setEnabled(global_sink_match()); | ||
| 139 | }); | ||
| 140 | } | ||
| 81 | } else if (setting->Id() == Settings::values.audio_input_device_id.Id()) { | 141 | } else if (setting->Id() == Settings::values.audio_input_device_id.Id()) { |
| 82 | input_device_combo_box = widget->combobox; | 142 | input_device_combo_box = widget->combobox; |
| 143 | |||
| 144 | if (!Settings::IsConfiguringGlobal()) { | ||
| 145 | restore_input_device_button = | ||
| 146 | ConfigurationShared::Widget::CreateRestoreGlobalButton( | ||
| 147 | Settings::values.audio_input_device_id.UsingGlobal(), widget); | ||
| 148 | widget->layout()->addWidget(restore_input_device_button); | ||
| 149 | connect(restore_input_device_button, &QAbstractButton::clicked, [this](bool) { | ||
| 150 | Settings::values.audio_input_device_id.SetGlobal(true); | ||
| 151 | SetInputDevicesFromDeviceID(); | ||
| 152 | restore_input_device_button->setVisible(false); | ||
| 153 | }); | ||
| 154 | connect(input_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), | ||
| 155 | [this, global_sink_match](int) { | ||
| 156 | if (updating_devices) { | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | Settings::values.audio_input_device_id.SetGlobal(false); | ||
| 160 | restore_input_device_button->setVisible(true); | ||
| 161 | restore_input_device_button->setEnabled(global_sink_match()); | ||
| 162 | }); | ||
| 163 | } | ||
| 83 | } | 164 | } |
| 84 | } | 165 | } |
| 85 | 166 | ||
| @@ -89,16 +170,13 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { | |||
| 89 | } | 170 | } |
| 90 | 171 | ||
| 91 | void ConfigureAudio::SetConfiguration() { | 172 | void ConfigureAudio::SetConfiguration() { |
| 92 | if (!Settings::IsConfiguringGlobal()) { | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | |||
| 96 | SetOutputSinkFromSinkID(); | 173 | SetOutputSinkFromSinkID(); |
| 97 | 174 | ||
| 98 | // The device list cannot be pre-populated (nor listed) until the output sink is known. | 175 | // The device list cannot be pre-populated (nor listed) until the output sink is known. |
| 99 | UpdateAudioDevices(sink_combo_box->currentIndex()); | 176 | UpdateAudioDevices(sink_combo_box->currentIndex()); |
| 100 | 177 | ||
| 101 | SetAudioDevicesFromDeviceID(); | 178 | SetOutputDevicesFromDeviceID(); |
| 179 | SetInputDevicesFromDeviceID(); | ||
| 102 | } | 180 | } |
| 103 | 181 | ||
| 104 | void ConfigureAudio::SetOutputSinkFromSinkID() { | 182 | void ConfigureAudio::SetOutputSinkFromSinkID() { |
| @@ -116,8 +194,8 @@ void ConfigureAudio::SetOutputSinkFromSinkID() { | |||
| 116 | sink_combo_box->setCurrentIndex(new_sink_index); | 194 | sink_combo_box->setCurrentIndex(new_sink_index); |
| 117 | } | 195 | } |
| 118 | 196 | ||
| 119 | void ConfigureAudio::SetAudioDevicesFromDeviceID() { | 197 | void ConfigureAudio::SetOutputDevicesFromDeviceID() { |
| 120 | int new_device_index = -1; | 198 | int new_device_index = 0; |
| 121 | 199 | ||
| 122 | const QString output_device_id = | 200 | const QString output_device_id = |
| 123 | QString::fromStdString(Settings::values.audio_output_device_id.GetValue()); | 201 | QString::fromStdString(Settings::values.audio_output_device_id.GetValue()); |
| @@ -129,8 +207,10 @@ void ConfigureAudio::SetAudioDevicesFromDeviceID() { | |||
| 129 | } | 207 | } |
| 130 | 208 | ||
| 131 | output_device_combo_box->setCurrentIndex(new_device_index); | 209 | output_device_combo_box->setCurrentIndex(new_device_index); |
| 210 | } | ||
| 132 | 211 | ||
| 133 | new_device_index = -1; | 212 | void ConfigureAudio::SetInputDevicesFromDeviceID() { |
| 213 | int new_device_index = 0; | ||
| 134 | const QString input_device_id = | 214 | const QString input_device_id = |
| 135 | QString::fromStdString(Settings::values.audio_input_device_id.GetValue()); | 215 | QString::fromStdString(Settings::values.audio_input_device_id.GetValue()); |
| 136 | for (int index = 0; index < input_device_combo_box->count(); index++) { | 216 | for (int index = 0; index < input_device_combo_box->count(); index++) { |
| @@ -149,15 +229,12 @@ void ConfigureAudio::ApplyConfiguration() { | |||
| 149 | apply_func(is_powered_on); | 229 | apply_func(is_powered_on); |
| 150 | } | 230 | } |
| 151 | 231 | ||
| 152 | if (Settings::IsConfiguringGlobal()) { | 232 | Settings::values.sink_id.LoadString( |
| 153 | Settings::values.sink_id.LoadString( | 233 | sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString()); |
| 154 | sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString()); | 234 | Settings::values.audio_output_device_id.SetValue( |
| 155 | Settings::values.audio_output_device_id.SetValue( | 235 | output_device_combo_box->itemText(output_device_combo_box->currentIndex()).toStdString()); |
| 156 | output_device_combo_box->itemText(output_device_combo_box->currentIndex()) | 236 | Settings::values.audio_input_device_id.SetValue( |
| 157 | .toStdString()); | 237 | input_device_combo_box->itemText(input_device_combo_box->currentIndex()).toStdString()); |
| 158 | Settings::values.audio_input_device_id.SetValue( | ||
| 159 | input_device_combo_box->itemText(input_device_combo_box->currentIndex()).toStdString()); | ||
| 160 | } | ||
| 161 | } | 238 | } |
| 162 | 239 | ||
| 163 | void ConfigureAudio::changeEvent(QEvent* event) { | 240 | void ConfigureAudio::changeEvent(QEvent* event) { |
| @@ -169,6 +246,7 @@ void ConfigureAudio::changeEvent(QEvent* event) { | |||
| 169 | } | 246 | } |
| 170 | 247 | ||
| 171 | void ConfigureAudio::UpdateAudioDevices(int sink_index) { | 248 | void ConfigureAudio::UpdateAudioDevices(int sink_index) { |
| 249 | updating_devices = true; | ||
| 172 | output_device_combo_box->clear(); | 250 | output_device_combo_box->clear(); |
| 173 | output_device_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); | 251 | output_device_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); |
| 174 | 252 | ||
| @@ -183,6 +261,7 @@ void ConfigureAudio::UpdateAudioDevices(int sink_index) { | |||
| 183 | for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, true)) { | 261 | for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, true)) { |
| 184 | input_device_combo_box->addItem(QString::fromStdString(device)); | 262 | input_device_combo_box->addItem(QString::fromStdString(device)); |
| 185 | } | 263 | } |
| 264 | updating_devices = false; | ||
| 186 | } | 265 | } |
| 187 | 266 | ||
| 188 | void ConfigureAudio::InitializeAudioSinkComboBox() { | 267 | void ConfigureAudio::InitializeAudioSinkComboBox() { |
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 82d7f6524..32a2fa5f0 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h | |||
| @@ -45,7 +45,8 @@ private: | |||
| 45 | void UpdateAudioDevices(int sink_index); | 45 | void UpdateAudioDevices(int sink_index); |
| 46 | 46 | ||
| 47 | void SetOutputSinkFromSinkID(); | 47 | void SetOutputSinkFromSinkID(); |
| 48 | void SetAudioDevicesFromDeviceID(); | 48 | void SetOutputDevicesFromDeviceID(); |
| 49 | void SetInputDevicesFromDeviceID(); | ||
| 49 | 50 | ||
| 50 | void Setup(const ConfigurationShared::Builder& builder); | 51 | void Setup(const ConfigurationShared::Builder& builder); |
| 51 | 52 | ||
| @@ -55,7 +56,11 @@ private: | |||
| 55 | 56 | ||
| 56 | std::vector<std::function<void(bool)>> apply_funcs{}; | 57 | std::vector<std::function<void(bool)>> apply_funcs{}; |
| 57 | 58 | ||
| 59 | bool updating_devices = false; | ||
| 58 | QComboBox* sink_combo_box; | 60 | QComboBox* sink_combo_box; |
| 61 | QPushButton* restore_sink_button; | ||
| 59 | QComboBox* output_device_combo_box; | 62 | QComboBox* output_device_combo_box; |
| 63 | QPushButton* restore_output_device_button; | ||
| 60 | QComboBox* input_device_combo_box; | 64 | QComboBox* input_device_combo_box; |
| 65 | QPushButton* restore_input_device_button; | ||
| 61 | }; | 66 | }; |