Allow unpausing with keys bound to pause.

This commit is contained in:
Henrik Rydgård 2023-12-20 16:55:39 +01:00
parent f47b87aabf
commit a996afb9f6
3 changed files with 21 additions and 1 deletions

View File

@ -219,4 +219,4 @@ namespace KeyMap {
bool IsKeyMapped(InputDeviceID device, int key);
bool HasChanged(int &prevGeneration);
}
} // namespace KeyMap

View File

@ -32,6 +32,7 @@
#include "Common/VR/PPSSPPVR.h"
#include "Common/UI/AsyncImageFileView.h"
#include "Core/KeyMap.h"
#include "Core/Reporting.h"
#include "Core/SaveState.h"
#include "Core/System.h"
@ -271,6 +272,24 @@ GamePauseScreen::~GamePauseScreen() {
__DisplaySetWasPaused();
}
bool GamePauseScreen::key(const KeyInput &key) {
if (!UIScreen::key(key) && (key.flags & KEY_DOWN)) {
// Special case to be able to unpause with a bound pause key.
// Normally we can't bind keys used in the UI.
InputMapping mapping(key.deviceId, key.keyCode);
std::vector<int> pspButtons;
KeyMap::InputMappingToPspButton(mapping, &pspButtons);
for (auto button : pspButtons) {
if (button == VIRTKEY_PAUSE) {
TriggerFinish(DR_CANCEL);
return true;
}
}
return false;
}
return false;
}
void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems, bool vertical) {
auto pa = GetI18NCategory(I18NCat::PAUSE);

View File

@ -36,6 +36,7 @@ public:
~GamePauseScreen();
void dialogFinished(const Screen *dialog, DialogResult dr) override;
bool key(const KeyInput &key) override;
const char *tag() const override { return "GamePause"; }