text
stringlengths
0
234
(
input,
acc & (1 => Integer'Value(Ada.Text_IO.Get_Line(input)))
);
end if;
end Read_Input_Rec;
F : Ada.Text_IO.File_Type;
acc : Integer_Array(1 .. 0);
begin
Ada.Text_IO.Open
(
File => F,
Mode => Ada.Text_IO.In_File,
Name => file_name
);
declare
result : Integer_Array := Read_Input_Rec(F, acc);
begin
Ada.Text_IO.Close(F);
return result;
Function Definition: function Convert is new Ada.Unchecked_Conversion
Function Body: (Source => Key_Kind, Target => Key_Code);
begin
return Convert (Kind);
end To_Code;
function To_Key (Code : Key_Code) return Key_Kind is
begin
for Kind in Key_Kind'Range loop
if Code = To_Code (Kind) then
return Kind;
end if;
end loop;
return Key_Unknown;
end To_Key;
function Hex_Image (Value : Unsigned_8) return String is
Hex : constant array (Unsigned_8 range 0 .. 15) of Character := "0123456789abcdef";
begin
return Hex (Value / 16) & Hex (Value mod 16);
end Hex_Image;
function Hex_Image (Value : Unsigned_16; Bit_Order : System.Bit_Order) return String is
Low : constant Unsigned_8 := Unsigned_8 (16#FF# and Value);
High : constant Unsigned_8 := Unsigned_8 (16#FF# and (Value / 256));
use type System.Bit_Order;
begin
if System.Default_Bit_Order = Bit_Order then
return Hex_Image (Low) & Hex_Image (High);
else
return Hex_Image (High) & Hex_Image (Low);
end if;
end Hex_Image;
function Hex_Image (Value : Unsigned_16) return String is
(Hex_Image (Value, System.High_Order_First));
function GUID (ID : Device_ID) return String is
(Hex_Image (ID.Bus, System.Low_Order_First) & "0000" &
Hex_Image (ID.Vendor, System.Low_Order_First) & "0000" &
Hex_Image (ID.Product, System.Low_Order_First) & "0000" &
Hex_Image (ID.Version, System.Low_Order_First) & "0000");
----------------------------------------------------------------------------
use all type Event_Device.Input_Dev.Access_Mode;
use type Event_Device.Input_Dev.Unsigned_14;
function ID (Object : Input_Device) return Device_ID is
Result : aliased Device_ID;
Error_Code : constant Integer := Event_Device.Input_Dev.IO_Control
(Object.FD, (Read, 'E', 16#02#, Result'Size / System.Storage_Unit), Result'Address);
begin
return (if Error_Code /= -1 then Result else (others => 0));
end ID;
function Location (Object : Input_Device) return String is
Result : aliased String (1 .. 128) := (others => ' ');
Length : constant Integer := Event_Device.Input_Dev.IO_Control
(Object.FD, (Read, 'E', 16#07#, Result'Length), Result'Address);
begin
return (if Length > 0 then Result (1 .. Length - 1) else "");
end Location;
function Unique_ID (Object : Input_Device) return String is
Result : aliased String (1 .. 128) := (others => ' ');
Length : constant Integer := Event_Device.Input_Dev.IO_Control
(Object.FD, (Read, 'E', 16#08#, Result'Length), Result'Address);
begin
return (if Length > 0 then Result (1 .. Length - 1) else "");
end Unique_ID;
----------------------------------------------------------------------------