From 0248614add99c1df1bc7c9ff97091f678ff75aca Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 12:36:28 -0400 Subject: GC Adapter Implementation --- src/input_common/gcadapter/gc_poller.h | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/input_common/gcadapter/gc_poller.h (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h new file mode 100644 index 000000000..d115b1d2a --- /dev/null +++ b/src/input_common/gcadapter/gc_poller.h @@ -0,0 +1,59 @@ +#pragma once + +#include +#include "core/frontend/input.h" + +namespace InputCommon { + + +/** + * A button device factory representing a gcpad. It receives gcpad events and forward them + * to all button devices it created. + */ +class GCButtonFactory final : public Input::Factory { +public: + GCButtonFactory(); + + /** + * Creates a button device from a button press + * @param params contains parameters for creating the device: + * - "code": the code of the key to bind with the button + */ + std::unique_ptr Create(const Common::ParamPackage& params) override; + + Common::ParamPackage GetNextInput(); + + /// For device input configuration/polling + void BeginConfiguration(); + void EndConfiguration(); + + bool IsPolling() { + return polling; + } + +private: + bool polling = false; +}; + +/// An analog device factory that creates analog devices from GC Adapter +class GCAnalogFactory final : public Input::Factory { +public: + GCAnalogFactory(); + std::unique_ptr Create(const Common::ParamPackage& params) override; + Common::ParamPackage GetNextInput(); + + /// For device input configuration/polling + void BeginConfiguration(); + void EndConfiguration(); + + bool IsPolling() { + return polling; + } + +private: + int analog_x_axis = -1; + int analog_y_axis = -1; + int controller_number = -1; + bool polling = false; +}; +} // namespace InputCommon -- cgit v1.2.3 From c94583d867fd909d8731ba50e085352aae0e6885 Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 15:31:57 -0400 Subject: Clang Formatting --- src/input_common/gcadapter/gc_poller.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h index d115b1d2a..43aa9e93a 100644 --- a/src/input_common/gcadapter/gc_poller.h +++ b/src/input_common/gcadapter/gc_poller.h @@ -1,3 +1,7 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #pragma once #include @@ -5,7 +9,6 @@ namespace InputCommon { - /** * A button device factory representing a gcpad. It receives gcpad events and forward them * to all button devices it created. -- cgit v1.2.3 From 121af3646dad0f80453d2ffffa688dd4435d3acc Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 18:43:01 -0400 Subject: Singleton GC Adapter class, remove globals, fix naming convention Fix clang formatting Manual fix for configure_input_player formatting Add missing lib usb cmake command --- src/input_common/gcadapter/gc_poller.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h index 43aa9e93a..29b8c0b7c 100644 --- a/src/input_common/gcadapter/gc_poller.h +++ b/src/input_common/gcadapter/gc_poller.h @@ -35,6 +35,7 @@ public: } private: + GCAdapter::Adapter* adapter; bool polling = false; }; @@ -54,9 +55,11 @@ public: } private: + GCAdapter::Adapter* adapter; int analog_x_axis = -1; int analog_y_axis = -1; int controller_number = -1; bool polling = false; }; + } // namespace InputCommon -- cgit v1.2.3 From 968d631aa59a0a4e51e219eaa143d2b95593c3e7 Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 21:15:58 -0400 Subject: std::arrays where appropriate, clear q in adapter class, other touch ups --- src/input_common/gcadapter/gc_poller.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h index 29b8c0b7c..31ff1c123 100644 --- a/src/input_common/gcadapter/gc_poller.h +++ b/src/input_common/gcadapter/gc_poller.h @@ -30,7 +30,7 @@ public: void BeginConfiguration(); void EndConfiguration(); - bool IsPolling() { + bool IsPolling() const { return polling; } @@ -50,7 +50,7 @@ public: void BeginConfiguration(); void EndConfiguration(); - bool IsPolling() { + bool IsPolling() const { return polling; } -- cgit v1.2.3 From 46b4461fbb0514dd50c096ef896b1752d81079d0 Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 21:50:58 -0400 Subject: shared_ptr for the GC adapter class, constexpr constants --- src/input_common/gcadapter/gc_poller.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h index 31ff1c123..d3a56da5b 100644 --- a/src/input_common/gcadapter/gc_poller.h +++ b/src/input_common/gcadapter/gc_poller.h @@ -15,7 +15,7 @@ namespace InputCommon { */ class GCButtonFactory final : public Input::Factory { public: - GCButtonFactory(); + GCButtonFactory(std::shared_ptr adapter_); /** * Creates a button device from a button press @@ -35,14 +35,14 @@ public: } private: - GCAdapter::Adapter* adapter; + std::shared_ptr adapter; bool polling = false; }; /// An analog device factory that creates analog devices from GC Adapter class GCAnalogFactory final : public Input::Factory { public: - GCAnalogFactory(); + GCAnalogFactory(std::shared_ptr adapter_); std::unique_ptr Create(const Common::ParamPackage& params) override; Common::ParamPackage GetNextInput(); @@ -55,7 +55,7 @@ public: } private: - GCAdapter::Adapter* adapter; + std::shared_ptr adapter; int analog_x_axis = -1; int analog_y_axis = -1; int controller_number = -1; -- cgit v1.2.3 From 28046ae3a9cd5e32c7cae1cf64aa005502bf1749 Mon Sep 17 00:00:00 2001 From: Ameer Date: Sun, 21 Jun 2020 23:56:56 -0400 Subject: Tidy up the pointers, use pair over tuple where appropriate --- src/input_common/gcadapter/gc_poller.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/input_common/gcadapter/gc_poller.h') diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h index d3a56da5b..e96af7d51 100644 --- a/src/input_common/gcadapter/gc_poller.h +++ b/src/input_common/gcadapter/gc_poller.h @@ -6,6 +6,7 @@ #include #include "core/frontend/input.h" +#include "input_common/gcadapter/gc_adapter.h" namespace InputCommon { @@ -15,7 +16,7 @@ namespace InputCommon { */ class GCButtonFactory final : public Input::Factory { public: - GCButtonFactory(std::shared_ptr adapter_); + explicit GCButtonFactory(std::shared_ptr adapter_); /** * Creates a button device from a button press @@ -42,7 +43,8 @@ private: /// An analog device factory that creates analog devices from GC Adapter class GCAnalogFactory final : public Input::Factory { public: - GCAnalogFactory(std::shared_ptr adapter_); + explicit GCAnalogFactory(std::shared_ptr adapter_); + std::unique_ptr Create(const Common::ParamPackage& params) override; Common::ParamPackage GetNextInput(); -- cgit v1.2.3