diff options
| author | 2020-06-21 21:50:58 -0400 | |
|---|---|---|
| committer | 2020-06-21 21:50:58 -0400 | |
| commit | 46b4461fbb0514dd50c096ef896b1752d81079d0 (patch) | |
| tree | 31245dd4ff76724295a20202cea9dba72635f3a0 /src/input_common/gcadapter/gc_poller.cpp | |
| parent | std::arrays where appropriate, clear q in adapter class, other touch ups (diff) | |
| download | yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.tar.gz yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.tar.xz yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.zip | |
shared_ptr for the GC adapter class, constexpr constants
Diffstat (limited to 'src/input_common/gcadapter/gc_poller.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_poller.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp index ac4126cb6..ad8b4b431 100644 --- a/src/input_common/gcadapter/gc_poller.cpp +++ b/src/input_common/gcadapter/gc_poller.cpp | |||
| @@ -14,7 +14,8 @@ namespace InputCommon { | |||
| 14 | 14 | ||
| 15 | class GCButton final : public Input::ButtonDevice { | 15 | class GCButton final : public Input::ButtonDevice { |
| 16 | public: | 16 | public: |
| 17 | explicit GCButton(int port_, int button_, int axis_, GCAdapter::Adapter* adapter) | 17 | explicit GCButton(int port_, int button_, int axis_, |
| 18 | std::shared_ptr<GCAdapter::Adapter> adapter) | ||
| 18 | : port(port_), button(button_), gcadapter(adapter) {} | 19 | : port(port_), button(button_), gcadapter(adapter) {} |
| 19 | 20 | ||
| 20 | ~GCButton() override; | 21 | ~GCButton() override; |
| @@ -26,13 +27,13 @@ public: | |||
| 26 | private: | 27 | private: |
| 27 | const int port; | 28 | const int port; |
| 28 | const int button; | 29 | const int button; |
| 29 | GCAdapter::Adapter* gcadapter; | 30 | std::shared_ptr<GCAdapter::Adapter> gcadapter; |
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | class GCAxisButton final : public Input::ButtonDevice { | 33 | class GCAxisButton final : public Input::ButtonDevice { |
| 33 | public: | 34 | public: |
| 34 | explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_, | 35 | explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_, |
| 35 | GCAdapter::Adapter* adapter) | 36 | std::shared_ptr<GCAdapter::Adapter> adapter) |
| 36 | : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_), | 37 | : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_), |
| 37 | gcadapter(adapter) {} | 38 | gcadapter(adapter) {} |
| 38 | 39 | ||
| @@ -49,12 +50,11 @@ private: | |||
| 49 | const int axis; | 50 | const int axis; |
| 50 | float threshold; | 51 | float threshold; |
| 51 | bool trigger_if_greater; | 52 | bool trigger_if_greater; |
| 52 | GCAdapter::Adapter* gcadapter; | 53 | std::shared_ptr<GCAdapter::Adapter> gcadapter; |
| 53 | }; | 54 | }; |
| 54 | 55 | ||
| 55 | GCButtonFactory::GCButtonFactory() { | 56 | GCButtonFactory::GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_) |
| 56 | adapter = GCAdapter::Adapter::GetInstance(); | 57 | : adapter(adapter_) {} |
| 57 | } | ||
| 58 | 58 | ||
| 59 | GCButton::~GCButton() = default; | 59 | GCButton::~GCButton() = default; |
| 60 | 60 | ||
| @@ -171,7 +171,8 @@ void GCButtonFactory::EndConfiguration() { | |||
| 171 | 171 | ||
| 172 | class GCAnalog final : public Input::AnalogDevice { | 172 | class GCAnalog final : public Input::AnalogDevice { |
| 173 | public: | 173 | public: |
| 174 | GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_, GCAdapter::Adapter* adapter) | 174 | GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_, |
| 175 | std::shared_ptr<GCAdapter::Adapter> adapter) | ||
| 175 | : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_), gcadapter(adapter) {} | 176 | : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_), gcadapter(adapter) {} |
| 176 | 177 | ||
| 177 | float GetAxis(int axis) const { | 178 | float GetAxis(int axis) const { |
| @@ -230,13 +231,12 @@ private: | |||
| 230 | const int axis_y; | 231 | const int axis_y; |
| 231 | const float deadzone; | 232 | const float deadzone; |
| 232 | mutable std::mutex mutex; | 233 | mutable std::mutex mutex; |
| 233 | GCAdapter::Adapter* gcadapter; | 234 | std::shared_ptr<GCAdapter::Adapter> gcadapter; |
| 234 | }; | 235 | }; |
| 235 | 236 | ||
| 236 | /// An analog device factory that creates analog devices from GC Adapter | 237 | /// An analog device factory that creates analog devices from GC Adapter |
| 237 | GCAnalogFactory::GCAnalogFactory() { | 238 | GCAnalogFactory::GCAnalogFactory(std::shared_ptr<GCAdapter::Adapter> adapter_) |
| 238 | adapter = GCAdapter::Adapter::GetInstance(); | 239 | : adapter(adapter_) {} |
| 239 | }; | ||
| 240 | 240 | ||
| 241 | /** | 241 | /** |
| 242 | * Creates analog device from joystick axes | 242 | * Creates analog device from joystick axes |