summaryrefslogtreecommitdiffstats
path: root/src/hid_core/frontend/emulated_controller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_core/frontend/emulated_controller.cpp')
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index 5cd26819c..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"
@@ -175,10 +176,9 @@ void EmulatedController::LoadDevices() {
if (npad_id_type == NpadIdType::Player1 || npad_id_type == NpadIdType::Handheld) {
camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"};
nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
-#ifdef HAVE_LIBUSB
+#ifndef ANDROID
ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
-#endif
-#ifdef ANDROID
+#else
android_params = Common::ParamPackage{"engine:android,port:100"};
#endif
}
@@ -1287,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 =