text stringlengths 0 234 |
|---|
function Convert is new Ada.Unchecked_Conversion |
(Source => Interfaces.C.unsigned_short, Target => Synchronization_Kind); |
function Convert is new Ada.Unchecked_Conversion |
(Source => Interfaces.C.unsigned_short, Target => Unsigned_16); |
function Convert is new Ada.Unchecked_Conversion |
(Source => Interfaces.C.unsigned_short, Target => Relative_Axis_Info_Kind); |
function Convert is new Ada.Unchecked_Conversion |
(Source => Unsigned_64, Target => Absolute_Axis_Info_Kind); |
-- Convert to Absolute_Axis_Info_Kind first before converting to |
-- Absolute_Axis_Kind, because the former has a representation clause |
Event : Input_Event; |
Result : Input_Dev.Result; |
Has_Dropped : Boolean := False; |
begin |
loop |
Result := Input_Dev.Read (Object.FD, Event); |
if not Result.Is_Success then |
if Result.Error = Would_Block then |
return Would_Block; |
else |
Value := (others => <>); |
return Error; |
end if; |
end if; |
case Event.Event is |
when Key => |
declare |
Code : constant Key_Code := Key_Code (Unsigned_16'(Convert (Event.Code))); |
begin |
Value.Keys (Key_Code_Index (Code)) := |
(if Event.Value /= 0 then Pressed else Released); |
Function Definition: procedure Info is |
Function Body: package ACL renames Ada.Command_Line; |
EF : Event_Device.Input_Device; |
Do_Rumble : constant Boolean := |
ACL.Argument_Count = 2 and then ACL.Argument (2) = "--ff=rumble"; |
Do_Periodic : constant Boolean := |
ACL.Argument_Count = 2 and then ACL.Argument (2) = "--ff=periodic"; |
Do_Read : constant Boolean := |
ACL.Argument_Count = 2 and then ACL.Argument (2) = "--read"; |
begin |
if ACL.Argument_Count /= 1 and not (Do_Rumble or Do_Periodic or Do_Read) then |
Ada.Text_IO.Put_Line ("Usage: <path to /dev/input/event*> [--read|--ff=rumble|periodic]"); |
ACL.Set_Exit_Status (ACL.Failure); |
return; |
end if; |
if not EF.Open (ACL.Argument (1)) then |
Ada.Text_IO.Put_Line ("Cannot open device " & ACL.Argument (1)); |
ACL.Set_Exit_Status (ACL.Failure); |
return; |
end if; |
Ada.Text_IO.Put_Line ("Device name: '" & EF.Name & "'"); |
Ada.Text_IO.Put_Line ("Location: '" & EF.Location & "'"); |
Ada.Text_IO.Put_Line ("Uniq ID: '" & EF.Unique_ID & "'"); |
declare |
ID : constant Event_Device.Device_ID := EF.ID; |
Props : constant Event_Device.Device_Properties := EF.Properties; |
Events : constant Event_Device.Device_Events := EF.Events; |
ID_A : constant String := Event_Device.Hex_Image (ID.Bus); |
ID_B : constant String := Event_Device.Hex_Image (ID.Vendor); |
ID_C : constant String := Event_Device.Hex_Image (ID.Product); |
ID_D : constant String := Event_Device.Hex_Image (ID.Version); |
begin |
Ada.Text_IO.Put_Line ("Bus ven pro ver: " & |
ID_A & " " & ID_B & " " & ID_C & " " & ID_D); |
Ada.Text_IO.Put_Line ("GUID: " & Event_Device.GUID (ID)); |
Ada.Text_IO.Put_Line ("Properties:"); |
Ada.Text_IO.Put_Line (" Pointer: " & Props.Pointer'Image); |
Ada.Text_IO.Put_Line (" Direct: " & Props.Direct'Image); |
Ada.Text_IO.Put_Line (" Button pad: " & Props.Button_Pad'Image); |
Ada.Text_IO.Put_Line (" Semi mt: " & Props.Semi_Multi_Touch'Image); |
Ada.Text_IO.Put_Line (" Top button pad: " & Props.Top_Button_Pad'Image); |
Ada.Text_IO.Put_Line (" Pointing stick: " & Props.Pointing_Stick'Image); |
Ada.Text_IO.Put_Line (" Accelerometer: " & Props.Accelerometer'Image); |
Ada.Text_IO.Put_Line ("Events:"); |
Ada.Text_IO.Put_Line (" Synchronization: " & Events.Synchronization'Image); |
if Events.Synchronization then |
declare |
Features : constant Event_Device.Synchronization_Features := EF.Features; |
begin |
for K in Event_Device.Synchronization_Kind'Range loop |
if Features (K) then |
Ada.Text_IO.Put_Line (" " & K'Image); |
end if; |
end loop; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.