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 committed 2021-08-12 00:02:19 +02:00
1 parent 81b4c3b376
commit aa3daca293
3 files changed
+20 -3

No files matched your search

+11
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;
+2
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);
}
+7 -3
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_));
}
}
}
}