Merge branch 'cemu-project:main' into main

This commit is contained in:
rcaridade145 2026-04-28 16:13:34 +01:00 committed by GitHub
commit e28ae3b4b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 83 additions and 38 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_VCPKG | | Use VCPKG package manager to obtain dependencies | ON | |
| ENABLE_VULKAN | | Enable the Vulkan graphics backend | ON | | | ENABLE_VULKAN | | Enable the Vulkan graphics backend | ON | |
| ENABLE_WXWIDGETS | | Enable wxWidgets UI | ON | Currently required | | ENABLE_WXWIDGETS | | Enable wxWidgets UI | ON | Currently required |
| ENABLE_LIBUSB | | Enable libusb | ON | |
### Windows ### Windows
| Flag | Description | Default | Note | | Flag | Description | Default | Note |

View File

@ -132,6 +132,11 @@ endif()
option(ENABLE_HIDAPI "Build with HIDAPI" ON) option(ENABLE_HIDAPI "Build with HIDAPI" ON)
option(ENABLE_SDL "Enables the SDLController backend" 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)
endif()
# audio backends # audio backends
if (WIN32) 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}") COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/bin/${folder}" "$<TARGET_BUNDLE_DIR:CemuBin>/Contents/SharedSupport/${folder}")
endforeach(folder) endforeach(folder)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if (ENABLE_LIBUSB)
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/lib/libusb-1.0.0.dylib") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
else() set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/lib/libusb-1.0.0.dylib")
set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/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() endif()
if (EXISTS "/usr/local/lib/libMoltenVK.dylib") if (EXISTS "/usr/local/lib/libMoltenVK.dylib")
@ -142,9 +144,6 @@ if (MACOS_BUNDLE)
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
"${MOLTENVK_PATH}" "${MOLTENVK_PATH}"
"${FRAMEWORKS_DIR}/libMoltenVK.dylib" "${FRAMEWORKS_DIR}/libMoltenVK.dylib"
COMMAND ${CMAKE_COMMAND} -E copy
"${LIBUSB_PATH}"
"${FRAMEWORKS_DIR}/libusb-1.0.0.dylib"
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
"${UPDATE_SH_PATH}" "${UPDATE_SH_PATH}"
"${RESOURCES_DIR}/update.sh" "${RESOURCES_DIR}/update.sh"
@ -152,17 +151,27 @@ if (MACOS_BUNDLE)
"${RESOURCES_DIR}/update.sh" "${RESOURCES_DIR}/update.sh"
) )
if (ENABLE_LIBUSB)
add_custom_command(TARGET CemuBin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${LIBUSB_PATH}"
"${FRAMEWORKS_DIR}/libusb-1.0.0.dylib"
)
endif()
set_target_properties(CemuBin PROPERTIES set_target_properties(CemuBin PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "@executable_path/../Frameworks" INSTALL_RPATH "@executable_path/../Frameworks"
) )
add_custom_command(TARGET CemuBin POST_BUILD if (ENABLE_LIBUSB)
add_custom_command(TARGET CemuBin POST_BUILD
COMMAND install_name_tool COMMAND install_name_tool
-change @rpath/libusb-1.0.0.dylib -change @rpath/libusb-1.0.0.dylib
@executable_path/../Frameworks/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib
"$<TARGET_FILE:CemuBin>" "$<TARGET_FILE:CemuBin>"
) )
endif()
else() else()
if(APPLE) if(APPLE)
find_library(MOLTENVK_LIBRARY find_library(MOLTENVK_LIBRARY

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#include "input/api/GameCube/GameCubeController.h" #include "input/api/GameCube/GameCubeController.h"
#ifdef HAS_GAMECUBE #if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
GameCubeController::GameCubeController(uint32 adapter, uint32 index) GameCubeController::GameCubeController(uint32 adapter, uint32 index)
: base_type(fmt::format("{}_{}", adapter, index), fmt::format("Controller {}", index + 1)), m_adapter(adapter), : 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/Controller.h"
#include "input/api/GameCube/GameCubeControllerProvider.h" #include "input/api/GameCube/GameCubeControllerProvider.h"
#ifdef HAS_GAMECUBE #if defined(HAS_GAMECUBE) && HAS_GAMECUBE && defined(HAS_LIBUSB)
class GameCubeController : public Controller<GameCubeControllerProvider> class GameCubeController : public Controller<GameCubeControllerProvider>
{ {

View File

@ -2,7 +2,7 @@
#include "input/api/GameCube/GameCubeController.h" #include "input/api/GameCube/GameCubeController.h"
#include "util/libusbWrapper/libusbWrapper.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; constexpr uint16_t kVendorId = 0x57e, kProductId = 0x337;

View File

@ -1,9 +1,10 @@
#pragma once #pragma once
#include "util/libusbWrapper/libusbWrapper.h"
#include "input/api/ControllerProvider.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 class GameCubeControllerProvider : public ControllerProviderBase
{ {

View File

@ -43,8 +43,6 @@ add_library(CemuUtil
ImageWriter/tga.h ImageWriter/tga.h
IniParser/IniParser.cpp IniParser/IniParser.cpp
IniParser/IniParser.h IniParser/IniParser.h
libusbWrapper/libusbWrapper.cpp
libusbWrapper/libusbWrapper.h
math/glm.h math/glm.h
math/quaternion.h math/quaternion.h
math/vector2.h math/vector2.h
@ -91,6 +89,13 @@ set_property(TARGET CemuUtil PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CON
cemu_use_precompiled_header(CemuUtil) 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_include_directories(CemuUtil PUBLIC "../")
target_link_libraries(CemuUtil PRIVATE target_link_libraries(CemuUtil PRIVATE