|
|
@ -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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|