diff options
| author | 2021-10-11 00:43:11 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:24 -0600 | |
| commit | 06a5ef5874144a70e30e577a83ba68d1dad79e78 (patch) | |
| tree | 867fa1153c7285c858cdb5bd7f60f08266532a88 /src/input_common/input_poller.cpp | |
| parent | core: Update input interpreter (diff) | |
| download | yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.gz yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.xz yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.zip | |
core/hid: Add output devices
Diffstat (limited to 'src/input_common/input_poller.cpp')
| -rw-r--r-- | src/input_common/input_poller.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 46a7dd276..781012886 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -592,6 +592,28 @@ private: | |||
| 592 | InputEngine* input_engine; | 592 | InputEngine* input_engine; |
| 593 | }; | 593 | }; |
| 594 | 594 | ||
| 595 | class OutputFromIdentifier final : public Input::OutputDevice { | ||
| 596 | public: | ||
| 597 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | ||
| 598 | : identifier(identifier_), input_engine(input_engine_) {} | ||
| 599 | |||
| 600 | virtual void SetLED( Input::LedStatus led_status) { | ||
| 601 | input_engine->SetLeds(identifier, led_status); | ||
| 602 | } | ||
| 603 | |||
| 604 | virtual Input::VibrationError SetVibration(Input::VibrationStatus vibration_status) { | ||
| 605 | return input_engine->SetRumble(identifier, vibration_status); | ||
| 606 | } | ||
| 607 | |||
| 608 | virtual Input::PollingError SetPollingMode(Input::PollingMode polling_mode) { | ||
| 609 | return input_engine->SetPollingMode(identifier, polling_mode); | ||
| 610 | } | ||
| 611 | |||
| 612 | private: | ||
| 613 | const PadIdentifier identifier; | ||
| 614 | InputEngine* input_engine; | ||
| 615 | }; | ||
| 616 | |||
| 595 | std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( | 617 | std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( |
| 596 | const Common::ParamPackage& params) { | 618 | const Common::ParamPackage& params) { |
| 597 | const PadIdentifier identifier = { | 619 | const PadIdentifier identifier = { |
| @@ -825,7 +847,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 825 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) | 847 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 826 | : input_engine(std::move(input_engine_)) {} | 848 | : input_engine(std::move(input_engine_)) {} |
| 827 | 849 | ||
| 828 | std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) { | 850 | std::unique_ptr<Input::InputDevice> InputFactory::Create( |
| 851 | const Common::ParamPackage& params) { | ||
| 829 | if (params.Has("button") && params.Has("axis")) { | 852 | if (params.Has("button") && params.Has("axis")) { |
| 830 | return CreateTriggerDevice(params); | 853 | return CreateTriggerDevice(params); |
| 831 | } | 854 | } |
| @@ -857,4 +880,19 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPack | |||
| 857 | return std::make_unique<DummyInput>(); | 880 | return std::make_unique<DummyInput>(); |
| 858 | } | 881 | } |
| 859 | 882 | ||
| 883 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) | ||
| 884 | : input_engine(std::move(input_engine_)) {} | ||
| 885 | |||
| 886 | std::unique_ptr<Input::OutputDevice> OutputFactory::Create( | ||
| 887 | const Common::ParamPackage& params) { | ||
| 888 | const PadIdentifier identifier = { | ||
| 889 | .guid = Common::UUID{params.Get("guid", "")}, | ||
| 890 | .port = static_cast<std::size_t>(params.Get("port", 0)), | ||
| 891 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | ||
| 892 | }; | ||
| 893 | |||
| 894 | input_engine->PreSetController(identifier); | ||
| 895 | return std::make_unique<OutputFromIdentifier>(identifier, input_engine.get()); | ||
| 896 | } | ||
| 897 | |||
| 860 | } // namespace InputCommon | 898 | } // namespace InputCommon |