I have already converted that code to pascal. I just havne't got round to adding it to the JEDI-SDL stuff yet... sorry ops:

[pascal]
unit FastEvents;

interface

uses SDL;

const

FASTEVENT_ERROR = -1;
FASTEVENT_OK = 0;

procedure Fast_PumpEvents;
function Fast_PollEvent(Event: PSDL_Event): UInt32;
function Fast_WaitEvent(Event: PSDL_Event): UInt32;
function Fast_PushEvent(Event: PSDL_Event): UInt32;

function Fast_GetError: string;

implementation

var
EventLock: PSDL_Mutex;
EventWait: PSDL_cond;
EventTimer: PSDL_TimerID;
Error: string;

{------------------------------------------------------------------------------}
{Thread Safe Pump Events}
{------------------------------------------------------------------------------}
procedure Fast_PumpEvents;
begin
SDL_LockMutex(eventLock);
SDL_PumpEvents();
SDL_UnlockMutex(eventLock);
end;

{------------------------------------------------------------------------------}
{Poll Event Wrapper}
{------------------------------------------------------------------------------}
function Fast_PollEvent(Event: PSDL_Event): UInt32;
begin
SDL_LockMutex(eventLock);
Result := SDL_PollEvent(event);
SDL_UnlockMutex(eventLock);
if (Result > 0) then
begin
SDL_CondSignal(eventWait);
end
end;

{------------------------------------------------------------------------------}
{Wait Event Wrapper}
{------------------------------------------------------------------------------}
function Fast_WaitEvent(Event: PSDL_Event): UInt32;
begin
Result := 0;
SDL_LockMutex(eventLock);
while (SDL_PollEvent(event) <= 0) do
begin
SDL_CondWait(eventWait, eventLock);
end;
SDL_UnlockMutex(eventLock);
SDL_CondSignal(eventWait);
end;

{------------------------------------------------------------------------------}
{Push Event Wrapper}
{------------------------------------------------------------------------------}
function Fast_PushEvent(Event: PSDL_Event): UInt32;
begin
SDL_LockMutex(EventLock);
while (SDL_PushEvent(Event) <= 0) do
begin
SDL_CondWait(eventWait, eventLock);
end;
SDL_UnlockMutex(eventLock);
SDL_CondSignal(eventWait);
Result := 1;
end;

{------------------------------------------------------------------------------}
{Get Error function }
{------------------------------------------------------------------------------}
function Fast_GetError: string;
begin
Result := Error;
end;

procedure Fast_SetError(const Value: string);
begin
Error := Value;
end;

{------------------------------------------------------------------------------}
{Time Callback to wake up all waiting threads}
{------------------------------------------------------------------------------}
function timerCallback(interval: UInt32; param: Pointer): UInt32;
cdecl;
begin
SDL_CondBroadcast(EventWait);
Result := interval;
end;

{------------------------------------------------------------------------------}
{Initialization- creates timers and mutexs}
{------------------------------------------------------------------------------}
function FastEventsInit: Integer;
begin
Result := FASTEVENT_ERROR;
if (SDL_INIT_TIMER and SDL_WasInit(SDL_INIT_TIMER) = 0) then
begin
SDL_InitSubSystem(SDL_INIT_TIMER);
end;
EventLock := SDL_CreateMutex;
if (EventLock = nil) then
begin
Fast_SetError('Fast Events: cannot create a mutex');
Exit;
end;
EventWait := SDL_CreateCond();
if (EventWait = nil) then
begin
Fast_SetError('Fast Events: cannot create a condition variable');
Exit;
end;
EventTimer := SDL_AddTimer(10, timerCallback, nil);
if (EventTimer = nil) then
begin
Fast_SetError('Fast Events: cannot add a timer');
Exit;
end;
Result := FASTEVENT_OK;
end;

{------------------------------------------------------------------------------}
{Clean Up}
{------------------------------------------------------------------------------}
procedure FastEventsQuit;
begin
SDL_DestroyMutex(eventLock);
eventLock := nil;
SDL_DestroyCond(eventWait);
eventWait := nil;
SDL_RemoveTimer(eventTimer);
end;


initialization

FastEventsInit;

finalization

FastEventsQuit;

end.
[/pascal]