mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Don't have pauseTrigger as an output parameter from ControlMapper::Key()
This commit is contained in:
@@ -303,7 +303,7 @@ void ControlMapper::ReleaseAll() {
|
||||
|
||||
Axis(axes.data(), axes.size());;
|
||||
for (const auto &key : keys) {
|
||||
Key(key, nullptr);
|
||||
Key(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no
|
||||
return keyInputUsed;
|
||||
}
|
||||
|
||||
bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) {
|
||||
bool ControlMapper::Key(const KeyInput &key) {
|
||||
double now = time_now_d();
|
||||
InputMapping mapping(key.deviceId, key.keyCode);
|
||||
|
||||
@@ -607,7 +607,7 @@ bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) {
|
||||
bool mappingFound = KeyMap::InputMappingToPspButton(mapping, nullptr);
|
||||
DEBUG_LOG(Log::System, "Key: %d DeviceId: %d", key.keyCode, key.deviceId);
|
||||
if (!mappingFound || key.deviceId == DEVICE_ID_DEFAULT) {
|
||||
*pauseTrigger = true;
|
||||
pauseTrigger_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-6
@@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Input/InputState.h"
|
||||
#include "Core/KeyMap.h"
|
||||
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
struct DisplayLayoutConfig;
|
||||
|
||||
// Pure interface.
|
||||
@@ -32,7 +33,7 @@ public:
|
||||
|
||||
// Inputs to the table-based mapping
|
||||
// These functions are free-threaded.
|
||||
bool Key(const KeyInput &key, bool *pauseTrigger);
|
||||
bool Key(const KeyInput &key);
|
||||
void Axis(const AxisInput *axes, size_t count);
|
||||
|
||||
// Required callbacks.
|
||||
@@ -60,6 +61,10 @@ public:
|
||||
|
||||
void GetDebugString(StringWriter &w) const;
|
||||
|
||||
bool PollPauseTrigger() {
|
||||
return pauseTrigger_.exchange(false);
|
||||
}
|
||||
|
||||
struct InputSample {
|
||||
float value;
|
||||
double timestamp;
|
||||
@@ -107,6 +112,8 @@ private:
|
||||
bool autoRotatingAnalogCW_ = false;
|
||||
bool autoRotatingAnalogCCW_ = false;
|
||||
|
||||
std::atomic<bool> pauseTrigger_{};
|
||||
|
||||
bool swapAxes_ = false;
|
||||
|
||||
int iInternalScreenRotationCached_ = 0;
|
||||
|
||||
@@ -518,8 +518,7 @@ bool AnalogCalibrationScreen::key(const KeyInput &key) {
|
||||
bool retval = UIScreen::key(key);
|
||||
|
||||
// Allow testing auto-rotation. If it collides with UI keys, too bad.
|
||||
bool pauseTrigger = false;
|
||||
g_controlMapper.Key(key, &pauseTrigger);
|
||||
g_controlMapper.Key(key);
|
||||
|
||||
if (UI::IsEscapeKey(key)) {
|
||||
TriggerFinish(DR_BACK);
|
||||
|
||||
+10
-6
@@ -1189,7 +1189,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
if (mappingFound) {
|
||||
for (auto b : pspButtons) {
|
||||
if (b == VIRTKEY_TOGGLE_DEBUGGER || b == VIRTKEY_PAUSE) {
|
||||
return g_controlMapper.Key(key, &pauseTrigger_);
|
||||
return g_controlMapper.Key(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1199,28 +1199,28 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
switch (key.deviceId) {
|
||||
case DEVICE_ID_KEYBOARD:
|
||||
if (!ImGui::GetIO().WantCaptureKeyboard) {
|
||||
g_controlMapper.Key(key, &pauseTrigger_);
|
||||
g_controlMapper.Key(key);
|
||||
}
|
||||
break;
|
||||
case DEVICE_ID_MOUSE:
|
||||
if (!ImGui::GetIO().WantCaptureMouse) {
|
||||
g_controlMapper.Key(key, &pauseTrigger_);
|
||||
g_controlMapper.Key(key);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_controlMapper.Key(key, &pauseTrigger_);
|
||||
g_controlMapper.Key(key);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Let up-events through to the controlMapper_ so input doesn't get stuck.
|
||||
if (key.flags & KeyInputFlags::UP) {
|
||||
g_controlMapper.Key(key, &pauseTrigger_);
|
||||
g_controlMapper.Key(key);
|
||||
}
|
||||
}
|
||||
|
||||
return UIScreen::UnsyncKey(key);
|
||||
}
|
||||
return g_controlMapper.Key(key, &pauseTrigger_);
|
||||
return g_controlMapper.Key(key);
|
||||
}
|
||||
|
||||
void EmuScreen::UnsyncAxis(const AxisInput *axes, size_t count) {
|
||||
@@ -1525,6 +1525,10 @@ void EmuScreen::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_controlMapper.PollPauseTrigger()) {
|
||||
pauseTrigger_ = true;
|
||||
}
|
||||
|
||||
if (pauseTrigger_) {
|
||||
pauseTrigger_ = false;
|
||||
screenManager()->push(new GamePauseScreen(gamePath_, bootPending_));
|
||||
|
||||
@@ -114,6 +114,7 @@ private:
|
||||
std::string errorMessage_;
|
||||
|
||||
// If set, pauses at the end of the frame.
|
||||
// We also poll the pause trigger from the ControlMapper. That needs refactoring.
|
||||
bool pauseTrigger_ = false;
|
||||
|
||||
// The last read chat message count, and how many new ones there are.
|
||||
|
||||
+2
-3
@@ -378,9 +378,8 @@ GamePauseScreen::~GamePauseScreen() {
|
||||
|
||||
bool GamePauseScreen::UnsyncKey(const KeyInput &key) {
|
||||
bool retval = UIScreen::UnsyncKey(key);
|
||||
bool pauseTrigger = false;
|
||||
retval = g_controlMapper.Key(key, &pauseTrigger) || retval;
|
||||
if (pauseTrigger) {
|
||||
retval = g_controlMapper.Key(key) || retval;
|
||||
if (g_controlMapper.PollPauseTrigger()) {
|
||||
TriggerFinish(DR_BACK);
|
||||
}
|
||||
return retval;
|
||||
|
||||
Reference in New Issue
Block a user