MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / loop

Function loop

test/browser/test_sdl_touch.c:37–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void loop() {
38 SDL_Event event;
39 while (SDL_PollEvent(&event)) {
40 switch(event.type) {
41 case SDL_FINGERMOTION:
42 case SDL_FINGERDOWN:
43 case SDL_FINGERUP: {
44 SDL_TouchFingerEvent *t = (SDL_TouchFingerEvent*)&event;
45 printf("type: %s, timestamp: %u, touchId: %llu, fingerId: %llu, x: %f, y: %f, dx: %f, dy: %f, pressure: %f\n",
46 TouchFingerTypeToString(event.type), t->timestamp, t->touchId, t->fingerId, t->x, t->y, t->dx, t->dy, t->pressure);
47
48 if (t->timestamp != 0 && t->x >= 0.f && t->x <= 1.f && t->y >= 0.f && t->y <= 1.f && t->pressure >= 0.f && t->pressure <= 1.f) {
49 if (event.type == SDL_FINGERDOWN) { got_down = 1; progress(); }
50 if (event.type == SDL_FINGERMOTION) { got_move = 1; progress(); }
51 if (event.type == SDL_FINGERDOWN) { got_up = 1; progress(); }
52 }
53 break;
54 }
55 }
56 }
57}
58
59int main() {
60 SDL_Init(SDL_INIT_VIDEO);

Callers

nothing calls this directly

Calls 3

printfFunction · 0.85
TouchFingerTypeToStringFunction · 0.85
progressFunction · 0.85

Tested by

no test coverage detected