Another thing to mention is that it's rather difficult to use SDL_GetKeyboardState with Pascal (since it needs an array). I looked into the old JEDI headers and they had a helper TYPE for that. I used it the same way:
Code:
type PKeyStateArr = ^TKeyStateArr;
TKeyStateArr = array[0..65000] of UInt8;
My keyboard handling function now looks like that:
Code:
function keystate (key:integer):boolean;
var state:pkeystatearr;
begin
SDL_Pumpevents();
state:=pkeyStateArr(SDL_Getkeyboardstate(nil));
if state[key]<>0 then
begin
Result:=True;
end
else
Result:=False;
end;
If one checks a key one has to use the SDL scancodes.
For example
Code:
if keystate (SDL_SCANCODE_RIGHT) then begin
inc (x);
end;
Maybe that's also interesting for Jarrod ...
Bookmarks