Add keybinding to rewind (backspace by default), if rewind states are enabled. Disable rewind on mobile.

This commit is contained in:
Henrik Rydgård 2013-12-05 16:15:33 +01:00
parent 78604f4e78
commit cd2adf80a4
6 changed files with 32 additions and 11 deletions

View File

@ -67,6 +67,7 @@ static const DefMappingStruct defaultQwertyKeyboardKeyMap[] = {
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct defaultAzertyKeyboardKeyMap[] = {
@ -95,6 +96,7 @@ static const DefMappingStruct defaultAzertyKeyboardKeyMap[] = {
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct defaultQwertzKeyboardKeyMap[] = {
@ -123,6 +125,7 @@ static const DefMappingStruct defaultQwertzKeyboardKeyMap[] = {
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct default360KeyMap[] = {
@ -190,6 +193,7 @@ static const DefMappingStruct defaultBlackberryQWERTYKeyMap[] = {
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct defaultPadMap[] = {
@ -279,17 +283,17 @@ void UpdateConfirmCancelKeys() {
int confirmKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
int cancelKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;
for(auto i = g_controllerMap[confirmKey].begin(); i != g_controllerMap[confirmKey].end(); ++i) {
for (auto i = g_controllerMap[confirmKey].begin(); i != g_controllerMap[confirmKey].end(); ++i) {
confirmKeys.push_back((keycode_t)i->keyCode);
}
for(auto i = g_controllerMap[cancelKey].begin(); i != g_controllerMap[cancelKey].end(); ++i) {
for (auto i = g_controllerMap[cancelKey].begin(); i != g_controllerMap[cancelKey].end(); ++i) {
cancelKeys.push_back((keycode_t)i->keyCode);
}
// Push several hard-coded keys before submitting to native.
const keycode_t hardcodedConfirmKeys[] = {
NKCODE_SPACE,
const keycode_t hardcodedConfirmKeys[] = {
NKCODE_SPACE,
NKCODE_ENTER,
};
@ -299,9 +303,9 @@ void UpdateConfirmCancelKeys() {
confirmKeys.push_back(hardcodedConfirmKeys[i]);
}
const keycode_t hardcodedCancelKeys[] = {
NKCODE_ESCAPE,
NKCODE_BACK,
const keycode_t hardcodedCancelKeys[] = {
NKCODE_ESCAPE,
NKCODE_BACK,
};
for (size_t i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
@ -329,7 +333,6 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
bool qwertz = false;
#ifdef _WIN32
HKL localeId = GetKeyboardLayout(0);
// TODO: Is this list complete enough?
switch ((int)localeId & 0xFFFF) {
case 0x407:
@ -427,7 +430,7 @@ const KeyMap_IntStrPair key_names[] = {
{NKCODE_F10, "F10"},
{NKCODE_F11, "F11"},
{NKCODE_F12, "F12"},
{NKCODE_GRAVE, "`"},
{NKCODE_SLASH, "/"},
{NKCODE_BACKSLASH, "\\"},
@ -454,7 +457,8 @@ const KeyMap_IntStrPair key_names[] = {
{NKCODE_ALT_RIGHT, "RAlt"},
{NKCODE_SPACE, "Space"},
{NKCODE_WINDOW, "Windows"},
{NKCODE_DEL, "Del"},
{NKCODE_DEL, "Backspace"},
{NKCODE_FORWARD_DEL, "Delete"},
{NKCODE_MOVE_HOME, "Home"},
{NKCODE_MOVE_END, "End"},
{NKCODE_ESCAPE, "Esc"},
@ -602,6 +606,9 @@ const KeyMap_IntStrPair psp_button_names[] = {
{VIRTKEY_UNTHROTTLE, "Unthrottle"},
{VIRTKEY_SPEED_TOGGLE, "SpeedToggle"},
{VIRTKEY_PAUSE, "Pause"},
#ifndef USING_GLES2
{VIRTKEY_REWIND, "Rewind"},
#endif
{VIRTKEY_AXIS_RIGHT_Y_MAX, "RightAn.Up"},
{VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"},

View File

@ -40,6 +40,7 @@ enum {
VIRTKEY_AXIS_RIGHT_Y_MIN = 0x10009,
VIRTKEY_AXIS_RIGHT_X_MAX = 0x1000a,
VIRTKEY_AXIS_RIGHT_Y_MAX = 0x1000b,
VIRTKEY_REWIND = 0x1000c,
VIRTKEY_LAST,
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
};

View File

@ -340,13 +340,16 @@ namespace SaveState
return;
rewindLastTime = time_now();
DEBUG_LOG(BOOT, "saving rewind state");
rewindStates.Save();
}
void Process()
{
#ifndef USING_GLES2
if (g_Config.iRewindFlipFrequency != 0 && gpuStats.numFlips != 0)
CheckRewindState();
#endif
if (!needsProcess)
return;

View File

@ -261,6 +261,14 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
case VIRTKEY_AXIS_RIGHT_Y_MAX:
setVKeyAnalogY(CTRL_STICK_RIGHT, VIRTKEY_AXIS_RIGHT_Y_MIN, VIRTKEY_AXIS_RIGHT_Y_MAX);
break;
case VIRTKEY_REWIND:
if (SaveState::CanRewind()) {
SaveState::Rewind();
} else {
osm.Show(s->T("norewind", "No rewind save states available"), 2.0);
}
break;
}
}

View File

@ -262,7 +262,9 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)")))->SetEnabled(!PSP_IsInited());
systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default)"), screenManager()));
#ifndef USING_GLES2
systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, s->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (0 = off, mem hog)"), screenManager()));
#endif
systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());

View File

@ -10,7 +10,7 @@ class DrawBuffer;
class OnScreenMessages {
public:
void Show(const std::string &message, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1, bool checkUnique = false);
void Show(const std::string &message, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1, bool checkUnique = true);
void ShowOnOff(const std::string &message, bool b, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1);
void Draw(DrawBuffer &draw);
bool IsEmpty() const { return messages_.empty(); }