Skip to content

Commit 80b6d88

Browse files
authored
Merge pull request #12173 from LunaMoo/mouseUIworkaround
Ignore mapped mouse input for UI
2 parents 2760834 + b7a49be commit 80b6d88

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Common/KeyMap.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,15 @@ void UpdateNativeMenuKeys() {
281281
int confirmKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
282282
int cancelKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;
283283

284-
KeyFromPspButton(confirmKey, &confirmKeys);
285-
KeyFromPspButton(cancelKey, &cancelKeys);
286-
KeyFromPspButton(CTRL_LTRIGGER, &tabLeft);
287-
KeyFromPspButton(CTRL_RTRIGGER, &tabRight);
288-
KeyFromPspButton(CTRL_UP, &upKeys);
289-
KeyFromPspButton(CTRL_DOWN, &downKeys);
290-
KeyFromPspButton(CTRL_LEFT, &leftKeys);
291-
KeyFromPspButton(CTRL_RIGHT, &rightKeys);
284+
// Mouse mapping might be problematic in UI, so let's ignore mouse for UI
285+
KeyFromPspButton(confirmKey, &confirmKeys, true);
286+
KeyFromPspButton(cancelKey, &cancelKeys, true);
287+
KeyFromPspButton(CTRL_LTRIGGER, &tabLeft, true);
288+
KeyFromPspButton(CTRL_RTRIGGER, &tabRight, true);
289+
KeyFromPspButton(CTRL_UP, &upKeys, true);
290+
KeyFromPspButton(CTRL_DOWN, &downKeys, true);
291+
KeyFromPspButton(CTRL_LEFT, &leftKeys, true);
292+
KeyFromPspButton(CTRL_RIGHT, &rightKeys, true);
292293

293294
#ifdef __ANDROID__
294295
// Hardcode DPAD on Android
@@ -786,11 +787,12 @@ bool KeyToPspButton(int deviceId, int key, std::vector<int> *pspKeys) {
786787
}
787788

788789
// TODO: vector output
789-
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys) {
790+
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys, bool ignoreMouse) {
790791
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
791792
if (iter->first == btn) {
792793
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
793-
keys->push_back(*iter2);
794+
if (!ignoreMouse || iter2->deviceId != DEVICE_ID_MOUSE)
795+
keys->push_back(*iter2);
794796
}
795797
}
796798
}
@@ -911,7 +913,7 @@ void SaveToIni(IniFile &file) {
911913

912914
for (size_t i = 0; i < ARRAY_SIZE(psp_button_names); i++) {
913915
std::vector<KeyDef> keys;
914-
KeyFromPspButton(psp_button_names[i].key, &keys);
916+
KeyFromPspButton(psp_button_names[i].key, &keys, false);
915917

916918
std::string value;
917919
for (size_t j = 0; j < keys.size(); j++) {

Common/KeyMap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace KeyMap {
108108
// buttons. You should have already translated
109109
// your platform's keys to KeyMap keys.
110110
bool KeyToPspButton(int deviceId, int key, std::vector<int> *pspKeys);
111-
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys);
111+
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys, bool ignoreMouse);
112112

113113
int TranslateKeyCodeToAxis(int keyCode, int &direction);
114114
int TranslateKeyCodeFromAxis(int axisId, int direction);

UI/ControlMappingScreen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void ControlMapper::Refresh() {
130130
LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)));
131131
rightColumn->SetSpacing(2.0f);
132132
std::vector<KeyDef> mappings;
133-
KeyMap::KeyFromPspButton(pspKey_, &mappings);
133+
KeyMap::KeyFromPspButton(pspKey_, &mappings, false);
134134

135135
for (size_t i = 0; i < mappings.size(); i++) {
136136
std::string deviceName = GetDeviceName(mappings[i].deviceId);

0 commit comments

Comments
 (0)