input_common: Allow disabling GCAdapter on platforms without libusb. (#6448)
This commit is contained in:
parent
7197367040
commit
81d24dd7fb
3 changed files with 38 additions and 14 deletions
|
@ -34,6 +34,8 @@ endif()
|
||||||
|
|
||||||
option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
|
option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
|
||||||
|
|
||||||
|
CMAKE_DEPENDENT_OPTION(ENABLE_LIBUSB "Enable libusb for GameCube Adapter support" ON "NOT IOS" OFF)
|
||||||
|
|
||||||
option(ENABLE_FFMPEG_AUDIO_DECODER "Enable FFmpeg audio (AAC) decoder" OFF)
|
option(ENABLE_FFMPEG_AUDIO_DECODER "Enable FFmpeg audio (AAC) decoder" OFF)
|
||||||
option(ENABLE_FFMPEG_VIDEO_DUMPER "Enable FFmpeg video dumper" OFF)
|
option(ENABLE_FFMPEG_VIDEO_DUMPER "Enable FFmpeg video dumper" OFF)
|
||||||
|
|
||||||
|
@ -224,6 +226,7 @@ if (ENABLE_QT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Ensure libusb is properly configured (based on dolphin libusb include)
|
# Ensure libusb is properly configured (based on dolphin libusb include)
|
||||||
|
if (ENABLE_LIBUSB)
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
find_package(LibUSB)
|
find_package(LibUSB)
|
||||||
|
@ -233,6 +236,7 @@ if (NOT LIBUSB_FOUND)
|
||||||
set(LIBUSB_INCLUDE_DIR "")
|
set(LIBUSB_INCLUDE_DIR "")
|
||||||
set(LIBUSB_LIBRARIES usb)
|
set(LIBUSB_LIBRARIES usb)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (ENABLE_FFMPEG)
|
if (ENABLE_FFMPEG)
|
||||||
if (CITRA_USE_BUNDLED_FFMPEG)
|
if (CITRA_USE_BUNDLED_FFMPEG)
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
add_library(input_common STATIC
|
add_library(input_common STATIC
|
||||||
analog_from_button.cpp
|
analog_from_button.cpp
|
||||||
analog_from_button.h
|
analog_from_button.h
|
||||||
gcadapter/gc_adapter.cpp
|
|
||||||
gcadapter/gc_adapter.h
|
|
||||||
gcadapter/gc_poller.cpp
|
|
||||||
gcadapter/gc_poller.h
|
|
||||||
keyboard.cpp
|
keyboard.cpp
|
||||||
keyboard.h
|
keyboard.h
|
||||||
main.cpp
|
main.cpp
|
||||||
|
@ -33,10 +29,20 @@ if(ENABLE_SDL2)
|
||||||
target_compile_definitions(input_common PRIVATE HAVE_SDL2)
|
target_compile_definitions(input_common PRIVATE HAVE_SDL2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_LIBUSB)
|
||||||
|
target_sources(input_common PRIVATE
|
||||||
|
gcadapter/gc_adapter.cpp
|
||||||
|
gcadapter/gc_adapter.h
|
||||||
|
gcadapter/gc_poller.cpp
|
||||||
|
gcadapter/gc_poller.h
|
||||||
|
)
|
||||||
|
target_include_directories(input_common PRIVATE ${LIBUSB_INCLUDE_DIR})
|
||||||
|
target_link_libraries(input_common PRIVATE ${LIBUSB_LIBRARIES})
|
||||||
|
add_definitions(-DENABLE_GCADAPTER)
|
||||||
|
endif()
|
||||||
|
|
||||||
create_target_directory_groups(input_common)
|
create_target_directory_groups(input_common)
|
||||||
target_link_libraries(input_common PUBLIC core PRIVATE common ${Boost_LIBRARIES})
|
target_link_libraries(input_common PUBLIC core PRIVATE common ${Boost_LIBRARIES})
|
||||||
target_include_directories(input_common PRIVATE ${LIBUSB_INCLUDE_DIR})
|
|
||||||
target_link_libraries(input_common PUBLIC ${LIBUSB_LIBRARIES})
|
|
||||||
set_target_properties(input_common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
set_target_properties(input_common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
||||||
|
|
||||||
if (CITRA_USE_PRECOMPILED_HEADERS)
|
if (CITRA_USE_PRECOMPILED_HEADERS)
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "input_common/analog_from_button.h"
|
#include "input_common/analog_from_button.h"
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
#include "input_common/gcadapter/gc_adapter.h"
|
#include "input_common/gcadapter/gc_adapter.h"
|
||||||
#include "input_common/gcadapter/gc_poller.h"
|
#include "input_common/gcadapter/gc_poller.h"
|
||||||
|
#endif
|
||||||
#include "input_common/keyboard.h"
|
#include "input_common/keyboard.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "input_common/motion_emu.h"
|
#include "input_common/motion_emu.h"
|
||||||
|
@ -18,20 +20,24 @@
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
std::shared_ptr<GCButtonFactory> gcbuttons;
|
std::shared_ptr<GCButtonFactory> gcbuttons;
|
||||||
std::shared_ptr<GCAnalogFactory> gcanalog;
|
std::shared_ptr<GCAnalogFactory> gcanalog;
|
||||||
std::shared_ptr<GCAdapter::Adapter> gcadapter;
|
std::shared_ptr<GCAdapter::Adapter> gcadapter;
|
||||||
|
#endif
|
||||||
static std::shared_ptr<Keyboard> keyboard;
|
static std::shared_ptr<Keyboard> keyboard;
|
||||||
static std::shared_ptr<MotionEmu> motion_emu;
|
static std::shared_ptr<MotionEmu> motion_emu;
|
||||||
static std::unique_ptr<CemuhookUDP::State> udp;
|
static std::unique_ptr<CemuhookUDP::State> udp;
|
||||||
static std::unique_ptr<SDL::State> sdl;
|
static std::unique_ptr<SDL::State> sdl;
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
gcadapter = std::make_shared<GCAdapter::Adapter>();
|
gcadapter = std::make_shared<GCAdapter::Adapter>();
|
||||||
gcbuttons = std::make_shared<GCButtonFactory>(gcadapter);
|
gcbuttons = std::make_shared<GCButtonFactory>(gcadapter);
|
||||||
Input::RegisterFactory<Input::ButtonDevice>("gcpad", gcbuttons);
|
Input::RegisterFactory<Input::ButtonDevice>("gcpad", gcbuttons);
|
||||||
gcanalog = std::make_shared<GCAnalogFactory>(gcadapter);
|
gcanalog = std::make_shared<GCAnalogFactory>(gcadapter);
|
||||||
Input::RegisterFactory<Input::AnalogDevice>("gcpad", gcanalog);
|
Input::RegisterFactory<Input::AnalogDevice>("gcpad", gcanalog);
|
||||||
|
#endif
|
||||||
keyboard = std::make_shared<Keyboard>();
|
keyboard = std::make_shared<Keyboard>();
|
||||||
Input::RegisterFactory<Input::ButtonDevice>("keyboard", keyboard);
|
Input::RegisterFactory<Input::ButtonDevice>("keyboard", keyboard);
|
||||||
Input::RegisterFactory<Input::AnalogDevice>("analog_from_button",
|
Input::RegisterFactory<Input::AnalogDevice>("analog_from_button",
|
||||||
|
@ -47,10 +53,12 @@ void Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
|
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
|
||||||
Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
|
Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
|
||||||
gcbuttons.reset();
|
gcbuttons.reset();
|
||||||
gcanalog.reset();
|
gcanalog.reset();
|
||||||
|
#endif
|
||||||
Input::UnregisterFactory<Input::ButtonDevice>("keyboard");
|
Input::UnregisterFactory<Input::ButtonDevice>("keyboard");
|
||||||
keyboard.reset();
|
keyboard.reset();
|
||||||
Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button");
|
Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button");
|
||||||
|
@ -99,9 +107,11 @@ Common::ParamPackage GetControllerButtonBinds(const Common::ParamPackage& params
|
||||||
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerButtonBindByGUID(
|
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerButtonBindByGUID(
|
||||||
params.Get("guid", "0"), params.Get("port", 0), native_button);
|
params.Get("guid", "0"), params.Get("port", 0), native_button);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
if (engine == "gcpad") {
|
if (engine == "gcpad") {
|
||||||
return gcbuttons->GetGcTo3DSMappedButton(params.Get("port", 0), native_button);
|
return gcbuttons->GetGcTo3DSMappedButton(params.Get("port", 0), native_button);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,9 +122,11 @@ Common::ParamPackage GetControllerAnalogBinds(const Common::ParamPackage& params
|
||||||
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerAnalogBindByGUID(
|
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerAnalogBindByGUID(
|
||||||
params.Get("guid", "0"), params.Get("port", 0), native_analog);
|
params.Get("guid", "0"), params.Get("port", 0), native_analog);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
if (engine == "gcpad") {
|
if (engine == "gcpad") {
|
||||||
return gcanalog->GetGcTo3DSMappedAnalog(params.Get("port", 0), native_analog);
|
return gcanalog->GetGcTo3DSMappedAnalog(params.Get("port", 0), native_analog);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +145,7 @@ std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) {
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
pollers = sdl->GetPollers(type);
|
pollers = sdl->GetPollers(type);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_GCADAPTER
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DeviceType::Analog:
|
case DeviceType::Analog:
|
||||||
pollers.push_back(std::make_unique<GCAnalogFactory>(*gcanalog));
|
pollers.push_back(std::make_unique<GCAnalogFactory>(*gcanalog));
|
||||||
|
@ -143,6 +156,7 @@ std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return pollers;
|
return pollers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue