
Dan,  the only change I made to sdl.ads was the following because I failed to figure out how to get it working as it was:

--fastrgv:
    subtype keyrange is interfaces.c.int range 0..511;
    type keyarraytype is array(keyrange) of Uint8;
   function SDL_GetKeyboardState (numkeys : access C.int) return access keyarraytype;
   --function SDL_GetKeyboardState (numkeys : access C.int) return access Uint8;
   pragma Import (C, SDL_GetKeyboardState, "SDL_GetKeyboardState");

...then my declaration and call in main looks like this:

key_map : access sdl.keyarraytype;
...
key_map := sdl_getkeyboardstate(numkeys'access);


If you have the time, perhaps you would show me how I should have done it !
Ultimately, we need an array of Uint8...

===========================================================================================

Dan Lee Vazquez Garcia
	
7:36 AM (6 hours ago)
		
to me
Hi, I think this is the safest way to do it. You could also just return an unconstrained C array as long as you know the size of the array (numkeys)  but you might get many warnings. Good luck!

with Interfaces.C.Pointers;

type Uint8Pointers is new Interfaces.C.Pointers
   (Index => C.size_t,
    Element => Uint8,
    Element_Array => Uint8Array,
    Default_Terminator => 0);

function SDL_GetKeyboardState (numkeys : access C.int)
    return Uint8Pointers.Pointer;
   
Count  : aliased int;
States_Ptr : Uint8Pointers.Pointer := SDL_GetKeyboardState (Count'Access);
-- Check that States_Ptr /= null and Count > 0
-- It is important to use the Value function with the count parameter
States : constant Uint8Array := Uint8Pointers.Value (States_Ptr, C.ptrdiff_t(Count)); 
