diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-01-26 15:55:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 15:55:47 +0100 |
commit | 4d206d849ec0ac2e90226eb67d90b310afd0a269 (patch) | |
tree | bb292c61287e988e13dfd5feaecaa6503d932baf /src/hid_core | |
parent | Merge pull request #12801 from german77/vibration-fix (diff) | |
parent | service: set: Implement more settings functions for Qlaunch (diff) | |
download | yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.gz yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.bz2 yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.lz yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.xz yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.zst yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.zip |
Diffstat (limited to 'src/hid_core')
-rw-r--r-- | src/hid_core/resource_manager.cpp | 8 | ||||
-rw-r--r-- | src/hid_core/resources/hid_firmware_settings.cpp | 12 | ||||
-rw-r--r-- | src/hid_core/resources/hid_firmware_settings.h | 3 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad.cpp | 5 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad.h | 7 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad_vibration.cpp | 36 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad_vibration.h | 7 |
7 files changed, 62 insertions, 16 deletions
diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index 8ef0df020..a2295219a 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -6,6 +6,8 @@ #include "core/core_timing.h" #include "core/hle/kernel/k_shared_memory.h" #include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/set/system_settings_server.h" +#include "core/hle/service/sm/sm.h" #include "hid_core/hid_core.h" #include "hid_core/hid_util.h" #include "hid_core/resource_manager.h" @@ -180,7 +182,11 @@ void ResourceManager::InitializeHidCommonSampler() { debug_pad->SetAppletResource(applet_resource, &shared_mutex); digitizer->SetAppletResource(applet_resource, &shared_mutex); keyboard->SetAppletResource(applet_resource, &shared_mutex); - npad->SetNpadExternals(applet_resource, &shared_mutex, handheld_config); + + const auto settings = + system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys"); + npad->SetNpadExternals(applet_resource, &shared_mutex, handheld_config, settings); + six_axis->SetAppletResource(applet_resource, &shared_mutex); mouse->SetAppletResource(applet_resource, &shared_mutex); debug_mouse->SetAppletResource(applet_resource, &shared_mutex); diff --git a/src/hid_core/resources/hid_firmware_settings.cpp b/src/hid_core/resources/hid_firmware_settings.cpp index 00ceff7e6..9c9019e8f 100644 --- a/src/hid_core/resources/hid_firmware_settings.cpp +++ b/src/hid_core/resources/hid_firmware_settings.cpp @@ -40,6 +40,13 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) { m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug", "touch_firmware_auto_update_disabled"); + bool has_rail_interface{}; + bool has_sio_mcu{}; + m_set_sys->GetSettingsItemValue<bool>(has_rail_interface, "hid", "has_rail_interface"); + m_set_sys->GetSettingsItemValue<bool>(has_sio_mcu, "hid", "has_sio_mcu"); + platform_config.has_rail_interface.Assign(has_rail_interface); + platform_config.has_sio_mcu.Assign(has_sio_mcu); + is_initialized = true; } @@ -103,4 +110,9 @@ HidFirmwareSettings::FeaturesPerId HidFirmwareSettings::FeaturesDisabledPerId() return features_per_id_disabled; } +Set::PlatformConfig HidFirmwareSettings::GetPlatformConfig() { + LoadSettings(false); + return platform_config; +} + } // namespace Service::HID diff --git a/src/hid_core/resources/hid_firmware_settings.h b/src/hid_core/resources/hid_firmware_settings.h index 3694fa9a3..7f146f1e6 100644 --- a/src/hid_core/resources/hid_firmware_settings.h +++ b/src/hid_core/resources/hid_firmware_settings.h @@ -4,6 +4,7 @@ #pragma once #include "common/common_types.h" +#include "core/hle/service/set/settings_types.h" namespace Core { class System; @@ -39,6 +40,7 @@ public: FirmwareSetting GetFirmwareUpdateFailure(); FeaturesPerId FeaturesDisabledPerId(); + Set::PlatformConfig GetPlatformConfig(); private: bool is_initialized{}; @@ -57,6 +59,7 @@ private: bool is_touch_firmware_auto_update_disabled{}; FirmwareSetting is_firmware_update_failure{}; FeaturesPerId features_per_id_disabled{}; + Set::PlatformConfig platform_config{}; std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; }; diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index d13a489c9..cde84b1bb 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -1080,12 +1080,15 @@ void NPad::UnregisterAppletResourceUserId(u64 aruid) { void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource, std::recursive_mutex* shared_mutex, - std::shared_ptr<HandheldConfig> handheld_config) { + std::shared_ptr<HandheldConfig> handheld_config, + std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { applet_resource_holder.applet_resource = resource; applet_resource_holder.shared_mutex = shared_mutex; applet_resource_holder.shared_npad_resource = &npad_resource; applet_resource_holder.handheld_config = handheld_config; + vibration_handler.SetSettingsService(settings); + for (auto& abstract_pad : abstracted_pads) { abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr, &vibration_handler, &hid_core); diff --git a/src/hid_core/resources/npad/npad.h b/src/hid_core/resources/npad/npad.h index 88289fa2b..502cb9b55 100644 --- a/src/hid_core/resources/npad/npad.h +++ b/src/hid_core/resources/npad/npad.h @@ -34,6 +34,10 @@ namespace Service::KernelHelpers { class ServiceContext; } // namespace Service::KernelHelpers +namespace Service::Set { +class ISystemSettingsServer; +} + union Result; namespace Service::HID { @@ -128,7 +132,8 @@ public: void UnregisterAppletResourceUserId(u64 aruid); void SetNpadExternals(std::shared_ptr<AppletResource> resource, std::recursive_mutex* shared_mutex, - std::shared_ptr<HandheldConfig> handheld_config); + std::shared_ptr<HandheldConfig> handheld_config, + std::shared_ptr<Service::Set::ISystemSettingsServer> settings); AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); diff --git a/src/hid_core/resources/npad/npad_vibration.cpp b/src/hid_core/resources/npad/npad_vibration.cpp index 05aad4c54..02b1f0290 100644 --- a/src/hid_core/resources/npad/npad_vibration.cpp +++ b/src/hid_core/resources/npad/npad_vibration.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include "core/hle/service/set/system_settings_server.h" #include "hid_core/hid_result.h" #include "hid_core/resources/npad/npad_vibration.h" @@ -13,10 +14,11 @@ NpadVibration::~NpadVibration() = default; Result NpadVibration::Activate() { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } volume = master_volume; return ResultSuccess; @@ -26,6 +28,12 @@ Result NpadVibration::Deactivate() { return ResultSuccess; } +Result NpadVibration::SetSettingsService( + std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { + m_set_sys = settings; + return ResultSuccess; +} + Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { std::scoped_lock lock{mutex}; @@ -34,7 +42,7 @@ Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { } volume = master_volume; - // nn::settings::system::SetVibrationMasterVolume(master_volume); + m_set_sys->SetVibrationMasterVolume(master_volume); return ResultSuccess; } @@ -48,10 +56,11 @@ Result NpadVibration::GetVibrationVolume(f32& out_volume) const { Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } out_volume = master_volume; return ResultSuccess; @@ -67,10 +76,11 @@ Result NpadVibration::BeginPermitVibrationSession(u64 aruid) { Result NpadVibration::EndPermitVibrationSession() { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } volume = master_volume; session_aruid = 0; diff --git a/src/hid_core/resources/npad/npad_vibration.h b/src/hid_core/resources/npad/npad_vibration.h index d5a95f2a0..6412ca4ab 100644 --- a/src/hid_core/resources/npad/npad_vibration.h +++ b/src/hid_core/resources/npad/npad_vibration.h @@ -8,6 +8,10 @@ #include "common/common_types.h" #include "core/hle/result.h" +namespace Service::Set { +class ISystemSettingsServer; +} + namespace Service::HID { class NpadVibration final { @@ -18,6 +22,7 @@ public: Result Activate(); Result Deactivate(); + Result SetSettingsService(std::shared_ptr<Service::Set::ISystemSettingsServer> settings); Result SetVibrationMasterVolume(f32 master_volume); Result GetVibrationVolume(f32& out_volume) const; Result GetVibrationMasterVolume(f32& out_volume) const; @@ -31,6 +36,8 @@ private: f32 volume{}; u64 session_aruid{}; mutable std::mutex mutex; + + std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; }; } // namespace Service::HID |