mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-21 21:34:25 +01:00
Merge pull request #3268 from thedax/master
Set accept/escape buttons based on the bound CROSS/CIRCLE buttons.
This commit is contained in:
commit
cbb7f025b8
4 files changed
+55
-3
No files matched your search
+49
-1
@@ -20,6 +20,10 @@
|
||||
#include "../Core/Config.h"
|
||||
#include "base/NativeApp.h"
|
||||
#include "KeyMap.h"
|
||||
#include "../Core/HLE/sceUtility.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace KeyMap {
|
||||
|
||||
@@ -205,6 +209,45 @@ static const DefMappingStruct defaultXperiaPlay[] = {
|
||||
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, +1},
|
||||
};
|
||||
|
||||
void UpdateConfirmCancelKeys() {
|
||||
std::vector<keycode_t> confirmKeys, cancelKeys;
|
||||
|
||||
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) {
|
||||
confirmKeys.push_back((keycode_t)i->keyCode);
|
||||
}
|
||||
|
||||
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,
|
||||
NKCODE_ENTER,
|
||||
};
|
||||
|
||||
// If they're not already bound, add them in.
|
||||
for(int i = 0; i < ARRAY_SIZE(hardcodedConfirmKeys); i++) {
|
||||
if(std::find(confirmKeys.begin(), confirmKeys.end(), hardcodedConfirmKeys[i]) == confirmKeys.end())
|
||||
confirmKeys.push_back(hardcodedConfirmKeys[i]);
|
||||
}
|
||||
|
||||
const keycode_t hardcodedCancelKeys[] = {
|
||||
NKCODE_ESCAPE,
|
||||
NKCODE_BACK,
|
||||
};
|
||||
|
||||
for(int i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
|
||||
if(std::find(cancelKeys.begin(), cancelKeys.end(), hardcodedCancelKeys[i]) == cancelKeys.end())
|
||||
cancelKeys.push_back(hardcodedCancelKeys[i]);
|
||||
}
|
||||
|
||||
SetConfirmCancelKeys(confirmKeys,cancelKeys);
|
||||
}
|
||||
|
||||
static void SetDefaultKeyMap(int deviceId, const DefMappingStruct *array, int count, bool replace) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (array[i].direction == 0)
|
||||
@@ -235,6 +278,8 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
|
||||
SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace);
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateConfirmCancelKeys();
|
||||
}
|
||||
|
||||
const KeyMap_IntStrPair key_names[] = {
|
||||
@@ -613,6 +658,8 @@ void SetKeyMapping(int btn, KeyDef key, bool replace) {
|
||||
}
|
||||
g_controllerMap[btn].push_back(key);
|
||||
}
|
||||
|
||||
UpdateConfirmCancelKeys();
|
||||
}
|
||||
|
||||
void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool replace) {
|
||||
@@ -674,7 +721,8 @@ void LoadFromIni(IniFile &file) {
|
||||
SetKeyMapping(psp_button_names[i].key, KeyDef(deviceId, keyCode), false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
UpdateConfirmCancelKeys();
|
||||
}
|
||||
|
||||
void SaveToIni(IniFile &file) {
|
||||
|
||||
+2
-1
@@ -151,5 +151,6 @@ namespace KeyMap {
|
||||
|
||||
void RestoreDefault();
|
||||
void QuickMap(int device);
|
||||
}
|
||||
|
||||
void UpdateConfirmCancelKeys();
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "math/curves.h"
|
||||
#include "Core/HW/atrac3plus.h"
|
||||
#include "Core/System.h"
|
||||
#include "Common/KeyMap.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Core/Host.h"
|
||||
@@ -455,6 +456,8 @@ UI::EventReturn GameSettingsScreen::OnBack(UI::EventParams &e) {
|
||||
PostMessage(MainWindow::hwndMain, MainWindow::WM_USER_ATRAC_STATUS_CHANGED, 0, 0);
|
||||
#endif
|
||||
|
||||
KeyMap::UpdateConfirmCancelKeys();
|
||||
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
Submodule native updated: 92dd9cd798...a8b45a68b9.
Reference in new issue
Block a user