diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 1 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 2 | ||||
| -rw-r--r-- | src/core/hid/hid_core.cpp | 21 | ||||
| -rw-r--r-- | src/core/hid/hid_core.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_controller.cpp | 14 |
5 files changed, 33 insertions, 15 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 7b0c4a49b..662260327 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -91,7 +91,6 @@ void EmulatedController::ReloadFromSettings() { | |||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | void EmulatedController::ReloadInput() { | 93 | void EmulatedController::ReloadInput() { |
| 94 | // LOG_ERROR(Service_HID, "reload config {}", NpadIdTypeToIndex(npad_id_type)); | ||
| 95 | // If you load any device here add the equivalent to the UnloadInput() function | 94 | // If you load any device here add the equivalent to the UnloadInput() function |
| 96 | const auto left_side = button_params[Settings::NativeButton::ZL]; | 95 | const auto left_side = button_params[Settings::NativeButton::ZL]; |
| 97 | const auto right_side = button_params[Settings::NativeButton::ZR]; | 96 | const auto right_side = button_params[Settings::NativeButton::ZR]; |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 3a0b20cf8..f3ee70726 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -329,7 +329,7 @@ private: | |||
| 329 | * @param type: Input type of the event to trigger | 329 | * @param type: Input type of the event to trigger |
| 330 | * @param is_service_update: indicates if this event should be sended to only services | 330 | * @param is_service_update: indicates if this event should be sended to only services |
| 331 | */ | 331 | */ |
| 332 | void TriggerOnChange(ControllerTriggerType type, bool is_service_update); | 332 | void TriggerOnChange(ControllerTriggerType type, bool is_service_update); |
| 333 | 333 | ||
| 334 | NpadIdType npad_id_type; | 334 | NpadIdType npad_id_type; |
| 335 | NpadType npad_type{NpadType::None}; | 335 | NpadType npad_type{NpadType::None}; |
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index ee76db110..bd17081bd 100644 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp | |||
| @@ -111,6 +111,27 @@ NpadStyleTag HIDCore::GetSupportedStyleTag() const { | |||
| 111 | return supported_style_tag; | 111 | return supported_style_tag; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | s8 HIDCore::GetPlayerCount() const { | ||
| 115 | s8 active_players = 0; | ||
| 116 | for (std::size_t player_index = 0; player_index < 8; player_index++) { | ||
| 117 | const auto* controller = GetEmulatedControllerByIndex(player_index); | ||
| 118 | if (controller->IsConnected()) { | ||
| 119 | active_players++; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | return active_players; | ||
| 123 | } | ||
| 124 | |||
| 125 | NpadIdType HIDCore::GetFirstNpadId() const { | ||
| 126 | for (std::size_t player_index = 0; player_index < 10; player_index++) { | ||
| 127 | const auto* controller = GetEmulatedControllerByIndex(player_index); | ||
| 128 | if (controller->IsConnected()) { | ||
| 129 | return controller->GetNpadIdType(); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | return NpadIdType::Player1; | ||
| 133 | } | ||
| 134 | |||
| 114 | void HIDCore::ReloadInputDevices() { | 135 | void HIDCore::ReloadInputDevices() { |
| 115 | player_1->ReloadFromSettings(); | 136 | player_1->ReloadFromSettings(); |
| 116 | player_2->ReloadFromSettings(); | 137 | player_2->ReloadFromSettings(); |
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h index f11f48b61..196466a72 100644 --- a/src/core/hid/hid_core.h +++ b/src/core/hid/hid_core.h | |||
| @@ -35,10 +35,16 @@ public: | |||
| 35 | void SetSupportedStyleTag(NpadStyleTag style_tag); | 35 | void SetSupportedStyleTag(NpadStyleTag style_tag); |
| 36 | NpadStyleTag GetSupportedStyleTag() const; | 36 | NpadStyleTag GetSupportedStyleTag() const; |
| 37 | 37 | ||
| 38 | // Reloads all input devices from settings | 38 | /// Counts the connected players from P1-P8 |
| 39 | s8 GetPlayerCount() const; | ||
| 40 | |||
| 41 | /// Returns the first connected npad id | ||
| 42 | NpadIdType GetFirstNpadId() const; | ||
| 43 | |||
| 44 | /// Reloads all input devices from settings | ||
| 39 | void ReloadInputDevices(); | 45 | void ReloadInputDevices(); |
| 40 | 46 | ||
| 41 | // Removes all callbacks from input common | 47 | /// Removes all callbacks from input common |
| 42 | void UnloadInputDevices(); | 48 | void UnloadInputDevices(); |
| 43 | 49 | ||
| 44 | private: | 50 | private: |
diff --git a/src/core/hle/service/am/applets/applet_controller.cpp b/src/core/hle/service/am/applets/applet_controller.cpp index c1b6cd126..658265a00 100644 --- a/src/core/hle/service/am/applets/applet_controller.cpp +++ b/src/core/hle/service/am/applets/applet_controller.cpp | |||
| @@ -243,19 +243,11 @@ void Controller::Execute() { | |||
| 243 | void Controller::ConfigurationComplete() { | 243 | void Controller::ConfigurationComplete() { |
| 244 | ControllerSupportResultInfo result_info{}; | 244 | ControllerSupportResultInfo result_info{}; |
| 245 | 245 | ||
| 246 | const auto& players = Settings::values.players.GetValue(); | ||
| 247 | |||
| 248 | // If enable_single_mode is enabled, player_count is 1 regardless of any other parameters. | 246 | // If enable_single_mode is enabled, player_count is 1 regardless of any other parameters. |
| 249 | // Otherwise, only count connected players from P1-P8. | 247 | // Otherwise, only count connected players from P1-P8. |
| 250 | result_info.player_count = | 248 | result_info.player_count = is_single_mode ? 1 : system.HIDCore().GetPlayerCount(); |
| 251 | is_single_mode | 249 | |
| 252 | ? 1 | 250 | result_info.selected_id = static_cast<u32>(system.HIDCore().GetFirstNpadId()); |
| 253 | : static_cast<s8>(std::count_if(players.begin(), players.end() - 2, | ||
| 254 | [](const auto& player) { return player.connected; })); | ||
| 255 | |||
| 256 | result_info.selected_id = HID::Controller_NPad::IndexToNPad(std::distance( | ||
| 257 | players.begin(), std::find_if(players.begin(), players.end(), | ||
| 258 | [](const auto& player) { return player.connected; }))); | ||
| 259 | 251 | ||
| 260 | result_info.result = 0; | 252 | result_info.result = 0; |
| 261 | 253 | ||