2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #12769 from german77/no-log

core: hid: Reduce controller requests
This commit is contained in:
liamwhite 2024-01-26 09:57:40 -05:00 committed by GitHub
commit 4349cdba07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 4 deletions

View file

@ -110,7 +110,11 @@ void EmulatedController::ReloadFromSettings() {
original_npad_type = npad_type; 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(); Disconnect();
if (player.connected) { if (player.connected) {
Connect(); Connect();
@ -1241,7 +1245,12 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
return false; 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) { if (!Settings::values.vibration_enabled) {
return false; return false;
@ -1272,7 +1281,10 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
} }
VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const { 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) { bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {

View file

@ -581,7 +581,8 @@ private:
f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard};
u32 turbo_button_state{0}; u32 turbo_button_state{0};
std::size_t nfc_handles{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 // Temporary values to avoid doing changes while the controller is in configuring mode
NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};

View file

@ -639,6 +639,15 @@ struct VibrationValue {
f32 low_frequency{}; f32 low_frequency{};
f32 high_amplitude{}; f32 high_amplitude{};
f32 high_frequency{}; 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."); static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");