early-access version 3287
This commit is contained in:
@@ -51,8 +51,29 @@ endif()
|
||||
|
||||
if (ENABLE_SDL2)
|
||||
target_sources(input_common PRIVATE
|
||||
drivers/joycon.cpp
|
||||
drivers/joycon.h
|
||||
drivers/sdl_driver.cpp
|
||||
drivers/sdl_driver.h
|
||||
helpers/joycon_driver.cpp
|
||||
helpers/joycon_driver.h
|
||||
helpers/joycon_protocol/calibration.cpp
|
||||
helpers/joycon_protocol/calibration.h
|
||||
helpers/joycon_protocol/common_protocol.cpp
|
||||
helpers/joycon_protocol/common_protocol.h
|
||||
helpers/joycon_protocol/generic_functions.cpp
|
||||
helpers/joycon_protocol/generic_functions.h
|
||||
helpers/joycon_protocol/joycon_types.h
|
||||
helpers/joycon_protocol/irs.cpp
|
||||
helpers/joycon_protocol/irs.h
|
||||
helpers/joycon_protocol/nfc.cpp
|
||||
helpers/joycon_protocol/nfc.h
|
||||
helpers/joycon_protocol/poller.cpp
|
||||
helpers/joycon_protocol/poller.h
|
||||
helpers/joycon_protocol/ringcon.cpp
|
||||
helpers/joycon_protocol/ringcon.h
|
||||
helpers/joycon_protocol/rumble.cpp
|
||||
helpers/joycon_protocol/rumble.h
|
||||
)
|
||||
target_link_libraries(input_common PRIVATE SDL2::SDL2)
|
||||
target_compile_definitions(input_common PRIVATE HAVE_SDL2)
|
||||
|
@@ -72,11 +72,11 @@ std::size_t Camera::getImageHeight() const {
|
||||
}
|
||||
}
|
||||
|
||||
Common::Input::CameraError Camera::SetCameraFormat(
|
||||
Common::Input::DriverResult Camera::SetCameraFormat(
|
||||
[[maybe_unused]] const PadIdentifier& identifier_,
|
||||
const Common::Input::CameraFormat camera_format) {
|
||||
status.format = camera_format;
|
||||
return Common::Input::CameraError::None;
|
||||
return Common::Input::DriverResult::Success;
|
||||
}
|
||||
|
||||
} // namespace InputCommon
|
||||
|
@@ -22,8 +22,8 @@ public:
|
||||
std::size_t getImageWidth() const;
|
||||
std::size_t getImageHeight() const;
|
||||
|
||||
Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_,
|
||||
Common::Input::CameraFormat camera_format) override;
|
||||
Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_,
|
||||
Common::Input::CameraFormat camera_format) override;
|
||||
|
||||
private:
|
||||
Common::Input::CameraStatus status{};
|
||||
|
@@ -324,7 +324,7 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Common::Input::VibrationError GCAdapter::SetVibration(
|
||||
Common::Input::DriverResult GCAdapter::SetVibration(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
||||
const auto processed_amplitude =
|
||||
@@ -333,9 +333,9 @@ Common::Input::VibrationError GCAdapter::SetVibration(
|
||||
pads[identifier.port].rumble_amplitude = processed_amplitude;
|
||||
|
||||
if (!rumble_enabled) {
|
||||
return Common::Input::VibrationError::Disabled;
|
||||
return Common::Input::DriverResult::Disabled;
|
||||
}
|
||||
return Common::Input::VibrationError::None;
|
||||
return Common::Input::DriverResult::Success;
|
||||
}
|
||||
|
||||
bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) {
|
||||
|
@@ -25,7 +25,7 @@ public:
|
||||
explicit GCAdapter(std::string input_engine_);
|
||||
~GCAdapter() override;
|
||||
|
||||
Common::Input::VibrationError SetVibration(
|
||||
Common::Input::DriverResult SetVibration(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||
|
||||
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
||||
|
@@ -318,6 +318,14 @@ void SDLDriver::InitJoystick(int joystick_index) {
|
||||
|
||||
const auto guid = GetGUID(sdl_joystick);
|
||||
|
||||
if (Settings::values.enable_joycon_driver) {
|
||||
if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e) {
|
||||
LOG_ERROR(Input, "Device black listed {}", joystick_index);
|
||||
SDL_JoystickClose(sdl_joystick);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::scoped_lock lock{joystick_map_mutex};
|
||||
if (joystick_map.find(guid) == joystick_map.end()) {
|
||||
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
|
||||
@@ -440,9 +448,14 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
|
||||
// Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and
|
||||
// not a generic one
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
|
||||
// Disable hidapi drivers for switch controllers when the custom joycon driver is enabled
|
||||
if (Settings::values.enable_joycon_driver) {
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "0");
|
||||
} else {
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
|
||||
}
|
||||
|
||||
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
|
||||
// driver on Linux.
|
||||
@@ -532,7 +545,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
|
||||
return devices;
|
||||
}
|
||||
|
||||
Common::Input::VibrationError SDLDriver::SetVibration(
|
||||
Common::Input::DriverResult SDLDriver::SetVibration(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||
const auto joystick =
|
||||
GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
|
||||
@@ -566,7 +579,7 @@ Common::Input::VibrationError SDLDriver::SetVibration(
|
||||
.vibration = new_vibration,
|
||||
});
|
||||
|
||||
return Common::Input::VibrationError::None;
|
||||
return Common::Input::DriverResult::Success;
|
||||
}
|
||||
|
||||
bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
bool IsStickInverted(const Common::ParamPackage& params) override;
|
||||
|
||||
Common::Input::VibrationError SetVibration(
|
||||
Common::Input::DriverResult SetVibration(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||
|
||||
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
||||
|
@@ -22,22 +22,23 @@ VirtualAmiibo::VirtualAmiibo(std::string input_engine_) : InputEngine(std::move(
|
||||
|
||||
VirtualAmiibo::~VirtualAmiibo() = default;
|
||||
|
||||
Common::Input::PollingError VirtualAmiibo::SetPollingMode(
|
||||
Common::Input::DriverResult VirtualAmiibo::SetPollingMode(
|
||||
[[maybe_unused]] const PadIdentifier& identifier_,
|
||||
const Common::Input::PollingMode polling_mode_) {
|
||||
polling_mode = polling_mode_;
|
||||
|
||||
if (polling_mode == Common::Input::PollingMode::NFC) {
|
||||
switch (polling_mode) {
|
||||
case Common::Input::PollingMode::NFC:
|
||||
if (state == State::Initialized) {
|
||||
state = State::WaitingForAmiibo;
|
||||
}
|
||||
} else {
|
||||
return Common::Input::DriverResult::Success;
|
||||
default:
|
||||
if (state == State::AmiiboIsOpen) {
|
||||
CloseAmiibo();
|
||||
}
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
return Common::Input::PollingError::None;
|
||||
}
|
||||
|
||||
Common::Input::NfcState VirtualAmiibo::SupportsNfc(
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
~VirtualAmiibo() override;
|
||||
|
||||
// Sets polling mode to a controller
|
||||
Common::Input::PollingError SetPollingMode(
|
||||
Common::Input::DriverResult SetPollingMode(
|
||||
const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override;
|
||||
|
||||
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
||||
|
@@ -79,6 +79,17 @@ void InputEngine::SetBattery(const PadIdentifier& identifier, Common::Input::Bat
|
||||
TriggerOnBatteryChange(identifier, value);
|
||||
}
|
||||
|
||||
void InputEngine::SetColor(const PadIdentifier& identifier, Common::Input::BodyColorStatus value) {
|
||||
{
|
||||
std::scoped_lock lock{mutex};
|
||||
ControllerData& controller = controller_list.at(identifier);
|
||||
if (!configuring) {
|
||||
controller.color = value;
|
||||
}
|
||||
}
|
||||
TriggerOnColorChange(identifier, value);
|
||||
}
|
||||
|
||||
void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value) {
|
||||
{
|
||||
std::scoped_lock lock{mutex};
|
||||
@@ -176,6 +187,18 @@ Common::Input::BatteryLevel InputEngine::GetBattery(const PadIdentifier& identif
|
||||
return controller.battery;
|
||||
}
|
||||
|
||||
Common::Input::BodyColorStatus InputEngine::GetColor(const PadIdentifier& identifier) const {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto controller_iter = controller_list.find(identifier);
|
||||
if (controller_iter == controller_list.cend()) {
|
||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||
identifier.pad, identifier.port);
|
||||
return {};
|
||||
}
|
||||
const ControllerData& controller = controller_iter->second;
|
||||
return controller.color;
|
||||
}
|
||||
|
||||
BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) const {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto controller_iter = controller_list.find(identifier);
|
||||
@@ -328,6 +351,20 @@ void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier,
|
||||
}
|
||||
}
|
||||
|
||||
void InputEngine::TriggerOnColorChange(const PadIdentifier& identifier,
|
||||
[[maybe_unused]] Common::Input::BodyColorStatus value) {
|
||||
std::scoped_lock lock{mutex_callback};
|
||||
for (const auto& poller_pair : callback_list) {
|
||||
const InputIdentifier& poller = poller_pair.second;
|
||||
if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Color, 0)) {
|
||||
continue;
|
||||
}
|
||||
if (poller.callback.on_change) {
|
||||
poller.callback.on_change();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int motion,
|
||||
const BasicMotion& value) {
|
||||
std::scoped_lock lock{mutex_callback};
|
||||
|
@@ -40,6 +40,7 @@ enum class EngineInputType {
|
||||
Battery,
|
||||
Button,
|
||||
Camera,
|
||||
Color,
|
||||
HatButton,
|
||||
Motion,
|
||||
Nfc,
|
||||
@@ -104,14 +105,17 @@ public:
|
||||
void EndConfiguration();
|
||||
|
||||
// Sets a led pattern for a controller
|
||||
virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier,
|
||||
[[maybe_unused]] const Common::Input::LedStatus& led_status) {}
|
||||
virtual Common::Input::DriverResult SetLeds(
|
||||
[[maybe_unused]] const PadIdentifier& identifier,
|
||||
[[maybe_unused]] const Common::Input::LedStatus& led_status) {
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
// Sets rumble to a controller
|
||||
virtual Common::Input::VibrationError SetVibration(
|
||||
virtual Common::Input::DriverResult SetVibration(
|
||||
[[maybe_unused]] const PadIdentifier& identifier,
|
||||
[[maybe_unused]] const Common::Input::VibrationStatus& vibration) {
|
||||
return Common::Input::VibrationError::NotSupported;
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
// Returns true if device supports vibrations
|
||||
@@ -120,17 +124,17 @@ public:
|
||||
}
|
||||
|
||||
// Sets polling mode to a controller
|
||||
virtual Common::Input::PollingError SetPollingMode(
|
||||
virtual Common::Input::DriverResult SetPollingMode(
|
||||
[[maybe_unused]] const PadIdentifier& identifier,
|
||||
[[maybe_unused]] const Common::Input::PollingMode polling_mode) {
|
||||
return Common::Input::PollingError::NotSupported;
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
// Sets camera format to a controller
|
||||
virtual Common::Input::CameraError SetCameraFormat(
|
||||
virtual Common::Input::DriverResult SetCameraFormat(
|
||||
[[maybe_unused]] const PadIdentifier& identifier,
|
||||
[[maybe_unused]] Common::Input::CameraFormat camera_format) {
|
||||
return Common::Input::CameraError::NotSupported;
|
||||
return Common::Input::DriverResult::NotSupported;
|
||||
}
|
||||
|
||||
// Returns success if nfc is supported
|
||||
@@ -199,6 +203,7 @@ public:
|
||||
bool GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const;
|
||||
f32 GetAxis(const PadIdentifier& identifier, int axis) const;
|
||||
Common::Input::BatteryLevel GetBattery(const PadIdentifier& identifier) const;
|
||||
Common::Input::BodyColorStatus GetColor(const PadIdentifier& identifier) const;
|
||||
BasicMotion GetMotion(const PadIdentifier& identifier, int motion) const;
|
||||
Common::Input::CameraStatus GetCamera(const PadIdentifier& identifier) const;
|
||||
Common::Input::NfcStatus GetNfc(const PadIdentifier& identifier) const;
|
||||
@@ -212,6 +217,7 @@ protected:
|
||||
void SetHatButton(const PadIdentifier& identifier, int button, u8 value);
|
||||
void SetAxis(const PadIdentifier& identifier, int axis, f32 value);
|
||||
void SetBattery(const PadIdentifier& identifier, Common::Input::BatteryLevel value);
|
||||
void SetColor(const PadIdentifier& identifier, Common::Input::BodyColorStatus value);
|
||||
void SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value);
|
||||
void SetCamera(const PadIdentifier& identifier, const Common::Input::CameraStatus& value);
|
||||
void SetNfc(const PadIdentifier& identifier, const Common::Input::NfcStatus& value);
|
||||
@@ -227,6 +233,7 @@ private:
|
||||
std::unordered_map<int, float> axes;
|
||||
std::unordered_map<int, BasicMotion> motions;
|
||||
Common::Input::BatteryLevel battery{};
|
||||
Common::Input::BodyColorStatus color{};
|
||||
Common::Input::CameraStatus camera{};
|
||||
Common::Input::NfcStatus nfc{};
|
||||
};
|
||||
@@ -235,6 +242,8 @@ private:
|
||||
void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value);
|
||||
void TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value);
|
||||
void TriggerOnBatteryChange(const PadIdentifier& identifier, Common::Input::BatteryLevel value);
|
||||
void TriggerOnColorChange(const PadIdentifier& identifier,
|
||||
Common::Input::BodyColorStatus value);
|
||||
void TriggerOnMotionChange(const PadIdentifier& identifier, int motion,
|
||||
const BasicMotion& value);
|
||||
void TriggerOnCameraChange(const PadIdentifier& identifier,
|
||||
|
@@ -498,6 +498,58 @@ private:
|
||||
InputEngine* input_engine;
|
||||
};
|
||||
|
||||
class InputFromColor final : public Common::Input::InputDevice {
|
||||
public:
|
||||
explicit InputFromColor(PadIdentifier identifier_, InputEngine* input_engine_)
|
||||
: identifier(identifier_), input_engine(input_engine_) {
|
||||
UpdateCallback engine_callback{[this]() { OnChange(); }};
|
||||
const InputIdentifier input_identifier{
|
||||
.identifier = identifier,
|
||||
.type = EngineInputType::Color,
|
||||
.index = 0,
|
||||
.callback = engine_callback,
|
||||
};
|
||||
last_color_value = {};
|
||||
callback_key = input_engine->SetCallback(input_identifier);
|
||||
}
|
||||
|
||||
~InputFromColor() override {
|
||||
input_engine->DeleteCallback(callback_key);
|
||||
}
|
||||
|
||||
Common::Input::BodyColorStatus GetStatus() const {
|
||||
return input_engine->GetColor(identifier);
|
||||
}
|
||||
|
||||
void ForceUpdate() override {
|
||||
const Common::Input::CallbackStatus status{
|
||||
.type = Common::Input::InputType::Color,
|
||||
.color_status = GetStatus(),
|
||||
};
|
||||
|
||||
last_color_value = status.color_status;
|
||||
TriggerOnChange(status);
|
||||
}
|
||||
|
||||
void OnChange() {
|
||||
const Common::Input::CallbackStatus status{
|
||||
.type = Common::Input::InputType::Color,
|
||||
.color_status = GetStatus(),
|
||||
};
|
||||
|
||||
if (status.color_status.body != last_color_value.body) {
|
||||
last_color_value = status.color_status;
|
||||
TriggerOnChange(status);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const PadIdentifier identifier;
|
||||
int callback_key;
|
||||
Common::Input::BodyColorStatus last_color_value;
|
||||
InputEngine* input_engine;
|
||||
};
|
||||
|
||||
class InputFromMotion final : public Common::Input::InputDevice {
|
||||
public:
|
||||
explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, float gyro_threshold_,
|
||||
@@ -754,11 +806,11 @@ public:
|
||||
explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
|
||||
: identifier(identifier_), input_engine(input_engine_) {}
|
||||
|
||||
void SetLED(const Common::Input::LedStatus& led_status) override {
|
||||
input_engine->SetLeds(identifier, led_status);
|
||||
Common::Input::DriverResult SetLED(const Common::Input::LedStatus& led_status) override {
|
||||
return input_engine->SetLeds(identifier, led_status);
|
||||
}
|
||||
|
||||
Common::Input::VibrationError SetVibration(
|
||||
Common::Input::DriverResult SetVibration(
|
||||
const Common::Input::VibrationStatus& vibration_status) override {
|
||||
return input_engine->SetVibration(identifier, vibration_status);
|
||||
}
|
||||
@@ -767,11 +819,12 @@ public:
|
||||
return input_engine->IsVibrationEnabled(identifier);
|
||||
}
|
||||
|
||||
Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) override {
|
||||
Common::Input::DriverResult SetPollingMode(Common::Input::PollingMode polling_mode) override {
|
||||
return input_engine->SetPollingMode(identifier, polling_mode);
|
||||
}
|
||||
|
||||
Common::Input::CameraError SetCameraFormat(Common::Input::CameraFormat camera_format) override {
|
||||
Common::Input::DriverResult SetCameraFormat(
|
||||
Common::Input::CameraFormat camera_format) override {
|
||||
return input_engine->SetCameraFormat(identifier, camera_format);
|
||||
}
|
||||
|
||||
@@ -966,6 +1019,18 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
||||
return std::make_unique<InputFromBattery>(identifier, input_engine.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateColorDevice(
|
||||
const Common::ParamPackage& params) {
|
||||
const PadIdentifier identifier = {
|
||||
.guid = Common::UUID{params.Get("guid", "")},
|
||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||
};
|
||||
|
||||
input_engine->PreSetController(identifier);
|
||||
return std::make_unique<InputFromColor>(identifier, input_engine.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
|
||||
Common::ParamPackage params) {
|
||||
const PadIdentifier identifier = {
|
||||
@@ -1053,6 +1118,9 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::Create(
|
||||
if (params.Has("battery")) {
|
||||
return CreateBatteryDevice(params);
|
||||
}
|
||||
if (params.Has("color")) {
|
||||
return CreateColorDevice(params);
|
||||
}
|
||||
if (params.Has("camera")) {
|
||||
return CreateCameraDevice(params);
|
||||
}
|
||||
|
@@ -190,6 +190,17 @@ private:
|
||||
std::unique_ptr<Common::Input::InputDevice> CreateBatteryDevice(
|
||||
const Common::ParamPackage& params);
|
||||
|
||||
/**
|
||||
* Creates a color device from the parameters given.
|
||||
* @param params contains parameters for creating the device:
|
||||
* - "guid": text string for identifying controllers
|
||||
* - "port": port of the connected device
|
||||
* - "pad": slot of the connected controller
|
||||
* @returns a unique input device with the parameters specified
|
||||
*/
|
||||
std::unique_ptr<Common::Input::InputDevice> CreateColorDevice(
|
||||
const Common::ParamPackage& params);
|
||||
|
||||
/**
|
||||
* Creates a motion device from the parameters given.
|
||||
* @param params contains parameters for creating the device:
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "input_common/drivers/gc_adapter.h"
|
||||
#endif
|
||||
#ifdef HAVE_SDL2
|
||||
#include "input_common/drivers/joycon.h"
|
||||
#include "input_common/drivers/sdl_driver.h"
|
||||
#endif
|
||||
|
||||
@@ -58,6 +59,7 @@ struct InputSubsystem::Impl {
|
||||
RegisterEngine("virtual_gamepad", virtual_gamepad);
|
||||
#ifdef HAVE_SDL2
|
||||
RegisterEngine("sdl", sdl);
|
||||
RegisterEngine("joycon", joycon);
|
||||
#endif
|
||||
|
||||
Common::Input::RegisterInputFactory("touch_from_button",
|
||||
@@ -87,6 +89,7 @@ struct InputSubsystem::Impl {
|
||||
UnregisterEngine(virtual_gamepad);
|
||||
#ifdef HAVE_SDL2
|
||||
UnregisterEngine(sdl);
|
||||
UnregisterEngine(joycon);
|
||||
#endif
|
||||
|
||||
Common::Input::UnregisterInputFactory("touch_from_button");
|
||||
@@ -109,6 +112,8 @@ struct InputSubsystem::Impl {
|
||||
auto udp_devices = udp_client->GetInputDevices();
|
||||
devices.insert(devices.end(), udp_devices.begin(), udp_devices.end());
|
||||
#ifdef HAVE_SDL2
|
||||
auto joycon_devices = joycon->GetInputDevices();
|
||||
devices.insert(devices.end(), joycon_devices.begin(), joycon_devices.end());
|
||||
auto sdl_devices = sdl->GetInputDevices();
|
||||
devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end());
|
||||
#endif
|
||||
@@ -140,6 +145,9 @@ struct InputSubsystem::Impl {
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return sdl;
|
||||
}
|
||||
if (engine == joycon->GetEngineName()) {
|
||||
return joycon;
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
@@ -223,6 +231,9 @@ struct InputSubsystem::Impl {
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
if (engine == joycon->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@@ -236,6 +247,7 @@ struct InputSubsystem::Impl {
|
||||
udp_client->BeginConfiguration();
|
||||
#ifdef HAVE_SDL2
|
||||
sdl->BeginConfiguration();
|
||||
joycon->BeginConfiguration();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -248,6 +260,7 @@ struct InputSubsystem::Impl {
|
||||
udp_client->EndConfiguration();
|
||||
#ifdef HAVE_SDL2
|
||||
sdl->EndConfiguration();
|
||||
joycon->EndConfiguration();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -278,6 +291,7 @@ struct InputSubsystem::Impl {
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
std::shared_ptr<SDLDriver> sdl;
|
||||
std::shared_ptr<Joycons> joycon;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user