From 77d33d61de5f562fec21c69f0f8c9dd192ceff4d Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 12 Aug 2023 20:16:37 -0700 Subject: [PATCH 1/2] GCAdapter: Fix spelling of constants --- Source/Core/InputCommon/GCAdapter.cpp | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index ec3c3a1fb3..2b0ce2b6c0 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -99,9 +99,9 @@ enum class ControllerType : u8 static std::array s_controller_rumble; -constexpr size_t CONTROLER_INPUT_PAYLOAD_EXPECTED_SIZE = 37; -constexpr size_t CONTROLER_OUTPUT_INIT_PAYLOAD_SIZE = 1; -constexpr size_t CONTROLER_OUTPUT_RUMBLE_PAYLOAD_SIZE = 5; +constexpr size_t CONTROLLER_INPUT_PAYLOAD_EXPECTED_SIZE = 37; +constexpr size_t CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE = 1; +constexpr size_t CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE = 5; struct PortState { @@ -115,7 +115,7 @@ struct PortState // Only access with s_mutex held! static std::array s_port_states; -static std::array s_controller_write_payload; +static std::array s_controller_write_payload; static std::atomic s_controller_write_payload_size{0}; static std::thread s_read_adapter_thread; @@ -200,7 +200,7 @@ static void ReadThreadFunc() while (s_read_adapter_thread_running.IsSet()) { #if GCADAPTER_USE_LIBUSB_IMPLEMENTATION - std::array input_buffer; + std::array input_buffer; int payload_size = 0; int error = libusb_interrupt_transfer(s_handle, s_endpoint_in, input_buffer.data(), @@ -289,7 +289,7 @@ static void WriteThreadFunc() LibusbUtils::ErrorWrap(error)); } #elif GCADAPTER_USE_ANDROID_IMPLEMENTATION - const jbyteArray jrumble_array = env->NewByteArray(CONTROLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); + const jbyteArray jrumble_array = env->NewByteArray(CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); jbyte* const jrumble = env->GetByteArrayElements(jrumble_array, nullptr); { @@ -650,9 +650,9 @@ static void AddGCAdapter(libusb_device* device) config.reset(); int size = 0; - std::array payload = {0x13}; + std::array payload = {0x13}; error = libusb_interrupt_transfer(s_handle, s_endpoint_out, payload.data(), - CONTROLER_OUTPUT_INIT_PAYLOAD_SIZE, &size, USB_TIMEOUT_MS); + CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE, &size, USB_TIMEOUT_MS); if (error != LIBUSB_SUCCESS) { WARN_LOG_FMT(CONTROLLERINTERFACE, "AddGCAdapter: libusb_interrupt_transfer failed: {}", @@ -776,7 +776,7 @@ static ControllerType IdentifyControllerType(u8 data) void ProcessInputPayload(const u8* data, std::size_t size) { - if (size != CONTROLER_INPUT_PAYLOAD_EXPECTED_SIZE + if (size != CONTROLLER_INPUT_PAYLOAD_EXPECTED_SIZE #if GCADAPTER_USE_LIBUSB_IMPLEMENTATION || data[0] != LIBUSB_DT_HID #endif @@ -891,11 +891,11 @@ void ResetRumble() return; ResetRumbleLockNeeded(); #elif GCADAPTER_USE_ANDROID_IMPLEMENTATION - std::array rumble = {0x11, 0, 0, 0, 0}; + std::array rumble = {0x11, 0, 0, 0, 0}; { std::lock_guard lk(s_write_mutex); s_controller_write_payload = rumble; - s_controller_write_payload_size.store(CONTROLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); + s_controller_write_payload_size.store(CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); } s_write_happened.Set(); #endif @@ -913,14 +913,14 @@ static void ResetRumbleLockNeeded() std::fill(std::begin(s_controller_rumble), std::end(s_controller_rumble), 0); - std::array rumble = { + std::array rumble = { 0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2], s_controller_rumble[3]}; int size = 0; const int error = libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble.data(), - CONTROLER_OUTPUT_RUMBLE_PAYLOAD_SIZE, &size, USB_TIMEOUT_MS); + CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE, &size, USB_TIMEOUT_MS); if (error != LIBUSB_SUCCESS) { WARN_LOG_FMT(CONTROLLERINTERFACE, "ResetRumbleLockNeeded: libusb_interrupt_transfer failed: {}", @@ -949,7 +949,7 @@ void Output(int chan, u8 rumble_command) s_port_states[chan].controller_type != ControllerType::Wireless) { s_controller_rumble[chan] = rumble_command; - std::array rumble = { + std::array rumble = { 0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2], s_controller_rumble[3]}; { @@ -957,7 +957,7 @@ void Output(int chan, u8 rumble_command) std::lock_guard lk(s_write_mutex); #endif s_controller_write_payload = rumble; - s_controller_write_payload_size.store(CONTROLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); + s_controller_write_payload_size.store(CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE); } s_write_happened.Set(); } From 274b11e4e911768e1218d32381102432e93cccd3 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 12 Aug 2023 20:18:15 -0700 Subject: [PATCH 2/2] GCAdapter: Fix Android unused constant warning CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE is only used by the libusb implementation. --- Source/Core/InputCommon/GCAdapter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index 2b0ce2b6c0..6334a23778 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -100,7 +100,9 @@ enum class ControllerType : u8 static std::array s_controller_rumble; constexpr size_t CONTROLLER_INPUT_PAYLOAD_EXPECTED_SIZE = 37; +#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION constexpr size_t CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE = 1; +#endif constexpr size_t CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE = 5; struct PortState