diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/glue/time/manager.cpp | 7 | ||||
-rw-r--r-- | src/hid_core/frontend/emulated_controller.cpp | 17 | ||||
-rw-r--r-- | src/hid_core/frontend/emulated_controller.h | 1 | ||||
-rw-r--r-- | src/hid_core/hid_types.h | 6 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad.cpp | 1 |
5 files changed, 27 insertions, 5 deletions
diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp index 059ac3fc9..cb88486dd 100644 --- a/src/core/hle/service/glue/time/manager.cpp +++ b/src/core/hle/service/glue/time/manager.cpp @@ -51,16 +51,17 @@ s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) { } s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) { + s32 year{2000}; + set_sys->GetSettingsItemValueImpl(year, "time", "standard_user_clock_initial_year"); + Service::PSC::Time::CalendarTime calendar{ - .year = 2000, + .year = static_cast<s16>(year), .month = 1, .day = 1, .hour = 0, .minute = 0, .second = 0, }; - set_sys->GetSettingsItemValueImpl<s16>(calendar.year, "time", - "standard_user_clock_initial_year"); return CalendarTimeToEpoch(calendar); } diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index 0e93fb4de..9aa08d5cc 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <algorithm> +#include <chrono> #include <common/scope_exit.h> #include "common/polyfill_ranges.h" @@ -1286,6 +1287,22 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV return false; } + if (!Settings::values.enable_accurate_vibrations.GetValue()) { + using std::chrono::duration_cast; + using std::chrono::milliseconds; + using std::chrono::steady_clock; + + const auto now = steady_clock::now(); + + // Filter out non-zero vibrations that are within 15ms of each other. + if ((vibration.low_amplitude != 0.0f || vibration.high_amplitude != 0.0f) && + duration_cast<milliseconds>(now - last_vibration_timepoint[index]) < milliseconds(15)) { + return false; + } + + last_vibration_timepoint[index] = now; + } + // Exponential amplification is too strong at low amplitudes. Switch to a linear // amplification if strength is set below 0.7f 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 100644 --- a/src/hid_core/frontend/emulated_controller.h +++ b/src/hid_core/frontend/emulated_controller.h @@ -583,6 +583,7 @@ private: std::size_t nfc_handles{0}; std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE, DEFAULT_VIBRATION_VALUE}; + std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{}; // Temporary values to avoid doing changes while the controller is in configuring mode 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 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h @@ -638,7 +638,11 @@ struct VibrationValue { if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) { return false; } - if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) { + // Changes in frequency without amplitude don't have any effect + if (low_amplitude == 0 && high_amplitude == 0) { + return true; + } + if (low_frequency != b.low_frequency || high_frequency != b.high_frequency) { return false; } return true; diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index e10e97e1c..ca1ccd659 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -3,7 +3,6 @@ #include <algorithm> #include <array> -#include <chrono> #include <cstring> #include "common/assert.h" |