mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
Merge pull request #18419 from hrydgard/gamelist-triangle-button-cleanup
Clean up the checks for triangle-button-for-info on the main screen
This commit is contained in:
6 files changed
+43
-7
No files matched your search
@@ -37,6 +37,7 @@ const char *GetDeviceName(int deviceId) {
|
||||
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;
|
||||
@@ -69,6 +70,10 @@ void SetTabLeftRightKeys(const std::vector<InputMapping> &tabLeft, const std::ve
|
||||
tabRightKeys = tabRight;
|
||||
}
|
||||
|
||||
void SetInfoKeys(const std::vector<InputMapping> &info) {
|
||||
infoKeys = info;
|
||||
}
|
||||
|
||||
void SetAnalogFlipY(std::unordered_map<InputDeviceID, int> flipYByDeviceId) {
|
||||
uiFlipAnalogY = flipYByDeviceId;
|
||||
}
|
||||
|
||||
@@ -191,12 +191,14 @@ struct AxisInput {
|
||||
extern std::vector<InputMapping> dpadKeys;
|
||||
extern std::vector<InputMapping> confirmKeys;
|
||||
extern std::vector<InputMapping> cancelKeys;
|
||||
extern std::vector<InputMapping> infoKeys;
|
||||
extern std::vector<InputMapping> tabLeftKeys;
|
||||
extern std::vector<InputMapping> tabRightKeys;
|
||||
void SetDPadKeys(const std::vector<InputMapping> &leftKey, const std::vector<InputMapping> &rightKey,
|
||||
const std::vector<InputMapping> &upKey, const std::vector<InputMapping> &downKey);
|
||||
void SetConfirmCancelKeys(const std::vector<InputMapping> &confirm, const std::vector<InputMapping> &cancel);
|
||||
void SetTabLeftRightKeys(const std::vector<InputMapping> &tabLeft, const std::vector<InputMapping> &tabRight);
|
||||
void SetInfoKeys(const std::vector<InputMapping> &info);
|
||||
|
||||
// 0 means unknown (attempt autodetect), -1 means flip, 1 means original direction.
|
||||
void SetAnalogFlipY(std::unordered_map<InputDeviceID, int> flipYByDeviceId);
|
||||
|
||||
@@ -307,6 +307,21 @@ bool IsEscapeKey(const KeyInput &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);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsTabLeftKey(const KeyInput &key) {
|
||||
if (tabLeftKeys.empty()) {
|
||||
// This path is pretty much not used, tabLeftKeys should be set.
|
||||
|
||||
@@ -1066,6 +1066,7 @@ void ApplyBoundsBySpec(Bounds &bounds, MeasureSpec horiz, MeasureSpec vert);
|
||||
bool IsDPadKey(const KeyInput &key);
|
||||
bool IsAcceptKey(const KeyInput &key);
|
||||
bool IsEscapeKey(const KeyInput &key);
|
||||
bool IsInfoKey(const KeyInput &key);
|
||||
bool IsTabLeftKey(const KeyInput &key);
|
||||
bool IsTabRightKey(const KeyInput &key);
|
||||
|
||||
|
||||
+16
-1
@@ -67,13 +67,16 @@ void UpdateNativeMenuKeys() {
|
||||
std::vector<InputMapping> confirmKeys, cancelKeys;
|
||||
std::vector<InputMapping> tabLeft, tabRight;
|
||||
std::vector<InputMapping> upKeys, downKeys, leftKeys, rightKeys;
|
||||
std::vector<InputMapping> infoKeys;
|
||||
|
||||
// Mouse mapping might be problematic in UI, so let's ignore mouse for UI
|
||||
|
||||
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;
|
||||
|
||||
// Mouse mapping might be problematic in UI, so let's ignore mouse for UI
|
||||
SingleInputMappingFromPspButton(confirmKey, &confirmKeys, true);
|
||||
SingleInputMappingFromPspButton(cancelKey, &cancelKeys, true);
|
||||
SingleInputMappingFromPspButton(CTRL_TRIANGLE, &infoKeys, true);
|
||||
SingleInputMappingFromPspButton(CTRL_LTRIGGER, &tabLeft, true);
|
||||
SingleInputMappingFromPspButton(CTRL_RTRIGGER, &tabRight, true);
|
||||
SingleInputMappingFromPspButton(CTRL_UP, &upKeys, true);
|
||||
@@ -116,9 +119,21 @@ void UpdateNativeMenuKeys() {
|
||||
cancelKeys.push_back(hardcodedCancelKeys[i]);
|
||||
}
|
||||
|
||||
const InputMapping hardcodedInfoKeys[] = {
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_S),
|
||||
InputMapping(DEVICE_ID_KEYBOARD, NKCODE_NUMPAD_ADD),
|
||||
InputMapping(DEVICE_ID_PAD_0, NKCODE_BUTTON_Y), // Also triangle
|
||||
};
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
SetDPadKeys(upKeys, downKeys, leftKeys, rightKeys);
|
||||
SetConfirmCancelKeys(confirmKeys, cancelKeys);
|
||||
SetTabLeftRightKeys(tabLeft, tabRight);
|
||||
SetInfoKeys(infoKeys);
|
||||
|
||||
std::unordered_map<InputDeviceID, int> flipYByDeviceId;
|
||||
for (InputDeviceID deviceId : g_seenDeviceIds) {
|
||||
|
||||
+4
-6
@@ -158,12 +158,10 @@ public:
|
||||
std::vector<int> pspKeys;
|
||||
bool showInfo = false;
|
||||
|
||||
if (HasFocus() && KeyMap::InputMappingToPspButton(InputMapping(key.deviceId, key.keyCode), &pspKeys)) {
|
||||
for (auto it = pspKeys.begin(), end = pspKeys.end(); it != end; ++it) {
|
||||
// If the button mapped to triangle, then show the info.
|
||||
if ((key.flags & KEY_UP) && *it == CTRL_TRIANGLE) {
|
||||
showInfo = true;
|
||||
}
|
||||
if (HasFocus() && UI::IsInfoKey(key)) {
|
||||
// If the button mapped to triangle, then show the info.
|
||||
if (key.flags & KEY_UP) {
|
||||
showInfo = true;
|
||||
}
|
||||
} else if (hovering_ && key.deviceId == DEVICE_ID_MOUSE && key.keyCode == NKCODE_EXT_MOUSEBUTTON_2) {
|
||||
// If it's the right mouse button, and it's not otherwise mapped, show the info also.
|
||||
|
||||
Reference in new issue
Block a user