Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore mapped mouse input for UI #12173

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Common/KeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,15 @@ void UpdateNativeMenuKeys() {
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;

KeyFromPspButton(confirmKey, &confirmKeys);
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);
// Mouse mapping might be problematic in UI, so let's ignore mouse for UI
KeyFromPspButton(confirmKey, &confirmKeys, true);
KeyFromPspButton(cancelKey, &cancelKeys, true);
KeyFromPspButton(CTRL_LTRIGGER, &tabLeft, true);
KeyFromPspButton(CTRL_RTRIGGER, &tabRight, true);
KeyFromPspButton(CTRL_UP, &upKeys, true);
KeyFromPspButton(CTRL_DOWN, &downKeys, true);
KeyFromPspButton(CTRL_LEFT, &leftKeys, true);
KeyFromPspButton(CTRL_RIGHT, &rightKeys, true);

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

// TODO: vector output
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys) {
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys, bool ignoreMouse) {
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
if (iter->first == btn) {
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
keys->push_back(*iter2);
if (!ignoreMouse || iter2->deviceId != DEVICE_ID_MOUSE)
keys->push_back(*iter2);
}
}
}
Expand Down Expand Up @@ -911,7 +913,7 @@ void SaveToIni(IniFile &file) {

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

std::string value;
for (size_t j = 0; j < keys.size(); j++) {
Expand Down
2 changes: 1 addition & 1 deletion Common/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace KeyMap {
// buttons. You should have already translated
// your platform's keys to KeyMap keys.
bool KeyToPspButton(int deviceId, int key, std::vector<int> *pspKeys);
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys);
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys, bool ignoreMouse);

int TranslateKeyCodeToAxis(int keyCode, int &direction);
int TranslateKeyCodeFromAxis(int axisId, int direction);
Expand Down
2 changes: 1 addition & 1 deletion UI/ControlMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void ControlMapper::Refresh() {
LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)));
rightColumn->SetSpacing(2.0f);
std::vector<KeyDef> mappings;
KeyMap::KeyFromPspButton(pspKey_, &mappings);
KeyMap::KeyFromPspButton(pspKey_, &mappings, false);

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