summaryrefslogtreecommitdiff
path: root/src/input_common/gcadapter/gc_poller.cpp
diff options
context:
space:
mode:
authorGravatar Ameer2020-06-21 21:50:58 -0400
committerGravatar Ameer2020-06-21 21:50:58 -0400
commit46b4461fbb0514dd50c096ef896b1752d81079d0 (patch)
tree31245dd4ff76724295a20202cea9dba72635f3a0 /src/input_common/gcadapter/gc_poller.cpp
parentstd::arrays where appropriate, clear q in adapter class, other touch ups (diff)
downloadyuzu-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.cpp24
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
15class GCButton final : public Input::ButtonDevice { 15class GCButton final : public Input::ButtonDevice {
16public: 16public:
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:
26private: 27private:
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
32class GCAxisButton final : public Input::ButtonDevice { 33class GCAxisButton final : public Input::ButtonDevice {
33public: 34public:
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
55GCButtonFactory::GCButtonFactory() { 56GCButtonFactory::GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_)
56 adapter = GCAdapter::Adapter::GetInstance(); 57 : adapter(adapter_) {}
57}
58 58
59GCButton::~GCButton() = default; 59GCButton::~GCButton() = default;
60 60
@@ -171,7 +171,8 @@ void GCButtonFactory::EndConfiguration() {
171 171
172class GCAnalog final : public Input::AnalogDevice { 172class GCAnalog final : public Input::AnalogDevice {
173public: 173public:
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
237GCAnalogFactory::GCAnalogFactory() { 238GCAnalogFactory::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