text
stringlengths
0
234
FF_Gain_Code : constant := 16#60#;
Event : constant Input_Dev.Input_Event :=
(Time => (0, 0),
Event => Force_Feedback,
Code => FF_Gain_Code,
Value => Interfaces.C.int (16#FF_FF.00# * Value));
Result_Unused : constant Input_Dev.Result := Input_Dev.Write (Object.FD, Event);
begin
-- Ignore any possible errors. If the device has been disconnected
-- then playing a force-feedback effect will fail, which can be
-- detected by the boolean returned by Play_Force_Feedback_Effect.
null;
end Set_Force_Feedback_Gain;
procedure Set_Force_Feedback_Auto_Center
(Object : Input_Device;
Value : Force_Feedback_Auto_Center)
is
FF_Auto_Center_Code : constant := 16#61#;
Event : constant Input_Dev.Input_Event :=
(Time => (0, 0),
Event => Force_Feedback,
Code => FF_Auto_Center_Code,
Value => Interfaces.C.int (16#FF_FF.00# * Value));
Result_Unused : constant Input_Dev.Result := Input_Dev.Write (Object.FD, Event);
begin
-- Ignore any possible errors. If the device has been disconnected
-- then playing a force-feedback effect will fail, which can be
-- detected by the boolean returned by Play_Force_Feedback_Effect.
null;
end Set_Force_Feedback_Auto_Center;
function Play_Force_Feedback_Effect
(Object : Input_Device;
Identifier : Uploaded_Force_Feedback_Effect_ID;
Count : Natural := 1) return Boolean
is
Event : constant Input_Dev.Input_Event :=
(Time => (0, 0),
Event => Force_Feedback,
Code => Interfaces.C.unsigned_short (Identifier),
Value => Interfaces.C.int (Count));
Result : constant Input_Dev.Result := Input_Dev.Write (Object.FD, Event);
begin
return Result.Is_Success;
end Play_Force_Feedback_Effect;
function Name (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#06#, Result'Length), Result'Address);
begin
return (if Length > 0 then Result (1 .. Length - 1) else "");
end Name;
function Is_Open (Object : Input_Device) return Boolean is
(Object.Open);
function Open
(Object : in out Input_Device;
File_Name : String;
Blocking : Boolean := True) return Boolean
is
Result : constant Input_Dev.Result := Input_Dev.Open (File_Name, Blocking => Blocking);
begin
if Result.Is_Success then
Object.FD := Result.FD;
end if;
Object.Open := Result.Is_Success;
return Object.Open;
end Open;
procedure Close (Object : in out Input_Device) is
Result : constant Input_Dev.Result := Input_Dev.Close (Object.FD);
begin
Object.FD := -1;
Object.Open := not Result.Is_Success;
end Close;
overriding procedure Finalize (Object : in out Input_Device) is
begin
if Object.Is_Open then
Object.Close;
end if;
end Finalize;
function Read
(Object : Input_Device;
Value : out State) return Read_Result
is
use Event_Device.Input_Dev;
use type Interfaces.C.unsigned_short;
use type Interfaces.C.int;