mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-04-26 04:45:18 -06:00
add ENABLE_LIBUSB option
This commit is contained in:
parent
02383542b2
commit
ee0d79ef64
@ -128,6 +128,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=1)
|
||||
else()
|
||||
add_compile_definitions(HAS_LIBUSB=0)
|
||||
endif()
|
||||
|
||||
# audio backends
|
||||
if (WIN32)
|
||||
|
||||
@ -113,10 +113,12 @@ if (MACOS_BUNDLE)
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/bin/${folder}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/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")
|
||||
@ -129,10 +131,14 @@ if (MACOS_BUNDLE)
|
||||
|
||||
add_custom_command (TARGET CemuBin POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${MOLTENVK_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib"
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${LIBUSB_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib"
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh"
|
||||
COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}"
|
||||
COMMAND install_name_tool -change @rpath/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME})
|
||||
COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}")
|
||||
|
||||
if (ENABLE_LIBUSB)
|
||||
add_custom_command (TARGET CemuBin POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${LIBUSB_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib"
|
||||
COMMAND install_name_tool -change @rpath/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME})
|
||||
endif()
|
||||
else()
|
||||
if(APPLE)
|
||||
find_library(MOLTENVK_LIBRARY
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
#include "nsyshid.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendEmulated.h"
|
||||
#if HAS_LIBUSB
|
||||
#include "BackendLibusb.h"
|
||||
#endif
|
||||
|
||||
namespace nsyshid::backend
|
||||
{
|
||||
void AttachDefaultBackends()
|
||||
{
|
||||
#if 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>();
|
||||
|
||||
@ -29,6 +29,7 @@ namespace nsyshid::backend::emulated
|
||||
auto device = std::make_shared<SkylanderPortalDevice>();
|
||||
AttachDevice(device);
|
||||
}
|
||||
#if 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");
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace nsyshid
|
||||
{
|
||||
#if 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
|
||||
@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "nsyshid.h"
|
||||
#if HAS_LIBUSB
|
||||
#include "BackendLibusb.h"
|
||||
#include "g721/g721.h"
|
||||
#endif
|
||||
|
||||
namespace nsyshid
|
||||
{
|
||||
#if 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 };
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 && 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 && HAS_LIBUSB
|
||||
case InputAPI::GameCube:
|
||||
return std::make_shared<GameCubeControllerProvider>();
|
||||
#endif
|
||||
|
||||
@ -40,7 +40,7 @@ InputManager::InputManager()
|
||||
#if HAS_DSU
|
||||
create_provider<DSUControllerProvider>();
|
||||
#endif
|
||||
#if HAS_GAMECUBE
|
||||
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && HAS_LIBUSB
|
||||
create_provider<GameCubeControllerProvider>();
|
||||
#endif
|
||||
#if HAS_WIIMOTE
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "input/api/GameCube/GameCubeController.h"
|
||||
|
||||
#ifdef HAS_GAMECUBE
|
||||
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && HAS_LIBUSB
|
||||
|
||||
GameCubeController::GameCubeController(uint32 adapter, uint32 index)
|
||||
: base_type(fmt::format("{}_{}", adapter, index), fmt::format("Controller {}", index + 1)), m_adapter(adapter),
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include "input/api/Controller.h"
|
||||
#include "input/api/GameCube/GameCubeControllerProvider.h"
|
||||
|
||||
#ifdef HAS_GAMECUBE
|
||||
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && HAS_LIBUSB
|
||||
|
||||
class GameCubeController : public Controller<GameCubeControllerProvider>
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include "input/api/GameCube/GameCubeController.h"
|
||||
#include "util/libusbWrapper/libusbWrapper.h"
|
||||
|
||||
#if HAS_GAMECUBE
|
||||
#if defined(HAS_GAMECUBE) && HAS_GAMECUBE && HAS_LIBUSB
|
||||
|
||||
constexpr uint16_t kVendorId = 0x57e, kProductId = 0x337;
|
||||
|
||||
|
||||
@ -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 && HAS_LIBUSB
|
||||
|
||||
#include "util/libusbWrapper/libusbWrapper.h"
|
||||
|
||||
class GameCubeControllerProvider : public ControllerProviderBase
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user