aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpineappleEA <pineaea@gmail.com>2024-02-25 00:30:13 +0100
committerpineappleEA <pineaea@gmail.com>2024-02-25 00:30:13 +0100
commitb9d9dc3c7109dec9b529a34be8eed644bd76e722 (patch)
tree8d2470bab75ad9ed1b43052b42a18c396ac6af6f
parent0cc974af92faa015598d614f6bec7d128d714774 (diff)
early-access version 4167EA-4167
-rwxr-xr-xREADME.md2
-rwxr-xr-xsrc/core/hle/service/glue/time/worker.cpp7
-rwxr-xr-xsrc/core/hle/service/set/system_settings_server.cpp13
-rwxr-xr-xsrc/core/hle/service/set/system_settings_server.h21
-rwxr-xr-xsrc/hid_core/frontend/emulated_controller.cpp17
-rwxr-xr-xsrc/hid_core/frontend/emulated_controller.h1
-rwxr-xr-xsrc/hid_core/hid_types.h6
-rwxr-xr-xsrc/hid_core/resources/npad/npad.cpp1
8 files changed, 43 insertions, 25 deletions
diff --git a/README.md b/README.md
index d097f9fe2..c7ded9519 100755
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
1yuzu emulator early access 1yuzu emulator early access
2============= 2=============
3 3
4This is the source code for early-access 4166. 4This is the source code for early-access 4167.
5 5
6## Legal Notice 6## Legal Notice
7 7
diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp
index b28569b68..b6bbd7965 100755
--- a/src/core/hle/service/glue/time/worker.cpp
+++ b/src/core/hle/service/glue/time/worker.cpp
@@ -26,12 +26,9 @@ Service::PSC::Time::SystemClockContext g_report_ephemeral_clock_context{};
26template <typename T> 26template <typename T>
27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys, 27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
28 const char* category, const char* name) { 28 const char* category, const char* name) {
29 std::vector<u8> interval_buf;
30 auto res = set_sys->GetSettingsItemValueImpl(interval_buf, category, name);
31 ASSERT(res == ResultSuccess);
32
33 T v{}; 29 T v{};
34 std::memcpy(&v, interval_buf.data(), sizeof(T)); 30 auto res = set_sys->GetSettingsItemValueImpl(v, category, name);
31 ASSERT(res == ResultSuccess);
35 return v; 32 return v;
36} 33}
37 34
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index 6a7ea83fd..900d5408f 100755
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -308,7 +308,7 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
308 SetupSettings(); 308 SetupSettings();
309 309
310 m_system_settings.region_code = 310 m_system_settings.region_code =
311 static_cast<SystemRegionCode>(Settings::values.region_index.GetValue()); 311 static_cast<SystemRegionCode>(::Settings::values.region_index.GetValue());
312 312
313 // TODO: Remove this when starter applet is fully functional 313 // TODO: Remove this when starter applet is fully functional
314 EulaVersion eula_version{ 314 EulaVersion eula_version{
@@ -715,7 +715,7 @@ Result ISystemSettingsServer::GetSettingsItemValueSize(
715} 715}
716 716
717Result ISystemSettingsServer::GetSettingsItemValue( 717Result ISystemSettingsServer::GetSettingsItemValue(
718 OutBuffer<BufferAttr_HipcMapAlias> out_data, 718 Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
719 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 719 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
720 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) { 720 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) {
721 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)}; 721 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)};
@@ -723,7 +723,7 @@ Result ISystemSettingsServer::GetSettingsItemValue(
723 723
724 LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name); 724 LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name);
725 725
726 R_RETURN(GetSettingsItemValueImpl(out_data, setting_category, setting_name)); 726 R_RETURN(GetSettingsItemValueImpl(out_data, *out_size, setting_category, setting_name));
727} 727}
728 728
729Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) { 729Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) {
@@ -1363,13 +1363,16 @@ void ISystemSettingsServer::SetSaveNeeded() {
1363 m_save_needed = true; 1363 m_save_needed = true;
1364} 1364}
1365 1365
1366Result ISystemSettingsServer::GetSettingsItemValueImpl(std::vector<u8>& out_value, 1366Result ISystemSettingsServer::GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
1367 const std::string& category, 1367 const std::string& category,
1368 const std::string& name) { 1368 const std::string& name) {
1369 auto settings{GetSettings()}; 1369 auto settings{GetSettings()};
1370 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown); 1370 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown);
1371 1371
1372 out_value = settings[category][name]; 1372 ASSERT_MSG(out_value.size() >= settings[category][name].size(),
1373 "Stored type is bigger than requested type");
1374 out_size = std::min<u64>(settings[category][name].size(), out_value.size());
1375 std::memcpy(out_value.data(), settings[category][name].data(), out_size);
1373 R_SUCCEED(); 1376 R_SUCCEED();
1374} 1377}
1375 1378
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 46e06c8ea..9a1154ad6 100755
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -34,20 +34,17 @@ public:
34 explicit ISystemSettingsServer(Core::System& system_); 34 explicit ISystemSettingsServer(Core::System& system_);
35 ~ISystemSettingsServer() override; 35 ~ISystemSettingsServer() override;
36 36
37 Result GetSettingsItemValueImpl(std::vector<u8>& out_value, const std::string& category, 37 Result GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
38 const std::string& name); 38 const std::string& category, const std::string& name);
39 39
40 template <typename T> 40 template <typename T>
41 Result GetSettingsItemValueImpl(T& value, const std::string& category, 41 Result GetSettingsItemValueImpl(T& out_value, const std::string& category,
42 const std::string& name) { 42 const std::string& name) {
43 std::vector<u8> data; 43 u64 data_size{};
44 const auto result = GetSettingsItemValueImpl(data, category, name); 44 std::vector<u8> data(sizeof(T));
45 if (result.IsError()) { 45 R_TRY(GetSettingsItemValueImpl(data, data_size, category, name));
46 return result; 46 std::memcpy(&out_value, data.data(), data_size);
47 } 47 R_SUCCEED();
48 ASSERT(data.size() >= sizeof(T));
49 std::memcpy(&value, data.data(), sizeof(T));
50 return result;
51 } 48 }
52 49
53public: 50public:
@@ -84,7 +81,7 @@ public:
84 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 81 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
85 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf); 82 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf);
86 Result GetSettingsItemValue( 83 Result GetSettingsItemValue(
87 OutBuffer<BufferAttr_HipcMapAlias> out_data, 84 Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
88 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 85 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
89 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer); 86 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer);
90 Result GetTvSettings(Out<TvSettings> out_tv_settings); 87 Result GetTvSettings(Out<TvSettings> out_tv_settings);
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index 5cd26819c..7664341bd 100755
--- a/src/hid_core/frontend/emulated_controller.cpp
+++ b/src/hid_core/frontend/emulated_controller.cpp
@@ -2,6 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <algorithm> 4#include <algorithm>
5#include <chrono>
5#include <common/scope_exit.h> 6#include <common/scope_exit.h>
6 7
7#include "common/polyfill_ranges.h" 8#include "common/polyfill_ranges.h"
@@ -1287,6 +1288,22 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1287 return false; 1288 return false;
1288 } 1289 }
1289 1290
1291 if (!Settings::values.enable_accurate_vibrations.GetValue()) {
1292 using std::chrono::duration_cast;
1293 using std::chrono::milliseconds;
1294 using std::chrono::steady_clock;
1295
1296 const auto now = steady_clock::now();
1297
1298 // Filter out non-zero vibrations that are within 15ms of each other.
1299 if ((vibration.low_amplitude != 0.0f || vibration.high_amplitude != 0.0f) &&
1300 duration_cast<milliseconds>(now - last_vibration_timepoint[index]) < milliseconds(15)) {
1301 return false;
1302 }
1303
1304 last_vibration_timepoint[index] = now;
1305 }
1306
1290 // Exponential amplification is too strong at low amplitudes. Switch to a linear 1307 // Exponential amplification is too strong at low amplitudes. Switch to a linear
1291 // amplification if strength is set below 0.7f 1308 // amplification if strength is set below 0.7f
1292 const Common::Input::VibrationAmplificationType type = 1309 const Common::Input::VibrationAmplificationType type =
diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h
index ab3c6fcd3..17ad6069e 100755
--- a/src/hid_core/frontend/emulated_controller.h
+++ b/src/hid_core/frontend/emulated_controller.h
@@ -583,6 +583,7 @@ private:
583 std::size_t nfc_handles{0}; 583 std::size_t nfc_handles{0};
584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE, 584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
585 DEFAULT_VIBRATION_VALUE}; 585 DEFAULT_VIBRATION_VALUE};
586 std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{};
586 587
587 // Temporary values to avoid doing changes while the controller is in configuring mode 588 // Temporary values to avoid doing changes while the controller is in configuring mode
588 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; 589 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h
index 1b2fc6295..38888fdd1 100755
--- a/src/hid_core/hid_types.h
+++ b/src/hid_core/hid_types.h
@@ -638,7 +638,11 @@ struct VibrationValue {
638 if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) { 638 if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) {
639 return false; 639 return false;
640 } 640 }
641 if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) { 641 // Changes in frequency without amplitude don't have any effect
642 if (low_amplitude == 0 && high_amplitude == 0) {
643 return true;
644 }
645 if (low_frequency != b.low_frequency || high_frequency != b.high_frequency) {
642 return false; 646 return false;
643 } 647 }
644 return true; 648 return true;
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp
index e10e97e1c..ca1ccd659 100755
--- a/src/hid_core/resources/npad/npad.cpp
+++ b/src/hid_core/resources/npad/npad.cpp
@@ -3,7 +3,6 @@
3 3
4#include <algorithm> 4#include <algorithm>
5#include <array> 5#include <array>
6#include <chrono>
7#include <cstring> 6#include <cstring>
8 7
9#include "common/assert.h" 8#include "common/assert.h"