summaryrefslogtreecommitdiff
path: root/src/input_common/input_poller.cpp
diff options
context:
space:
mode:
authorGravatar liamwhite2022-07-24 13:31:28 -0400
committerGravatar GitHub2022-07-24 13:31:28 -0400
commit5af06d14337a61d9ed1093079d13f68cbb1f5451 (patch)
tree88df3fada076b04c2ab2da8972d1d785f492b520 /src/input_common/input_poller.cpp
parentMerge pull request #8545 from Kelebek1/Audio (diff)
parentyuzu: Add webcam support and rebase to latest master (diff)
downloadyuzu-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 '')
-rw-r--r--src/input_common/input_poller.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 49ccb4422..133422d5c 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -664,6 +664,47 @@ private:
664 InputEngine* input_engine; 664 InputEngine* input_engine;
665}; 665};
666 666
667class InputFromCamera final : public Common::Input::InputDevice {
668public:
669 explicit InputFromCamera(PadIdentifier identifier_, InputEngine* input_engine_)
670 : identifier(identifier_), input_engine(input_engine_) {
671 UpdateCallback engine_callback{[this]() { OnChange(); }};
672 const InputIdentifier input_identifier{
673 .identifier = identifier,
674 .type = EngineInputType::Camera,
675 .index = 0,
676 .callback = engine_callback,
677 };
678 callback_key = input_engine->SetCallback(input_identifier);
679 }
680
681 ~InputFromCamera() override {
682 input_engine->DeleteCallback(callback_key);
683 }
684
685 Common::Input::CameraStatus GetStatus() const {
686 return input_engine->GetCamera(identifier);
687 }
688
689 void ForceUpdate() override {
690 OnChange();
691 }
692
693 void OnChange() {
694 const Common::Input::CallbackStatus status{
695 .type = Common::Input::InputType::IrSensor,
696 .camera_status = GetStatus(),
697 };
698
699 TriggerOnChange(status);
700 }
701
702private:
703 const PadIdentifier identifier;
704 int callback_key;
705 InputEngine* input_engine;
706};
707
667class OutputFromIdentifier final : public Common::Input::OutputDevice { 708class OutputFromIdentifier final : public Common::Input::OutputDevice {
668public: 709public:
669 explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) 710 explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
@@ -682,6 +723,10 @@ public:
682 return input_engine->SetPollingMode(identifier, polling_mode); 723 return input_engine->SetPollingMode(identifier, polling_mode);
683 } 724 }
684 725
726 Common::Input::CameraError SetCameraFormat(Common::Input::CameraFormat camera_format) override {
727 return input_engine->SetCameraFormat(identifier, camera_format);
728 }
729
685private: 730private:
686 const PadIdentifier identifier; 731 const PadIdentifier identifier;
687 InputEngine* input_engine; 732 InputEngine* input_engine;
@@ -920,6 +965,18 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
920 properties_y, properties_z, input_engine.get()); 965 properties_y, properties_z, input_engine.get());
921} 966}
922 967
968std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateCameraDevice(
969 const Common::ParamPackage& params) {
970 const PadIdentifier identifier = {
971 .guid = Common::UUID{params.Get("guid", "")},
972 .port = static_cast<std::size_t>(params.Get("port", 0)),
973 .pad = static_cast<std::size_t>(params.Get("pad", 0)),
974 };
975
976 input_engine->PreSetController(identifier);
977 return std::make_unique<InputFromCamera>(identifier, input_engine.get());
978}
979
923InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) 980InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_)
924 : input_engine(std::move(input_engine_)) {} 981 : input_engine(std::move(input_engine_)) {}
925 982
@@ -928,6 +985,9 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::Create(
928 if (params.Has("battery")) { 985 if (params.Has("battery")) {
929 return CreateBatteryDevice(params); 986 return CreateBatteryDevice(params);
930 } 987 }
988 if (params.Has("camera")) {
989 return CreateCameraDevice(params);
990 }
931 if (params.Has("button") && params.Has("axis")) { 991 if (params.Has("button") && params.Has("axis")) {
932 return CreateTriggerDevice(params); 992 return CreateTriggerDevice(params);
933 } 993 }