diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-01-12 16:02:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 16:02:13 +0100 |
commit | f7a3c135e2f17cc00d1f006146afc73a21408e3a (patch) | |
tree | f5439b576b7ba8e2d6835b49d45a558c66121ae7 /src/hid_core/resources/vibration/n64_vibration_device.cpp | |
parent | Merge pull request #12642 from t895/adapter-refactor (diff) | |
parent | service: hid: Create abstracted pad structure (diff) | |
download | yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar.gz yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar.bz2 yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar.lz yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar.xz yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.tar.zst yuzu-f7a3c135e2f17cc00d1f006146afc73a21408e3a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/hid_core/resources/vibration/n64_vibration_device.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/hid_core/resources/vibration/n64_vibration_device.cpp b/src/hid_core/resources/vibration/n64_vibration_device.cpp new file mode 100644 index 000000000..639f87abf --- /dev/null +++ b/src/hid_core/resources/vibration/n64_vibration_device.cpp @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "hid_core/hid_result.h" +#include "hid_core/resources/npad/npad_types.h" +#include "hid_core/resources/npad/npad_vibration.h" +#include "hid_core/resources/vibration/n64_vibration_device.h" + +namespace Service::HID { + +NpadN64VibrationDevice::NpadN64VibrationDevice() {} + +Result NpadN64VibrationDevice::IncrementRefCounter() { + if (ref_counter == 0 && is_mounted) { + f32 volume = 1.0f; + const auto result = vibration_handler->GetVibrationVolume(volume); + if (result.IsSuccess()) { + // TODO: SendVibrationInBool + } + } + + ref_counter++; + return ResultSuccess; +} + +Result NpadN64VibrationDevice::DecrementRefCounter() { + if (ref_counter == 1) { + if (!is_mounted) { + ref_counter = 0; + if (is_mounted != false) { + // TODO: SendVibrationInBool + } + return ResultSuccess; + } + f32 volume = 1.0f; + const auto result = vibration_handler->GetVibrationVolume(volume); + if (result.IsSuccess()) { + // TODO + } + } + + if (ref_counter > 0) { + ref_counter--; + } + + return ResultSuccess; +} + +Result NpadN64VibrationDevice::SendValueInBool(bool is_vibrating) { + if (ref_counter < 1) { + return ResultVibrationNotInitialized; + } + if (is_mounted) { + f32 volume = 1.0f; + const auto result = vibration_handler->GetVibrationVolume(volume); + if (result.IsError()) { + return result; + } + // TODO: SendVibrationInBool + } + return ResultSuccess; +} + +Result NpadN64VibrationDevice::SendVibrationNotificationPattern([[maybe_unused]] u32 pattern) { + if (!is_mounted) { + return ResultSuccess; + } + f32 volume = 1.0f; + const auto result = vibration_handler->GetVibrationVolume(volume); + if (result.IsError()) { + return result; + } + if (volume <= 0.0) { + pattern = 0; + } + // TODO: SendVibrationNotificationPattern + return ResultSuccess; +} + +} // namespace Service::HID |