|
|
@ -54,7 +54,6 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadType type |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void EmulatedController::ReloadFromSettings() { |
|
|
void EmulatedController::ReloadFromSettings() { |
|
|
//LOG_ERROR(Service_HID, "reload config from settings {}", NpadIdTypeToIndex(npad_id_type));
|
|
|
|
|
|
const auto player_index = NpadIdTypeToIndex(npad_id_type); |
|
|
const auto player_index = NpadIdTypeToIndex(npad_id_type); |
|
|
const auto& player = Settings::values.players.GetValue()[player_index]; |
|
|
const auto& player = Settings::values.players.GetValue()[player_index]; |
|
|
|
|
|
|
|
|
@ -640,12 +639,22 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v |
|
|
if (!output_devices[device_index]) { |
|
|
if (!output_devices[device_index]) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
const auto player_index = NpadIdTypeToIndex(npad_id_type); |
|
|
|
|
|
const auto& player = Settings::values.players.GetValue()[player_index]; |
|
|
|
|
|
const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; |
|
|
|
|
|
|
|
|
|
|
|
// Exponential amplification is too strong at low amplitudes. Switch to a linear
|
|
|
|
|
|
// amplification if strength is set below 0.7f
|
|
|
|
|
|
const Input::VibrationAmplificationType type = |
|
|
|
|
|
strength > 0.7f ? Input::VibrationAmplificationType::Exponential |
|
|
|
|
|
: Input::VibrationAmplificationType::Linear; |
|
|
|
|
|
|
|
|
const Input::VibrationStatus status = { |
|
|
const Input::VibrationStatus status = { |
|
|
.low_amplitude = vibration.high_amplitude, |
|
|
|
|
|
.low_frequency = vibration.high_amplitude, |
|
|
|
|
|
.high_amplitude = vibration.high_amplitude, |
|
|
|
|
|
.high_frequency = vibration.high_amplitude, |
|
|
|
|
|
|
|
|
.low_amplitude = std::min(vibration.low_amplitude * strength, 1.0f), |
|
|
|
|
|
.low_frequency = vibration.low_frequency, |
|
|
|
|
|
.high_amplitude = std::min(vibration.high_amplitude * strength, 1.0f), |
|
|
|
|
|
.high_frequency = vibration.high_frequency, |
|
|
|
|
|
.type = type, |
|
|
}; |
|
|
}; |
|
|
return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; |
|
|
return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; |
|
|
} |
|
|
} |
|
|
@ -661,6 +670,7 @@ bool EmulatedController::TestVibration(std::size_t device_index) { |
|
|
.low_frequency = 160.0f, |
|
|
.low_frequency = 160.0f, |
|
|
.high_amplitude = 0.001f, |
|
|
.high_amplitude = 0.001f, |
|
|
.high_frequency = 320.0f, |
|
|
.high_frequency = 320.0f, |
|
|
|
|
|
.type = Input::VibrationAmplificationType::Linear, |
|
|
}; |
|
|
}; |
|
|
return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; |
|
|
return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; |
|
|
} |
|
|
} |
|
|
|