mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-19 09:19:05 +02:00
Add a hotkey to swap D-pad and left analog stick keys
This commit is contained in:
1 parent
47b731b882
commit
5201f03720
3 files changed
+31
No files matched your search
@@ -650,6 +650,8 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
||||
{VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MIN, "RightAn.Left"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MAX, "RightAn.Right"},
|
||||
|
||||
{VIRTKEY_AXIS_SWAP, "AxisSwap"},
|
||||
};
|
||||
|
||||
const int AXIS_BIND_NKCODE_START = 4000;
|
||||
@@ -920,4 +922,27 @@ const std::set<std::string> &GetSeenPads() {
|
||||
}
|
||||
|
||||
|
||||
void SwapKeys(int btn1, int btn2) {
|
||||
std::vector<KeyDef> keys1;
|
||||
std::vector<KeyDef> keys2;
|
||||
KeyFromPspButton(psp_button_names[btn1].key, &keys1);
|
||||
KeyFromPspButton(psp_button_names[btn2].key, &keys2);
|
||||
RemoveButtonMapping(psp_button_names[btn1].key);
|
||||
RemoveButtonMapping(psp_button_names[btn2].key);
|
||||
for (size_t j = 0; j < keys1.size(); j++) {
|
||||
SetKeyMapping(psp_button_names[btn2].key, KeyDef(keys1[j].deviceId, keys1[j].keyCode), false);
|
||||
}
|
||||
for (size_t j = 0; j < keys2.size(); j++) {
|
||||
SetKeyMapping(psp_button_names[btn1].key, KeyDef(keys2[j].deviceId, keys2[j].keyCode), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Swap direction buttons and left analog axis
|
||||
void SwapAxis() {
|
||||
SwapKeys(0, 12);
|
||||
SwapKeys(1, 13);
|
||||
SwapKeys(2, 14);
|
||||
SwapKeys(3, 15);
|
||||
}
|
||||
|
||||
} // KeyMap
|
||||
Reference in new issue
Block a user