mirror of https://git.suyu.dev/suyu/suyu
std::arrays where appropriate, clear q in adapter class, other touch ups
This commit is contained in:
parent
5f0fa4cb82
commit
968d631aa5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue