SDLUtils.def 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. DEFINITION MODULE SDLUtils ;
  2. (*
  3. m2SDL - small pure-Modula-2 helpers over the FOR "C" bindings.
  4. CStrToM2 copies NUL-terminated C strings (ADDRESS) into
  5. Modula-2 CHAR arrays (NUL-terminated, truncated to fit).
  6. PollM2Event decodes one queued SDL_Event into a small record:
  7. SDL2 puts the Uint32 type at offset 0 of every event, and for
  8. key events the Sint32 keysym.sym at offset 20 (see <SDL_events.h>
  9. and <SDL_keyboard.h>). DrainEvents pumps the queue and reports
  10. whether a quit event was seen.
  11. *)
  12. FROM SYSTEM IMPORT ADDRESS;
  13. EXPORT UNQUALIFIED
  14. EventKind, M2Event,
  15. CStrToM2, GetErrorString, PollM2Event, DrainEvents;
  16. TYPE
  17. EventKind = (evQuit, evKey, evOther);
  18. M2Event = RECORD
  19. kind: EventKind;
  20. sym: INTEGER; (* valid when kind = evKey *)
  21. pressed: BOOLEAN; (* valid when kind = evKey *)
  22. END;
  23. PROCEDURE CStrToM2 (src: ADDRESS; VAR dst: ARRAY OF CHAR);
  24. PROCEDURE GetErrorString (VAR buf: ARRAY OF CHAR);
  25. PROCEDURE PollM2Event (VAR ev: M2Event) : BOOLEAN;
  26. PROCEDURE DrainEvents (VAR quit: BOOLEAN);
  27. END SDLUtils.