diff options
| author | 2022-07-24 13:31:28 -0400 | |
|---|---|---|
| committer | 2022-07-24 13:31:28 -0400 | |
| commit | 5af06d14337a61d9ed1093079d13f68cbb1f5451 (patch) | |
| tree | 88df3fada076b04c2ab2da8972d1d785f492b520 /src/input_common/input_engine.cpp | |
| parent | Merge pull request #8545 from Kelebek1/Audio (diff) | |
| parent | yuzu: Add webcam support and rebase to latest master (diff) | |
| download | yuzu-5af06d14337a61d9ed1093079d13f68cbb1f5451.tar.gz yuzu-5af06d14337a61d9ed1093079d13f68cbb1f5451.tar.xz yuzu-5af06d14337a61d9ed1093079d13f68cbb1f5451.zip | |
Merge pull request #8484 from german77/irs_release
service: irs: Add camera support, split processors and implement ImageTransferProcessor
Diffstat (limited to 'src/input_common/input_engine.cpp')
| -rw-r--r-- | src/input_common/input_engine.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 12214d146..6ede0e4b0 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -90,6 +90,18 @@ void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, const B | |||
| 90 | TriggerOnMotionChange(identifier, motion, value); | 90 | TriggerOnMotionChange(identifier, motion, value); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | void InputEngine::SetCamera(const PadIdentifier& identifier, | ||
| 94 | const Common::Input::CameraStatus& value) { | ||
| 95 | { | ||
| 96 | std::scoped_lock lock{mutex}; | ||
| 97 | ControllerData& controller = controller_list.at(identifier); | ||
| 98 | if (!configuring) { | ||
| 99 | controller.camera = value; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | TriggerOnCameraChange(identifier, value); | ||
| 103 | } | ||
| 104 | |||
| 93 | bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { | 105 | bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { |
| 94 | std::scoped_lock lock{mutex}; | 106 | std::scoped_lock lock{mutex}; |
| 95 | const auto controller_iter = controller_list.find(identifier); | 107 | const auto controller_iter = controller_list.find(identifier); |
| @@ -165,6 +177,18 @@ BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) | |||
| 165 | return controller.motions.at(motion); | 177 | return controller.motions.at(motion); |
| 166 | } | 178 | } |
| 167 | 179 | ||
| 180 | Common::Input::CameraStatus InputEngine::GetCamera(const PadIdentifier& identifier) const { | ||
| 181 | std::scoped_lock lock{mutex}; | ||
| 182 | const auto controller_iter = controller_list.find(identifier); | ||
| 183 | if (controller_iter == controller_list.cend()) { | ||
| 184 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), | ||
| 185 | identifier.pad, identifier.port); | ||
| 186 | return {}; | ||
| 187 | } | ||
| 188 | const ControllerData& controller = controller_iter->second; | ||
| 189 | return controller.camera; | ||
| 190 | } | ||
| 191 | |||
| 168 | void InputEngine::ResetButtonState() { | 192 | void InputEngine::ResetButtonState() { |
| 169 | for (const auto& controller : controller_list) { | 193 | for (const auto& controller : controller_list) { |
| 170 | for (const auto& button : controller.second.buttons) { | 194 | for (const auto& button : controller.second.buttons) { |
| @@ -317,6 +341,20 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot | |||
| 317 | }); | 341 | }); |
| 318 | } | 342 | } |
| 319 | 343 | ||
| 344 | void InputEngine::TriggerOnCameraChange(const PadIdentifier& identifier, | ||
| 345 | [[maybe_unused]] const Common::Input::CameraStatus& value) { | ||
| 346 | std::scoped_lock lock{mutex_callback}; | ||
| 347 | for (const auto& poller_pair : callback_list) { | ||
| 348 | const InputIdentifier& poller = poller_pair.second; | ||
| 349 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Camera, 0)) { | ||
| 350 | continue; | ||
| 351 | } | ||
| 352 | if (poller.callback.on_change) { | ||
| 353 | poller.callback.on_change(); | ||
| 354 | } | ||
| 355 | } | ||
| 356 | } | ||
| 357 | |||
| 320 | bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier, | 358 | bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier, |
| 321 | const PadIdentifier& identifier, EngineInputType type, | 359 | const PadIdentifier& identifier, EngineInputType type, |
| 322 | int index) const { | 360 | int index) const { |