aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/input_common/input_engine.cpp
diff options
context:
space:
mode:
authorgerman77 <[email protected]>2022-06-18 23:32:07 -0500
committergerman77 <[email protected]>2022-07-23 19:38:42 -0500
commitf19e7be6e84357234c9fdae3395f988a9bb1ac5b (patch)
treecc93872ac739fd7b967f8f62ea6abf2c8639221d /src/input_common/input_engine.cpp
parent97729fd8e9c2f8cabc626ab03a666c9428e01c5e (diff)
downloadyuzu-mainline-f19e7be6e84357234c9fdae3395f988a9bb1ac5b.tar.gz
yuzu-mainline-f19e7be6e84357234c9fdae3395f988a9bb1ac5b.zip
input_common: Add camera driver
Diffstat (limited to 'src/input_common/input_engine.cpp')
-rw-r--r--src/input_common/input_engine.cpp38
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
TriggerOnMotionChange(identifier, motion, value);
}
+void InputEngine::SetCamera(const PadIdentifier& identifier,
+ const Common::Input::CameraStatus& value) {
+ {
+ std::scoped_lock lock{mutex};
+ ControllerData& controller = controller_list.at(identifier);
+ if (!configuring) {
+ controller.camera = value;
+ }
+ }
+ TriggerOnCameraChange(identifier, value);
+}
+
bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const {
std::scoped_lock lock{mutex};
const auto controller_iter = controller_list.find(identifier);
@@ -165,6 +177,18 @@ BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion)
return controller.motions.at(motion);
}
+Common::Input::CameraStatus InputEngine::GetCamera(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.camera;
+}
+
void InputEngine::ResetButtonState() {
for (const auto& controller : controller_list) {
for (const auto& button : controller.second.buttons) {
@@ -317,6 +341,20 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot
});
}
+void InputEngine::TriggerOnCameraChange(const PadIdentifier& identifier,
+ [[maybe_unused]] const Common::Input::CameraStatus& 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::Camera, 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 {