summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/glue/time/manager.cpp7
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp17
-rw-r--r--src/hid_core/frontend/emulated_controller.h1
-rw-r--r--src/hid_core/hid_types.h6
-rw-r--r--src/hid_core/resources/npad/npad.cpp1
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) {
51} 51}
52 52
53s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) { 53s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) {
54 s32 year{2000};
55 set_sys->GetSettingsItemValueImpl(year, "time", "standard_user_clock_initial_year");
56
54 Service::PSC::Time::CalendarTime calendar{ 57 Service::PSC::Time::CalendarTime calendar{
55 .year = 2000, 58 .year = static_cast<s16>(year),
56 .month = 1, 59 .month = 1,
57 .day = 1, 60 .day = 1,
58 .hour = 0, 61 .hour = 0,
59 .minute = 0, 62 .minute = 0,
60 .second = 0, 63 .second = 0,
61 }; 64 };
62 set_sys->GetSettingsItemValueImpl<s16>(calendar.year, "time",
63 "standard_user_clock_initial_year");
64 return CalendarTimeToEpoch(calendar); 65 return CalendarTimeToEpoch(calendar);
65} 66}
66 67
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 @@
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"
@@ -1286,6 +1287,22 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1286 return false; 1287 return false;
1287 } 1288 }
1288 1289
1290 if (!Settings::values.enable_accurate_vibrations.GetValue()) {
1291 using std::chrono::duration_cast;
1292 using std::chrono::milliseconds;
1293 using std::chrono::steady_clock;
1294
1295 const auto now = steady_clock::now();
1296
1297 // Filter out non-zero vibrations that are within 15ms of each other.
1298 if ((vibration.low_amplitude != 0.0f || vibration.high_amplitude != 0.0f) &&
1299 duration_cast<milliseconds>(now - last_vibration_timepoint[index]) < milliseconds(15)) {
1300 return false;
1301 }
1302
1303 last_vibration_timepoint[index] = now;
1304 }
1305
1289 // Exponential amplification is too strong at low amplitudes. Switch to a linear 1306 // Exponential amplification is too strong at low amplitudes. Switch to a linear
1290 // amplification if strength is set below 0.7f 1307 // amplification if strength is set below 0.7f
1291 const Common::Input::VibrationAmplificationType type = 1308 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:
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 100644
--- 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 100644
--- 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"