aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNarr the Reg <[email protected]>2024-01-25 23:46:00 -0600
committerNarr the Reg <[email protected]>2024-01-25 23:46:46 -0600
commitf2012e5aff21e1ba0d06bfab868191d221e8f7ed (patch)
tree0c170b92b72a5be216c2b0e3aafd451feb2bb7f4 /src
parente04368ad7cf4c8d8820ef4da451d9954ff38cb2d (diff)
downloadyuzu-android-f2012e5aff21e1ba0d06bfab868191d221e8f7ed.tar.gz
yuzu-android-f2012e5aff21e1ba0d06bfab868191d221e8f7ed.zip
service: hid: Don't try to vibrate if device isn't initialized
Diffstat (limited to 'src')
-rw-r--r--src/hid_core/resource_manager.cpp4
-rw-r--r--src/hid_core/resources/vibration/vibration_base.cpp4
-rw-r--r--src/hid_core/resources/vibration/vibration_base.h1
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,
device = GetNSVibrationDevice(handle);
}
if (device != nullptr) {
+ // Prevent sending vibrations to an inactive vibration handle
+ if (!device->IsActive()) {
+ return ResultSuccess;
+ }
result = device->SendVibrationValue(value);
}
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() {
return ResultSuccess;
}
+bool NpadVibrationBase::IsActive() const {
+ return ref_counter > 0;
+}
+
bool NpadVibrationBase::IsVibrationMounted() const {
return is_mounted;
}
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:
virtual Result Activate();
virtual Result Deactivate();
+ bool IsActive() const;
bool IsVibrationMounted() const;
protected: