diff options
| author | 2024-01-22 23:30:34 -0600 | |
|---|---|---|
| committer | 2024-01-25 17:14:18 -0600 | |
| commit | 53b321c945d7e6782a6011b7ee55035da8f54dbc (patch) | |
| tree | ab538a4d934f71453bd4b16a929599ae5f525668 /src/hid_core/resources | |
| parent | Merge pull request #12759 from liamwhite/mp-misc (diff) | |
| download | yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.gz yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.xz yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.zip | |
service: set: Implement more settings functions for Qlaunch
Diffstat (limited to 'src/hid_core/resources')
| -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 |
6 files changed, 55 insertions, 15 deletions
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) { | |||
| 40 | m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug", | 40 | m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug", |
| 41 | "touch_firmware_auto_update_disabled"); | 41 | "touch_firmware_auto_update_disabled"); |
| 42 | 42 | ||
| 43 | bool has_rail_interface{}; | ||
| 44 | bool has_sio_mcu{}; | ||
| 45 | m_set_sys->GetSettingsItemValue<bool>(has_rail_interface, "hid", "has_rail_interface"); | ||
| 46 | m_set_sys->GetSettingsItemValue<bool>(has_sio_mcu, "hid", "has_sio_mcu"); | ||
| 47 | platform_config.has_rail_interface.Assign(has_rail_interface); | ||
| 48 | platform_config.has_sio_mcu.Assign(has_sio_mcu); | ||
| 49 | |||
| 43 | is_initialized = true; | 50 | is_initialized = true; |
| 44 | } | 51 | } |
| 45 | 52 | ||
| @@ -103,4 +110,9 @@ HidFirmwareSettings::FeaturesPerId HidFirmwareSettings::FeaturesDisabledPerId() | |||
| 103 | return features_per_id_disabled; | 110 | return features_per_id_disabled; |
| 104 | } | 111 | } |
| 105 | 112 | ||
| 113 | Set::PlatformConfig HidFirmwareSettings::GetPlatformConfig() { | ||
| 114 | LoadSettings(false); | ||
| 115 | return platform_config; | ||
| 116 | } | ||
| 117 | |||
| 106 | } // namespace Service::HID | 118 | } // 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 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | 6 | #include "common/common_types.h" |
| 7 | #include "core/hle/service/set/settings_types.h" | ||
| 7 | 8 | ||
| 8 | namespace Core { | 9 | namespace Core { |
| 9 | class System; | 10 | class System; |
| @@ -39,6 +40,7 @@ public: | |||
| 39 | 40 | ||
| 40 | FirmwareSetting GetFirmwareUpdateFailure(); | 41 | FirmwareSetting GetFirmwareUpdateFailure(); |
| 41 | FeaturesPerId FeaturesDisabledPerId(); | 42 | FeaturesPerId FeaturesDisabledPerId(); |
| 43 | Set::PlatformConfig GetPlatformConfig(); | ||
| 42 | 44 | ||
| 43 | private: | 45 | private: |
| 44 | bool is_initialized{}; | 46 | bool is_initialized{}; |
| @@ -57,6 +59,7 @@ private: | |||
| 57 | bool is_touch_firmware_auto_update_disabled{}; | 59 | bool is_touch_firmware_auto_update_disabled{}; |
| 58 | FirmwareSetting is_firmware_update_failure{}; | 60 | FirmwareSetting is_firmware_update_failure{}; |
| 59 | FeaturesPerId features_per_id_disabled{}; | 61 | FeaturesPerId features_per_id_disabled{}; |
| 62 | Set::PlatformConfig platform_config{}; | ||
| 60 | 63 | ||
| 61 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; | 64 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; |
| 62 | }; | 65 | }; |
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) { | |||
| 1080 | 1080 | ||
| 1081 | void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource, | 1081 | void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource, |
| 1082 | std::recursive_mutex* shared_mutex, | 1082 | std::recursive_mutex* shared_mutex, |
| 1083 | std::shared_ptr<HandheldConfig> handheld_config) { | 1083 | std::shared_ptr<HandheldConfig> handheld_config, |
| 1084 | std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { | ||
| 1084 | applet_resource_holder.applet_resource = resource; | 1085 | applet_resource_holder.applet_resource = resource; |
| 1085 | applet_resource_holder.shared_mutex = shared_mutex; | 1086 | applet_resource_holder.shared_mutex = shared_mutex; |
| 1086 | applet_resource_holder.shared_npad_resource = &npad_resource; | 1087 | applet_resource_holder.shared_npad_resource = &npad_resource; |
| 1087 | applet_resource_holder.handheld_config = handheld_config; | 1088 | applet_resource_holder.handheld_config = handheld_config; |
| 1088 | 1089 | ||
| 1090 | vibration_handler.SetSettingsService(settings); | ||
| 1091 | |||
| 1089 | for (auto& abstract_pad : abstracted_pads) { | 1092 | for (auto& abstract_pad : abstracted_pads) { |
| 1090 | abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr, | 1093 | abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr, |
| 1091 | &vibration_handler, &hid_core); | 1094 | &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 { | |||
| 34 | class ServiceContext; | 34 | class ServiceContext; |
| 35 | } // namespace Service::KernelHelpers | 35 | } // namespace Service::KernelHelpers |
| 36 | 36 | ||
| 37 | namespace Service::Set { | ||
| 38 | class ISystemSettingsServer; | ||
| 39 | } | ||
| 40 | |||
| 37 | union Result; | 41 | union Result; |
| 38 | 42 | ||
| 39 | namespace Service::HID { | 43 | namespace Service::HID { |
| @@ -128,7 +132,8 @@ public: | |||
| 128 | void UnregisterAppletResourceUserId(u64 aruid); | 132 | void UnregisterAppletResourceUserId(u64 aruid); |
| 129 | void SetNpadExternals(std::shared_ptr<AppletResource> resource, | 133 | void SetNpadExternals(std::shared_ptr<AppletResource> resource, |
| 130 | std::recursive_mutex* shared_mutex, | 134 | std::recursive_mutex* shared_mutex, |
| 131 | std::shared_ptr<HandheldConfig> handheld_config); | 135 | std::shared_ptr<HandheldConfig> handheld_config, |
| 136 | std::shared_ptr<Service::Set::ISystemSettingsServer> settings); | ||
| 132 | 137 | ||
| 133 | AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); | 138 | AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); |
| 134 | 139 | ||
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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/set/system_settings_server.h" | ||
| 4 | #include "hid_core/hid_result.h" | 5 | #include "hid_core/hid_result.h" |
| 5 | #include "hid_core/resources/npad/npad_vibration.h" | 6 | #include "hid_core/resources/npad/npad_vibration.h" |
| 6 | 7 | ||
| @@ -13,10 +14,11 @@ NpadVibration::~NpadVibration() = default; | |||
| 13 | Result NpadVibration::Activate() { | 14 | Result NpadVibration::Activate() { |
| 14 | std::scoped_lock lock{mutex}; | 15 | std::scoped_lock lock{mutex}; |
| 15 | 16 | ||
| 16 | const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); | 17 | f32 master_volume = 1.0f; |
| 17 | // if (master_volume < 0.0f || master_volume > 1.0f) { | 18 | m_set_sys->GetVibrationMasterVolume(master_volume); |
| 18 | // return ResultVibrationStrengthOutOfRange; | 19 | if (master_volume < 0.0f || master_volume > 1.0f) { |
| 19 | // } | 20 | return ResultVibrationStrengthOutOfRange; |
| 21 | } | ||
| 20 | 22 | ||
| 21 | volume = master_volume; | 23 | volume = master_volume; |
| 22 | return ResultSuccess; | 24 | return ResultSuccess; |
| @@ -26,6 +28,12 @@ Result NpadVibration::Deactivate() { | |||
| 26 | return ResultSuccess; | 28 | return ResultSuccess; |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 31 | Result NpadVibration::SetSettingsService( | ||
| 32 | std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { | ||
| 33 | m_set_sys = settings; | ||
| 34 | return ResultSuccess; | ||
| 35 | } | ||
| 36 | |||
| 29 | Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { | 37 | Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { |
| 30 | std::scoped_lock lock{mutex}; | 38 | std::scoped_lock lock{mutex}; |
| 31 | 39 | ||
| @@ -34,7 +42,7 @@ Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { | |||
| 34 | } | 42 | } |
| 35 | 43 | ||
| 36 | volume = master_volume; | 44 | volume = master_volume; |
| 37 | // nn::settings::system::SetVibrationMasterVolume(master_volume); | 45 | m_set_sys->SetVibrationMasterVolume(master_volume); |
| 38 | 46 | ||
| 39 | return ResultSuccess; | 47 | return ResultSuccess; |
| 40 | } | 48 | } |
| @@ -48,10 +56,11 @@ Result NpadVibration::GetVibrationVolume(f32& out_volume) const { | |||
| 48 | Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { | 56 | Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { |
| 49 | std::scoped_lock lock{mutex}; | 57 | std::scoped_lock lock{mutex}; |
| 50 | 58 | ||
| 51 | const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); | 59 | f32 master_volume = 1.0f; |
| 52 | // if (master_volume < 0.0f || master_volume > 1.0f) { | 60 | m_set_sys->GetVibrationMasterVolume(master_volume); |
| 53 | // return ResultVibrationStrengthOutOfRange; | 61 | if (master_volume < 0.0f || master_volume > 1.0f) { |
| 54 | // } | 62 | return ResultVibrationStrengthOutOfRange; |
| 63 | } | ||
| 55 | 64 | ||
| 56 | out_volume = master_volume; | 65 | out_volume = master_volume; |
| 57 | return ResultSuccess; | 66 | return ResultSuccess; |
| @@ -67,10 +76,11 @@ Result NpadVibration::BeginPermitVibrationSession(u64 aruid) { | |||
| 67 | Result NpadVibration::EndPermitVibrationSession() { | 76 | Result NpadVibration::EndPermitVibrationSession() { |
| 68 | std::scoped_lock lock{mutex}; | 77 | std::scoped_lock lock{mutex}; |
| 69 | 78 | ||
| 70 | const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); | 79 | f32 master_volume = 1.0f; |
| 71 | // if (master_volume < 0.0f || master_volume > 1.0f) { | 80 | m_set_sys->GetVibrationMasterVolume(master_volume); |
| 72 | // return ResultVibrationStrengthOutOfRange; | 81 | if (master_volume < 0.0f || master_volume > 1.0f) { |
| 73 | // } | 82 | return ResultVibrationStrengthOutOfRange; |
| 83 | } | ||
| 74 | 84 | ||
| 75 | volume = master_volume; | 85 | volume = master_volume; |
| 76 | session_aruid = 0; | 86 | 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 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/hle/result.h" | 9 | #include "core/hle/result.h" |
| 10 | 10 | ||
| 11 | namespace Service::Set { | ||
| 12 | class ISystemSettingsServer; | ||
| 13 | } | ||
| 14 | |||
| 11 | namespace Service::HID { | 15 | namespace Service::HID { |
| 12 | 16 | ||
| 13 | class NpadVibration final { | 17 | class NpadVibration final { |
| @@ -18,6 +22,7 @@ public: | |||
| 18 | Result Activate(); | 22 | Result Activate(); |
| 19 | Result Deactivate(); | 23 | Result Deactivate(); |
| 20 | 24 | ||
| 25 | Result SetSettingsService(std::shared_ptr<Service::Set::ISystemSettingsServer> settings); | ||
| 21 | Result SetVibrationMasterVolume(f32 master_volume); | 26 | Result SetVibrationMasterVolume(f32 master_volume); |
| 22 | Result GetVibrationVolume(f32& out_volume) const; | 27 | Result GetVibrationVolume(f32& out_volume) const; |
| 23 | Result GetVibrationMasterVolume(f32& out_volume) const; | 28 | Result GetVibrationMasterVolume(f32& out_volume) const; |
| @@ -31,6 +36,8 @@ private: | |||
| 31 | f32 volume{}; | 36 | f32 volume{}; |
| 32 | u64 session_aruid{}; | 37 | u64 session_aruid{}; |
| 33 | mutable std::mutex mutex; | 38 | mutable std::mutex mutex; |
| 39 | |||
| 40 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; | ||
| 34 | }; | 41 | }; |
| 35 | 42 | ||
| 36 | } // namespace Service::HID | 43 | } // namespace Service::HID |