comma: detected single frame released events (#8)

This commit is contained in:
Maxime Desroches 2025-06-21 18:11:44 -07:00 committed by GitHub
parent e0823aace6
commit c0753673e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -628,6 +628,8 @@ void PollInputEvents(void) {
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
CORE.Input.Touch.pointCount = 0; CORE.Input.Touch.pointCount = 0;
int released_detected = 0;
struct input_event event = {0}; struct input_event event = {0};
while (read(platform.touch.fd, &event, sizeof(struct input_event)) == sizeof(struct input_event)) { while (read(platform.touch.fd, &event, sizeof(struct input_event)) == sizeof(struct input_event)) {
if (event.type == SYN_REPORT) { // synchronization frame. Expose completed events back to the library if (event.type == SYN_REPORT) { // synchronization frame. Expose completed events back to the library
@ -647,6 +649,9 @@ void PollInputEvents(void) {
} }
} else if (platform.touch.fingers[i].action == TOUCH_ACTION_UP) { } else if (platform.touch.fingers[i].action == TOUCH_ACTION_UP) {
if (CORE.Input.Touch.currentTouchState[i] == 1) {
released_detected = 1;
}
CORE.Input.Touch.position[i].x = -1; CORE.Input.Touch.position[i].x = -1;
CORE.Input.Touch.position[i].y = -1; CORE.Input.Touch.position[i].y = -1;
CORE.Input.Touch.currentTouchState[i] = 0; CORE.Input.Touch.currentTouchState[i] = 0;
@ -667,6 +672,12 @@ void PollInputEvents(void) {
} }
} }
// hack for now to detect gestures in single frame
if (released_detected) {
CORE.Input.Touch.previousTouchState[0] = 1;
CORE.Input.Touch.currentTouchState[0] = 0;
}
// count how many fingers are left on the screen after processing all events // count how many fingers are left on the screen after processing all events
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) { for (int i = 0; i < MAX_TOUCH_POINTS; ++i) {
CORE.Input.Touch.pointCount += platform.touch.fingers[i].action != TOUCH_ACTION_UP; CORE.Input.Touch.pointCount += platform.touch.fingers[i].action != TOUCH_ACTION_UP;