[hid_core] Quick fix for PR 2747 (#2753)

Ensures that only the controllers enabled in the settings remain active when the game is running.

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2753
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
This commit is contained in:
MaranBr 2025-10-16 20:33:38 +02:00 committed by crueter
parent bfc10723bc
commit b7021afff6
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6

View file

@ -765,9 +765,13 @@ void EmulatedController::StartMotionCalibration() {
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
Common::UUID uuid) { Common::UUID uuid) {
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index];
if (index >= controller.button_values.size()) { if (index >= controller.button_values.size()) {
return; return;
} }
std::unique_lock lock{mutex}; std::unique_lock lock{mutex};
bool value_changed = false; bool value_changed = false;
const auto new_status = TransformToButton(callback); const auto new_status = TransformToButton(callback);
@ -920,11 +924,12 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback
lock.unlock(); lock.unlock();
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
if (!is_connected && !controller_connected[player_index]) { if (!is_connected && !controller_connected[player_index]) {
if (player.connected) {
Connect(); Connect();
controller_connected[player_index] = true; controller_connected[player_index] = true;
} }
}
TriggerOnChange(ControllerTriggerType::Button, true); TriggerOnChange(ControllerTriggerType::Button, true);
} }