diff options
Diffstat (limited to 'src/input_common/gcadapter/gc_poller.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_poller.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp index ed99f98b4..ad321e933 100644 --- a/src/input_common/gcadapter/gc_poller.cpp +++ b/src/input_common/gcadapter/gc_poller.cpp | |||
| @@ -34,13 +34,7 @@ public: | |||
| 34 | explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_, | 34 | explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_, |
| 35 | GCAdapter::Adapter* adapter) | 35 | GCAdapter::Adapter* adapter) |
| 36 | : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_), | 36 | : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_), |
| 37 | gcadapter(adapter), origin_value(adapter->GetOriginValue(port_, axis_)) { | 37 | gcadapter(adapter), origin_value(adapter->GetOriginValue(port_, axis_)) {} |
| 38 | // L/R triggers range is only in positive direction beginning near 0 | ||
| 39 | // 0.0 threshold equates to near half trigger press, but threshold accounts for variability. | ||
| 40 | if (axis > 3) { | ||
| 41 | threshold *= -0.5; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | 38 | ||
| 45 | bool GetStatus() const override { | 39 | bool GetStatus() const override { |
| 46 | const float current_axis_value = gcadapter->GetPadState()[port].axes.at(axis); | 40 | const float current_axis_value = gcadapter->GetPadState()[port].axes.at(axis); |
| @@ -152,14 +146,11 @@ public: | |||
| 152 | 146 | ||
| 153 | float GetAxis(int axis) const { | 147 | float GetAxis(int axis) const { |
| 154 | std::lock_guard lock{mutex}; | 148 | std::lock_guard lock{mutex}; |
| 149 | const auto origin_value = axis % 2 == 0 ? origin_value_x : origin_value_y; | ||
| 155 | // division is not by a perfect 128 to account for some variance in center location | 150 | // division is not by a perfect 128 to account for some variance in center location |
| 156 | // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range | 151 | // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range |
| 157 | // [20-230] | 152 | // [20-230] |
| 158 | if (axis % 2 == 0) { | 153 | return (gcadapter->GetPadState()[port].axes.at(axis) - origin_value) / 95.0f; |
| 159 | return (gcadapter->GetPadState()[port].axes.at(axis) - origin_value_x) / 95.0f; | ||
| 160 | } else { | ||
| 161 | return (gcadapter->GetPadState()[port].axes.at(axis) - origin_value_y) / 95.0f; | ||
| 162 | } | ||
| 163 | } | 154 | } |
| 164 | 155 | ||
| 165 | std::pair<float, float> GetAnalog(int axis_x, int axis_y) const { | 156 | std::pair<float, float> GetAnalog(int axis_x, int axis_y) const { |