Touch controls concept

This commit is contained in:
Shinovon 2026-05-03 08:52:21 +05:00
parent b310f7081f
commit a56793f44b
2 changed files with 124 additions and 53 deletions

View file

@ -117,16 +117,16 @@ void tbDisplay()
CFont::SetFontStyle(FONT_BANK);
sprintf(temp, "FPS: %.2f", Diag_GetFPS());
if (frames >= 15) {
RDebug_Printf("FPS: %.2f", Diag_GetFPS());
RDebug_Printf("vbo: %d, draw: %d, render: %d, matfx: %d, skin: %d, im2d: %d, im3d: %d", vboUploads, draw, render, matfx, skin, im2d, im3d);
for (uint32 i = 0; i < TimerBar.count; i++) {
MaxTimes[i] = Max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
RDebug_Printf("%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]);
}
MaxFrameTime = Max(MaxFrameTime, FrameEndTime - FrameInitTime);
RDebug_Printf("EndOfFrame: %.2f", endOfFrameTime);
RDebug_Printf("Frame Time: %.2f", MaxFrameTime);
RDebug_Printf(" ");
// RDebug_Printf("FPS: %.2f", Diag_GetFPS());
// RDebug_Printf("vbo: %d, draw: %d, render: %d, matfx: %d, skin: %d, im2d: %d, im3d: %d", vboUploads, draw, render, matfx, skin, im2d, im3d);
// for (uint32 i = 0; i < TimerBar.count; i++) {
// MaxTimes[i] = Max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
// RDebug_Printf("%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]);
// }
// MaxFrameTime = Max(MaxFrameTime, FrameEndTime - FrameInitTime);
// RDebug_Printf("EndOfFrame: %.2f", endOfFrameTime);
// RDebug_Printf("Frame Time: %.2f", MaxFrameTime);
// RDebug_Printf(" ");
frames = 0;
} else frames++;

View file

@ -55,8 +55,11 @@ const TUid KUidRE3 = {0xe0d67647};
#define JOY_B 1 // circle
#define JOY_X 2 // square
#define JOY_Y 3 // triangle
#define JOY_LB 6
#define JOY_RB 7
#define JOY_L1 4
#define JOY_R1 5
#define JOY_L2 6
#define JOY_R2 7
#define JOY_BACK 8
#define JOY_START 11
#define JOY_DPAD_UP 12
#define JOY_DPAD_RIGHT 13
@ -501,8 +504,10 @@ public:
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent) {
int x = aPointerEvent.iPosition.iX;
int y = aPointerEvent.iPosition.iY;
int w = RsGlobal.width;
int h = RsGlobal.height;
int w = Size().iWidth;
int h = Size().iHeight;
if (h > 360) y += h - 360;
// if (FrontEndMenuManager.m_bMenuActive) {
// PSGLOBAL(lastMousePos).x = x;
@ -526,39 +531,106 @@ public:
static int stickCenterX[10];
static int stickCenterY[10];
if (i > 9) {
if (i >= 10) {
CCoeControl::HandlePointerEventL(aPointerEvent);
return;
}
if (aPointerEvent.iType == TPointerEvent::EButton1Down) {
if (x < w / 3 && y > h / 4) {
// bottom left: left stick
activeZone[i] = 1;
stickCenterX[i] = x;
stickCenterY[i] = y;
} else if (x > w * 2 / 3 && y > h / 4) {
// bottom right: right stick
activeZone[i] = 2;
stickCenterX[i] = x;
stickCenterY[i] = y;
} else if (x > w - (w / 5) && y < h / 4) {
// top right: enter/exit
activeZone[i] = 3;
virtualButtons[JOY_Y] = 1;
} else if (x < w / 5 && y < h / 4) {
// top left: brake
activeZone[i] = 4;
virtualButtons[JOY_X] = 1;
} else {
// gas
activeZone[i] = 5;
virtualButtons[JOY_B] = 1;
// if (x < w / 3 && y > h / 4) {
// // bottom left: left stick
// activeZone[i] = 1;
// stickCenterX[i] = x;
// stickCenterY[i] = y;
// } else if (x > w * 2 / 3 && y > h / 4) {
// // bottom right: right stick
// activeZone[i] = 2;
// stickCenterX[i] = x;
// stickCenterY[i] = y;
// } else if (x > w - (w / 5) && y < h / 4) {
// // top right: enter/exit
// activeZone[i] = 3;
// virtualButtons[JOY_Y] = 1;
// } else if (x < w / 5 && y < h / 4) {
// // top left: brake
// activeZone[i] = 4;
// virtualButtons[JOY_X] = 1;
// } else {
// // gas
// activeZone[i] = 5;
// virtualButtons[JOY_B] = 1;
// }
if (y >= 0 && y <= 32) {
if (x > 40 && x < 40 + 90) {
// l1
activeZone[i] = JOY_L1 + 1;
virtualButtons[JOY_L1] = 1;
} else if (x > 180 && x < 180 + 90) {
// l2
activeZone[i] = JOY_L2 + 1;
virtualButtons[JOY_L2] = 1;
} else if (x > w - 40 && x < w - 40 - 90) {
// r1
activeZone[i] = JOY_R1 + 1;
virtualButtons[JOY_R1] = 1;
} else if (x > w - 180 && x < w - 180 - 90) {
// r2
activeZone[i] = JOY_R2 + 1;
virtualButtons[JOY_R2] = 1;
}
} else if (y > 200 && y <= 360 && (x < 200 || x > w - 200)) {
if (x < 200) {
activeZone[i] = -1;
stickCenterX[i] = x;
stickCenterY[i] = y;
} else {
activeZone[i] = -2;
stickCenterX[i] = x;
stickCenterY[i] = y;
}
} else if (y >= 280 && y <= 280 + 32) {
if (x > 320 - 80 && x < 320 - 20) {
// select
activeZone[i] = JOY_BACK + 1;
virtualButtons[JOY_BACK] = 1;
} else if (x > 320 + 20 && x < 320 + 80) {
// start
activeZone[i] = JOY_START + 1;
virtualButtons[JOY_START] = 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;
}
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_A;
} else if (x < w / 8) {
b = JOY_X;
} else {
b = JOY_B;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;
}
}
}
if (aPointerEvent.iType == TPointerEvent::EDrag) {
if (activeZone[i] == 1 || activeZone[i] == 2) {
} else if (aPointerEvent.iType == TPointerEvent::EDrag) {
if (activeZone[i] == -1 || activeZone[i] == -2) {
float dx = (float)(x - stickCenterX[i]) / (w / 8.0f);
float dy = (float)(y - stickCenterY[i]) / (h / 6.0f);
@ -567,7 +639,7 @@ public:
if (dy < -1.0f) dy = -1.0f;
if (dy > 1.0f) dy = 1.0f;
if (activeZone[i] == 1) {
if (activeZone[i] == -1) {
virtualLeftStickX = dx;
virtualLeftStickY = dy;
} else {
@ -575,21 +647,20 @@ public:
virtualRightStickY = dy;
}
}
}
if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
if (activeZone[i] == 1) {
} else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
switch (activeZone[i]) {
case -1:
virtualLeftStickX = 0.0f;
virtualLeftStickY = 0.0f;
} else if (activeZone[i] == 2) {
break;
case -2:
virtualRightStickX = 0.0f;
virtualRightStickY = 0.0f;
} else if (activeZone[i] == 3) {
virtualButtons[JOY_Y] = 0;
} else if (activeZone[i] == 4) {
virtualButtons[JOY_X] = 0;
} else if (activeZone[i] == 5) {
virtualButtons[JOY_B] = 0;
break;
case 0:
break;
default:
virtualButtons[activeZone[i] - 1] = 0;
}
activeZone[i] = 0;
}