aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/hid_core
diff options
context:
space:
mode:
authorliamwhite <[email protected]>2024-01-26 09:57:40 -0500
committerGitHub <[email protected]>2024-01-26 09:57:40 -0500
commit4349cdba070b159181d7090a27beb794bb83e481 (patch)
tree1bd25e48ffeb2dcc0d033fdf3a900d91fa1e4360 /src/hid_core
parent59aee2b4617811a07307fddcb03c0d55cdc8e16b (diff)
parentad4622da2cad626b1acdbf1c3985d4d5b6e86bb0 (diff)
downloadyuzu-android-4349cdba070b159181d7090a27beb794bb83e481.tar.gz
yuzu-android-4349cdba070b159181d7090a27beb794bb83e481.zip
Merge pull request #12769 from german77/no-log
core: hid: Reduce controller requests
Diffstat (limited to 'src/hid_core')
-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() {
original_npad_type = npad_type;
}
- SetPollingMode(EmulatedDeviceIndex::RightIndex, Common::Input::PollingMode::Active);
+ // Disable special features before disconnecting
+ if (controller.right_polling_mode != Common::Input::PollingMode::Active) {
+ SetPollingMode(EmulatedDeviceIndex::RightIndex, Common::Input::PollingMode::Active);
+ }
+
Disconnect();
if (player.connected) {
Connect();
@@ -1241,7 +1245,12 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
return false;
}
- last_vibration_value = vibration;
+ // Skip duplicated vibrations
+ if (last_vibration_value[index] == vibration) {
+ return Settings::values.vibration_enabled.GetValue();
+ }
+
+ last_vibration_value[index] = vibration;
if (!Settings::values.vibration_enabled) {
return false;
@@ -1272,7 +1281,10 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
}
VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const {
- return last_vibration_value;
+ if (device_index >= DeviceIndex::MaxDeviceIndex) {
+ return Core::HID::DEFAULT_VIBRATION_VALUE;
+ }
+ return last_vibration_value[static_cast<std::size_t>(device_index)];
}
bool 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:
f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard};
u32 turbo_button_state{0};
std::size_t nfc_handles{0};
- VibrationValue last_vibration_value{DEFAULT_VIBRATION_VALUE};
+ std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
+ DEFAULT_VIBRATION_VALUE};
// 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 2c3f02f34..a01292a70 100644
--- a/src/hid_core/hid_types.h
+++ b/src/hid_core/hid_types.h
@@ -639,6 +639,15 @@ struct VibrationValue {
f32 low_frequency{};
f32 high_amplitude{};
f32 high_frequency{};
+ bool operator==(const VibrationValue& b) {
+ if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) {
+ return false;
+ }
+ if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) {
+ return false;
+ }
+ return true;
+ }
};
static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");