diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9908b4..84111f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,6 @@ if (ENABLE_DISCORD_RPC) endif() if (ENABLE_HIDAPI) - find_package(hidapi REQUIRED) set(SUPPORTS_WIIMOTE ON) add_compile_definitions(HAS_HIDAPI) endif () diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index cdf9cbba..f0baba0b 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -92,10 +92,6 @@ target_link_libraries(CemuInput PRIVATE CemuGui ) -if (ENABLE_HIDAPI) - target_link_libraries(CemuInput PRIVATE hidapi::hidapi) -endif() - if (ENABLE_BLUEZ) target_link_libraries(CemuInput PRIVATE bluez::bluez) endif () diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp index 5780909f..02e12cee 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp @@ -7,18 +7,18 @@ static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330; static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22; static constexpr auto PRO_CONTROLLER_NAME = L"Nintendo RVL-CNT-01-UC"; -HidapiWiimote::HidapiWiimote(hid_device* dev, std::string_view path) +HidapiWiimote::HidapiWiimote(SDL_hid_device* dev, std::string_view path) : m_handle(dev), m_path(path) { } bool HidapiWiimote::write_data(const std::vector &data) { - return hid_write(m_handle, data.data(), data.size()) >= 0; + return SDL_hid_write(m_handle, data.data(), data.size()) >= 0; } std::optional> HidapiWiimote::read_data() { std::array read_data{}; - const auto result = hid_read(m_handle, read_data.data(), WIIMOTE_MAX_INPUT_REPORT_LENGTH); + const auto result = SDL_hid_read(m_handle, read_data.data(), WIIMOTE_MAX_INPUT_REPORT_LENGTH); if (result < 0) return {}; return {{read_data.cbegin(), read_data.cbegin() + result}}; @@ -26,24 +26,24 @@ std::optional> HidapiWiimote::read_data() { std::vector HidapiWiimote::get_devices() { std::vector wiimote_devices; - hid_init(); - const auto device_enumeration = hid_enumerate(WIIMOTE_VENDOR_ID, 0x0); + SDL_hid_init(); + const auto device_enumeration = SDL_hid_enumerate(WIIMOTE_VENDOR_ID, 0x0); for (auto it = device_enumeration; it != nullptr; it = it->next){ if (it->product_id != WIIMOTE_PRODUCT_ID && it->product_id != WIIMOTE_MP_PRODUCT_ID) continue; if (std::wcscmp(it->product_string, PRO_CONTROLLER_NAME) == 0) continue; - auto dev = hid_open_path(it->path); + auto dev = SDL_hid_open_path(it->path); if (!dev){ - cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, boost::nowide::narrow(hid_error(nullptr))); + cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, SDL_GetError()); } else { - hid_set_nonblocking(dev, true); + SDL_hid_set_nonblocking(dev, true); wiimote_devices.push_back(std::make_shared(dev, it->path)); } } - hid_free_enumeration(device_enumeration); + SDL_hid_free_enumeration(device_enumeration); return wiimote_devices; } @@ -55,5 +55,5 @@ bool HidapiWiimote::operator==(const WiimoteDevice& rhs) const { } HidapiWiimote::~HidapiWiimote() { - hid_close(m_handle); + SDL_hid_close(m_handle); } diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.h b/src/input/api/Wiimote/hidapi/HidapiWiimote.h index 952a36f0..ffb83541 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.h +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.h @@ -1,11 +1,11 @@ #pragma once #include -#include +#include class HidapiWiimote : public WiimoteDevice { public: - HidapiWiimote(hid_device* dev, std::string_view path); + HidapiWiimote(SDL_hid_device* dev, std::string_view path); ~HidapiWiimote() override; bool write_data(const std::vector &data) override; @@ -15,7 +15,7 @@ public: static std::vector get_devices(); private: - hid_device* m_handle; + SDL_hid_device* m_handle; const std::string m_path; }; diff --git a/vcpkg.json b/vcpkg.json index 598fe809..576c7b27 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -32,7 +32,6 @@ "name": "fmt", "version>=": "12.1.0" }, - "hidapi", "libpng", "glm", {