summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/settings.h12
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp2
-rw-r--r--src/core/hle/service/cmif_serialization.h6
-rw-r--r--src/core/hle/service/hid/hid_server.cpp45
-rw-r--r--src/core/hle/service/hid/hid_server.h5
-rw-r--r--src/hid_core/hid_types.h5
-rw-r--r--src/hid_core/resources/npad/npad.cpp11
-rw-r--r--src/hid_core/resources/npad/npad.h2
-rw-r--r--src/yuzu/configuration/configure_audio.cpp117
-rw-r--r--src/yuzu/configuration/configure_audio.h7
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 {
Linkage linkage{};
// Audio
- Setting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio,
- Specialization::RuntimeList};
- Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio,
- Specialization::RuntimeList};
- Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio,
- Specialization::RuntimeList};
+ SwitchableSetting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine",
+ Category::Audio, Specialization::RuntimeList};
+ SwitchableSetting<std::string> audio_output_device_id{
+ linkage, "auto", "output_device", Category::Audio, Specialization::RuntimeList};
+ SwitchableSetting<std::string> audio_input_device_id{
+ linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList};
SwitchableSetting<AudioMode, true> sound_index{
linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround,
"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) {
LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
process_id);
- const auto current = system.GetApplicationProcessProgramID();
+ const auto current = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID());
std::vector<u32> out;
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
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex + 1, InBufferIndex, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InLargeData) {
- constexpr size_t BufferSize = sizeof(ArgType);
+ constexpr size_t BufferSize = sizeof(typename ArgType::Type);
// Clear the existing data.
std::memset(&std::get<ArgIndex>(args), 0, BufferSize);
@@ -324,7 +324,7 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex + 1, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) {
- constexpr size_t BufferSize = sizeof(ArgType);
+ constexpr size_t BufferSize = sizeof(typename ArgType::Type);
// Clear the existing data.
std::memset(&std::get<ArgIndex>(args).raw, 0, BufferSize);
@@ -394,7 +394,7 @@ void WriteOutArgument(bool is_domain, CallArguments& args, u8* raw_data, HLERequ
return WriteOutArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::OutLargeData) {
- constexpr size_t BufferSize = sizeof(ArgType);
+ constexpr size_t BufferSize = sizeof(typename ArgType::Type);
ASSERT(ctx.CanWriteBuffer(OutBufferIndex));
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 @@
#include "core/hle/kernel/k_shared_memory.h"
#include "core/hle/kernel/k_transfer_memory.h"
#include "core/hle/kernel/kernel.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/hid/hid_server.h"
#include "core/hle/service/ipc_helpers.h"
#include "core/memory.h"
@@ -153,7 +154,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{104, &IHidServer::DeactivateNpad, "DeactivateNpad"},
{106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"},
{107, &IHidServer::DisconnectNpad, "DisconnectNpad"},
- {108, &IHidServer::GetPlayerLedPattern, "GetPlayerLedPattern"},
+ {108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"},
{109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"},
{120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
{121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
@@ -1136,19 +1137,39 @@ void IHidServer::DisconnectNpad(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
-void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()};
-
- Core::HID::LedPattern pattern{0, 0, 0, 0};
- auto controller = GetResourceManager()->GetNpad();
- const auto result = controller->GetLedPattern(npad_id, pattern);
-
+Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
+ Core::HID::NpadIdType npad_id) {
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push(pattern.raw);
+ switch (npad_id) {
+ case Core::HID::NpadIdType::Player1:
+ *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 0};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player2:
+ *out_led_pattern = Core::HID::LedPattern{1, 1, 0, 0};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player3:
+ *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 0};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player4:
+ *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 1};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player5:
+ *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 1};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player6:
+ *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 0};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player7:
+ *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 1};
+ R_SUCCEED();
+ case Core::HID::NpadIdType::Player8:
+ *out_led_pattern = Core::HID::LedPattern{0, 1, 1, 0};
+ R_SUCCEED();
+ default:
+ *out_led_pattern = Core::HID::LedPattern{0, 0, 0, 0};
+ R_SUCCEED();
+ }
}
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 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
+#include "hid_core/hid_types.h"
namespace Core {
class System;
@@ -66,7 +68,8 @@ private:
void DeactivateNpad(HLERequestContext& ctx);
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
void DisconnectNpad(HLERequestContext& ctx);
- void GetPlayerLedPattern(HLERequestContext& ctx);
+ Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
+ Core::HID::NpadIdType npad_id);
void ActivateNpadWithRevision(HLERequestContext& ctx);
void SetNpadJoyHoldType(HLERequestContext& ctx);
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 {
static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size");
struct LedPattern {
- explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) {
+ LedPattern() {
+ raw = 0;
+ }
+ LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) {
position1.Assign(light1);
position2.Assign(light2);
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,
return ResultSuccess;
}
-Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const {
- if (!IsNpadIdValid(npad_id)) {
- LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
- return ResultInvalidNpadId;
- }
- const auto aruid = applet_resource_holder.applet_resource->GetActiveAruid();
- const auto& controller = GetControllerFromNpadIdType(aruid, npad_id).device;
- pattern = controller->GetLedPattern();
- return ResultSuccess;
-}
-
Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
Core::HID::NpadIdType npad_id) const {
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:
Result ResetIsSixAxisSensorDeviceNewlyAssigned(
u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle);
- Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
-
Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
Core::HID::NpadIdType npad_id) const;
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 @@
#include <memory>
#include <vector>
#include <QComboBox>
+#include <QPushButton>
#include "audio_core/sink/sink.h"
#include "audio_core/sink/sink_details.h"
@@ -67,19 +68,99 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
hold.emplace(std::pair{setting->Id(), widget});
+ auto global_sink_match = [this] {
+ return static_cast<Settings::AudioEngine>(sink_combo_box->currentIndex()) ==
+ Settings::values.sink_id.GetValue(true);
+ };
if (setting->Id() == Settings::values.sink_id.Id()) {
// TODO (lat9nq): Let the system manage sink_id
sink_combo_box = widget->combobox;
InitializeAudioSinkComboBox();
- connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
- &ConfigureAudio::UpdateAudioDevices);
+ if (Settings::IsConfiguringGlobal()) {
+ connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
+ &ConfigureAudio::UpdateAudioDevices);
+ } else {
+ restore_sink_button = ConfigurationShared::Widget::CreateRestoreGlobalButton(
+ Settings::values.sink_id.UsingGlobal(), widget);
+ widget->layout()->addWidget(restore_sink_button);
+ connect(restore_sink_button, &QAbstractButton::clicked, [this](bool) {
+ Settings::values.sink_id.SetGlobal(true);
+ const int sink_index = static_cast<int>(Settings::values.sink_id.GetValue());
+ sink_combo_box->setCurrentIndex(sink_index);
+ ConfigureAudio::UpdateAudioDevices(sink_index);
+ Settings::values.audio_output_device_id.SetGlobal(true);
+ Settings::values.audio_input_device_id.SetGlobal(true);
+ restore_sink_button->setVisible(false);
+ });
+ connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged),
+ [this, global_sink_match](const int slot) {
+ Settings::values.sink_id.SetGlobal(false);
+ Settings::values.audio_output_device_id.SetGlobal(false);
+ Settings::values.audio_input_device_id.SetGlobal(false);
+
+ restore_sink_button->setVisible(true);
+ restore_sink_button->setEnabled(true);
+ output_device_combo_box->setCurrentIndex(0);
+ restore_output_device_button->setVisible(true);
+ restore_output_device_button->setEnabled(global_sink_match());
+ input_device_combo_box->setCurrentIndex(0);
+ restore_input_device_button->setVisible(true);
+ restore_input_device_button->setEnabled(global_sink_match());
+ ConfigureAudio::UpdateAudioDevices(slot);
+ });
+ }
} else if (setting->Id() == Settings::values.audio_output_device_id.Id()) {
// Keep track of output (and input) device comboboxes to populate them with system
// devices, which are determined at run time
output_device_combo_box = widget->combobox;
+
+ if (!Settings::IsConfiguringGlobal()) {
+ restore_output_device_button =
+ ConfigurationShared::Widget::CreateRestoreGlobalButton(
+ Settings::values.audio_output_device_id.UsingGlobal(), widget);
+ restore_output_device_button->setEnabled(global_sink_match());
+ restore_output_device_button->setVisible(
+ !Settings::values.audio_output_device_id.UsingGlobal());
+ widget->layout()->addWidget(restore_output_device_button);
+ connect(restore_output_device_button, &QAbstractButton::clicked, [this](bool) {
+ Settings::values.audio_output_device_id.SetGlobal(true);
+ SetOutputDevicesFromDeviceID();
+ restore_output_device_button->setVisible(false);
+ });
+ connect(output_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged),
+ [this, global_sink_match](int) {
+ if (updating_devices) {
+ return;
+ }
+ Settings::values.audio_output_device_id.SetGlobal(false);
+ restore_output_device_button->setVisible(true);
+ restore_output_device_button->setEnabled(global_sink_match());
+ });
+ }
} else if (setting->Id() == Settings::values.audio_input_device_id.Id()) {
input_device_combo_box = widget->combobox;
+
+ if (!Settings::IsConfiguringGlobal()) {
+ restore_input_device_button =
+ ConfigurationShared::Widget::CreateRestoreGlobalButton(
+ Settings::values.audio_input_device_id.UsingGlobal(), widget);
+ widget->layout()->addWidget(restore_input_device_button);
+ connect(restore_input_device_button, &QAbstractButton::clicked, [this](bool) {
+ Settings::values.audio_input_device_id.SetGlobal(true);
+ SetInputDevicesFromDeviceID();
+ restore_input_device_button->setVisible(false);
+ });
+ connect(input_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged),
+ [this, global_sink_match](int) {
+ if (updating_devices) {
+ return;
+ }
+ Settings::values.audio_input_device_id.SetGlobal(false);
+ restore_input_device_button->setVisible(true);
+ restore_input_device_button->setEnabled(global_sink_match());
+ });
+ }
}
}
@@ -89,16 +170,13 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
}
void ConfigureAudio::SetConfiguration() {
- if (!Settings::IsConfiguringGlobal()) {
- return;
- }
-
SetOutputSinkFromSinkID();
// The device list cannot be pre-populated (nor listed) until the output sink is known.
UpdateAudioDevices(sink_combo_box->currentIndex());
- SetAudioDevicesFromDeviceID();
+ SetOutputDevicesFromDeviceID();
+ SetInputDevicesFromDeviceID();
}
void ConfigureAudio::SetOutputSinkFromSinkID() {
@@ -116,8 +194,8 @@ void ConfigureAudio::SetOutputSinkFromSinkID() {
sink_combo_box->setCurrentIndex(new_sink_index);
}
-void ConfigureAudio::SetAudioDevicesFromDeviceID() {
- int new_device_index = -1;
+void ConfigureAudio::SetOutputDevicesFromDeviceID() {
+ int new_device_index = 0;
const QString output_device_id =
QString::fromStdString(Settings::values.audio_output_device_id.GetValue());
@@ -129,8 +207,10 @@ void ConfigureAudio::SetAudioDevicesFromDeviceID() {
}
output_device_combo_box->setCurrentIndex(new_device_index);
+}
- new_device_index = -1;
+void ConfigureAudio::SetInputDevicesFromDeviceID() {
+ int new_device_index = 0;
const QString input_device_id =
QString::fromStdString(Settings::values.audio_input_device_id.GetValue());
for (int index = 0; index < input_device_combo_box->count(); index++) {
@@ -149,15 +229,12 @@ void ConfigureAudio::ApplyConfiguration() {
apply_func(is_powered_on);
}
- if (Settings::IsConfiguringGlobal()) {
- Settings::values.sink_id.LoadString(
- sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString());
- Settings::values.audio_output_device_id.SetValue(
- output_device_combo_box->itemText(output_device_combo_box->currentIndex())
- .toStdString());
- Settings::values.audio_input_device_id.SetValue(
- input_device_combo_box->itemText(input_device_combo_box->currentIndex()).toStdString());
- }
+ Settings::values.sink_id.LoadString(
+ sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString());
+ Settings::values.audio_output_device_id.SetValue(
+ output_device_combo_box->itemText(output_device_combo_box->currentIndex()).toStdString());
+ Settings::values.audio_input_device_id.SetValue(
+ input_device_combo_box->itemText(input_device_combo_box->currentIndex()).toStdString());
}
void ConfigureAudio::changeEvent(QEvent* event) {
@@ -169,6 +246,7 @@ void ConfigureAudio::changeEvent(QEvent* event) {
}
void ConfigureAudio::UpdateAudioDevices(int sink_index) {
+ updating_devices = true;
output_device_combo_box->clear();
output_device_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name));
@@ -183,6 +261,7 @@ void ConfigureAudio::UpdateAudioDevices(int sink_index) {
for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, true)) {
input_device_combo_box->addItem(QString::fromStdString(device));
}
+ updating_devices = false;
}
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:
void UpdateAudioDevices(int sink_index);
void SetOutputSinkFromSinkID();
- void SetAudioDevicesFromDeviceID();
+ void SetOutputDevicesFromDeviceID();
+ void SetInputDevicesFromDeviceID();
void Setup(const ConfigurationShared::Builder& builder);
@@ -55,7 +56,11 @@ private:
std::vector<std::function<void(bool)>> apply_funcs{};
+ bool updating_devices = false;
QComboBox* sink_combo_box;
+ QPushButton* restore_sink_button;
QComboBox* output_device_combo_box;
+ QPushButton* restore_output_device_button;
QComboBox* input_device_combo_box;
+ QPushButton* restore_input_device_button;
};