check if NpadId is valid when update

This commit is contained in:
Dima 2022-10-29 23:39:28 +03:00 committed by Billy Laws
parent a409f30e91
commit baa6b5d5ea
2 changed files with 22 additions and 1 deletions

View File

@ -23,7 +23,7 @@ namespace skyline::input {
controller.device = nullptr;
for (auto &id : supportedIds) {
if (id == NpadId::Unknown)
if (id == NpadId::Unknown || !IsNpadIdValid(id))
continue;
auto &device{at(id)};

View File

@ -80,6 +80,27 @@ namespace skyline::input {
}));
}
/**
* @brief Checks if the NpadId is valid
*/
bool IsNpadIdValid(NpadId id) {
switch (id) {
case NpadId::Player1:
case NpadId::Player2:
case NpadId::Player3:
case NpadId::Player4:
case NpadId::Player5:
case NpadId::Player6:
case NpadId::Player7:
case NpadId::Player8:
case NpadId::Unknown:
case NpadId::Handheld:
return true;
default:
return false;
}
}
/**
* @brief Deduces all the mappings from guest controllers -> players based on the configuration supplied by HID services and available controllers
* @note If any class members were edited, the mutex shouldn't be released till this is called