diff --git a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp index c9b11d94e4..95b8b6bdfa 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp @@ -8,7 +8,6 @@ #include "Common/Assert.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" -#include "Core/HW/WiimoteCommon/WiimoteHid.h" using namespace WiimoteCommon; using namespace WiimoteReal; @@ -65,8 +64,8 @@ bool WiimoteScannerHidapi::IsReady() const void WiimoteScannerHidapi::FindWiimotes(std::vector& wiimotes, Wiimote*& board) { - hid_device_info* list = hid_enumerate(0x0, 0x0); - for (hid_device_info* device = list; device; device = device->next) + hid_device_info* list = hid_enumerate(0x0, 0x0); // FYI: 0 for all VID/PID. + for (hid_device_info* device = list; device != nullptr; device = device->next) { const std::string name = device->product_string ? WStringToUTF8(device->product_string) : ""; const bool is_wiimote = @@ -89,7 +88,7 @@ void WiimoteScannerHidapi::FindWiimotes(std::vector& wiimotes, Wiimote hid_free_enumeration(list); } -WiimoteHidapi::WiimoteHidapi(const std::string& device_path) : m_device_path(device_path) +WiimoteHidapi::WiimoteHidapi(std::string device_path) : m_device_path(std::move(device_path)) { } @@ -145,6 +144,7 @@ int WiimoteHidapi::IORead(u8* buf) int WiimoteHidapi::IOWrite(const u8* buf, size_t len) { + assert(len > 0); DEBUG_ASSERT(buf[0] == (WR_SET_REPORT | BT_OUTPUT)); int result = hid_write(m_handle, buf + 1, len - 1); if (result == -1) diff --git a/Source/Core/Core/HW/WiimoteReal/IOhidapi.h b/Source/Core/Core/HW/WiimoteReal/IOhidapi.h index 9a6f6f09cf..f4340e3bc2 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOhidapi.h +++ b/Source/Core/Core/HW/WiimoteReal/IOhidapi.h @@ -13,7 +13,7 @@ namespace WiimoteReal class WiimoteHidapi final : public Wiimote { public: - explicit WiimoteHidapi(const std::string& device_path); + explicit WiimoteHidapi(std::string device_path); ~WiimoteHidapi() override; std::string GetId() const override { return m_device_path; } @@ -26,7 +26,7 @@ protected: int IOWrite(const u8* buf, size_t len) override; private: - std::string m_device_path; + const std::string m_device_path; hid_device* m_handle = nullptr; };