summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp16
-rw-r--r--src/input_common/gcadapter/gc_adapter.h5
-rw-r--r--src/input_common/gcadapter/gc_poller.cpp16
-rw-r--r--src/input_common/gcadapter/gc_poller.h4
-rw-r--r--src/input_common/main.cpp1
5 files changed, 15 insertions, 27 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index 0696a96c7..498bd0d6e 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -134,7 +134,7 @@ void Adapter::Read() {
payload_size = payload_size_in;
}
- GCPadStatus pad[4];
+ std::array<GCPadStatus, 4> pad;
if (payload_size != sizeof(controller_payload_copy) ||
controller_payload_copy[0] != LIBUSB_DT_HID) {
LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size,
@@ -224,9 +224,7 @@ void Adapter::Setup() {
current_status = NO_ADAPTER_DETECTED;
}
- for (int i = 0; i < 4; i++) {
- adapter_controllers_status[i] = ControllerTypes::None;
- }
+ adapter_controllers_status.fill(ControllerTypes::None);
libusb_device** devs; // pointer to list of connected usb devices
@@ -332,9 +330,7 @@ void Adapter::Reset() {
adapter_input_thread.join();
}
- for (int i = 0; i < 4; i++) {
- adapter_controllers_status[i] = ControllerTypes::None;
- }
+ adapter_controllers_status.fill(ControllerTypes::None);
current_status = NO_ADAPTER_DETECTED;
@@ -354,10 +350,16 @@ void Adapter::ResetDeviceType(int port) {
}
void Adapter::BeginConfiguration() {
+ for (auto& pq : pad_queue) {
+ pq.Clear();
+ }
configuring = true;
}
void Adapter::EndConfiguration() {
+ for (auto& pq : pad_queue) {
+ pq.Clear();
+ }
configuring = false;
}
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h
index a32ca0464..cb0dd0ab1 100644
--- a/src/input_common/gcadapter/gc_adapter.h
+++ b/src/input_common/gcadapter/gc_adapter.h
@@ -96,6 +96,8 @@ public:
std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue();
std::array<GCState, 4>& GetPadState();
+ std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue() const;
+ std::array<GCState, 4>& GetPadState() const;
private:
/// Singleton instance.
@@ -139,8 +141,7 @@ private:
int current_status = NO_ADAPTER_DETECTED;
libusb_device_handle* usb_adapter_handle = nullptr;
- ControllerTypes adapter_controllers_status[4] = {ControllerTypes::None, ControllerTypes::None,
- ControllerTypes::None, ControllerTypes::None};
+ std::array<ControllerTypes, 4> adapter_controllers_status{};
std::mutex s_mutex;
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp
index 0e591baca..ac4126cb6 100644
--- a/src/input_common/gcadapter/gc_poller.cpp
+++ b/src/input_common/gcadapter/gc_poller.cpp
@@ -56,9 +56,7 @@ GCButtonFactory::GCButtonFactory() {
adapter = GCAdapter::Adapter::GetInstance();
}
-GCButton::~GCButton() {
- // GCAdapter::Shutdown();
-}
+GCButton::~GCButton() = default;
std::unique_ptr<Input::ButtonDevice> GCButtonFactory::Create(const Common::ParamPackage& params) {
int button_id = params.Get("button", 0);
@@ -163,17 +161,11 @@ Common::ParamPackage GCButtonFactory::GetNextInput() {
void GCButtonFactory::BeginConfiguration() {
polling = true;
- for (int i = 0; i < 4; i++) {
- adapter->GetPadQueue()[i].Clear();
- }
adapter->BeginConfiguration();
}
void GCButtonFactory::EndConfiguration() {
polling = false;
- for (int i = 0; i < 4; i++) {
- adapter->GetPadQueue()[i].Clear();
- }
adapter->EndConfiguration();
}
@@ -265,17 +257,11 @@ std::unique_ptr<Input::AnalogDevice> GCAnalogFactory::Create(const Common::Param
void GCAnalogFactory::BeginConfiguration() {
polling = true;
- for (int i = 0; i < 4; i++) {
- adapter->GetPadQueue()[i].Clear();
- }
adapter->BeginConfiguration();
}
void GCAnalogFactory::EndConfiguration() {
polling = false;
- for (int i = 0; i < 4; i++) {
- adapter->GetPadQueue()[i].Clear();
- }
adapter->EndConfiguration();
}
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;
}
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index 536e5c80a..89dddf7cf 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -2,7 +2,6 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include <iostream>
#include <memory>
#include <thread>
#include <libusb.h>