1/*  Part of the SDL3 pack for SWI-Prolog.
    2
    3    SDL_events.h — event polling.
    4
    5    @see https://wiki.libsdl.org/SDL3/SDL_events
    6*/
    7
    8:- module(sdl_events, [
    9    sdl_pollevent/1
   10]).   11
   12:- use_module(library(sdl/foreign), [sdl_pollevent_/1]).
 sdl_pollevent(-Event:dict) is semidet
Poll the next pending event. Succeeds once with a dict for each pending event, and fails when the queue is empty.

Event is a dict whose tag is the event type and which always contains the keys type and timestamp. Additional type-specific keys are present depending on the tag:

   31event_struct(quit, []).
   32event_struct(mousemotion, [windowID, which, state, x, y, xrel, yrel]).
   33event_struct(mousebutton, [windowID, which, button, state, clicks, x, y]).
   34event_struct(keyboard, [windowID, state, repeat, keysym]).
   35
   36sdl_pollevent(Event) :-
   37   sdl_pollevent_(SDL_Event),
   38   compound_name_arguments(SDL_Event, Tag, Args),
   39   event_struct(Tag, Names),
   40   AllNames = [type, timestamp | Names],
   41   pairs_keys_values(Pairs, AllNames, Args),
   42   dict_create(Event, Tag, Pairs)