Quellcode durchsuchen

comma: detected single frame released events (#8)

pull/5008/head
Maxime Desroches vor 3 Wochen
committed von GitHub
Ursprung
Commit
c0753673e6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: B5690EEEBB952194
1 geänderte Dateien mit 11 neuen und 0 gelöschten Zeilen
  1. +11
    -0
      src/platforms/rcore_comma.c

+ 11
- 0
src/platforms/rcore_comma.c Datei anzeigen

@ -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;

Laden…
Abbrechen
Speichern