code.witches.io/go/sdl2@v0.1.1/events.c (about)

     1  #include "events.h"
     2  #include <stdio.h>
     3  #include <stdatomic.h>
     4  #include "_cgo_export.h"
     5  
     6  void collectEvents(volatile Uint32 *collectEventsQuit) {
     7    SDL_Event event;
     8    while(atomic_load(collectEventsQuit) == 0) {
     9  
    10      SDL_PumpEvents();
    11  
    12  #if 0
    13      switch(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
    14      case 1:
    15        if (atomic_load(collectEventsQuit) == 0) {
    16          propevent(&event);
    17        }
    18      }
    19  #else
    20      if (SDL_WaitEventTimeout(&event, 10) == 1) {
    21        if (atomic_load(collectEventsQuit) == 0) {
    22          propevent(&event);
    23        }
    24      }
    25  #endif
    26    }
    27    atomic_fetch_add(collectEventsQuit, 1);
    28  }