mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
applet/controller: Enable configuring mode while the applet is open
This commit is contained in:
parent
639402850a
commit
a4a0638bc8
1 changed files with 12 additions and 7 deletions
|
@ -29,7 +29,7 @@ namespace {
|
||||||
|
|
||||||
void UpdateController(Core::HID::EmulatedController* controller,
|
void UpdateController(Core::HID::EmulatedController* controller,
|
||||||
Core::HID::NpadStyleIndex controller_type, bool connected) {
|
Core::HID::NpadStyleIndex controller_type, bool connected) {
|
||||||
if (controller->IsConnected()) {
|
if (controller->IsConnected(true)) {
|
||||||
controller->Disconnect();
|
controller->Disconnect();
|
||||||
}
|
}
|
||||||
controller->SetNpadStyleIndex(controller_type);
|
controller->SetNpadStyleIndex(controller_type);
|
||||||
|
@ -139,6 +139,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
|
||||||
DisableUnsupportedPlayers();
|
DisableUnsupportedPlayers();
|
||||||
|
|
||||||
for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
|
for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
|
||||||
|
system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration();
|
||||||
SetEmulatedControllers(player_index);
|
SetEmulatedControllers(player_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,20 +234,24 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
|
||||||
|
|
||||||
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
||||||
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
||||||
|
for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
|
||||||
|
system.HIDCore().GetEmulatedControllerByIndex(player_index)->DisableConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtControllerSelectorDialog::LoadConfiguration() {
|
void QtControllerSelectorDialog::LoadConfiguration() {
|
||||||
const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
|
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
|
||||||
const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
|
const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
|
||||||
const auto connected = controller->IsConnected() || (index == 0 && handheld->IsConnected());
|
const auto connected =
|
||||||
|
controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true));
|
||||||
player_groupboxes[index]->setChecked(connected);
|
player_groupboxes[index]->setChecked(connected);
|
||||||
connected_controller_checkboxes[index]->setChecked(connected);
|
connected_controller_checkboxes[index]->setChecked(connected);
|
||||||
emulated_controllers[index]->setCurrentIndex(
|
emulated_controllers[index]->setCurrentIndex(
|
||||||
GetIndexFromControllerType(controller->GetNpadStyleIndex(), index));
|
GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index));
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateDockedState(handheld->IsConnected());
|
UpdateDockedState(handheld->IsConnected(true));
|
||||||
|
|
||||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
|
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
|
||||||
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
|
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
|
||||||
|
@ -510,8 +515,8 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index)
|
||||||
const auto player_connected = player_groupboxes[player_index]->isChecked() &&
|
const auto player_connected = player_groupboxes[player_index]->isChecked() &&
|
||||||
controller_type != Core::HID::NpadStyleIndex::Handheld;
|
controller_type != Core::HID::NpadStyleIndex::Handheld;
|
||||||
|
|
||||||
if (controller->GetNpadStyleIndex() == controller_type &&
|
if (controller->GetNpadStyleIndex(true) == controller_type &&
|
||||||
controller->IsConnected() == player_connected) {
|
controller->IsConnected(true) == player_connected) {
|
||||||
// Set vibration devices in the event that the input device has changed.
|
// Set vibration devices in the event that the input device has changed.
|
||||||
ConfigureVibration::SetVibrationDevices(player_index);
|
ConfigureVibration::SetVibrationDevices(player_index);
|
||||||
return;
|
return;
|
||||||
|
@ -633,7 +638,7 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
|
||||||
for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) {
|
for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) {
|
||||||
auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
|
auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
|
||||||
// Disconnect any unsupported players here and disable or hide them if applicable.
|
// Disconnect any unsupported players here and disable or hide them if applicable.
|
||||||
UpdateController(controller, controller->GetNpadStyleIndex(), false);
|
UpdateController(controller, controller->GetNpadStyleIndex(true), false);
|
||||||
// Hide the player widgets when max_supported_controllers is less than or equal to 4.
|
// Hide the player widgets when max_supported_controllers is less than or equal to 4.
|
||||||
if (max_supported_players <= 4) {
|
if (max_supported_players <= 4) {
|
||||||
player_widgets[index]->hide();
|
player_widgets[index]->hide();
|
||||||
|
|
Loading…
Reference in a new issue