diff options
| author | 2024-01-25 23:46:00 -0600 | |
|---|---|---|
| committer | 2024-01-25 23:46:46 -0600 | |
| commit | f2012e5aff21e1ba0d06bfab868191d221e8f7ed (patch) | |
| tree | 0c170b92b72a5be216c2b0e3aafd451feb2bb7f4 /src/hid_core | |
| parent | Merge pull request #12759 from liamwhite/mp-misc (diff) | |
| download | yuzu-f2012e5aff21e1ba0d06bfab868191d221e8f7ed.tar.gz yuzu-f2012e5aff21e1ba0d06bfab868191d221e8f7ed.tar.xz yuzu-f2012e5aff21e1ba0d06bfab868191d221e8f7ed.zip | |
service: hid: Don't try to vibrate if device isn't initialized
Diffstat (limited to 'src/hid_core')
| -rw-r--r-- | src/hid_core/resource_manager.cpp | 4 | ||||
| -rw-r--r-- | src/hid_core/resources/vibration/vibration_base.cpp | 4 | ||||
| -rw-r--r-- | src/hid_core/resources/vibration/vibration_base.h | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index ca824b4a3..8ef0df020 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp | |||
| @@ -373,6 +373,10 @@ Result ResourceManager::SendVibrationValue(u64 aruid, | |||
| 373 | device = GetNSVibrationDevice(handle); | 373 | device = GetNSVibrationDevice(handle); |
| 374 | } | 374 | } |
| 375 | if (device != nullptr) { | 375 | if (device != nullptr) { |
| 376 | // Prevent sending vibrations to an inactive vibration handle | ||
| 377 | if (!device->IsActive()) { | ||
| 378 | return ResultSuccess; | ||
| 379 | } | ||
| 376 | result = device->SendVibrationValue(value); | 380 | result = device->SendVibrationValue(value); |
| 377 | } | 381 | } |
| 378 | return result; | 382 | return result; |
diff --git a/src/hid_core/resources/vibration/vibration_base.cpp b/src/hid_core/resources/vibration/vibration_base.cpp index f28d30406..90bff88f4 100644 --- a/src/hid_core/resources/vibration/vibration_base.cpp +++ b/src/hid_core/resources/vibration/vibration_base.cpp | |||
| @@ -23,6 +23,10 @@ Result NpadVibrationBase::Deactivate() { | |||
| 23 | return ResultSuccess; | 23 | return ResultSuccess; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | bool NpadVibrationBase::IsActive() const { | ||
| 27 | return ref_counter > 0; | ||
| 28 | } | ||
| 29 | |||
| 26 | bool NpadVibrationBase::IsVibrationMounted() const { | 30 | bool NpadVibrationBase::IsVibrationMounted() const { |
| 27 | return is_mounted; | 31 | return is_mounted; |
| 28 | } | 32 | } |
diff --git a/src/hid_core/resources/vibration/vibration_base.h b/src/hid_core/resources/vibration/vibration_base.h index 69c26e669..8fe35634d 100644 --- a/src/hid_core/resources/vibration/vibration_base.h +++ b/src/hid_core/resources/vibration/vibration_base.h | |||
| @@ -21,6 +21,7 @@ public: | |||
| 21 | virtual Result Activate(); | 21 | virtual Result Activate(); |
| 22 | virtual Result Deactivate(); | 22 | virtual Result Deactivate(); |
| 23 | 23 | ||
| 24 | bool IsActive() const; | ||
| 24 | bool IsVibrationMounted() const; | 25 | bool IsVibrationMounted() const; |
| 25 | 26 | ||
| 26 | protected: | 27 | protected: |