mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
@@ -35,12 +35,14 @@ const char *GetDeviceName(int deviceId) {
|
||||
|
||||
bool g_IsMappingMouseInput;
|
||||
|
||||
// TODO: Replace these with using the ControlMapper system.
|
||||
std::vector<InputMapping> dpadKeys;
|
||||
std::vector<InputMapping> confirmKeys;
|
||||
std::vector<InputMapping> cancelKeys;
|
||||
std::vector<InputMapping> infoKeys;
|
||||
std::vector<InputMapping> tabLeftKeys;
|
||||
std::vector<InputMapping> tabRightKeys;
|
||||
|
||||
static std::unordered_map<InputDeviceID, int> uiFlipAnalogY;
|
||||
|
||||
static void AppendKeys(std::vector<InputMapping> &keys, const std::vector<InputMapping> &newKeys) {
|
||||
|
||||
+10
-47
@@ -289,66 +289,29 @@ bool IsDPadKey(const KeyInput &key) {
|
||||
}
|
||||
|
||||
bool IsAcceptKey(const KeyInput &key) {
|
||||
if (confirmKeys.empty()) {
|
||||
// This path is pretty much not used, confirmKeys should be set.
|
||||
// TODO: Get rid of this stuff?
|
||||
if (key.deviceId == DEVICE_ID_KEYBOARD) {
|
||||
return key.keyCode == NKCODE_SPACE || key.keyCode == NKCODE_ENTER || key.keyCode == NKCODE_Z || key.keyCode == NKCODE_NUMPAD_ENTER;
|
||||
} else {
|
||||
return key.keyCode == NKCODE_BUTTON_A || key.keyCode == NKCODE_BUTTON_CROSS || key.keyCode == NKCODE_BUTTON_1 || key.keyCode == NKCODE_DPAD_CENTER;
|
||||
}
|
||||
} else {
|
||||
return MatchesKeyDef(confirmKeys, key);
|
||||
}
|
||||
_dbg_assert_(!confirmKeys.empty());
|
||||
return MatchesKeyDef(confirmKeys, key);
|
||||
}
|
||||
|
||||
bool IsEscapeKey(const KeyInput &key) {
|
||||
if (cancelKeys.empty()) {
|
||||
// This path is pretty much not used, cancelKeys should be set.
|
||||
// TODO: Get rid of this stuff?
|
||||
if (key.deviceId == DEVICE_ID_KEYBOARD) {
|
||||
return key.keyCode == NKCODE_ESCAPE || key.keyCode == NKCODE_BACK;
|
||||
} else {
|
||||
return key.keyCode == NKCODE_BUTTON_CIRCLE || key.keyCode == NKCODE_BUTTON_B || key.keyCode == NKCODE_BUTTON_2;
|
||||
}
|
||||
} else {
|
||||
return MatchesKeyDef(cancelKeys, key);
|
||||
}
|
||||
_dbg_assert_(!cancelKeys.empty());
|
||||
return MatchesKeyDef(cancelKeys, key);
|
||||
}
|
||||
|
||||
// Corresponds to Triangle
|
||||
bool IsInfoKey(const KeyInput &key) {
|
||||
if (infoKeys.empty()) {
|
||||
// This path is pretty much not used, infoKeys should be set.
|
||||
// TODO: Get rid of this stuff?
|
||||
if (key.deviceId == DEVICE_ID_KEYBOARD) {
|
||||
return key.keyCode == NKCODE_S || key.keyCode == NKCODE_NUMPAD_ADD;
|
||||
} else {
|
||||
return key.keyCode == NKCODE_BUTTON_Y || key.keyCode == NKCODE_BUTTON_3;
|
||||
}
|
||||
} else {
|
||||
return MatchesKeyDef(infoKeys, key);
|
||||
}
|
||||
_dbg_assert_(!infoKeys.empty());
|
||||
return MatchesKeyDef(infoKeys, key);
|
||||
}
|
||||
|
||||
bool IsTabLeftKey(const KeyInput &key) {
|
||||
if (tabLeftKeys.empty()) {
|
||||
// This path is pretty much not used, tabLeftKeys should be set.
|
||||
// TODO: Get rid of this stuff?
|
||||
return key.keyCode == NKCODE_BUTTON_L1;
|
||||
} else {
|
||||
return MatchesKeyDef(tabLeftKeys, key);
|
||||
}
|
||||
_dbg_assert_(!tabLeftKeys.empty());
|
||||
return MatchesKeyDef(tabLeftKeys, key);
|
||||
}
|
||||
|
||||
bool IsTabRightKey(const KeyInput &key) {
|
||||
if (tabRightKeys.empty()) {
|
||||
// This path is pretty much not used, tabRightKeys should be set.
|
||||
// TODO: Get rid of this stuff?
|
||||
return key.keyCode == NKCODE_BUTTON_R1;
|
||||
} else {
|
||||
return MatchesKeyDef(tabRightKeys, key);
|
||||
}
|
||||
_dbg_assert_(!tabRightKeys.empty());
|
||||
return MatchesKeyDef(tabRightKeys, key);
|
||||
}
|
||||
|
||||
bool Clickable::Key(const KeyInput &key) {
|
||||
|
||||
+24
-12
@@ -84,6 +84,11 @@ void SingleInputMappingFromPspButton(int btn, std::vector<InputMapping> *mapping
|
||||
}
|
||||
}
|
||||
|
||||
static void InsertIntoVector(std::vector<InputMapping> *vec, const InputMapping &mapping) {
|
||||
if (std::find(vec->begin(), vec->end(), mapping) == vec->end())
|
||||
vec->push_back(mapping);
|
||||
}
|
||||
|
||||
// TODO: This is such a mess...
|
||||
void UpdateNativeMenuKeys() {
|
||||
std::vector<InputMapping> confirmKeys, cancelKeys;
|
||||
@@ -92,9 +97,10 @@ void UpdateNativeMenuKeys() {
|
||||
std::vector<InputMapping> infoKeys;
|
||||
|
||||
// Mouse mapping might be problematic in UI, so let's ignore mouse for UI
|
||||
const bool confirmWithCross = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS;
|
||||
|
||||
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;
|
||||
const int confirmKey = confirmWithCross ? CTRL_CROSS : CTRL_CIRCLE;
|
||||
const int cancelKey = confirmWithCross ? CTRL_CIRCLE : CTRL_CROSS;
|
||||
|
||||
SingleInputMappingFromPspButton(confirmKey, &confirmKeys, true);
|
||||
SingleInputMappingFromPspButton(cancelKey, &cancelKeys, true);
|
||||
@@ -106,7 +112,7 @@ void UpdateNativeMenuKeys() {
|
||||
SingleInputMappingFromPspButton(CTRL_LEFT, &leftKeys, true);
|
||||
SingleInputMappingFromPspButton(CTRL_RIGHT, &rightKeys, true);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
// Hardcode DPAD on Android
|
||||
upKeys.push_back(InputMapping(DEVICE_ID_ANY, NKCODE_DPAD_UP));
|
||||
downKeys.push_back(InputMapping(DEVICE_ID_ANY, NKCODE_DPAD_DOWN));
|
||||
@@ -119,26 +125,24 @@ void UpdateNativeMenuKeys() {
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_SPACE),
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_ENTER),
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_NUMPAD_ENTER),
|
||||
InputMapping(DEVICE_ID_ANY, NKCODE_BUTTON_A),
|
||||
InputMapping(DEVICE_ID_PAD_0, NKCODE_DPAD_CENTER), // A number of Android devices.
|
||||
InputMapping(DEVICE_ID_ANY, confirmWithCross ? NKCODE_BUTTON_A : NKCODE_BUTTON_B),
|
||||
InputMapping(DEVICE_ID_PAD_0, NKCODE_DPAD_CENTER), // A number of old obscure Android devices need this.
|
||||
};
|
||||
|
||||
// If they're not already bound, add them in.
|
||||
for (size_t i = 0; i < ARRAY_SIZE(hardcodedConfirmKeys); i++) {
|
||||
if (std::find(confirmKeys.begin(), confirmKeys.end(), hardcodedConfirmKeys[i]) == confirmKeys.end())
|
||||
confirmKeys.push_back(hardcodedConfirmKeys[i]);
|
||||
InsertIntoVector(&confirmKeys, hardcodedConfirmKeys[i]);
|
||||
}
|
||||
|
||||
const InputMapping hardcodedCancelKeys[] = {
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE),
|
||||
InputMapping(DEVICE_ID_ANY, NKCODE_BACK),
|
||||
InputMapping(DEVICE_ID_ANY, NKCODE_BUTTON_B),
|
||||
InputMapping(DEVICE_ID_ANY, confirmWithCross ? NKCODE_BUTTON_B : NKCODE_BUTTON_A),
|
||||
InputMapping(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4),
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
|
||||
if (std::find(cancelKeys.begin(), cancelKeys.end(), hardcodedCancelKeys[i]) == cancelKeys.end())
|
||||
cancelKeys.push_back(hardcodedCancelKeys[i]);
|
||||
InsertIntoVector(&cancelKeys, hardcodedCancelKeys[i]);
|
||||
}
|
||||
|
||||
const InputMapping hardcodedInfoKeys[] = {
|
||||
@@ -148,10 +152,18 @@ void UpdateNativeMenuKeys() {
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(hardcodedInfoKeys); i++) {
|
||||
if (std::find(infoKeys.begin(), infoKeys.end(), hardcodedInfoKeys[i]) == infoKeys.end())
|
||||
infoKeys.push_back(hardcodedInfoKeys[i]);
|
||||
InsertIntoVector(&infoKeys, hardcodedInfoKeys[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
for (size_t i = 0; i < confirmKeys.size(); i++) {
|
||||
INFO_LOG(Log::System, "Confirm key: %s", MultiInputMapping(confirmKeys[i]).ToVisualString().c_str());
|
||||
}
|
||||
for (size_t i = 0; i < cancelKeys.size(); i++) {
|
||||
INFO_LOG(Log::System, "Cancel key: %s", MultiInputMapping(cancelKeys[i]).ToVisualString().c_str());
|
||||
}
|
||||
*/
|
||||
|
||||
SetDPadKeys(upKeys, downKeys, leftKeys, rightKeys);
|
||||
SetConfirmCancelKeys(confirmKeys, cancelKeys);
|
||||
SetTabLeftRightKeys(tabLeft, tabRight);
|
||||
|
||||
@@ -164,8 +164,6 @@ GameSettingsScreen::~GameSettingsScreen() {
|
||||
|
||||
System_Notify(SystemNotification::UI);
|
||||
|
||||
KeyMap::UpdateNativeMenuKeys();
|
||||
|
||||
// Wipe some caches after potentially changing settings.
|
||||
// Let's not send resize messages here, handled elsewhere.
|
||||
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
|
||||
@@ -1466,7 +1464,10 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||
static const char *timeFormat[] = { "24HR", "12HR" };
|
||||
systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, sy->T("Time Format"), timeFormat, 0, ARRAY_SIZE(timeFormat), I18NCat::SYSTEM, screenManager()));
|
||||
static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" };
|
||||
systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, sy->T("Confirmation Button"), buttonPref, 0, ARRAY_SIZE(buttonPref), I18NCat::SYSTEM, screenManager()));
|
||||
PopupMultiChoice *buttonPrefChoice = systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, sy->T("Confirmation Button"), buttonPref, 0, ARRAY_SIZE(buttonPref), I18NCat::SYSTEM, screenManager()));
|
||||
buttonPrefChoice->OnChoice.Add([](UI::EventParams &e) {
|
||||
KeyMap::UpdateNativeMenuKeys();
|
||||
});
|
||||
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE))
|
||||
systemSettings->Add(new ItemHeader(sy->T("Recording")));
|
||||
|
||||
Reference in New Issue
Block a user