diff options
author | german77 <juangerman-13@hotmail.com> | 2022-12-26 18:11:01 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-01-20 01:05:22 +0100 |
commit | 527dad70976a158e94defc51707347e064a31099 (patch) | |
tree | d9e9e68799d0c051e8e6a8a2dda7170ea911831d /src/input_common/drivers | |
parent | Address review comments (diff) | |
download | yuzu-527dad70976a158e94defc51707347e064a31099.tar yuzu-527dad70976a158e94defc51707347e064a31099.tar.gz yuzu-527dad70976a158e94defc51707347e064a31099.tar.bz2 yuzu-527dad70976a158e94defc51707347e064a31099.tar.lz yuzu-527dad70976a158e94defc51707347e064a31099.tar.xz yuzu-527dad70976a158e94defc51707347e064a31099.tar.zst yuzu-527dad70976a158e94defc51707347e064a31099.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/drivers/camera.cpp | 4 | ||||
-rw-r--r-- | src/input_common/drivers/camera.h | 4 | ||||
-rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 6 | ||||
-rw-r--r-- | src/input_common/drivers/gc_adapter.h | 2 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.cpp | 41 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.h | 12 | ||||
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 4 | ||||
-rw-r--r-- | src/input_common/drivers/sdl_driver.h | 2 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 4 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.h | 2 |
10 files changed, 39 insertions, 42 deletions
diff --git a/src/input_common/drivers/camera.cpp b/src/input_common/drivers/camera.cpp index fad9177dc..04970f635 100644 --- a/src/input_common/drivers/camera.cpp +++ b/src/input_common/drivers/camera.cpp @@ -72,11 +72,11 @@ std::size_t Camera::getImageHeight() const { } } -Common::Input::CameraError Camera::SetCameraFormat( +Common::Input::DriverResult Camera::SetCameraFormat( [[maybe_unused]] const PadIdentifier& identifier_, const Common::Input::CameraFormat camera_format) { status.format = camera_format; - return Common::Input::CameraError::None; + return Common::Input::DriverResult::Success; } } // namespace InputCommon diff --git a/src/input_common/drivers/camera.h b/src/input_common/drivers/camera.h index ead3e0fde..24b27e325 100644 --- a/src/input_common/drivers/camera.h +++ b/src/input_common/drivers/camera.h @@ -22,8 +22,8 @@ public: std::size_t getImageWidth() const; std::size_t getImageHeight() const; - Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_, - Common::Input::CameraFormat camera_format) override; + Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_, + Common::Input::CameraFormat camera_format) override; private: Common::Input::CameraStatus status{}; diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 826fa2109..ecb3e9dc2 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp @@ -324,7 +324,7 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) { return true; } -Common::Input::VibrationError GCAdapter::SetVibration( +Common::Input::DriverResult GCAdapter::SetVibration( const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; const auto processed_amplitude = @@ -333,9 +333,9 @@ Common::Input::VibrationError GCAdapter::SetVibration( pads[identifier.port].rumble_amplitude = processed_amplitude; if (!rumble_enabled) { - return Common::Input::VibrationError::Disabled; + return Common::Input::DriverResult::Disabled; } - return Common::Input::VibrationError::None; + return Common::Input::DriverResult::Success; } bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) { diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index b5270fd0b..3c2eb376d 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h @@ -25,7 +25,7 @@ public: explicit GCAdapter(std::string input_engine_); ~GCAdapter() override; - Common::Input::VibrationError SetVibration( + Common::Input::DriverResult SetVibration( const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; bool IsVibrationEnabled(const PadIdentifier& identifier) override; diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 696a6db39..cf54f1b53 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -233,8 +233,8 @@ bool Joycons::IsVibrationEnabled(const PadIdentifier& identifier) { return handle->IsVibrationEnabled(); } -Common::Input::VibrationError Joycons::SetVibration( - const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { +Common::Input::DriverResult Joycons::SetVibration(const PadIdentifier& identifier, + const Common::Input::VibrationStatus& vibration) { const Joycon::VibrationValue native_vibration{ .low_amplitude = vibration.low_amplitude, .low_frequency = vibration.low_frequency, @@ -243,32 +243,31 @@ Common::Input::VibrationError Joycons::SetVibration( }; auto handle = GetHandle(identifier); if (handle == nullptr) { - return Common::Input::VibrationError::InvalidHandle; + return Common::Input::DriverResult::InvalidHandle; } handle->SetVibration(native_vibration); - return Common::Input::VibrationError::None; + return Common::Input::DriverResult::Success; } -void Joycons::SetLeds(const PadIdentifier& identifier, const Common::Input::LedStatus& led_status) { +Common::Input::DriverResult Joycons::SetLeds(const PadIdentifier& identifier, + const Common::Input::LedStatus& led_status) { auto handle = GetHandle(identifier); if (handle == nullptr) { - return; + return Common::Input::DriverResult::InvalidHandle; } int led_config = led_status.led_1 ? 1 : 0; led_config += led_status.led_2 ? 2 : 0; led_config += led_status.led_3 ? 4 : 0; led_config += led_status.led_4 ? 8 : 0; - const auto result = handle->SetLedConfig(static_cast<u8>(led_config)); - if (result != Joycon::DriverResult::Success) { - LOG_ERROR(Input, "Failed to set led config"); - } + return static_cast<Common::Input::DriverResult>( + handle->SetLedConfig(static_cast<u8>(led_config))); } -Common::Input::CameraError Joycons::SetCameraFormat(const PadIdentifier& identifier_, - Common::Input::CameraFormat camera_format) { - return Common::Input::CameraError::NotSupported; +Common::Input::DriverResult Joycons::SetCameraFormat(const PadIdentifier& identifier_, + Common::Input::CameraFormat camera_format) { + return Common::Input::DriverResult::NotSupported; }; Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const { @@ -280,32 +279,30 @@ Common::Input::NfcState Joycons::WriteNfcData(const PadIdentifier& identifier_, return Common::Input::NfcState::NotSupported; }; -Common::Input::PollingError Joycons::SetPollingMode(const PadIdentifier& identifier, +Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) { auto handle = GetHandle(identifier); if (handle == nullptr) { LOG_ERROR(Input, "Invalid handle {}", identifier.port); - return Common::Input::PollingError::InvalidHandle; + return Common::Input::DriverResult::InvalidHandle; } switch (polling_mode) { case Common::Input::PollingMode::NFC: - handle->SetNfcMode(); + return static_cast<Common::Input::DriverResult>(handle->SetNfcMode()); break; case Common::Input::PollingMode::Active: - handle->SetActiveMode(); + return static_cast<Common::Input::DriverResult>(handle->SetActiveMode()); break; case Common::Input::PollingMode::Pasive: - handle->SetPasiveMode(); + return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode()); break; case Common::Input::PollingMode::Ring: - handle->SetRingConMode(); + return static_cast<Common::Input::DriverResult>(handle->SetRingConMode()); break; default: - return Common::Input::PollingError::NotSupported; + return Common::Input::DriverResult::NotSupported; } - - return Common::Input::PollingError::None; } void Joycons::OnBatteryUpdate(std::size_t port, Joycon::ControllerType type, diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 56c117270..1a04c19fd 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -29,20 +29,20 @@ public: ~Joycons(); bool IsVibrationEnabled(const PadIdentifier& identifier) override; - Common::Input::VibrationError SetVibration( + Common::Input::DriverResult SetVibration( const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; - void SetLeds(const PadIdentifier& identifier, - const Common::Input::LedStatus& led_status) override; + Common::Input::DriverResult SetLeds(const PadIdentifier& identifier, + const Common::Input::LedStatus& led_status) override; - Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_, - Common::Input::CameraFormat camera_format) override; + Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_, + Common::Input::CameraFormat camera_format) override; Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_, const std::vector<u8>& data) override; - Common::Input::PollingError SetPollingMode( + Common::Input::DriverResult SetPollingMode( const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) override; /// Used for automapping features diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index c9496a0d8..51a9d8962 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -545,7 +545,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { return devices; } -Common::Input::VibrationError SDLDriver::SetVibration( +Common::Input::DriverResult SDLDriver::SetVibration( const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { const auto joystick = GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); @@ -579,7 +579,7 @@ Common::Input::VibrationError SDLDriver::SetVibration( .vibration = new_vibration, }); - return Common::Input::VibrationError::None; + return Common::Input::DriverResult::Success; } bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) { diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index 366bcc496..ffde169b3 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h @@ -63,7 +63,7 @@ public: bool IsStickInverted(const Common::ParamPackage& params) override; - Common::Input::VibrationError SetVibration( + Common::Input::DriverResult SetVibration( const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; bool IsVibrationEnabled(const PadIdentifier& identifier) override; diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 63ffaca67..29e129d3c 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp @@ -22,7 +22,7 @@ VirtualAmiibo::VirtualAmiibo(std::string input_engine_) : InputEngine(std::move( VirtualAmiibo::~VirtualAmiibo() = default; -Common::Input::PollingError VirtualAmiibo::SetPollingMode( +Common::Input::DriverResult VirtualAmiibo::SetPollingMode( [[maybe_unused]] const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) { polling_mode = polling_mode_; @@ -37,7 +37,7 @@ Common::Input::PollingError VirtualAmiibo::SetPollingMode( } } - return Common::Input::PollingError::None; + return Common::Input::DriverResult::Success; } Common::Input::NfcState VirtualAmiibo::SupportsNfc( diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 0f9dad333..13cacfc0a 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h @@ -36,7 +36,7 @@ public: ~VirtualAmiibo() override; // Sets polling mode to a controller - Common::Input::PollingError SetPollingMode( + Common::Input::DriverResult SetPollingMode( const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override; Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; |