Skip to content

Commit

Permalink
Merge pull request #18128 from hrydgard/assorted-fixes-3
Browse files Browse the repository at this point in the history
Restore touch D-Pad behavior
  • Loading branch information
hrydgard authored Sep 11, 2023
2 parents 181ac68 + 72be2f5 commit 4d58bb8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions Core/ControlMapper.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions Windows/RawInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ namespace WindowsRawInput {

if (key.keyCode) {
NativeKey(key);

auto keyDown = std::find(keyboardKeysDown.begin(), keyboardKeysDown.end(), key.keyCode);
auto keyDown = keyboardKeysDown.find(key.keyCode);
if (keyDown != keyboardKeysDown.end())
keyboardKeysDown.erase(keyDown);
}
Expand Down

0 comments on commit 4d58bb8

Please sign in to comment.