input_common: Drop Pro controller support from custom driver

This commit is contained in:
german77 2023-01-08 21:37:13 -06:00 committed by Narr the Reg
parent d05ea2f3eb
commit b40aefb39e
4 changed files with 4 additions and 43 deletions

View file

@ -44,12 +44,6 @@ void Joycons::Reset() {
} }
device->Stop(); device->Stop();
} }
for (const auto& device : pro_joycons) {
if (!device) {
continue;
}
device->Stop();
}
SDL_hid_exit(); SDL_hid_exit();
} }
@ -65,11 +59,6 @@ void Joycons::Setup() {
PreSetController(GetIdentifier(port, Joycon::ControllerType::Right)); PreSetController(GetIdentifier(port, Joycon::ControllerType::Right));
device = std::make_shared<Joycon::JoyconDriver>(port++); device = std::make_shared<Joycon::JoyconDriver>(port++);
} }
port = 0;
for (auto& device : pro_joycons) {
PreSetController(GetIdentifier(port, Joycon::ControllerType::Pro));
device = std::make_shared<Joycon::JoyconDriver>(port++);
}
if (!scan_thread_running) { if (!scan_thread_running) {
scan_thread = std::jthread([this](std::stop_token stop_token) { ScanThread(stop_token); }); scan_thread = std::jthread([this](std::stop_token stop_token) { ScanThread(stop_token); });
@ -141,14 +130,6 @@ bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {
} }
} }
break; break;
case Joycon::ControllerType::Pro:
case Joycon::ControllerType::Grip:
for (const auto& device : pro_joycons) {
if (is_handle_identical(device)) {
return false;
}
}
break;
default: default:
return false; return false;
} }
@ -219,13 +200,6 @@ std::shared_ptr<Joycon::JoyconDriver> Joycons::GetNextFreeHandle(
} }
} }
} }
if (type == Joycon::ControllerType::Pro || type == Joycon::ControllerType::Grip) {
for (const auto& device : pro_joycons) {
if (!device->IsConnected()) {
return device;
}
}
}
return nullptr; return nullptr;
} }
@ -431,13 +405,6 @@ std::shared_ptr<Joycon::JoyconDriver> Joycons::GetHandle(PadIdentifier identifie
} }
} }
} }
if (type == Joycon::ControllerType::Pro || type == Joycon::ControllerType::Grip) {
for (const auto& device : pro_joycons) {
if (is_handle_active(device)) {
return device;
}
}
}
return nullptr; return nullptr;
} }
@ -475,9 +442,6 @@ std::vector<Common::ParamPackage> Joycons::GetInputDevices() const {
for (const auto& controller : right_joycons) { for (const auto& controller : right_joycons) {
add_entry(controller); add_entry(controller);
} }
for (const auto& controller : pro_joycons) {
add_entry(controller);
}
// List dual joycon pairs // List dual joycon pairs
for (std::size_t i = 0; i < MaxSupportedControllers; i++) { for (std::size_t i = 0; i < MaxSupportedControllers; i++) {

View file

@ -104,7 +104,6 @@ private:
// Joycon types are split by type to ease supporting dualjoycon configurations // Joycon types are split by type to ease supporting dualjoycon configurations
std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> left_joycons{}; std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> left_joycons{};
std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> right_joycons{}; std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> right_joycons{};
std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> pro_joycons{};
}; };
} // namespace InputCommon } // namespace InputCommon

View file

@ -319,7 +319,8 @@ void SDLDriver::InitJoystick(int joystick_index) {
const auto guid = GetGUID(sdl_joystick); const auto guid = GetGUID(sdl_joystick);
if (Settings::values.enable_joycon_driver) { if (Settings::values.enable_joycon_driver) {
if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e) { if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e &&
(guid.uuid[8] == 0x06 || guid.uuid[8] == 0x07)) {
LOG_ERROR(Input, "Device black listed {}", joystick_index); LOG_ERROR(Input, "Device black listed {}", joystick_index);
SDL_JoystickClose(sdl_joystick); SDL_JoystickClose(sdl_joystick);
return; return;
@ -451,11 +452,10 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
// Disable hidapi drivers for switch controllers when the custom joycon driver is enabled // Disable hidapi drivers for switch controllers when the custom joycon driver is enabled
if (Settings::values.enable_joycon_driver) { if (Settings::values.enable_joycon_driver) {
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "0");
} else { } else {
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
} }
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
// driver on Linux. // driver on Linux.

View file

@ -540,11 +540,9 @@ void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) {
DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info,
ControllerType& controller_type) { ControllerType& controller_type) {
static constexpr std::array<std::pair<u32, ControllerType>, 4> supported_devices{ static constexpr std::array<std::pair<u32, ControllerType>, 2> supported_devices{
std::pair<u32, ControllerType>{0x2006, ControllerType::Left}, std::pair<u32, ControllerType>{0x2006, ControllerType::Left},
{0x2007, ControllerType::Right}, {0x2007, ControllerType::Right},
{0x2009, ControllerType::Pro},
{0x200E, ControllerType::Grip},
}; };
constexpr u16 nintendo_vendor_id = 0x057e; constexpr u16 nintendo_vendor_id = 0x057e;