From 06fadd5cad811c0a40a0fcb22b641c0e4e1bca3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6glund?= Date: Fri, 28 Aug 2015 20:55:32 +0200 Subject: [PATCH] Set DPad keys in native for UI navigation Complements the update to the key repeat logic in native. Also renames UpdateConfirmCancelKeys to UpdateNativeMenuKeys since even before this commit, the function also set the TabLeft and TabRight keys. --- Common/KeyMap.cpp | 14 ++++++++++---- Common/KeyMap.h | 2 +- UI/GameSettingsScreen.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index 7db7721819..f1f2dc5295 100644 --- a/Common/KeyMap.cpp +++ b/Common/KeyMap.cpp @@ -294,9 +294,10 @@ static void KeyCodesFromPspButton(int btn, std::vector *keycodes) { } } -void UpdateConfirmCancelKeys() { +void UpdateNativeMenuKeys() { std::vector confirmKeys, cancelKeys; std::vector tabLeft, tabRight; + std::vector upKeys, downKeys, leftKeys, rightKeys; 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; @@ -305,6 +306,10 @@ void UpdateConfirmCancelKeys() { KeyFromPspButton(cancelKey, &cancelKeys); KeyFromPspButton(CTRL_LTRIGGER, &tabLeft); KeyFromPspButton(CTRL_RTRIGGER, &tabRight); + KeyFromPspButton(CTRL_UP, &upKeys); + KeyFromPspButton(CTRL_DOWN, &downKeys); + KeyFromPspButton(CTRL_LEFT, &leftKeys); + KeyFromPspButton(CTRL_RIGHT, &rightKeys); // Push several hard-coded keys before submitting to native. const KeyDef hardcodedConfirmKeys[] = { @@ -328,6 +333,7 @@ void UpdateConfirmCancelKeys() { cancelKeys.push_back(hardcodedCancelKeys[i]); } + SetDPadKeys(upKeys, downKeys, leftKeys, rightKeys); SetConfirmCancelKeys(confirmKeys, cancelKeys); SetTabLeftRightKeys(tabLeft, tabRight); } @@ -402,7 +408,7 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { break; } - UpdateConfirmCancelKeys(); + UpdateNativeMenuKeys(); } const KeyMap_IntStrPair key_names[] = { @@ -830,7 +836,7 @@ void SetKeyMapping(int btn, KeyDef key, bool replace) { g_controllerMap[btn].push_back(key); } - UpdateConfirmCancelKeys(); + UpdateNativeMenuKeys(); } void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool replace) { @@ -900,7 +906,7 @@ void LoadFromIni(IniFile &file) { } } - UpdateConfirmCancelKeys(); + UpdateNativeMenuKeys(); } void SaveToIni(IniFile &file) { diff --git a/Common/KeyMap.h b/Common/KeyMap.h index 1a8973dd36..e986c7e0ae 100644 --- a/Common/KeyMap.h +++ b/Common/KeyMap.h @@ -126,7 +126,7 @@ namespace KeyMap { void RestoreDefault(); void SwapAxis(); - void UpdateConfirmCancelKeys(); + void UpdateNativeMenuKeys(); void NotifyPadConnected(const std::string &name); bool IsNvidiaShield(const std::string &name); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 436ad99ba8..b08ff5b242 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -837,7 +837,7 @@ void GameSettingsScreen::onFinish(DialogResult result) { host->UpdateUI(); - KeyMap::UpdateConfirmCancelKeys(); + KeyMap::UpdateNativeMenuKeys(); } /*