Skip to content
Merged
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
25 changes: 25 additions & 0 deletions UI/GamepadEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "UI/GamepadEmu.h"

static uint32_t usedPointerMask = 0;
static uint32_t analogPointerMask = 0;

static u32 GetButtonColor() {
return g_Config.iTouchButtonStyle != 0 ? 0xFFFFFF : 0xc0b080;
Expand Down Expand Up @@ -96,6 +97,9 @@ void MultiTouchButton::GetContentDimensions(const UIContext &dc, float &w, float
}

void MultiTouchButton::Touch(const TouchInput &input) {
if (analogPointerMask & (1 << input.id))
return;

GamepadView::Touch(input);
if ((input.flags & TOUCH_DOWN) && bounds_.Contains(input.x, input.y)) {
pointerDownMask_ |= 1 << input.id;
Expand Down Expand Up @@ -152,6 +156,9 @@ void MultiTouchButton::Draw(UIContext &dc) {
}

void BoolButton::Touch(const TouchInput &input) {
if (analogPointerMask & (1 << input.id))
return;

bool lastDown = pointerDownMask_ != 0;
MultiTouchButton::Touch(input);
bool down = pointerDownMask_ != 0;
Expand All @@ -165,6 +172,9 @@ void BoolButton::Touch(const TouchInput &input) {
}

void PSPButton::Touch(const TouchInput &input) {
if (analogPointerMask & (1 << input.id))
return;

bool lastDown = pointerDownMask_ != 0;
MultiTouchButton::Touch(input);
bool down = pointerDownMask_ != 0;
Expand Down Expand Up @@ -192,6 +202,9 @@ void ComboKey::GetContentDimensions(const UIContext &dc, float &w, float &h) con
}

void ComboKey::Touch(const TouchInput &input) {
if (analogPointerMask & (1 << input.id))
return;

using namespace CustomKey;
bool lastDown = pointerDownMask_ != 0;
MultiTouchButton::Touch(input);
Expand Down Expand Up @@ -231,6 +244,9 @@ void PSPDpad::GetContentDimensions(const UIContext &dc, float &w, float &h) cons
}

void PSPDpad::Touch(const TouchInput &input) {
if (analogPointerMask & (1 << input.id))
return;

GamepadView::Touch(input);

if (input.flags & TOUCH_DOWN) {
Expand All @@ -241,6 +257,9 @@ void PSPDpad::Touch(const TouchInput &input) {
}
}
if (input.flags & TOUCH_MOVE) {
if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y)) {
dragPointerId_ = input.id;
}
if (input.id == dragPointerId_) {
ProcessTouch(input.x, input.y, true);
}
Expand Down Expand Up @@ -397,6 +416,7 @@ void PSPStick::Touch(const TouchInput &input) {
centerY_ = bounds_.centerY();
__CtrlSetAnalogXY(stick_, 0.0f, 0.0f);
usedPointerMask = 0;
analogPointerMask = 0;
return;
}
if (input.flags & TOUCH_DOWN) {
Expand All @@ -410,6 +430,7 @@ void PSPStick::Touch(const TouchInput &input) {
}
dragPointerId_ = input.id;
usedPointerMask |= 1 << input.id;
analogPointerMask |= 1 << input.id;
ProcessTouch(input.x, input.y, true);
}
}
Expand All @@ -424,6 +445,7 @@ void PSPStick::Touch(const TouchInput &input) {
centerX_ = bounds_.centerX();
centerY_ = bounds_.centerY();
usedPointerMask &= ~(1 << input.id);
analogPointerMask &= ~(1 << input.id);
ProcessTouch(input.x, input.y, false);
}
}
Expand Down Expand Up @@ -497,6 +519,7 @@ void PSPCustomStick::Touch(const TouchInput &input) {
posX_ = 0.0f;
posY_ = 0.0f;
usedPointerMask = 0;
analogPointerMask = 0;
return;
}
if (input.flags & TOUCH_DOWN) {
Expand All @@ -510,6 +533,7 @@ void PSPCustomStick::Touch(const TouchInput &input) {
}
dragPointerId_ = input.id;
usedPointerMask |= 1 << input.id;
analogPointerMask |= 1 << input.id;
ProcessTouch(input.x, input.y, true);
}
}
Expand All @@ -524,6 +548,7 @@ void PSPCustomStick::Touch(const TouchInput &input) {
centerX_ = bounds_.centerX();
centerY_ = bounds_.centerY();
usedPointerMask &= ~(1 << input.id);
analogPointerMask &= ~(1 << input.id);
ProcessTouch(input.x, input.y, false);
}
}
Expand Down