If it's a TV and VIRTKEY_PAUSE is not mapped to a pad control, pause on app switch.

This commit is contained in:
Henrik Rydgård 2021-08-11 23:26:39 +02:00
parent 81b4c3b376
commit aa3daca293
3 changed files with 20 additions and 3 deletions

View file

@ -905,6 +905,17 @@ void RemoveButtonMapping(int btn) {
}
}
bool IsKeyMapped(int device, int key) {
for (auto &iter : g_controllerMap) {
for (auto &mappedKey : iter.second) {
if (mappedKey == KeyDef(device, key)) {
return true;
}
}
}
return false;
}
void SetKeyMapping(int btn, KeyDef key, bool replace) {
if (key.keyCode < 0)
return;

View file

@ -163,4 +163,6 @@ namespace KeyMap {
const std::set<std::string> &GetSeenPads();
void AutoConfForPad(const std::string &name);
bool IsKeyMapped(int device, int key);
}

View file

@ -506,10 +506,14 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
}
#endif
} else if (!strcmp(message, "app_resumed") && screenManager()->topScreen() == this) {
// If there's no back button mapped, use this as the way to get into the menu.
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
if (!KeyMap::IsKeyMapped(DEVICE_ID_PAD_0, VIRTKEY_PAUSE) || !KeyMap::IsKeyMapped(DEVICE_ID_PAD_1, VIRTKEY_PAUSE)) {
// If it's a TV (so no built-in back button), and there's no back button mapped to a pad,
// use this as the fallback way to get into the menu.
// TODO: Check mappings.
screenManager()->push(new GamePauseScreen(gamePath_));
screenManager()->push(new GamePauseScreen(gamePath_));
}
}
}
}