Skip to content

Commit

Permalink
Restore the D-Pad behavior (see #18028)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 11, 2023
1 parent ef6ea1b commit 72be2f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions Core/ControlMapper.cpp
Expand Up @@ -251,6 +251,7 @@ void ControlMapper::SwapMappingIfEnabled(uint32_t *vkey) {
}

// Can only be called from Key or Axis.
// mutex_ should be locked.
// TODO: We should probably make a batched version of this.
bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double now) {
// Instead of taking an input key and finding what it outputs, we loop through the OUTPUTS and
Expand Down
25 changes: 13 additions & 12 deletions UI/GamepadEmu.cpp
Expand Up @@ -351,22 +351,23 @@ void PSPDpad::ProcessTouch(float x, float y, bool down) {
}

int lastDown = down_;
int pressed = ctrlMask & ~lastDown;
int released = (~ctrlMask) & lastDown;
down_ = ctrlMask;
__CtrlUpdateButtons(ctrlMask, CTRL_LEFT | CTRL_RIGHT | CTRL_UP | CTRL_DOWN);

if (g_Config.bHapticFeedback) {
int pressed = down_ & ~lastDown;
static const int dir[4] = { CTRL_RIGHT, CTRL_DOWN, CTRL_LEFT, CTRL_UP };
bool vibrate = false;
for (int i = 0; i < 4; i++) {
if (pressed & dir[i]) {
vibrate = true;
}
bool vibrate = false;
static const int dir[4] = { CTRL_RIGHT, CTRL_DOWN, CTRL_LEFT, CTRL_UP };
for (int i = 0; i < 4; i++) {
if (pressed & dir[i]) {
vibrate = true;
__CtrlUpdateButtons(dir[i], 0);
}
if (vibrate) {
System_Vibrate(HAPTIC_VIRTUAL_KEY);
if (released & dir[i]) {
__CtrlUpdateButtons(0, dir[i]);
}
}
if (vibrate && g_Config.bHapticFeedback) {
System_Vibrate(HAPTIC_VIRTUAL_KEY);
}
}

void PSPDpad::Draw(UIContext &dc) {
Expand Down

0 comments on commit 72be2f5

Please sign in to comment.