From c0c4ed0d3bff9670bfaab6a8de304e37ec9e0896 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sun, 27 Sep 2020 11:40:15 -0400 Subject: [PATCH] controllers/npad: Connect a controller on init if none are connected --- src/core/hle/service/hid/controllers/npad.cpp | 13 +++++++++++++ src/yuzu/configuration/config.cpp | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index e311bc18c..c4b26196a 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -224,6 +224,19 @@ void Controller_NPad::OnInit() { player.connected}; }); + // Connect the Player 1 or Handheld controller if none are connected. + if (std::none_of(connected_controllers.begin(), connected_controllers.end(), + [](const ControllerHolder& controller) { return controller.is_connected; })) { + const auto controller = MapSettingsTypeToNPad(Settings::values.players[0].controller_type); + if (controller == NPadControllerType::Handheld) { + Settings::values.players[HANDHELD_INDEX].connected = true; + connected_controllers[HANDHELD_INDEX] = {controller, true}; + } else { + Settings::values.players[0].connected = true; + connected_controllers[0] = {controller, true}; + } + } + // Account for handheld if (connected_controllers[HANDHELD_INDEX].is_connected) { connected_controllers[HANDHELD_INDEX].type = NPadControllerType::Handheld; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 5c8b02fbe..545cafca9 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -280,7 +280,8 @@ void Config::ReadPlayerValue(std::size_t player_index) { } } else { player.connected = - ReadSetting(QStringLiteral("%1connected").arg(player_prefix), false).toBool(); + ReadSetting(QStringLiteral("%1connected").arg(player_prefix), player_index == 0) + .toBool(); player.controller_type = static_cast( qt_config