input_engine: Pass VibrationStatus by const reference in SetRumble()
Avoids creating copies of the struct where not necessary.
This commit is contained in:
parent
2b92d22bda
commit
38f3442ea5
7 changed files with 12 additions and 12 deletions
|
@ -266,11 +266,9 @@ class OutputDevice {
|
||||||
public:
|
public:
|
||||||
virtual ~OutputDevice() = default;
|
virtual ~OutputDevice() = default;
|
||||||
|
|
||||||
virtual void SetLED([[maybe_unused]] LedStatus led_status) {
|
virtual void SetLED([[maybe_unused]] LedStatus led_status) {}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual VibrationError SetVibration([[maybe_unused]] VibrationStatus vibration_status) {
|
virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
|
||||||
return VibrationError::NotSupported;
|
return VibrationError::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,8 +325,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier,
|
Common::Input::VibrationError GCAdapter::SetRumble(
|
||||||
const Common::Input::VibrationStatus vibration) {
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||||
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
||||||
const auto processed_amplitude =
|
const auto processed_amplitude =
|
||||||
static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8);
|
static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
~GCAdapter() override;
|
~GCAdapter() override;
|
||||||
|
|
||||||
Common::Input::VibrationError SetRumble(
|
Common::Input::VibrationError SetRumble(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||||
|
|
||||||
/// Used for automapping features
|
/// Used for automapping features
|
||||||
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
||||||
|
|
|
@ -491,8 +491,9 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
|
|
||||||
const Common::Input::VibrationStatus vibration) {
|
Common::Input::VibrationError SDLDriver::SetRumble(
|
||||||
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||||
const auto joystick =
|
const auto joystick =
|
||||||
GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port));
|
GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port));
|
||||||
const auto process_amplitude_exp = [](f32 amplitude, f32 factor) {
|
const auto process_amplitude_exp = [](f32 amplitude, f32 factor) {
|
||||||
|
@ -526,6 +527,7 @@ Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifi
|
||||||
|
|
||||||
return Common::Input::VibrationError::None;
|
return Common::Input::VibrationError::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid,
|
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid,
|
||||||
s32 axis, float value) const {
|
s32 axis, float value) const {
|
||||||
Common::ParamPackage params{};
|
Common::ParamPackage params{};
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
u8 GetHatButtonId(const std::string& direction_name) const override;
|
u8 GetHatButtonId(const std::string& direction_name) const override;
|
||||||
|
|
||||||
Common::Input::VibrationError SetRumble(
|
Common::Input::VibrationError SetRumble(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitJoystick(int joystick_index);
|
void InitJoystick(int joystick_index);
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
// Sets rumble to a controller
|
// Sets rumble to a controller
|
||||||
virtual Common::Input::VibrationError SetRumble(
|
virtual Common::Input::VibrationError SetRumble(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier,
|
[[maybe_unused]] const PadIdentifier& identifier,
|
||||||
[[maybe_unused]] const Common::Input::VibrationStatus vibration) {
|
[[maybe_unused]] const Common::Input::VibrationStatus& vibration) {
|
||||||
return Common::Input::VibrationError::NotSupported;
|
return Common::Input::VibrationError::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Common::Input::VibrationError SetVibration(
|
virtual Common::Input::VibrationError SetVibration(
|
||||||
Common::Input::VibrationStatus vibration_status) {
|
const Common::Input::VibrationStatus& vibration_status) {
|
||||||
return input_engine->SetRumble(identifier, vibration_status);
|
return input_engine->SetRumble(identifier, vibration_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue