mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Fix if you activate 1 button in touch overlay, then activate another button with a different finger, then release first finger, then release second finger, the second button still stays activated on mobile
This commit is contained in:
parent
e2ea5289a0
commit
95d8f3803f
45
src/Input.c
45
src/Input.c
@ -75,21 +75,26 @@ static cc_bool AnyBlockTouches(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Input_AddTouch(long id, int x, int y) {
|
void Input_AddTouch(long id, int x, int y) {
|
||||||
int i = Pointers_Count;
|
int i;
|
||||||
touches[i].id = id;
|
for (i = 0; i < INPUT_MAX_POINTERS; i++) {
|
||||||
touches[i].type = TOUCH_TYPE_ALL;
|
if (touches[i].type) continue;
|
||||||
touches[i].begX = x;
|
|
||||||
touches[i].begY = y;
|
|
||||||
|
|
||||||
touches[i].start = DateTime_CurrentUTC_MS();
|
touches[i].id = id;
|
||||||
/* Also set last click time, otherwise quickly tapping */
|
touches[i].type = TOUCH_TYPE_ALL;
|
||||||
/* sometimes triggers a 'delete' in InputHandler_PickBlocks, */
|
touches[i].begX = x;
|
||||||
/* and then another 'delete' in CheckBlockTap. */
|
touches[i].begY = y;
|
||||||
input_lastClick = touches[i].start;
|
|
||||||
|
|
||||||
Pointers_Count++;
|
touches[i].start = DateTime_CurrentUTC_MS();
|
||||||
Pointer_SetPosition(i, x, y);
|
/* Also set last click time, otherwise quickly tapping */
|
||||||
Pointer_SetPressed(i, true);
|
/* sometimes triggers a 'delete' in InputHandler_PickBlocks, */
|
||||||
|
/* and then another 'delete' in CheckBlockTap. */
|
||||||
|
input_lastClick = touches[i].start;
|
||||||
|
|
||||||
|
if (i == Pointers_Count) Pointers_Count++;
|
||||||
|
Pointer_SetPosition(i, x, y);
|
||||||
|
Pointer_SetPressed(i, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool MovedFromBeg(int i, int x, int y) {
|
static cc_bool MovedFromBeg(int i, int x, int y) {
|
||||||
@ -100,7 +105,7 @@ static cc_bool MovedFromBeg(int i, int x, int y) {
|
|||||||
void Input_UpdateTouch(long id, int x, int y) {
|
void Input_UpdateTouch(long id, int x, int y) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < Pointers_Count; i++) {
|
for (i = 0; i < Pointers_Count; i++) {
|
||||||
if (touches[i].id != id) continue;
|
if (touches[i].id != id || !touches[i].type) continue;
|
||||||
|
|
||||||
if (Input_RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) {
|
if (Input_RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) {
|
||||||
/* If the pointer hasn't been locked to gui or block yet, moving a bit */
|
/* If the pointer hasn't been locked to gui or block yet, moving a bit */
|
||||||
@ -137,18 +142,18 @@ static void CheckBlockTap(int i) {
|
|||||||
void Input_RemoveTouch(long id, int x, int y) {
|
void Input_RemoveTouch(long id, int x, int y) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < Pointers_Count; i++) {
|
for (i = 0; i < Pointers_Count; i++) {
|
||||||
if (touches[i].id != id) continue;
|
if (touches[i].id != id || !touches[i].type) continue;
|
||||||
|
|
||||||
Pointer_SetPosition(i, x, y);
|
Pointer_SetPosition(i, x, y);
|
||||||
Pointer_SetPressed(i, false);
|
Pointer_SetPressed(i, false);
|
||||||
CheckBlockTap(i);
|
CheckBlockTap(i);
|
||||||
|
|
||||||
/* found the touch, remove it */
|
/* found the touch, remove it */
|
||||||
for (; i < Pointers_Count - 1; i++) {
|
touches[i].type = 0;
|
||||||
touches[i] = touches[i + 1];
|
Pointers[i].x = -100000;
|
||||||
Pointers[i] = Pointers[i + 1];
|
Pointers[i].y = -100000;
|
||||||
}
|
|
||||||
|
|
||||||
Pointers_Count--;
|
if ((i + 1) == Pointers_Count) Pointers_Count--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user