This commit is contained in:
Emma 2026-04-23 18:04:03 +01:00 committed by GitHub
commit 83facbfb9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 84 additions and 40 deletions

View File

@ -250,6 +250,7 @@ Example usage: `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DENABLE_SDL=ON -
| ENABLE_VCPKG | | Use VCPKG package manager to obtain dependencies | ON | |
| ENABLE_VULKAN | | Enable the Vulkan graphics backend | ON | |
| ENABLE_WXWIDGETS | | Enable wxWidgets UI | ON | Currently required |
| ENABLE_LIBUSB | | Enable libusb | ON | |
### Windows
| Flag | Description | Default | Note |

View File

@ -132,6 +132,13 @@ endif()
option(ENABLE_HIDAPI "Build with HIDAPI" ON)
option(ENABLE_SDL "Enables the SDLController backend" ON)
option(ENABLE_LIBUSB "Build with libusb support" ON)
if (ENABLE_LIBUSB)
add_compile_definitions(HAS_LIBUSB)
else()
add_compile_definitions(HAS_LIBUSB)
endif()
# audio backends
if (WIN32)

View File

@ -119,10 +119,12 @@ if (MACOS_BUNDLE)
COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/bin/${folder}" "$<TARGET_BUNDLE_DIR:CemuBin>/Contents/SharedSupport/${folder}")
endforeach(folder)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/lib/libusb-1.0.0.dylib")
else()
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/lib/libusb-1.0.0.dylib")
if (ENABLE_LIBUSB)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/lib/libusb-1.0.0.dylib")
else()
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/lib/libusb-1.0.0.dylib")
endif()
endif()
if (EXISTS "/usr/local/lib/libMoltenVK.dylib")
@ -142,9 +144,11 @@ if (MACOS_BUNDLE)
COMMAND ${CMAKE_COMMAND} -E copy
"${MOLTENVK_PATH}"
"${FRAMEWORKS_DIR}/libMoltenVK.dylib"
COMMAND ${CMAKE_COMMAND} -E copy
"${LIBUSB_PATH}"
"${FRAMEWORKS_DIR}/libusb-1.0.0.dylib"
if (ENABLE_LIBUSB)
COMMAND ${CMAKE_COMMAND} -E copy
"${LIBUSB_PATH}"
"${FRAMEWORKS_DIR}/libusb-1.0.0.dylib"
endif()
COMMAND ${CMAKE_COMMAND} -E copy
"${UPDATE_SH_PATH}"
"${RESOURCES_DIR}/update.sh"
@ -157,12 +161,14 @@ if (MACOS_BUNDLE)
INSTALL_RPATH "@executable_path/../Frameworks"
)
add_custom_command(TARGET CemuBin POST_BUILD
COMMAND install_name_tool
-change @rpath/libusb-1.0.0.dylib
@executable_path/../Frameworks/libusb-1.0.0.dylib
"$<TARGET_FILE:CemuBin>"
)
if (ENABLE_LIBUSB)
add_custom_command(TARGET CemuBin POST_BUILD
COMMAND install_name_tool
-change @rpath/libusb-1.0.0.dylib
@executable_path/../Frameworks/libusb-1.0.0.dylib
"$<TARGET_FILE:CemuBin>"
)
endif()
else()
if(APPLE)
find_library(MOLTENVK_LIBRARY

View File

@ -471,8 +471,6 @@ add_library(CemuCafe
OS/libs/nsyshid/Whitelist.h
OS/libs/nsyshid/BackendEmulated.cpp
OS/libs/nsyshid/BackendEmulated.h
OS/libs/nsyshid/BackendLibusb.cpp
OS/libs/nsyshid/BackendLibusb.h
OS/libs/nsyshid/Dimensions.cpp
OS/libs/nsyshid/Dimensions.h
OS/libs/nsyshid/Infinity.cpp
@ -617,6 +615,13 @@ set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CON
cemu_use_precompiled_header(CemuCafe)
if (ENABLE_LIBUSB)
target_sources(CemuCafe PRIVATE
OS/libs/nsyshid/BackendLibusb.cpp
OS/libs/nsyshid/BackendLibusb.h
)
endif()
target_include_directories(CemuCafe PUBLIC "../")
if (glslang_VERSION VERSION_LESS "15.0.0")
@ -645,17 +650,19 @@ if (ENABLE_WAYLAND)
target_link_libraries(CemuCafe PUBLIC Wayland::Client)
endif()
if (ENABLE_VCPKG)
if(WIN32)
set(PKG_CONFIG_EXECUTABLE "${VCPKG_INSTALLED_DIR}/x64-windows/tools/pkgconf/pkgconf.exe")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(CemuCafe PRIVATE PkgConfig::libusb)
else ()
find_package(libusb MODULE REQUIRED)
target_link_libraries(CemuCafe PRIVATE libusb::libusb)
endif ()
if (ENABLE_LIBUSB)
if (ENABLE_VCPKG)
if(WIN32)
set(PKG_CONFIG_EXECUTABLE "${VCPKG_INSTALLED_DIR}/x64-windows/tools/pkgconf/pkgconf.exe")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(CemuCafe PRIVATE PkgConfig::libusb)
else ()
find_package(libusb MODULE REQUIRED)
target_link_libraries(CemuCafe PRIVATE libusb::libusb)
endif ()
endif()
if(WIN32)
target_link_libraries(CemuCafe PRIVATE iphlpapi)

View File

@ -1,12 +1,15 @@
#include "nsyshid.h"
#include "Backend.h"
#include "BackendEmulated.h"
#ifdef HAS_LIBUSB
#include "BackendLibusb.h"
#endif
namespace nsyshid::backend
{
void AttachDefaultBackends()
{
#ifdef HAS_LIBUSB
// add libusb backend
{
auto backendLibusb = std::make_shared<backend::libusb::BackendLibusb>();
@ -15,6 +18,7 @@ namespace nsyshid::backend
AttachBackend(backendLibusb);
}
}
#endif
// add emulated backend
{
auto backendEmulated = std::make_shared<backend::emulated::BackendEmulated>();

View File

@ -29,6 +29,7 @@ namespace nsyshid::backend::emulated
auto device = std::make_shared<SkylanderPortalDevice>();
AttachDevice(device);
}
#ifdef HAS_LIBUSB
else if (auto usb_portal = FindDeviceById(0x1430, 0x1F17))
{
cemuLog_logDebug(LogType::Force, "Attaching Xbox 360 Portal");
@ -36,6 +37,7 @@ namespace nsyshid::backend::emulated
auto device = std::make_shared<SkylanderXbox360PortalLibusb>(usb_portal);
AttachDevice(device);
}
#endif
if (GetConfig().emulated_usb_devices.emulate_infinity_base && !FindDeviceById(0x0E6F, 0x0129))
{
cemuLog_logDebug(LogType::Force, "Attaching Emulated Base");

View File

@ -2,6 +2,7 @@
namespace nsyshid
{
#ifdef HAS_LIBUSB
SkylanderXbox360PortalLibusb::SkylanderXbox360PortalLibusb(std::shared_ptr<Device> usbPortal)
: Device(0x1430, 0x0150, 1, 2, 0)
{
@ -157,4 +158,5 @@ namespace nsyshid
{
return true;
}
#endif
} // namespace nsyshid

View File

@ -1,11 +1,14 @@
#pragma once
#include "nsyshid.h"
#ifdef HAS_LIBUSB
#include "BackendLibusb.h"
#include "g721/g721.h"
#endif
namespace nsyshid
{
#ifdef HAS_LIBUSB
class SkylanderXbox360PortalLibusb final : public Device {
public:
SkylanderXbox360PortalLibusb(std::shared_ptr<Device> usbPortal);
@ -40,6 +43,7 @@ namespace nsyshid
bool m_IsOpened;
struct g72x_state m_state;
};
#endif
constexpr uint8 XBOX_DATA_HEADER[] = { 0x0B, 0x14 };
constexpr uint8 XBOX_AUDIO_DATA_HEADER[] = { 0x0B, 0x17 };

View File

@ -23,10 +23,6 @@ add_library(CemuInput
api/Keyboard/KeyboardControllerProvider.cpp
api/Keyboard/KeyboardController.cpp
api/Keyboard/KeyboardController.h
api/GameCube/GameCubeController.cpp
api/GameCube/GameCubeControllerProvider.h
api/GameCube/GameCubeControllerProvider.cpp
api/GameCube/GameCubeController.h
emulated/ProController.cpp
emulated/EmulatedController.h
emulated/EmulatedController.cpp
@ -45,6 +41,15 @@ set_property(TARGET CemuInput PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CO
cemu_use_precompiled_header(CemuInput)
if (ENABLE_LIBUSB)
target_sources(CemuInput PRIVATE
api/GameCube/GameCubeController.cpp
api/GameCube/GameCubeControllerProvider.h
api/GameCube/GameCubeControllerProvider.cpp
api/GameCube/GameCubeController.h
)
endif()
if(WIN32)
# XInput
target_sources(CemuInput PRIVATE

View File

@ -83,7 +83,7 @@ ControllerPtr ControllerFactory::CreateController(InputAPI::Type api, std::strin
return std::make_shared<DSUController>(index);
}
#endif
#if HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
case InputAPI::GameCube:
{
const auto index = uuid.find_first_of('_');
@ -165,7 +165,7 @@ ControllerProviderPtr ControllerFactory::CreateControllerProvider(InputAPI::Type
}
#endif
#if HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
case InputAPI::GameCube:
return std::make_shared<GameCubeControllerProvider>();
#endif

View File

@ -40,7 +40,7 @@ InputManager::InputManager()
#if HAS_DSU
create_provider<DSUControllerProvider>();
#endif
#if HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
create_provider<GameCubeControllerProvider>();
#endif
#if HAS_WIIMOTE

View File

@ -1,6 +1,6 @@
#include "input/api/GameCube/GameCubeController.h"
#ifdef HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
GameCubeController::GameCubeController(uint32 adapter, uint32 index)
: base_type(fmt::format("{}_{}", adapter, index), fmt::format("Controller {}", index + 1)), m_adapter(adapter),

View File

@ -3,7 +3,7 @@
#include "input/api/Controller.h"
#include "input/api/GameCube/GameCubeControllerProvider.h"
#ifdef HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
class GameCubeController : public Controller<GameCubeControllerProvider>
{

View File

@ -2,7 +2,7 @@
#include "input/api/GameCube/GameCubeController.h"
#include "util/libusbWrapper/libusbWrapper.h"
#if HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
constexpr uint16_t kVendorId = 0x57e, kProductId = 0x337;

View File

@ -1,9 +1,10 @@
#pragma once
#include "util/libusbWrapper/libusbWrapper.h"
#include "input/api/ControllerProvider.h"
#ifdef HAS_GAMECUBE
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
#include "util/libusbWrapper/libusbWrapper.h"
class GameCubeControllerProvider : public ControllerProviderBase
{

View File

@ -43,8 +43,6 @@ add_library(CemuUtil
ImageWriter/tga.h
IniParser/IniParser.cpp
IniParser/IniParser.h
libusbWrapper/libusbWrapper.cpp
libusbWrapper/libusbWrapper.h
math/glm.h
math/quaternion.h
math/vector2.h
@ -91,6 +89,13 @@ set_property(TARGET CemuUtil PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CON
cemu_use_precompiled_header(CemuUtil)
if (ENABLE_LIBUSB)
target_sources(CemuUtil PRIVATE
libusbWrapper/libusbWrapper.cpp
libusbWrapper/libusbWrapper.h
)
endif()
target_include_directories(CemuUtil PUBLIC "../")
target_link_libraries(CemuUtil PRIVATE