diff options
| author | 2022-06-18 23:32:07 -0500 | |
|---|---|---|
| committer | 2022-07-23 19:38:42 -0500 | |
| commit | f19e7be6e84357234c9fdae3395f988a9bb1ac5b (patch) | |
| tree | cc93872ac739fd7b967f8f62ea6abf2c8639221d /src/input_common/input_engine.cpp | |
| parent | Merge pull request #8545 from Kelebek1/Audio (diff) | |
| download | yuzu-f19e7be6e84357234c9fdae3395f988a9bb1ac5b.tar.gz yuzu-f19e7be6e84357234c9fdae3395f988a9bb1ac5b.tar.xz yuzu-f19e7be6e84357234c9fdae3395f988a9bb1ac5b.zip | |
input_common: Add camera driver
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 { |