Skip to content

Commit

Permalink
Fix an issue where stray KEY_UP events could confuse the control mapp…
Browse files Browse the repository at this point in the history
…er into setting empty events

This had some not-so-good consequences, like inability to map anything
in VR, and sometimes empty MultiMappings would result that we could end
up asserting on before the previous commit.
  • Loading branch information
hrydgard committed May 5, 2023
1 parent eec1ad5 commit cd33b79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
keyInput.deviceId = controllerIds[j];

//process the key action

if (m.pressed != pressed) {
if (pressed && haptics) {
INVR_Vibrate(100, j, 1000);
Expand Down Expand Up @@ -446,7 +447,8 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
mousePressed = pressed;
}

//mouse wheel emulation
// mouse wheel emulation
// TODO: Spams key-up events if nothing changed!
for (int j = 0; j < 2; j++) {
keyInput.deviceId = controllerIds[j];
float scroll = -IN_VRGetJoystickState(j).y;
Expand Down
9 changes: 9 additions & 0 deletions UI/ControlMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
}
}
if (key.flags & KEY_UP) {
// If the key released wasn't part of the mapping, ignore it here. Some device can cause
// stray key-up events.
InputMapping upMapping(key.deviceId, key.keyCode);
if (!mapping_.mappings.contains(upMapping)) {
return true;
}

if (callback_)
callback_(mapping_);
TriggerFinish(DR_YES);
Expand Down Expand Up @@ -391,7 +398,9 @@ bool KeyMappingNewMouseKeyDialog::key(const KeyInput &key) {
}

mapped_ = true;

MultiInputMapping kdf(InputMapping(key.deviceId, key.keyCode));

TriggerFinish(DR_YES);
g_Config.bMapMouse = false;
if (callback_)
Expand Down

0 comments on commit cd33b79

Please sign in to comment.