Skip to content

Commit d652fe0

Browse files
committed
Add rumble functionality from alexispaez-master.
2 parents 9cfd435 + 5854fa2 commit d652fe0

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/inputs/sdl-inputs-joysticks-game_controllers.adb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,33 @@ package body SDL.Inputs.Joysticks.Game_Controllers is
271271
begin
272272
return To_Boolean (SDL_Is_Game_Controller (C.int (Device) - 1));
273273
end Is_Game_Controller;
274+
275+
function Has_Rumble (Self : in Game_Controller) return Boolean is
276+
function SDL_Game_Controller_Has_Rumble (Controller : in SDL.C_Pointers.Game_Controller_Pointer)
277+
return SDL_Bool with
278+
Import => True,
279+
Convention => C,
280+
External_Name => "SDL_GameControllerHasRumble";
281+
begin
282+
return To_Boolean (SDL_Game_Controller_Has_Rumble (Self.Internal));
283+
end Has_Rumble;
284+
285+
function Rumble (Self : in Game_Controller;
286+
Low_Frequency : in Uint16;
287+
High_Frequency : in Uint16;
288+
Duration : in Uint32) return Integer is
289+
function SDL_Game_Controller_Rumble (Controller : in SDL.C_Pointers.Game_Controller_Pointer;
290+
Low_Frequency : in Uint16;
291+
High_Frequency : in Uint16;
292+
Duration : in Uint32)
293+
return C.int with
294+
Import => True,
295+
Convention => C,
296+
External_Name => "SDL_GameControllerRumble";
297+
begin
298+
return Integer (SDL_Game_Controller_Rumble (Self.Internal,
299+
Low_Frequency,
300+
High_Frequency,
301+
Duration));
302+
end Rumble;
274303
end SDL.Inputs.Joysticks.Game_Controllers;

src/inputs/sdl-inputs-joysticks-game_controllers.ads

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ package SDL.Inputs.Joysticks.Game_Controllers is
4949

5050
Null_Game_Controller : constant Game_Controller;
5151

52+
subtype Uint16 is Interfaces.Unsigned_16;
53+
subtype Uint32 is Interfaces.Unsigned_32;
54+
5255
procedure Add_Mapping (Data : in String; Updated_Existing : out Boolean);
5356
procedure Add_Mappings_From_File (Database_Filename : in String; Number_Added : out Natural);
5457

@@ -92,6 +95,15 @@ package SDL.Inputs.Joysticks.Game_Controllers is
9295

9396
function Is_Game_Controller (Device : in Devices) return Boolean with
9497
Inline => True;
98+
99+
function Has_Rumble (Self : in Game_Controller) return Boolean with
100+
Inline => True;
101+
102+
function Rumble (Self : in Game_Controller;
103+
Low_Frequency : in Uint16;
104+
High_Frequency : in Uint16;
105+
Duration : in Uint32) return Integer with
106+
Inline => True;
95107
private
96108
type Game_Controller is new Ada.Finalization.Limited_Controlled with
97109
record

0 commit comments

Comments
 (0)