diff options
author | bunnei <bunneidev@gmail.com> | 2022-10-02 23:28:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-02 23:28:43 +0200 |
commit | 61399de5dbc64ada1c9e5ec3d84be76c215fdc0c (patch) | |
tree | 72313f1b749d0771e38dbfcf539121a02d4b9ae0 /src/input_common/input_engine.cpp | |
parent | Merge pull request #8992 from Morph1984/vi-vsync-event (diff) | |
parent | service: mii: Copy only valid name bytes (diff) | |
download | yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.gz yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.bz2 yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.lz yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.xz yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.zst yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/input_engine.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 6ede0e4b0..61cfd0911 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -102,6 +102,17 @@ void InputEngine::SetCamera(const PadIdentifier& identifier, TriggerOnCameraChange(identifier, value); } +void InputEngine::SetNfc(const PadIdentifier& identifier, const Common::Input::NfcStatus& value) { + { + std::scoped_lock lock{mutex}; + ControllerData& controller = controller_list.at(identifier); + if (!configuring) { + controller.nfc = value; + } + } + TriggerOnNfcChange(identifier, value); +} + bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { std::scoped_lock lock{mutex}; const auto controller_iter = controller_list.find(identifier); @@ -189,6 +200,18 @@ Common::Input::CameraStatus InputEngine::GetCamera(const PadIdentifier& identifi return controller.camera; } +Common::Input::NfcStatus InputEngine::GetNfc(const PadIdentifier& identifier) const { + std::scoped_lock lock{mutex}; + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { + LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), + identifier.pad, identifier.port); + return {}; + } + const ControllerData& controller = controller_iter->second; + return controller.nfc; +} + void InputEngine::ResetButtonState() { for (const auto& controller : controller_list) { for (const auto& button : controller.second.buttons) { @@ -355,6 +378,20 @@ void InputEngine::TriggerOnCameraChange(const PadIdentifier& identifier, } } +void InputEngine::TriggerOnNfcChange(const PadIdentifier& identifier, + [[maybe_unused]] const Common::Input::NfcStatus& value) { + std::scoped_lock lock{mutex_callback}; + for (const auto& poller_pair : callback_list) { + const InputIdentifier& poller = poller_pair.second; + if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Nfc, 0)) { + continue; + } + if (poller.callback.on_change) { + poller.callback.on_change(); + } + } +} + bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier, const PadIdentifier& identifier, EngineInputType type, int index) const { |