Hi all,
I am trying to use SDLInput.pas for my PGDAnnual2009 entry and am having some issues...

I am using a TSDLInputManager class that I have already created like so:

[pascal]InputManager := TSDLInputManager.Create([itJoystick , itKeyBoard, itMouse]);[/pascal]

Issue #1 I have tried enabling all three input types (joystick, keyboard and mouse) using this code:

[pascal]InputManager.Enable([itJoystick,itKeyBoard,itMouse]);[/pascal]

but it crashes and gives me an error dialog box:

Project DayOfDestruction.exe raised exception class EListError with message 'List index out of bounds (0)'. Process stopped. Use Step or Run to continue.
Would this be because I don't have a joystick attached to my system?

I would have thought that the code would have done some error checking behind the scenes...

it seems I can fix it using this code instead as a workaround:

[pascal] If InputManager.JoyStick.NumOfJoySticks > 0 Then
InputManager.Enable([itJoystick,itKeyBoard,itMouse])
Else
InputManager.Enable([itKeyBoard,itMouse]);[/pascal]

But I don't think I should have to do this myself

Issue #2 I am trying to detect keypresses using the keyboard input manager like so:

[pascal]InputManager.KeyBoard.OnKeyUp := OnKeyUp;[/pascal]

Where the OnKeyUp method is this:

[pascal]Procedure TGame.OnKeyUp(var Key: TSDLKey; Shift: TSDLMod; unicode : UInt16);
Begin
If Key = SDLK_ESCAPE Then ExitApplication;
End;[/pascal]

but it is never being called for some reason...

As you can see from the code below the update method of the InputManager is being called ok in my main SDL loop:

[pascal]Procedure TSDLApplication.Run(Const AWidth,AHeight,ADepth : Uint32;
Const AFullScreen : Boolean);
Const
cLockFPS = 60;
cMinTimeSlice = Round(1/cLockFPS);
cMaxTimeSlice = 1;
Var
event : TSDL_Event;
TimeSlice : Single;
FPS : Single;
Begin
FWidth := AWidth;
FHeight := AHeight;
FDepth := ADepth;
FFullScreen := AFullScreen;
Try
If Not Initialize Then Exit;
FTimer.Init;

TimeSlice := cMinTimeSlice;
FFinished := False;
While Not FFinished Do
Begin
FInputManager.UpdateInputs(event);
If SDL_MustLock(FVideoBuffer) Then
SDL_LockSurface(FVideoBuffer);

FPS := FTimer.GetFPS;
ProcessFrame(TimeSlice,FPS,FFinished);

If SDL_MustLock(FVideoBuffer) Then
SDL_UnlockSurface(FVideoBuffer);

Case FOpenGLEnabled Of
False : SDL_Flip(FVideoBuffer);
True : SDL_GL_SwapBuffers;
End;

TimeSlice := FTimer.GetElapsedSeconds;
FTimer.LockFPS(cLockFPS);
End;
Finally
Cleanup;
End;
End;[/pascal]

Any ideas?

cheers,
Paul