diff options
| author | 2020-06-30 17:28:02 -0400 | |
|---|---|---|
| committer | 2020-06-30 17:28:02 -0400 | |
| commit | a76e11e7f0c97222388bede03325aa71f1434510 (patch) | |
| tree | b1af57677dabe161da2e6a596d752c880ea1769f /src/input_common/gcadapter/gc_poller.cpp | |
| parent | fix implicit conversion of size_t type to int (diff) | |
| download | yuzu-a76e11e7f0c97222388bede03325aa71f1434510.tar.gz yuzu-a76e11e7f0c97222388bede03325aa71f1434510.tar.xz yuzu-a76e11e7f0c97222388bede03325aa71f1434510.zip | |
Address feedback regarding increments, const vars, and general cleanup
Diffstat (limited to 'src/input_common/gcadapter/gc_poller.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_poller.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp index 06e16880f..a9de9fedf 100644 --- a/src/input_common/gcadapter/gc_poller.cpp +++ b/src/input_common/gcadapter/gc_poller.cpp | |||
| @@ -39,9 +39,9 @@ public: | |||
| 39 | bool GetStatus() const override { | 39 | bool GetStatus() const override { |
| 40 | const float axis_value = (gcadapter->GetPadState()[port].axes.at(axis) - 128.0f) / 128.0f; | 40 | const float axis_value = (gcadapter->GetPadState()[port].axes.at(axis) - 128.0f) / 128.0f; |
| 41 | if (trigger_if_greater) { | 41 | if (trigger_if_greater) { |
| 42 | return axis_value > 0.10f; // TODO(ameerj) : Fix threshold. | 42 | return axis_value > threshold; // TODO(ameerj) : Fix threshold. |
| 43 | } | 43 | } |
| 44 | return axis_value < -0.10f; | 44 | return axis_value < -threshold; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | private: | 47 | private: |
| @@ -87,16 +87,13 @@ Common::ParamPackage GCButtonFactory::GetNextInput() { | |||
| 87 | Common::ParamPackage params; | 87 | Common::ParamPackage params; |
| 88 | GCAdapter::GCPadStatus pad; | 88 | GCAdapter::GCPadStatus pad; |
| 89 | auto& queue = adapter->GetPadQueue(); | 89 | auto& queue = adapter->GetPadQueue(); |
| 90 | for (int port = 0; port < queue.size(); port++) { | 90 | for (std::size_t port = 0; port < queue.size(); ++port) { |
| 91 | while (queue[port].Pop(pad)) { | 91 | while (queue[port].Pop(pad)) { |
| 92 | // This while loop will break on the earliest detected button | 92 | // This while loop will break on the earliest detected button |
| 93 | params.Set("engine", "gcpad"); | 93 | params.Set("engine", "gcpad"); |
| 94 | params.Set("port", port); | 94 | params.Set("port", static_cast<int>(port)); |
| 95 | // I was debating whether to keep these verbose for ease of reading | 95 | for (const auto& button : GCAdapter::PadButtonArray) { |
| 96 | // or to use a while loop shifting the bits to test and set the value. | 96 | const u16 button_value = static_cast<u16>(button); |
| 97 | |||
| 98 | for (auto button : GCAdapter::PadButtonArray) { | ||
| 99 | u16 button_value = static_cast<u16>(button); | ||
| 100 | if (pad.button & button_value) { | 97 | if (pad.button & button_value) { |
| 101 | params.Set("button", button_value); | 98 | params.Set("button", button_value); |
| 102 | break; | 99 | break; |
| @@ -228,7 +225,7 @@ void GCAnalogFactory::EndConfiguration() { | |||
| 228 | Common::ParamPackage GCAnalogFactory::GetNextInput() { | 225 | Common::ParamPackage GCAnalogFactory::GetNextInput() { |
| 229 | GCAdapter::GCPadStatus pad; | 226 | GCAdapter::GCPadStatus pad; |
| 230 | auto& queue = adapter->GetPadQueue(); | 227 | auto& queue = adapter->GetPadQueue(); |
| 231 | for (int port = 0; port < queue.size(); port++) { | 228 | for (std::size_t port = 0; port < queue.size(); ++port) { |
| 232 | while (queue[port].Pop(pad)) { | 229 | while (queue[port].Pop(pad)) { |
| 233 | if (pad.axis == GCAdapter::PadAxes::Undefined || | 230 | if (pad.axis == GCAdapter::PadAxes::Undefined || |
| 234 | std::abs((pad.axis_value - 128.0f) / 128.0f) < 0.1) { | 231 | std::abs((pad.axis_value - 128.0f) / 128.0f) < 0.1) { |