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