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 Allegro.Displays;                  use Allegro.Displays; 
  10. with Interfaces;                        use Interfaces; 
  11.  
  12. -- Allegro 5.0.9 - Keyboard routines 
  13. package Allegro.Keyboard is 
  14.  
  15.     ALLEGRO_KEY_A            : constant Integer := 1; 
  16.     ALLEGRO_KEY_B            : constant Integer := 2; 
  17.     ALLEGRO_KEY_C            : constant Integer := 3; 
  18.     ALLEGRO_KEY_D            : constant Integer := 4; 
  19.     ALLEGRO_KEY_E            : constant Integer := 5; 
  20.     ALLEGRO_KEY_F            : constant Integer := 6; 
  21.     ALLEGRO_KEY_G            : constant Integer := 7; 
  22.     ALLEGRO_KEY_H            : constant Integer := 8; 
  23.     ALLEGRO_KEY_I            : constant Integer := 9; 
  24.     ALLEGRO_KEY_J            : constant Integer := 10; 
  25.     ALLEGRO_KEY_K            : constant Integer := 11; 
  26.     ALLEGRO_KEY_L            : constant Integer := 12; 
  27.     ALLEGRO_KEY_M            : constant Integer := 13; 
  28.     ALLEGRO_KEY_N            : constant Integer := 14; 
  29.     ALLEGRO_KEY_O            : constant Integer := 15; 
  30.     ALLEGRO_KEY_P            : constant Integer := 16; 
  31.     ALLEGRO_KEY_Q            : constant Integer := 17; 
  32.     ALLEGRO_KEY_R            : constant Integer := 18; 
  33.     ALLEGRO_KEY_S            : constant Integer := 19; 
  34.     ALLEGRO_KEY_T            : constant Integer := 20; 
  35.     ALLEGRO_KEY_U            : constant Integer := 21; 
  36.     ALLEGRO_KEY_V            : constant Integer := 22; 
  37.     ALLEGRO_KEY_W            : constant Integer := 23; 
  38.     ALLEGRO_KEY_X            : constant Integer := 24; 
  39.     ALLEGRO_KEY_Y            : constant Integer := 25; 
  40.     ALLEGRO_KEY_Z            : constant Integer := 26; 
  41.  
  42.     ALLEGRO_KEY_0            : constant Integer := 27; 
  43.     ALLEGRO_KEY_1            : constant Integer := 28; 
  44.     ALLEGRO_KEY_2            : constant Integer := 29; 
  45.     ALLEGRO_KEY_3            : constant Integer := 30; 
  46.     ALLEGRO_KEY_4            : constant Integer := 31; 
  47.     ALLEGRO_KEY_5            : constant Integer := 32; 
  48.     ALLEGRO_KEY_6            : constant Integer := 33; 
  49.     ALLEGRO_KEY_7            : constant Integer := 34; 
  50.     ALLEGRO_KEY_8            : constant Integer := 35; 
  51.     ALLEGRO_KEY_9            : constant Integer := 36; 
  52.  
  53.     ALLEGRO_KEY_PAD_0        : constant Integer := 37; 
  54.     ALLEGRO_KEY_PAD_1        : constant Integer := 38; 
  55.     ALLEGRO_KEY_PAD_2        : constant Integer := 39; 
  56.     ALLEGRO_KEY_PAD_3        : constant Integer := 40; 
  57.     ALLEGRO_KEY_PAD_4        : constant Integer := 41; 
  58.     ALLEGRO_KEY_PAD_5        : constant Integer := 42; 
  59.     ALLEGRO_KEY_PAD_6        : constant Integer := 43; 
  60.     ALLEGRO_KEY_PAD_7        : constant Integer := 44; 
  61.     ALLEGRO_KEY_PAD_8        : constant Integer := 45; 
  62.     ALLEGRO_KEY_PAD_9        : constant Integer := 46; 
  63.  
  64.     ALLEGRO_KEY_F1           : constant Integer := 47; 
  65.     ALLEGRO_KEY_F2           : constant Integer := 48; 
  66.     ALLEGRO_KEY_F3           : constant Integer := 49; 
  67.     ALLEGRO_KEY_F4           : constant Integer := 50; 
  68.     ALLEGRO_KEY_F5           : constant Integer := 51; 
  69.     ALLEGRO_KEY_F6           : constant Integer := 52; 
  70.     ALLEGRO_KEY_F7           : constant Integer := 53; 
  71.     ALLEGRO_KEY_F8           : constant Integer := 54; 
  72.     ALLEGRO_KEY_F9           : constant Integer := 55; 
  73.     ALLEGRO_KEY_F10          : constant Integer := 56; 
  74.     ALLEGRO_KEY_F11          : constant Integer := 57; 
  75.     ALLEGRO_KEY_F12          : constant Integer := 58; 
  76.  
  77.     ALLEGRO_KEY_ESCAPE       : constant Integer := 59; 
  78.     ALLEGRO_KEY_TILDE        : constant Integer := 60; 
  79.     ALLEGRO_KEY_MINUS        : constant Integer := 61; 
  80.     ALLEGRO_KEY_EQUALS       : constant Integer := 62; 
  81.     ALLEGRO_KEY_BACKSPACE    : constant Integer := 63; 
  82.     ALLEGRO_KEY_TAB          : constant Integer := 64; 
  83.     ALLEGRO_KEY_OPENBRACE    : constant Integer := 65; 
  84.     ALLEGRO_KEY_CLOSEBRACE   : constant Integer := 66; 
  85.     ALLEGRO_KEY_ENTER        : constant Integer := 67; 
  86.     ALLEGRO_KEY_SEMICOLON    : constant Integer := 68; 
  87.     ALLEGRO_KEY_QUOTE        : constant Integer := 69; 
  88.     ALLEGRO_KEY_BACKSLASH    : constant Integer := 70; 
  89.     ALLEGRO_KEY_BACKSLASH2   : constant Integer := 71; -- DirectInput calls this DIK_OEM_102: "< > | on UK/Germany keyboards" 
  90.     ALLEGRO_KEY_COMMA        : constant Integer := 72; 
  91.     ALLEGRO_KEY_FULLSTOP     : constant Integer := 73; 
  92.     ALLEGRO_KEY_SLASH        : constant Integer := 74; 
  93.     ALLEGRO_KEY_SPACE        : constant Integer := 75; 
  94.  
  95.     ALLEGRO_KEY_INSERT       : constant Integer := 76; 
  96.     ALLEGRO_KEY_DELETE       : constant Integer := 77; 
  97.     ALLEGRO_KEY_HOME         : constant Integer := 78; 
  98.     ALLEGRO_KEY_END          : constant Integer := 79; 
  99.     ALLEGRO_KEY_PGUP         : constant Integer := 80; 
  100.     ALLEGRO_KEY_PGDN         : constant Integer := 81; 
  101.     ALLEGRO_KEY_LEFT         : constant Integer := 82; 
  102.     ALLEGRO_KEY_RIGHT        : constant Integer := 83; 
  103.     ALLEGRO_KEY_UP           : constant Integer := 84; 
  104.     ALLEGRO_KEY_DOWN         : constant Integer := 85; 
  105.  
  106.     ALLEGRO_KEY_PAD_SLASH    : constant Integer := 86; 
  107.     ALLEGRO_KEY_PAD_ASTERISK : constant Integer := 87; 
  108.     ALLEGRO_KEY_PAD_MINUS    : constant Integer := 88; 
  109.     ALLEGRO_KEY_PAD_PLUS     : constant Integer := 89; 
  110.     ALLEGRO_KEY_PAD_DELETE   : constant Integer := 90; 
  111.     ALLEGRO_KEY_PAD_ENTER    : constant Integer := 91; 
  112.  
  113.     ALLEGRO_KEY_PRINTSCREEN  : constant Integer := 92; 
  114.     ALLEGRO_KEY_PAUSE        : constant Integer := 93; 
  115.  
  116.     ALLEGRO_KEY_ABNT_C1      : constant Integer := 94; 
  117.     ALLEGRO_KEY_YEN          : constant Integer := 95; 
  118.     ALLEGRO_KEY_KANA         : constant Integer := 96; 
  119.     ALLEGRO_KEY_CONVERT      : constant Integer := 97; 
  120.     ALLEGRO_KEY_NOCONVERT    : constant Integer := 98; 
  121.     ALLEGRO_KEY_AT           : constant Integer := 99; 
  122.     ALLEGRO_KEY_CIRCUMFLEX   : constant Integer := 100; 
  123.     ALLEGRO_KEY_COLON2       : constant Integer := 101; 
  124.     ALLEGRO_KEY_KANJI        : constant Integer := 102; 
  125.  
  126.     ALLEGRO_KEY_PAD_EQUALS   : constant Integer := 103;  -- MacOS X 
  127.     ALLEGRO_KEY_BACKQUOTE    : constant Integer := 104;  -- MacOS X 
  128.     ALLEGRO_KEY_SEMICOLON2   : constant Integer := 105;  -- MacOS X 
  129.     ALLEGRO_KEY_COMMAND      : constant Integer := 106;  -- MacOS X 
  130.     ALLEGRO_KEY_UNKNOWN      : constant Integer := 107; 
  131.  
  132.     ALLEGRO_KEY_LSHIFT       : constant Integer := 215; 
  133.     ALLEGRO_KEY_RSHIFT       : constant Integer := 216; 
  134.     ALLEGRO_KEY_LCTRL        : constant Integer := 217; 
  135.     ALLEGRO_KEY_RCTRL        : constant Integer := 218; 
  136.     ALLEGRO_KEY_ALT          : constant Integer := 219; 
  137.     ALLEGRO_KEY_ALTGR        : constant Integer := 220; 
  138.     ALLEGRO_KEY_LWIN         : constant Integer := 221; 
  139.     ALLEGRO_KEY_RWIN         : constant Integer := 222; 
  140.     ALLEGRO_KEY_MENU         : constant Integer := 223; 
  141.     ALLEGRO_KEY_SCROLLLOCK   : constant Integer := 224; 
  142.     ALLEGRO_KEY_NUMLOCK      : constant Integer := 225; 
  143.     ALLEGRO_KEY_CAPSLOCK     : constant Integer := 226; 
  144.  
  145.     ALLEGRO_KEY_MODIFIERS : constant Integer := 215; 
  146.     ALLEGRO_KEY_MAX       : constant Integer := 227; 
  147.  
  148.     KEYMOD_SHIFT      : constant Unsigned_32 := 16#0001#; 
  149.     KEYMOD_CTRL       : constant Unsigned_32 := 16#0002#; 
  150.     KEYMOD_ALT        : constant Unsigned_32 := 16#0004#; 
  151.     KEYMOD_LWIN       : constant Unsigned_32 := 16#0008#; 
  152.     KEYMOD_RWIN       : constant Unsigned_32 := 16#0010#; 
  153.     KEYMOD_MENU       : constant Unsigned_32 := 16#0020#; 
  154.     KEYMOD_ALTGR      : constant Unsigned_32 := 16#0040#; 
  155.     KEYMOD_COMMAND    : constant Unsigned_32 := 16#0080#; 
  156.     KEYMOD_SCROLLLOCK : constant Unsigned_32 := 16#0100#; 
  157.     KEYMOD_NUMLOCK    : constant Unsigned_32 := 16#0200#; 
  158.     KEYMOD_CAPSLOCK   : constant Unsigned_32 := 16#0400#; 
  159.     KEYMOD_INALTSEQ   : constant Unsigned_32 := 16#0800#; 
  160.     KEYMOD_ACCENT1    : constant Unsigned_32 := 16#1000#; 
  161.     KEYMOD_ACCENT2    : constant Unsigned_32 := 16#2000#; 
  162.     KEYMOD_ACCENT3    : constant Unsigned_32 := 16#4000#; 
  163.     KEYMOD_ACCENT4    : constant Unsigned_32 := 16#8000#; 
  164.  
  165.     type Allegro_Keyboard is limited private; 
  166.     type A_Allegro_Keyboard is access all Allegro_Keyboard; 
  167.  
  168.     type Int_Array is array (Integer range <>) of Unsigned_32; 
  169.     pragma Convention( C, Int_Array ); 
  170.  
  171.     type Allegro_Keyboard_State is 
  172.         record 
  173.             display  : A_Allegro_Display; 
  174.             internal : Int_Array(0..(ALLEGRO_KEY_MAX+31)/32-1);  -- Allegro internal 
  175.         end record; 
  176.     pragma Convention( C, Allegro_Keyboard_State ); 
  177.  
  178.     ---------------------------------------------------------------------------- 
  179.  
  180.     -- Keyboard routines 
  181.  
  182.     function Al_Install_Keyboard return Boolean; 
  183.  
  184.     procedure Al_Uninstall_Keyboard; 
  185.     pragma Import( C, Al_Uninstall_Keyboard, "al_uninstall_keyboard" ); 
  186.  
  187.     function Al_Is_Keyboard_Installed return Boolean; 
  188.  
  189.     function Al_Set_Keyboard_Leds( leds : Integer ) return Boolean; 
  190.  
  191.     function Al_Keycode_To_Name( keycode : Integer ) return String; 
  192.  
  193.     procedure Al_Get_Keyboard_State( ret_state : in out Allegro_Keyboard_State ); 
  194.     pragma Import( C, Al_Get_Keyboard_State, "al_get_keyboard_state" ); 
  195.  
  196.     function Al_Key_Down( state   : Allegro_Keyboard_State; 
  197.                           keycode : Integer ) return Boolean; 
  198.  
  199.     function Al_Get_Keyboard_Event_Source return A_Allegro_Event_Source; 
  200.     pragma Import( C, Al_Get_Keyboard_Event_Source, "al_get_keyboard_event_source" ); 
  201.  
  202. private 
  203.  
  204.     type Allegro_Keyboard is limited null record; 
  205.     pragma Convention( C, Allegro_Keyboard ); 
  206.  
  207. end Allegro.Keyboard;