summaryrefslogtreecommitdiffstats
path: root/src/input_common/input_poller.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-11 07:43:11 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:24 +0100
commit06a5ef5874144a70e30e577a83ba68d1dad79e78 (patch)
tree867fa1153c7285c858cdb5bd7f60f08266532a88 /src/input_common/input_poller.cpp
parentcore: Update input interpreter (diff)
downloadyuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.gz
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.bz2
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.lz
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.xz
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.tar.zst
yuzu-06a5ef5874144a70e30e577a83ba68d1dad79e78.zip
Diffstat (limited to 'src/input_common/input_poller.cpp')
-rw-r--r--src/input_common/input_poller.cpp40
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:
InputEngine* input_engine;
};
+class OutputFromIdentifier final : public Input::OutputDevice {
+public:
+ explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
+ : identifier(identifier_), input_engine(input_engine_) {}
+
+ virtual void SetLED( Input::LedStatus led_status) {
+ input_engine->SetLeds(identifier, led_status);
+ }
+
+ virtual Input::VibrationError SetVibration(Input::VibrationStatus vibration_status) {
+ return input_engine->SetRumble(identifier, vibration_status);
+ }
+
+ virtual Input::PollingError SetPollingMode(Input::PollingMode polling_mode) {
+ return input_engine->SetPollingMode(identifier, polling_mode);
+ }
+
+private:
+ const PadIdentifier identifier;
+ InputEngine* input_engine;
+};
+
std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice(
const Common::ParamPackage& params) {
const PadIdentifier identifier = {
@@ -825,7 +847,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par
InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_)
: input_engine(std::move(input_engine_)) {}
-std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) {
+std::unique_ptr<Input::InputDevice> InputFactory::Create(
+ const Common::ParamPackage& params) {
if (params.Has("button") && params.Has("axis")) {
return CreateTriggerDevice(params);
}
@@ -857,4 +880,19 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPack
return std::make_unique<DummyInput>();
}
+OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_)
+ : input_engine(std::move(input_engine_)) {}
+
+std::unique_ptr<Input::OutputDevice> OutputFactory::Create(
+ const Common::ParamPackage& params) {
+ const PadIdentifier identifier = {
+ .guid = Common::UUID{params.Get("guid", "")},
+ .port = static_cast<std::size_t>(params.Get("port", 0)),
+ .pad = static_cast<std::size_t>(params.Get("pad", 0)),
+ };
+
+ input_engine->PreSetController(identifier);
+ return std::make_unique<OutputFromIdentifier>(identifier, input_engine.get());
+}
+
} // namespace InputCommon