1. -- 
  2. -- Copyright (c) 2013 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Interfaces;                        use Interfaces; 
  10.  
  11. -- Allegro 5.0.9 - Joystick routines 
  12. package Allegro.Joystick is 
  13.  
  14.     type Allegro_Joystick is limited private; 
  15.     type A_Allegro_Joystick is access all Allegro_Joystick; 
  16.  
  17.     subtype Joystick_Flags is Unsigned_32; 
  18.     JOYFLAG_DIGITAL  : constant Joystick_Flags := 16#01#; 
  19.     JOYFLAG_ANALOGUE : constant Joystick_Flags := 16#02#; 
  20.  
  21.     -- Joystick state 
  22.  
  23.     type Axis_Array is array(0..2) of Float; 
  24.     pragma Convention( C, Axis_Array ); 
  25.  
  26.     type Joystick_Stick is 
  27.         record 
  28.             axis : Axis_Array;        -- -1.0 to 1.0 
  29.         end record; 
  30.     pragma Convention( C, Joystick_Stick ); 
  31.  
  32.     type Stick_Array is array(0..7) of Joystick_Stick; 
  33.     pragma Convention( C, Stick_Array ); 
  34.  
  35.     type Button_Array is array(0..31) of Integer; 
  36.     pragma Convention( C, Button_Array ); 
  37.  
  38.     type Joystick_State is 
  39.         record 
  40.             stick  : Stick_Array; 
  41.             button : Button_Array;    -- 0 to 32767 
  42.         end record; 
  43.     pragma Convention( C, Joystick_State ); 
  44.     type A_Joystick_State is access all Joystick_State; 
  45.  
  46.     ---------------------------------------------------------------------------- 
  47.  
  48.     function Al_Install_Joystick return Boolean; 
  49.  
  50.     procedure Al_Uninstall_Joystick; 
  51.     pragma Import( C, Al_Uninstall_Joystick, "al_uninstall_joystick" ); 
  52.  
  53.     function Al_Is_Joystick_Installed return Boolean; 
  54.  
  55.     function Al_Reconfigure_Joysticks return Boolean; 
  56.  
  57.     function Al_Get_Num_Joysticks return Integer; 
  58.     pragma Import( C, Al_Get_Num_Joysticks, "al_get_num_joysticks" ); 
  59.  
  60.     function Al_Get_Joystick( num : Integer ) return A_Allegro_Joystick; 
  61.     pragma Import( C, Al_Get_Joystick, "al_get_joystick" ); 
  62.  
  63.     procedure Al_Release_Joystick( joy : A_Allegro_Joystick ); 
  64.     pragma Import( C, Al_Release_Joystick, "al_release_joystick" ); 
  65.  
  66.     function Al_Get_Joystick_Active( joy : A_Allegro_Joystick ) return Boolean; 
  67.  
  68.     function Al_Get_Joystick_Name( joy : A_Allegro_Joystick ) return String; 
  69.  
  70.     function Al_Get_Joystick_Num_Sticks( joy : A_Allegro_Joystick ) return Integer; 
  71.     pragma Import( C, Al_Get_Joystick_Num_Sticks, "al_get_joystick_num_sticks" ); 
  72.  
  73.     function Al_Get_Joystick_Stick_Flags( joy   : A_Allegro_Joystick; 
  74.                                           stick : Integer ) return Joystick_Flags; 
  75.     pragma Import( C, Al_Get_Joystick_Stick_Flags, "al_get_joystick_stick_flags" ); 
  76.  
  77.     function Al_Get_Joystick_Stick_Name( joy   : A_Allegro_Joystick; 
  78.                                          stick : Integer ) return String; 
  79.  
  80.     function Al_Get_Joystick_Num_Axes( joy   : A_Allegro_Joystick; 
  81.                                        stick : Integer ) return Integer; 
  82.     pragma Import( C, Al_Get_Joystick_Num_Axes, "al_get_joystick_num_axes" ); 
  83.  
  84.     function Al_Get_Joystick_Axis_Name( joy   : A_Allegro_Joystick; 
  85.                                         stick : Integer; 
  86.                                         axis  : Integer ) return String; 
  87.  
  88.     function Al_Get_Joystick_Num_Buttons( joy : A_Allegro_Joystick ) return Integer; 
  89.     pragma Import( C, Al_Get_Joystick_Num_Buttons, "al_get_joystick_num_buttons" ); 
  90.  
  91.     function Al_Get_Joystick_Button_Name( joy    : A_Allegro_Joystick; 
  92.                                           button : Integer ) return String; 
  93.  
  94.     procedure Al_Get_Joystick_State( joy       : A_Allegro_Joystick; 
  95.                                      ret_state : A_Joystick_State ); 
  96.     pragma Import( C, Al_Get_Joystick_State, "al_get_joystick_state" ); 
  97.  
  98.     function Al_Get_Joystick_Event_Source return A_Allegro_Event_Source; 
  99.     pragma Import( C, Al_Get_Joystick_Event_Source, "al_get_joystick_event_source" ); 
  100.  
  101. private 
  102.  
  103.     type Allegro_Joystick is limited null record; 
  104.     pragma Convention( C, Allegro_Joystick ); 
  105.  
  106. end Allegro.Joystick;