Improve touch controls

This commit is contained in:
Shinovon 2026-05-12 13:17:18 +05:00
parent 6c644421fd
commit 52c4681c0c
2 changed files with 73 additions and 46 deletions

View file

@ -625,6 +625,10 @@ public:
RestartTimerL(10000);
}
static bool c(int px, int py, int x, int y, int w, int h) {
return px >= x && py >= y && px <= x + w && py <= y + h;
}
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent) {
touch = true;
int x = aPointerEvent.iPosition.iX;
@ -683,7 +687,7 @@ public:
activeZone[i] = JOY_R2 + 1;
virtualButtons[JOY_R2] = 1;
}
} else if (y > 200 && y <= 360 && (x < 200 || x > w - 200)) {
} else if (y > 220 && y <= 360 && (x < 200 || x > w - 200)) {
if (x < 200) {
activeZone[i] = -1;
stickCenterX[i] = x;
@ -712,35 +716,44 @@ public:
virtualButtons[JOY_R3] = 1;
}
} else if (y >= 80 && y <= 80 + 120) {
if (x < w / 4) {
// dpad
int b = 0;
if (y < 125) {
b = JOY_DPAD_UP;
} else if (y > 155) {
b = JOY_DPAD_DOWN;
} else if (x < w / 8) {
b = JOY_DPAD_LEFT;
} else {
b = JOY_DPAD_RIGHT;
do {
int cy = (h * 2) / 5;
if (x < w / 4) {
// dpad
int b = 0;
int cx = w / 8;
if (c(x, y, cx - 20, cy - 60, 40, 30)) {
b = JOY_DPAD_UP;
} else if (c(x, y, cx - 20, cy + 30, 40, 40)) {
b = JOY_DPAD_DOWN;
} else if (c(x, y, cx - 75, cy - 20, 40, 40)) {
b = JOY_DPAD_LEFT;
} else if (c(x, y, cx + 35, cy - 20, 40, 40)) {
b = JOY_DPAD_RIGHT;
} else {
break;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;
} else if (x > w - w / 4) {
// abxy
int cx = w - w / 8;
int b = 0;
if (c(x, y, cx - 20, cy - 60, 40, 40)) {
b = JOY_Y;
} else if (c(x, y, cx - 20, cy + 30, 40, 40)) {
b = JOY_B;
} else if (c(x, y, cx - 75, cy - 20, 40, 40)) {
b = JOY_X;
} else if (c(x, y, cx + 35, cy - 20, 40, 40)) {
b = JOY_A;
} else {
break;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;
} else if (x > w - w / 4) {
// abxy
int b = 0;
if (y < 125) {
b = JOY_Y;
} else if (y > 155) {
b = JOY_B;
} else if (x < w - w / 8) {
b = JOY_X;
} else {
b = JOY_A;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;
}
} while (0);
}
} else if (aPointerEvent.iType == TPointerEvent::EDrag) {
if (activeZone[i] == -1 || activeZone[i] == -2) {