diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/input.h | 46 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 10 | ||||
| -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 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 26 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_driver.h | 10 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/joycon_types.h | 1 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 19 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 11 |
17 files changed, 100 insertions, 104 deletions
diff --git a/src/common/input.h b/src/common/input.h index 1e5ba038d..d61cd7ca8 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -64,20 +64,19 @@ enum class CameraFormat { | |||
| 64 | None, | 64 | None, |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | // Vibration reply from the controller | 67 | // Different results that can happen from a device request |
| 68 | enum class VibrationError { | 68 | enum class DriverResult { |
| 69 | None, | 69 | Success, |
| 70 | NotSupported, | 70 | WrongReply, |
| 71 | Disabled, | 71 | Timeout, |
| 72 | UnsupportedControllerType, | ||
| 73 | HandleInUse, | ||
| 74 | ErrorReadingData, | ||
| 75 | ErrorWritingData, | ||
| 76 | NoDeviceDetected, | ||
| 72 | InvalidHandle, | 77 | InvalidHandle, |
| 73 | Unknown, | ||
| 74 | }; | ||
| 75 | |||
| 76 | // Polling mode reply from the controller | ||
| 77 | enum class PollingError { | ||
| 78 | None, | ||
| 79 | NotSupported, | 78 | NotSupported, |
| 80 | InvalidHandle, | 79 | Disabled, |
| 81 | Unknown, | 80 | Unknown, |
| 82 | }; | 81 | }; |
| 83 | 82 | ||
| @@ -94,13 +93,6 @@ enum class NfcState { | |||
| 94 | Unknown, | 93 | Unknown, |
| 95 | }; | 94 | }; |
| 96 | 95 | ||
| 97 | // Ir camera reply from the controller | ||
| 98 | enum class CameraError { | ||
| 99 | None, | ||
| 100 | NotSupported, | ||
| 101 | Unknown, | ||
| 102 | }; | ||
| 103 | |||
| 104 | // Hint for amplification curve to be used | 96 | // Hint for amplification curve to be used |
| 105 | enum class VibrationAmplificationType { | 97 | enum class VibrationAmplificationType { |
| 106 | Linear, | 98 | Linear, |
| @@ -336,22 +328,24 @@ class OutputDevice { | |||
| 336 | public: | 328 | public: |
| 337 | virtual ~OutputDevice() = default; | 329 | virtual ~OutputDevice() = default; |
| 338 | 330 | ||
| 339 | virtual void SetLED([[maybe_unused]] const LedStatus& led_status) {} | 331 | virtual DriverResult SetLED([[maybe_unused]] const LedStatus& led_status) { |
| 332 | return DriverResult::NotSupported; | ||
| 333 | } | ||
| 340 | 334 | ||
| 341 | virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) { | 335 | virtual DriverResult SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) { |
| 342 | return VibrationError::NotSupported; | 336 | return DriverResult::NotSupported; |
| 343 | } | 337 | } |
| 344 | 338 | ||
| 345 | virtual bool IsVibrationEnabled() { | 339 | virtual bool IsVibrationEnabled() { |
| 346 | return false; | 340 | return false; |
| 347 | } | 341 | } |
| 348 | 342 | ||
| 349 | virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) { | 343 | virtual DriverResult SetPollingMode([[maybe_unused]] PollingMode polling_mode) { |
| 350 | return PollingError::NotSupported; | 344 | return DriverResult::NotSupported; |
| 351 | } | 345 | } |
| 352 | 346 | ||
| 353 | virtual CameraError SetCameraFormat([[maybe_unused]] CameraFormat camera_format) { | 347 | virtual DriverResult SetCameraFormat([[maybe_unused]] CameraFormat camera_format) { |
| 354 | return CameraError::NotSupported; | 348 | return DriverResult::NotSupported; |
| 355 | } | 349 | } |
| 356 | 350 | ||
| 357 | virtual NfcState SupportsNfc() const { | 351 | virtual NfcState SupportsNfc() const { |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 1ed57f949..62da5be6c 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -1178,7 +1178,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 1178 | .type = type, | 1178 | .type = type, |
| 1179 | }; | 1179 | }; |
| 1180 | return output_devices[device_index]->SetVibration(status) == | 1180 | return output_devices[device_index]->SetVibration(status) == |
| 1181 | Common::Input::VibrationError::None; | 1181 | Common::Input::DriverResult::Success; |
| 1182 | } | 1182 | } |
| 1183 | 1183 | ||
| 1184 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { | 1184 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { |
| @@ -1208,8 +1208,8 @@ bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) | |||
| 1208 | const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode); | 1208 | const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode); |
| 1209 | const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode); | 1209 | const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode); |
| 1210 | 1210 | ||
| 1211 | return virtual_nfc_result == Common::Input::PollingError::None || | 1211 | return virtual_nfc_result == Common::Input::DriverResult::Success || |
| 1212 | mapped_nfc_result == Common::Input::PollingError::None; | 1212 | mapped_nfc_result == Common::Input::DriverResult::Success; |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | bool EmulatedController::SetCameraFormat( | 1215 | bool EmulatedController::SetCameraFormat( |
| @@ -1220,13 +1220,13 @@ bool EmulatedController::SetCameraFormat( | |||
| 1220 | auto& camera_output_device = output_devices[2]; | 1220 | auto& camera_output_device = output_devices[2]; |
| 1221 | 1221 | ||
| 1222 | if (right_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>( | 1222 | if (right_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>( |
| 1223 | camera_format)) == Common::Input::CameraError::None) { | 1223 | camera_format)) == Common::Input::DriverResult::Success) { |
| 1224 | return true; | 1224 | return true; |
| 1225 | } | 1225 | } |
| 1226 | 1226 | ||
| 1227 | // Fallback to Qt camera if native device doesn't have support | 1227 | // Fallback to Qt camera if native device doesn't have support |
| 1228 | return camera_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>( | 1228 | return camera_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>( |
| 1229 | camera_format)) == Common::Input::CameraError::None; | 1229 | camera_format)) == Common::Input::DriverResult::Success; |
| 1230 | } | 1230 | } |
| 1231 | 1231 | ||
| 1232 | Common::ParamPackage EmulatedController::GetRingParam() const { | 1232 | Common::ParamPackage EmulatedController::GetRingParam() const { |
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 { | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | Common::Input::CameraError Camera::SetCameraFormat( | 75 | Common::Input::DriverResult Camera::SetCameraFormat( |
| 76 | [[maybe_unused]] const PadIdentifier& identifier_, | 76 | [[maybe_unused]] const PadIdentifier& identifier_, |
| 77 | const Common::Input::CameraFormat camera_format) { | 77 | const Common::Input::CameraFormat camera_format) { |
| 78 | status.format = camera_format; | 78 | status.format = camera_format; |
| 79 | return Common::Input::CameraError::None; | 79 | return Common::Input::DriverResult::Success; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | } // namespace InputCommon | 82 | } // 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: | |||
| 22 | std::size_t getImageWidth() const; | 22 | std::size_t getImageWidth() const; |
| 23 | std::size_t getImageHeight() const; | 23 | std::size_t getImageHeight() const; |
| 24 | 24 | ||
| 25 | Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_, | 25 | Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_, |
| 26 | Common::Input::CameraFormat camera_format) override; | 26 | Common::Input::CameraFormat camera_format) override; |
| 27 | 27 | ||
| 28 | private: | 28 | private: |
| 29 | Common::Input::CameraStatus status{}; | 29 | 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) { | |||
| 324 | return true; | 324 | return true; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | Common::Input::VibrationError GCAdapter::SetVibration( | 327 | Common::Input::DriverResult GCAdapter::SetVibration( |
| 328 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | 328 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { |
| 329 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; | 329 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; |
| 330 | const auto processed_amplitude = | 330 | const auto processed_amplitude = |
| @@ -333,9 +333,9 @@ Common::Input::VibrationError GCAdapter::SetVibration( | |||
| 333 | pads[identifier.port].rumble_amplitude = processed_amplitude; | 333 | pads[identifier.port].rumble_amplitude = processed_amplitude; |
| 334 | 334 | ||
| 335 | if (!rumble_enabled) { | 335 | if (!rumble_enabled) { |
| 336 | return Common::Input::VibrationError::Disabled; | 336 | return Common::Input::DriverResult::Disabled; |
| 337 | } | 337 | } |
| 338 | return Common::Input::VibrationError::None; | 338 | return Common::Input::DriverResult::Success; |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) { | 341 | 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: | |||
| 25 | explicit GCAdapter(std::string input_engine_); | 25 | explicit GCAdapter(std::string input_engine_); |
| 26 | ~GCAdapter() override; | 26 | ~GCAdapter() override; |
| 27 | 27 | ||
| 28 | Common::Input::VibrationError SetVibration( | 28 | Common::Input::DriverResult SetVibration( |
| 29 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; | 29 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; |
| 30 | 30 | ||
| 31 | bool IsVibrationEnabled(const PadIdentifier& identifier) override; | 31 | 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) { | |||
| 233 | return handle->IsVibrationEnabled(); | 233 | return handle->IsVibrationEnabled(); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | Common::Input::VibrationError Joycons::SetVibration( | 236 | Common::Input::DriverResult Joycons::SetVibration(const PadIdentifier& identifier, |
| 237 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | 237 | const Common::Input::VibrationStatus& vibration) { |
| 238 | const Joycon::VibrationValue native_vibration{ | 238 | const Joycon::VibrationValue native_vibration{ |
| 239 | .low_amplitude = vibration.low_amplitude, | 239 | .low_amplitude = vibration.low_amplitude, |
| 240 | .low_frequency = vibration.low_frequency, | 240 | .low_frequency = vibration.low_frequency, |
| @@ -243,32 +243,31 @@ Common::Input::VibrationError Joycons::SetVibration( | |||
| 243 | }; | 243 | }; |
| 244 | auto handle = GetHandle(identifier); | 244 | auto handle = GetHandle(identifier); |
| 245 | if (handle == nullptr) { | 245 | if (handle == nullptr) { |
| 246 | return Common::Input::VibrationError::InvalidHandle; | 246 | return Common::Input::DriverResult::InvalidHandle; |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | handle->SetVibration(native_vibration); | 249 | handle->SetVibration(native_vibration); |
| 250 | return Common::Input::VibrationError::None; | 250 | return Common::Input::DriverResult::Success; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | void Joycons::SetLeds(const PadIdentifier& identifier, const Common::Input::LedStatus& led_status) { | 253 | Common::Input::DriverResult Joycons::SetLeds(const PadIdentifier& identifier, |
| 254 | const Common::Input::LedStatus& led_status) { | ||
| 254 | auto handle = GetHandle(identifier); | 255 | auto handle = GetHandle(identifier); |
| 255 | if (handle == nullptr) { | 256 | if (handle == nullptr) { |
| 256 | return; | 257 | return Common::Input::DriverResult::InvalidHandle; |
| 257 | } | 258 | } |
| 258 | int led_config = led_status.led_1 ? 1 : 0; | 259 | int led_config = led_status.led_1 ? 1 : 0; |
| 259 | led_config += led_status.led_2 ? 2 : 0; | 260 | led_config += led_status.led_2 ? 2 : 0; |
| 260 | led_config += led_status.led_3 ? 4 : 0; | 261 | led_config += led_status.led_3 ? 4 : 0; |
| 261 | led_config += led_status.led_4 ? 8 : 0; | 262 | led_config += led_status.led_4 ? 8 : 0; |
| 262 | 263 | ||
| 263 | const auto result = handle->SetLedConfig(static_cast<u8>(led_config)); | 264 | return static_cast<Common::Input::DriverResult>( |
| 264 | if (result != Joycon::DriverResult::Success) { | 265 | handle->SetLedConfig(static_cast<u8>(led_config))); |
| 265 | LOG_ERROR(Input, "Failed to set led config"); | ||
| 266 | } | ||
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | Common::Input::CameraError Joycons::SetCameraFormat(const PadIdentifier& identifier_, | 268 | Common::Input::DriverResult Joycons::SetCameraFormat(const PadIdentifier& identifier_, |
| 270 | Common::Input::CameraFormat camera_format) { | 269 | Common::Input::CameraFormat camera_format) { |
| 271 | return Common::Input::CameraError::NotSupported; | 270 | return Common::Input::DriverResult::NotSupported; |
| 272 | }; | 271 | }; |
| 273 | 272 | ||
| 274 | Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const { | 273 | Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const { |
| @@ -280,32 +279,30 @@ Common::Input::NfcState Joycons::WriteNfcData(const PadIdentifier& identifier_, | |||
| 280 | return Common::Input::NfcState::NotSupported; | 279 | return Common::Input::NfcState::NotSupported; |
| 281 | }; | 280 | }; |
| 282 | 281 | ||
| 283 | Common::Input::PollingError Joycons::SetPollingMode(const PadIdentifier& identifier, | 282 | Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identifier, |
| 284 | const Common::Input::PollingMode polling_mode) { | 283 | const Common::Input::PollingMode polling_mode) { |
| 285 | auto handle = GetHandle(identifier); | 284 | auto handle = GetHandle(identifier); |
| 286 | if (handle == nullptr) { | 285 | if (handle == nullptr) { |
| 287 | LOG_ERROR(Input, "Invalid handle {}", identifier.port); | 286 | LOG_ERROR(Input, "Invalid handle {}", identifier.port); |
| 288 | return Common::Input::PollingError::InvalidHandle; | 287 | return Common::Input::DriverResult::InvalidHandle; |
| 289 | } | 288 | } |
| 290 | 289 | ||
| 291 | switch (polling_mode) { | 290 | switch (polling_mode) { |
| 292 | case Common::Input::PollingMode::NFC: | 291 | case Common::Input::PollingMode::NFC: |
| 293 | handle->SetNfcMode(); | 292 | return static_cast<Common::Input::DriverResult>(handle->SetNfcMode()); |
| 294 | break; | 293 | break; |
| 295 | case Common::Input::PollingMode::Active: | 294 | case Common::Input::PollingMode::Active: |
| 296 | handle->SetActiveMode(); | 295 | return static_cast<Common::Input::DriverResult>(handle->SetActiveMode()); |
| 297 | break; | 296 | break; |
| 298 | case Common::Input::PollingMode::Pasive: | 297 | case Common::Input::PollingMode::Pasive: |
| 299 | handle->SetPasiveMode(); | 298 | return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode()); |
| 300 | break; | 299 | break; |
| 301 | case Common::Input::PollingMode::Ring: | 300 | case Common::Input::PollingMode::Ring: |
| 302 | handle->SetRingConMode(); | 301 | return static_cast<Common::Input::DriverResult>(handle->SetRingConMode()); |
| 303 | break; | 302 | break; |
| 304 | default: | 303 | default: |
| 305 | return Common::Input::PollingError::NotSupported; | 304 | return Common::Input::DriverResult::NotSupported; |
| 306 | } | 305 | } |
| 307 | |||
| 308 | return Common::Input::PollingError::None; | ||
| 309 | } | 306 | } |
| 310 | 307 | ||
| 311 | void Joycons::OnBatteryUpdate(std::size_t port, Joycon::ControllerType type, | 308 | 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: | |||
| 29 | ~Joycons(); | 29 | ~Joycons(); |
| 30 | 30 | ||
| 31 | bool IsVibrationEnabled(const PadIdentifier& identifier) override; | 31 | bool IsVibrationEnabled(const PadIdentifier& identifier) override; |
| 32 | Common::Input::VibrationError SetVibration( | 32 | Common::Input::DriverResult SetVibration( |
| 33 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; | 33 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; |
| 34 | 34 | ||
| 35 | void SetLeds(const PadIdentifier& identifier, | 35 | Common::Input::DriverResult SetLeds(const PadIdentifier& identifier, |
| 36 | const Common::Input::LedStatus& led_status) override; | 36 | const Common::Input::LedStatus& led_status) override; |
| 37 | 37 | ||
| 38 | Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_, | 38 | Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_, |
| 39 | Common::Input::CameraFormat camera_format) override; | 39 | Common::Input::CameraFormat camera_format) override; |
| 40 | 40 | ||
| 41 | Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; | 41 | Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; |
| 42 | Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_, | 42 | Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_, |
| 43 | const std::vector<u8>& data) override; | 43 | const std::vector<u8>& data) override; |
| 44 | 44 | ||
| 45 | Common::Input::PollingError SetPollingMode( | 45 | Common::Input::DriverResult SetPollingMode( |
| 46 | const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) override; | 46 | const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) override; |
| 47 | 47 | ||
| 48 | /// Used for automapping features | 48 | /// 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 { | |||
| 545 | return devices; | 545 | return devices; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | Common::Input::VibrationError SDLDriver::SetVibration( | 548 | Common::Input::DriverResult SDLDriver::SetVibration( |
| 549 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | 549 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { |
| 550 | const auto joystick = | 550 | const auto joystick = |
| 551 | GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); | 551 | GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); |
| @@ -579,7 +579,7 @@ Common::Input::VibrationError SDLDriver::SetVibration( | |||
| 579 | .vibration = new_vibration, | 579 | .vibration = new_vibration, |
| 580 | }); | 580 | }); |
| 581 | 581 | ||
| 582 | return Common::Input::VibrationError::None; | 582 | return Common::Input::DriverResult::Success; |
| 583 | } | 583 | } |
| 584 | 584 | ||
| 585 | bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) { | 585 | 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: | |||
| 63 | 63 | ||
| 64 | bool IsStickInverted(const Common::ParamPackage& params) override; | 64 | bool IsStickInverted(const Common::ParamPackage& params) override; |
| 65 | 65 | ||
| 66 | Common::Input::VibrationError SetVibration( | 66 | Common::Input::DriverResult SetVibration( |
| 67 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; | 67 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; |
| 68 | 68 | ||
| 69 | bool IsVibrationEnabled(const PadIdentifier& identifier) override; | 69 | 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( | |||
| 22 | 22 | ||
| 23 | VirtualAmiibo::~VirtualAmiibo() = default; | 23 | VirtualAmiibo::~VirtualAmiibo() = default; |
| 24 | 24 | ||
| 25 | Common::Input::PollingError VirtualAmiibo::SetPollingMode( | 25 | Common::Input::DriverResult VirtualAmiibo::SetPollingMode( |
| 26 | [[maybe_unused]] const PadIdentifier& identifier_, | 26 | [[maybe_unused]] const PadIdentifier& identifier_, |
| 27 | const Common::Input::PollingMode polling_mode_) { | 27 | const Common::Input::PollingMode polling_mode_) { |
| 28 | polling_mode = polling_mode_; | 28 | polling_mode = polling_mode_; |
| @@ -37,7 +37,7 @@ Common::Input::PollingError VirtualAmiibo::SetPollingMode( | |||
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | return Common::Input::PollingError::None; | 40 | return Common::Input::DriverResult::Success; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | Common::Input::NfcState VirtualAmiibo::SupportsNfc( | 43 | 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: | |||
| 36 | ~VirtualAmiibo() override; | 36 | ~VirtualAmiibo() override; |
| 37 | 37 | ||
| 38 | // Sets polling mode to a controller | 38 | // Sets polling mode to a controller |
| 39 | Common::Input::PollingError SetPollingMode( | 39 | Common::Input::DriverResult SetPollingMode( |
| 40 | const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override; | 40 | const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override; |
| 41 | 41 | ||
| 42 | Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; | 42 | Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override; |
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 8982a2397..b00b6110b 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp | |||
| @@ -459,23 +459,23 @@ SerialNumber JoyconDriver::GetHandleSerialNumber() const { | |||
| 459 | return handle_serial_number; | 459 | return handle_serial_number; |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | void JoyconDriver::SetCallbacks(const Joycon::JoyconCallbacks& callbacks) { | 462 | void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) { |
| 463 | joycon_poller->SetCallbacks(callbacks); | 463 | joycon_poller->SetCallbacks(callbacks); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, | 466 | DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, |
| 467 | ControllerType& controller_type) { | 467 | ControllerType& controller_type) { |
| 468 | static constexpr std::array<std::pair<u32, Joycon::ControllerType>, 4> supported_devices{ | 468 | static constexpr std::array<std::pair<u32, ControllerType>, 4> supported_devices{ |
| 469 | std::pair<u32, Joycon::ControllerType>{0x2006, Joycon::ControllerType::Left}, | 469 | std::pair<u32, ControllerType>{0x2006, ControllerType::Left}, |
| 470 | {0x2007, Joycon::ControllerType::Right}, | 470 | {0x2007, ControllerType::Right}, |
| 471 | {0x2009, Joycon::ControllerType::Pro}, | 471 | {0x2009, ControllerType::Pro}, |
| 472 | {0x200E, Joycon::ControllerType::Grip}, | 472 | {0x200E, ControllerType::Grip}, |
| 473 | }; | 473 | }; |
| 474 | constexpr u16 nintendo_vendor_id = 0x057e; | 474 | constexpr u16 nintendo_vendor_id = 0x057e; |
| 475 | 475 | ||
| 476 | controller_type = Joycon::ControllerType::None; | 476 | controller_type = ControllerType::None; |
| 477 | if (device_info->vendor_id != nintendo_vendor_id) { | 477 | if (device_info->vendor_id != nintendo_vendor_id) { |
| 478 | return Joycon::DriverResult::UnsupportedControllerType; | 478 | return DriverResult::UnsupportedControllerType; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | for (const auto& [product_id, type] : supported_devices) { | 481 | for (const auto& [product_id, type] : supported_devices) { |
| @@ -487,10 +487,10 @@ Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_inf | |||
| 487 | return Joycon::DriverResult::UnsupportedControllerType; | 487 | return Joycon::DriverResult::UnsupportedControllerType; |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | Joycon::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, | 490 | DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, |
| 491 | Joycon::SerialNumber& serial_number) { | 491 | SerialNumber& serial_number) { |
| 492 | if (device_info->serial_number == nullptr) { | 492 | if (device_info->serial_number == nullptr) { |
| 493 | return Joycon::DriverResult::Unknown; | 493 | return DriverResult::Unknown; |
| 494 | } | 494 | } |
| 495 | std::memcpy(&serial_number, device_info->serial_number, 15); | 495 | std::memcpy(&serial_number, device_info->serial_number, 15); |
| 496 | return Joycon::DriverResult::Success; | 496 | return Joycon::DriverResult::Success; |
diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index c9118ee93..bf38a3009 100644 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h | |||
| @@ -46,15 +46,15 @@ public: | |||
| 46 | DriverResult SetNfcMode(); | 46 | DriverResult SetNfcMode(); |
| 47 | DriverResult SetRingConMode(); | 47 | DriverResult SetRingConMode(); |
| 48 | 48 | ||
| 49 | void SetCallbacks(const Joycon::JoyconCallbacks& callbacks); | 49 | void SetCallbacks(const JoyconCallbacks& callbacks); |
| 50 | 50 | ||
| 51 | // Returns device type from hidapi handle | 51 | // Returns device type from hidapi handle |
| 52 | static Joycon::DriverResult GetDeviceType(SDL_hid_device_info* device_info, | 52 | static DriverResult GetDeviceType(SDL_hid_device_info* device_info, |
| 53 | Joycon::ControllerType& controller_type); | 53 | ControllerType& controller_type); |
| 54 | 54 | ||
| 55 | // Returns serial number from hidapi handle | 55 | // Returns serial number from hidapi handle |
| 56 | static Joycon::DriverResult GetSerialNumber(SDL_hid_device_info* device_info, | 56 | static DriverResult GetSerialNumber(SDL_hid_device_info* device_info, |
| 57 | Joycon::SerialNumber& serial_number); | 57 | SerialNumber& serial_number); |
| 58 | 58 | ||
| 59 | private: | 59 | private: |
| 60 | struct SupportedFeatures { | 60 | struct SupportedFeatures { |
diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index de512fe63..36c00a8d7 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h | |||
| @@ -284,6 +284,7 @@ enum class DriverResult { | |||
| 284 | NoDeviceDetected, | 284 | NoDeviceDetected, |
| 285 | InvalidHandle, | 285 | InvalidHandle, |
| 286 | NotSupported, | 286 | NotSupported, |
| 287 | Disabled, | ||
| 287 | Unknown, | 288 | Unknown, |
| 288 | }; | 289 | }; |
| 289 | 290 | ||
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 6301c5719..50b5a3dc8 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -105,14 +105,17 @@ public: | |||
| 105 | void EndConfiguration(); | 105 | void EndConfiguration(); |
| 106 | 106 | ||
| 107 | // Sets a led pattern for a controller | 107 | // Sets a led pattern for a controller |
| 108 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, | 108 | virtual Common::Input::DriverResult SetLeds( |
| 109 | [[maybe_unused]] const Common::Input::LedStatus& led_status) {} | 109 | [[maybe_unused]] const PadIdentifier& identifier, |
| 110 | [[maybe_unused]] const Common::Input::LedStatus& led_status) { | ||
| 111 | return Common::Input::DriverResult::NotSupported; | ||
| 112 | } | ||
| 110 | 113 | ||
| 111 | // Sets rumble to a controller | 114 | // Sets rumble to a controller |
| 112 | virtual Common::Input::VibrationError SetVibration( | 115 | virtual Common::Input::DriverResult SetVibration( |
| 113 | [[maybe_unused]] const PadIdentifier& identifier, | 116 | [[maybe_unused]] const PadIdentifier& identifier, |
| 114 | [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { | 117 | [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { |
| 115 | return Common::Input::VibrationError::NotSupported; | 118 | return Common::Input::DriverResult::NotSupported; |
| 116 | } | 119 | } |
| 117 | 120 | ||
| 118 | // Returns true if device supports vibrations | 121 | // Returns true if device supports vibrations |
| @@ -121,17 +124,17 @@ public: | |||
| 121 | } | 124 | } |
| 122 | 125 | ||
| 123 | // Sets polling mode to a controller | 126 | // Sets polling mode to a controller |
| 124 | virtual Common::Input::PollingError SetPollingMode( | 127 | virtual Common::Input::DriverResult SetPollingMode( |
| 125 | [[maybe_unused]] const PadIdentifier& identifier, | 128 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Common::Input::PollingMode polling_mode) { | 129 | [[maybe_unused]] const Common::Input::PollingMode polling_mode) { |
| 127 | return Common::Input::PollingError::NotSupported; | 130 | return Common::Input::DriverResult::NotSupported; |
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | // Sets camera format to a controller | 133 | // Sets camera format to a controller |
| 131 | virtual Common::Input::CameraError SetCameraFormat( | 134 | virtual Common::Input::DriverResult SetCameraFormat( |
| 132 | [[maybe_unused]] const PadIdentifier& identifier, | 135 | [[maybe_unused]] const PadIdentifier& identifier, |
| 133 | [[maybe_unused]] Common::Input::CameraFormat camera_format) { | 136 | [[maybe_unused]] Common::Input::CameraFormat camera_format) { |
| 134 | return Common::Input::CameraError::NotSupported; | 137 | return Common::Input::DriverResult::NotSupported; |
| 135 | } | 138 | } |
| 136 | 139 | ||
| 137 | // Returns success if nfc is supported | 140 | // Returns success if nfc is supported |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 368ffbdd5..15cbf7e5f 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -806,11 +806,11 @@ public: | |||
| 806 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 806 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 807 | : identifier(identifier_), input_engine(input_engine_) {} | 807 | : identifier(identifier_), input_engine(input_engine_) {} |
| 808 | 808 | ||
| 809 | void SetLED(const Common::Input::LedStatus& led_status) override { | 809 | Common::Input::DriverResult SetLED(const Common::Input::LedStatus& led_status) override { |
| 810 | input_engine->SetLeds(identifier, led_status); | 810 | return input_engine->SetLeds(identifier, led_status); |
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | Common::Input::VibrationError SetVibration( | 813 | Common::Input::DriverResult SetVibration( |
| 814 | const Common::Input::VibrationStatus& vibration_status) override { | 814 | const Common::Input::VibrationStatus& vibration_status) override { |
| 815 | return input_engine->SetVibration(identifier, vibration_status); | 815 | return input_engine->SetVibration(identifier, vibration_status); |
| 816 | } | 816 | } |
| @@ -819,11 +819,12 @@ public: | |||
| 819 | return input_engine->IsVibrationEnabled(identifier); | 819 | return input_engine->IsVibrationEnabled(identifier); |
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) override { | 822 | Common::Input::DriverResult SetPollingMode(Common::Input::PollingMode polling_mode) override { |
| 823 | return input_engine->SetPollingMode(identifier, polling_mode); | 823 | return input_engine->SetPollingMode(identifier, polling_mode); |
| 824 | } | 824 | } |
| 825 | 825 | ||
| 826 | Common::Input::CameraError SetCameraFormat(Common::Input::CameraFormat camera_format) override { | 826 | Common::Input::DriverResult SetCameraFormat( |
| 827 | Common::Input::CameraFormat camera_format) override { | ||
| 827 | return input_engine->SetCameraFormat(identifier, camera_format); | 828 | return input_engine->SetCameraFormat(identifier, camera_format); |
| 828 | } | 829 | } |
| 829 | 830 | ||