summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp18
-rw-r--r--src/hid_core/frontend/emulated_controller.h3
-rw-r--r--src/hid_core/hid_types.h9
3 files changed, 26 insertions, 4 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index e12e5a77e..819460eb5 100644
--- a/src/hid_core/frontend/emulated_controller.cpp
+++ b/src/hid_core/frontend/emulated_controller.cpp
@@ -110,7 +110,11 @@ void EmulatedController::ReloadFromSettings() {
110 original_npad_type = npad_type; 110 original_npad_type = npad_type;
111 } 111 }
112 112
113 SetPollingMode(EmulatedDeviceIndex::RightIndex, Common::Input::PollingMode::Active); 113 // Disable special features before disconnecting
114 if (controller.right_polling_mode != Common::Input::PollingMode::Active) {
115 SetPollingMode(EmulatedDeviceIndex::RightIndex, Common::Input::PollingMode::Active);
116 }
117
114 Disconnect(); 118 Disconnect();
115 if (player.connected) { 119 if (player.connected) {
116 Connect(); 120 Connect();
@@ -1241,7 +1245,12 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1241 return false; 1245 return false;
1242 } 1246 }
1243 1247
1244 last_vibration_value = vibration; 1248 // Skip duplicated vibrations
1249 if (last_vibration_value[index] == vibration) {
1250 return Settings::values.vibration_enabled.GetValue();
1251 }
1252
1253 last_vibration_value[index] = vibration;
1245 1254
1246 if (!Settings::values.vibration_enabled) { 1255 if (!Settings::values.vibration_enabled) {
1247 return false; 1256 return false;
@@ -1272,7 +1281,10 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1272} 1281}
1273 1282
1274VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const { 1283VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const {
1275 return last_vibration_value; 1284 if (device_index >= DeviceIndex::MaxDeviceIndex) {
1285 return Core::HID::DEFAULT_VIBRATION_VALUE;
1286 }
1287 return last_vibration_value[static_cast<std::size_t>(device_index)];
1276} 1288}
1277 1289
1278bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { 1290bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h
index 168abe089..701b38300 100644
--- a/src/hid_core/frontend/emulated_controller.h
+++ b/src/hid_core/frontend/emulated_controller.h
@@ -581,7 +581,8 @@ private:
581 f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; 581 f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard};
582 u32 turbo_button_state{0}; 582 u32 turbo_button_state{0};
583 std::size_t nfc_handles{0}; 583 std::size_t nfc_handles{0};
584 VibrationValue last_vibration_value{DEFAULT_VIBRATION_VALUE}; 584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
585 DEFAULT_VIBRATION_VALUE};
585 586
586 // Temporary values to avoid doing changes while the controller is in configuring mode 587 // Temporary values to avoid doing changes while the controller is in configuring mode
587 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; 588 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h
index 2c3f02f34..a01292a70 100644
--- a/src/hid_core/hid_types.h
+++ b/src/hid_core/hid_types.h
@@ -639,6 +639,15 @@ struct VibrationValue {
639 f32 low_frequency{}; 639 f32 low_frequency{};
640 f32 high_amplitude{}; 640 f32 high_amplitude{};
641 f32 high_frequency{}; 641 f32 high_frequency{};
642 bool operator==(const VibrationValue& b) {
643 if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) {
644 return false;
645 }
646 if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) {
647 return false;
648 }
649 return true;
650 }
642}; 651};
643static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); 652static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");
644 653