mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-09 11:49:58 +00:00
core: hid: Add fallback for dualjoycon and pro controllers
This commit is contained in:
parent
6c72b7f011
commit
18550b165b
2 changed files with 35 additions and 1 deletions
|
@ -99,8 +99,10 @@ void EmulatedController::ReloadFromSettings() {
|
||||||
// Other or debug controller should always be a pro controller
|
// Other or debug controller should always be a pro controller
|
||||||
if (npad_id_type != NpadIdType::Other) {
|
if (npad_id_type != NpadIdType::Other) {
|
||||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||||
|
original_npad_type = npad_type;
|
||||||
} else {
|
} else {
|
||||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||||
|
original_npad_type = npad_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.connected) {
|
if (player.connected) {
|
||||||
|
@ -339,6 +341,7 @@ void EmulatedController::DisableConfiguration() {
|
||||||
Disconnect();
|
Disconnect();
|
||||||
}
|
}
|
||||||
SetNpadStyleIndex(tmp_npad_type);
|
SetNpadStyleIndex(tmp_npad_type);
|
||||||
|
original_npad_type = tmp_npad_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply temporary connected status to the real controller
|
// Apply temporary connected status to the real controller
|
||||||
|
@ -950,13 +953,27 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
|
||||||
if (!is_connected) {
|
if (!is_connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to reconnect with the original type
|
||||||
|
if (npad_type != original_npad_type) {
|
||||||
|
Disconnect();
|
||||||
|
const auto current_npad_type = npad_type;
|
||||||
|
SetNpadStyleIndex(original_npad_type);
|
||||||
|
if (IsControllerSupported()) {
|
||||||
|
Connect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetNpadStyleIndex(current_npad_type);
|
||||||
|
Connect();
|
||||||
|
}
|
||||||
|
|
||||||
if (IsControllerSupported()) {
|
if (IsControllerSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
// Fallback fullkey controllers to Pro controllers
|
// Fallback Fullkey controllers to Pro controllers
|
||||||
if (IsControllerFullkey() && supported_style_tag.fullkey) {
|
if (IsControllerFullkey() && supported_style_tag.fullkey) {
|
||||||
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
|
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
|
||||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||||
|
@ -964,6 +981,22 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback Dual joycon controllers to Pro controllers
|
||||||
|
if (npad_type == NpadStyleIndex::JoyconDual && supported_style_tag.fullkey) {
|
||||||
|
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
|
||||||
|
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||||
|
Connect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback Pro controllers to Dual joycon
|
||||||
|
if (npad_type == NpadStyleIndex::ProController && supported_style_tag.joycon_dual) {
|
||||||
|
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Dual Joycons", npad_type);
|
||||||
|
SetNpadStyleIndex(NpadStyleIndex::JoyconDual);
|
||||||
|
Connect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller",
|
LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller",
|
||||||
npad_type);
|
npad_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,6 +401,7 @@ private:
|
||||||
|
|
||||||
const NpadIdType npad_id_type;
|
const NpadIdType npad_id_type;
|
||||||
NpadStyleIndex npad_type{NpadStyleIndex::None};
|
NpadStyleIndex npad_type{NpadStyleIndex::None};
|
||||||
|
NpadStyleIndex original_npad_type{NpadStyleIndex::None};
|
||||||
NpadStyleTag supported_style_tag{NpadStyleSet::All};
|
NpadStyleTag supported_style_tag{NpadStyleSet::All};
|
||||||
bool is_connected{false};
|
bool is_connected{false};
|
||||||
bool is_configuring{false};
|
bool is_configuring{false};
|
||||||
|
|
Loading…
Reference in a new issue