summaryrefslogtreecommitdiff
path: root/src/hid_core/frontend
diff options
context:
space:
mode:
authorGravatar liamwhite2024-01-26 09:57:40 -0500
committerGravatar GitHub2024-01-26 09:57:40 -0500
commit4349cdba070b159181d7090a27beb794bb83e481 (patch)
tree1bd25e48ffeb2dcc0d033fdf3a900d91fa1e4360 /src/hid_core/frontend
parentMerge pull request #12809 from t895/error-message (diff)
parentcore: hid: Skip duplicated vibrations (diff)
downloadyuzu-4349cdba070b159181d7090a27beb794bb83e481.tar.gz
yuzu-4349cdba070b159181d7090a27beb794bb83e481.tar.xz
yuzu-4349cdba070b159181d7090a27beb794bb83e481.zip
Merge pull request #12769 from german77/no-log
core: hid: Reduce controller requests
Diffstat (limited to 'src/hid_core/frontend')
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp18
-rw-r--r--src/hid_core/frontend/emulated_controller.h3
2 files changed, 17 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};