1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | --------------------------------------------------------------------------------------------------------------------
-- This source code is subject to the Zlib license, see the LICENCE file in the root of this directory.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Inputs.Joysticks.Game_Controllers
--------------------------------------------------------------------------------------------------------------------
with SDL.Events.Joysticks.Game_Controllers;
package SDL.Inputs.Joysticks.Game_Controllers is
pragma Preelaborate;
type Bind_Types is (None, Button, Axis, Hat) with
Convention => C;
type Hat_Bindings is
record
Hat : SDL.Events.Joysticks.Hats;
Mask : SDL.Events.Joysticks.Hat_Positions;
end record with
Convention => C;
type Binding_Values (Which : Bind_Types := None) is
record
case Which is
when None =>
null;
when Button =>
Button : SDL.Events.Joysticks.Game_Controllers.Buttons;
when Axis =>
Axis : SDL.Events.Joysticks.Game_Controllers.Axes;
when Hat =>
Hat : Hat_Bindings;
end case;
end record with
Unchecked_Union;
type Bindings is
record
Which : Bind_Types;
Value : Binding_Values (None);
end record with
Convention => C;
Mapping_Error : exception;
type Game_Controller is new Ada.Finalization.Limited_Controlled with private;
Null_Game_Controller : constant Game_Controller;
procedure Add_Mapping (Data : in String; Updated_Existing : out Boolean);
procedure Add_Mappings_From_File (Database_Filename : in String; Number_Added : out Natural);
function Axis_Value (Self : in Game_Controller;
Axis : in SDL.Events.Joysticks.Game_Controllers.LR_Axes)
return SDL.Events.Joysticks.Game_Controllers.LR_Axes_Values;
function Axis_Value (Self : in Game_Controller;
Axis : in SDL.Events.Joysticks.Game_Controllers.Trigger_Axes)
return SDL.Events.Joysticks.Game_Controllers.Trigger_Axes_Values;
procedure Close (Self : in out Game_Controller);
function Get_Axis (Axis : in String) return SDL.Events.Joysticks.Game_Controllers.Axes;
function Get_Binding (Self : in Game_Controller; Axis : in SDL.Events.Joysticks.Game_Controllers.Axes)
return Bindings;
function Get_Binding (Self : in Game_Controller; Button : in SDL.Events.Joysticks.Game_Controllers.Buttons)
return Bindings;
function Get_Button (Button_Name : in String) return SDL.Events.Joysticks.Game_Controllers.Buttons;
function Get_Joystick (Self : in Game_Controller) return Joystick;
function Get_Mapping (Self : in Game_Controller) return String;
function Get_Mapping (Controller : in GUIDs) return String;
function Get_Name (Self : in Game_Controller) return String;
function Get_Name (Device : in Devices) return String;
function Image (Axis : in SDL.Events.Joysticks.Game_Controllers.Axes) return String;
function Image (Button : in SDL.Events.Joysticks.Game_Controllers.Buttons) return String;
function Is_Attached (Self : in Game_Controller) return Boolean with
Inline => True;
function Is_Button_Pressed (Self : in Game_Controller; Button : in SDL.Events.Joysticks.Buttons)
return SDL.Events.Button_State with
Inline => True;
function Is_Game_Controller (Device : in Devices) return Boolean with
Inline => True;
private
type Game_Controller is new Ada.Finalization.Limited_Controlled with
record
Internal : SDL.C_Pointers.Game_Controller_Pointer := null;
Owns : Boolean := True;
end record;
Null_Game_Controller : constant Game_Controller := (Ada.Finalization.Limited_Controlled with
Internal => null,
Owns => True);
end SDL.Inputs.Joysticks.Game_Controllers;
|