package Allegro.Keyboard is
type A_Keyboard_Hook is
access procedure;
type A_Keyboard_Callback is
access function( key : Integer ) return Integer;
type A_Keyboard_Ucallback is
access function( key: Integer; scancode : A_Integer ) return Integer;
type A_Keyboard_Lowlevel_Callback is
access procedure( scancode : Integer );
KB_SHIFT_FLAG : constant Unsigned_32;
KB_CTRL_FLAG : constant Unsigned_32;
KB_ALT_FLAG : constant Unsigned_32;
KB_LWIN_FLAG : constant Unsigned_32;
KB_RWIN_FLAG : constant Unsigned_32;
KB_MENU_FLAG : constant Unsigned_32;
KB_COMMAND_FLAG : constant Unsigned_32;
KB_SCROLOCK_FLAG : constant Unsigned_32;
KB_NUMLOCK_FLAG : constant Unsigned_32;
KB_CAPSLOCK_FLAG : constant Unsigned_32;
KB_INALTSEQ_FLAG : constant Unsigned_32;
KB_ACCENT1_FLAG : constant Unsigned_32;
KB_ACCENT2_FLAG : constant Unsigned_32;
KB_ACCENT3_FLAG : constant Unsigned_32;
KB_ACCENT4_FLAG : constant Unsigned_32;
KEY_A : constant Integer := 1;
KEY_B : constant Integer := 2;
KEY_C : constant Integer := 3;
KEY_D : constant Integer := 4;
KEY_E : constant Integer := 5;
KEY_F : constant Integer := 6;
KEY_G : constant Integer := 7;
KEY_H : constant Integer := 8;
KEY_I : constant Integer := 9;
KEY_J : constant Integer := 10;
KEY_K : constant Integer := 11;
KEY_L : constant Integer := 12;
KEY_M : constant Integer := 13;
KEY_N : constant Integer := 14;
KEY_O : constant Integer := 15;
KEY_P : constant Integer := 16;
KEY_Q : constant Integer := 17;
KEY_R : constant Integer := 18;
KEY_S : constant Integer := 19;
KEY_T : constant Integer := 20;
KEY_U : constant Integer := 21;
KEY_V : constant Integer := 22;
KEY_W : constant Integer := 23;
KEY_X : constant Integer := 24;
KEY_Y : constant Integer := 25;
KEY_Z : constant Integer := 26;
KEY_0 : constant Integer := 27;
KEY_1 : constant Integer := 28;
KEY_2 : constant Integer := 29;
KEY_3 : constant Integer := 30;
KEY_4 : constant Integer := 31;
KEY_5 : constant Integer := 32;
KEY_6 : constant Integer := 33;
KEY_7 : constant Integer := 34;
KEY_8 : constant Integer := 35;
KEY_9 : constant Integer := 36;
KEY_0_PAD : constant Integer := 37;
KEY_1_PAD : constant Integer := 38;
KEY_2_PAD : constant Integer := 39;
KEY_3_PAD : constant Integer := 40;
KEY_4_PAD : constant Integer := 41;
KEY_5_PAD : constant Integer := 42;
KEY_6_PAD : constant Integer := 43;
KEY_7_PAD : constant Integer := 44;
KEY_8_PAD : constant Integer := 45;
KEY_9_PAD : constant Integer := 46;
KEY_F1 : constant Integer := 47;
KEY_F2 : constant Integer := 48;
KEY_F3 : constant Integer := 49;
KEY_F4 : constant Integer := 50;
KEY_F5 : constant Integer := 51;
KEY_F6 : constant Integer := 52;
KEY_F7 : constant Integer := 53;
KEY_F8 : constant Integer := 54;
KEY_F9 : constant Integer := 55;
KEY_F10 : constant Integer := 56;
KEY_F11 : constant Integer := 57;
KEY_F12 : constant Integer := 58;
KEY_ESC : constant Integer := 59;
KEY_TILDE : constant Integer := 60;
KEY_MINUS : constant Integer := 61;
KEY_EQUALS : constant Integer := 62;
KEY_BACKSPACE : constant Integer := 63;
KEY_TAB : constant Integer := 64;
KEY_OPENBRACE : constant Integer := 65;
KEY_CLOSEBRACE : constant Integer := 66;
KEY_ENTER : constant Integer := 67;
KEY_COLON : constant Integer := 68;
KEY_QUOTE : constant Integer := 69;
KEY_BACKSLASH : constant Integer := 70;
KEY_BACKSLASH2 : constant Integer := 71;
KEY_COMMA : constant Integer := 72;
KEY_STOP : constant Integer := 73;
KEY_SLASH : constant Integer := 74;
KEY_SPACE : constant Integer := 75;
KEY_INSERT : constant Integer := 76;
KEY_DEL : constant Integer := 77;
KEY_HOME : constant Integer := 78;
KEY_END : constant Integer := 79;
KEY_PGUP : constant Integer := 80;
KEY_PGDN : constant Integer := 81;
KEY_LEFT : constant Integer := 82;
KEY_RIGHT : constant Integer := 83;
KEY_UP : constant Integer := 84;
KEY_DOWN : constant Integer := 85;
KEY_SLASH_PAD : constant Integer := 86;
KEY_ASTERISK : constant Integer := 87;
KEY_MINUS_PAD : constant Integer := 88;
KEY_PLUS_PAD : constant Integer := 89;
KEY_DEL_PAD : constant Integer := 90;
KEY_ENTER_PAD : constant Integer := 91;
KEY_PRTSCR : constant Integer := 92;
KEY_PAUSE : constant Integer := 93;
KEY_ABNT_C1 : constant Integer := 94;
KEY_YEN : constant Integer := 95;
KEY_KANA : constant Integer := 96;
KEY_CONVERT : constant Integer := 97;
KEY_NOCONVERT : constant Integer := 98;
KEY_AT : constant Integer := 99;
KEY_CIRCUMFLEX : constant Integer := 100;
KEY_COLON2 : constant Integer := 101;
KEY_KANJI : constant Integer := 102;
KEY_EQUALS_PAD : constant Integer := 103;
KEY_BACKQUOTE : constant Integer := 104;
KEY_SEMICOLON : constant Integer := 105;
KEY_COMMAND : constant Integer := 106;
KEY_UNKNOWN1 : constant Integer := 107;
KEY_UNKNOWN2 : constant Integer := 108;
KEY_UNKNOWN3 : constant Integer := 109;
KEY_UNKNOWN4 : constant Integer := 110;
KEY_UNKNOWN5 : constant Integer := 111;
KEY_UNKNOWN6 : constant Integer := 112;
KEY_UNKNOWN7 : constant Integer := 113;
KEY_UNKNOWN8 : constant Integer := 114;
KEY_MODIFIERS : constant Integer := 115;
KEY_LSHIFT : constant Integer := 115;
KEY_RSHIFT : constant Integer := 116;
KEY_LCONTROL : constant Integer := 117;
KEY_RCONTROL : constant Integer := 118;
KEY_ALT : constant Integer := 119;
KEY_ALTGR : constant Integer := 120;
KEY_LWIN : constant Integer := 121;
KEY_RWIN : constant Integer := 122;
KEY_MENU : constant Integer := 123;
KEY_SCRLOCK : constant Integer := 124;
KEY_NUMLOCK : constant Integer := 125;
KEY_CAPSLOCK : constant Integer := 126;
KEY_MAX : constant Integer;
procedure Clear_Keybuf;
function Get_Key_Status( keycode : Integer ) return Integer;
pragma Precondition( keycode > 0 and then keycode < KEY_MAX );
function Get_Key_Shifts return Unsigned_32;
function Install_Keyboard return Integer;
procedure Install_Keyboard_Hooks( keypressed, readkey : A_Keyboard_Hook );
function Key_Pressed return Integer;
function Keyboard_Needs_Poll return Integer;
function Poll_Keyboard return Integer;
function Read_Key return Integer;
procedure Remove_Keyboard;
function Scancode_To_Ascii( scancode : Integer ) return Integer;
pragma Precondition( scancode > 0 and then scancode < KEY_MAX );
function Scancode_To_Char( scancode : Integer;
shifted : Boolean ) return Character;
pragma Precondition( scancode > 0 and then scancode < KEY_MAX );
function Scancode_To_Name( scancode : Integer ) return String;
pragma Precondition( scancode > 0 and then scancode < KEY_MAX );
procedure Set_Key_Led_Flag( flag : Integer );
procedure Set_Keyboard_Callback( cb : A_Keyboard_Callback );
procedure Set_Keyboard_Lowlevel_Callback( cb : A_Keyboard_Lowlevel_Callback );
procedure Set_Keyboard_Rate( dlay, repeat : Integer );
procedure Set_Keyboard_Ucallback( cb : A_Keyboard_Ucallback );
procedure Set_Leds( leds : Integer );
procedure Set_Three_Finger_Flag( flag : Integer );
procedure Simulate_Keypress( key : Integer );
procedure Simulate_Ukeypress( key, scancode : Integer );
pragma Precondition( scancode >= 0 and then scancode < KEY_MAX );
function Uread_Key( scancode : A_Integer ) return Integer;
private
KB_SHIFT_FLAG : constant Unsigned_32 := 16#00000001#;
KB_CTRL_FLAG : constant Unsigned_32 := 16#00000002#;
KB_ALT_FLAG : constant Unsigned_32 := 16#00000004#;
KB_LWIN_FLAG : constant Unsigned_32 := 16#00000008#;
KB_RWIN_FLAG : constant Unsigned_32 := 16#00000010#;
KB_MENU_FLAG : constant Unsigned_32 := 16#00000020#;
KB_COMMAND_FLAG : constant Unsigned_32 := 16#00000040#;
KB_SCROLOCK_FLAG : constant Unsigned_32 := 16#00000100#;
KB_NUMLOCK_FLAG : constant Unsigned_32 := 16#00000200#;
KB_CAPSLOCK_FLAG : constant Unsigned_32 := 16#00000400#;
KB_INALTSEQ_FLAG : constant Unsigned_32 := 16#00000800#;
KB_ACCENT1_FLAG : constant Unsigned_32 := 16#00001000#;
KB_ACCENT2_FLAG : constant Unsigned_32 := 16#00002000#;
KB_ACCENT3_FLAG : constant Unsigned_32 := 16#00004000#;
KB_ACCENT4_FLAG : constant Unsigned_32 := 16#00008000#;
KEY_MAX : constant Integer := 127;
type Key_Character_Array is array (1..KEY_MAX) of Character;
scancode_to_char_lo : constant Key_Character_Array :=
Key_Character_Array'(
KEY_A => 'a',
KEY_B => 'b',
KEY_C => 'c',
KEY_D => 'd',
KEY_E => 'e',
KEY_F => 'f',
KEY_G => 'g',
KEY_H => 'h',
KEY_I => 'i',
KEY_J => 'j',
KEY_K => 'k',
KEY_L => 'l',
KEY_M => 'm',
KEY_N => 'n',
KEY_O => 'o',
KEY_P => 'p',
KEY_Q => 'q',
KEY_R => 'r',
KEY_S => 's',
KEY_T => 't',
KEY_U => 'u',
KEY_V => 'v',
KEY_W => 'w',
KEY_X => 'x',
KEY_Y => 'y',
KEY_Z => 'z',
KEY_0 => '0',
KEY_1 => '1',
KEY_2 => '2',
KEY_3 => '3',
KEY_4 => '4',
KEY_5 => '5',
KEY_6 => '6',
KEY_7 => '7',
KEY_8 => '8',
KEY_9 => '9',
KEY_0_PAD => '0',
KEY_1_PAD => '1',
KEY_2_PAD => '2',
KEY_3_PAD => '3',
KEY_4_PAD => '4',
KEY_5_PAD => '5',
KEY_6_PAD => '6',
KEY_7_PAD => '7',
KEY_8_PAD => '8',
KEY_9_PAD => '9',
KEY_TILDE => '`',
KEY_MINUS => '-',
KEY_EQUALS => '=',
KEY_OPENBRACE => '[',
KEY_CLOSEBRACE => ']',
KEY_COLON => ';',
KEY_QUOTE => ''',
KEY_BACKSLASH => '\',
KEY_BACKSLASH2 => '\',
KEY_COMMA => ',',
KEY_STOP => '.',
KEY_SLASH => '/',
KEY_SPACE => ' ',
KEY_SLASH_PAD => '/',
KEY_ASTERISK => '*',
KEY_MINUS_PAD => '-',
KEY_PLUS_PAD => '+',
KEY_DEL_PAD => '.',
others => Character'Val( 0 )
);
scancode_to_char_hi : constant Key_Character_Array :=
Key_Character_Array'(
KEY_A => 'A',
KEY_B => 'B',
KEY_C => 'C',
KEY_D => 'D',
KEY_E => 'E',
KEY_F => 'F',
KEY_G => 'G',
KEY_H => 'H',
KEY_I => 'I',
KEY_J => 'J',
KEY_K => 'K',
KEY_L => 'L',
KEY_M => 'M',
KEY_N => 'N',
KEY_O => 'O',
KEY_P => 'P',
KEY_Q => 'Q',
KEY_R => 'R',
KEY_S => 'S',
KEY_T => 'T',
KEY_U => 'U',
KEY_V => 'V',
KEY_W => 'W',
KEY_X => 'X',
KEY_Y => 'Y',
KEY_Z => 'Z',
KEY_0 => ')',
KEY_1 => '!',
KEY_2 => '@',
KEY_3 => '#',
KEY_4 => '$',
KEY_5 => '%',
KEY_6 => '^',
KEY_7 => '&',
KEY_8 => '*',
KEY_9 => '(',
KEY_0_PAD => '0',
KEY_1_PAD => '1',
KEY_2_PAD => '2',
KEY_3_PAD => '3',
KEY_4_PAD => '4',
KEY_5_PAD => '5',
KEY_6_PAD => '6',
KEY_7_PAD => '7',
KEY_8_PAD => '8',
KEY_9_PAD => '9',
KEY_TILDE => '~',
KEY_MINUS => '_',
KEY_EQUALS => '+',
KEY_OPENBRACE => '{',
KEY_CLOSEBRACE => '}',
KEY_COLON => ':',
KEY_QUOTE => '"',
KEY_BACKSLASH => '|',
KEY_BACKSLASH2 => '|',
KEY_COMMA => '<',
KEY_STOP => '>',
KEY_SLASH => '?',
KEY_SPACE => ' ',
KEY_SLASH_PAD => '/',
KEY_ASTERISK => '*',
KEY_MINUS_PAD => '-',
KEY_PLUS_PAD => '+',
KEY_DEL_PAD => '.',
others => Character'Val( 0 )
);
pragma Convention( C, A_Keyboard_Callback );
pragma Convention( C, A_Keyboard_Hook );
pragma Convention( C, A_Keyboard_Lowlevel_Callback );
pragma Convention( C, A_Keyboard_Ucallback );
pragma Import( C, Clear_Keybuf, "clear_keybuf" );
pragma Import( C, Get_Key_Shifts, "get_key_shifts" );
pragma Import( C, Get_Key_Status, "get_key_status" );
pragma Import( C, Install_Keyboard, "install_keyboard" );
pragma Import( C, Install_Keyboard_Hooks, "install_keyboard_hooks" );
pragma Import( C, Keyboard_Needs_Poll, "keyboard_needs_poll" );
pragma Import( C, Key_Pressed, "keypressed" );
pragma Import( C, Poll_Keyboard, "poll_keyboard" );
pragma Import( C, Read_Key, "readkey" );
pragma Import( C, Remove_Keyboard, "remove_keyboard" );
pragma Import( C, Scancode_To_Ascii, "scancode_to_ascii" );
pragma Import( C, Set_Key_Led_Flag, "set_key_led_flag" );
pragma Import( C, Set_Keyboard_Callback, "set_keyboard_callback" );
pragma Import( C, Set_Keyboard_Lowlevel_Callback, "set_keyboard_lowlevel_callback" );
pragma Import( C, Set_Keyboard_Rate, "set_keyboard_rate" );
pragma Import( C, Set_Keyboard_Ucallback, "set_keyboard_ucallback" );
pragma Import( C, Set_Leds, "set_leds" );
pragma Import( C, Set_Three_Finger_Flag, "set_three_finger_flag" );
pragma Import( C, Simulate_Keypress, "simulate_keypress" );
pragma Import( C, Simulate_Ukeypress, "simulate_ukeypress" );
pragma Import( C, Uread_Key, "ureadkey" );
end Allegro.Keyboard;