forked from ada-game-framework/sdlada
/
sdl-events-events.ads
141 lines (116 loc) · 5.64 KB
/
sdl-events-events.ads
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Events.Events
--
-- Combines all of the various event types into a single variant record to match the union in the SDL library. Not
-- the nicest of names for the package, but it works.
--------------------------------------------------------------------------------------------------------------------
with SDL.Events.Windows;
with SDL.Events.Keyboards;
with SDL.Events.Mice;
with SDL.Events.Joysticks;
with SDL.Events.Controllers;
with SDL.Events.Touches;
with SDL.Events.Files;
package SDL.Events.Events is
type Event_Selector is (Is_Event,
Is_Window_Event,
Is_Keyboard_Event,
Is_Text_Editing_Event,
Is_Text_Input_Event,
Is_Mouse_Motion_Event,
Is_Mouse_Button_Event,
Is_Mouse_Wheel_Event,
Is_Joystick_Axis_Event,
Is_Joystick_Ball_Event,
Is_Joystick_Hat_Event,
Is_Joystick_Button_Event,
Is_Joystick_Device_Event,
Is_Controller_Axis_Event,
Is_Controller_Button_Event,
Is_Controller_Device_Event,
Is_Touch_Finger_Event,
Is_Touch_Multi_Gesture_Event,
Is_Touch_Dollar_Gesture,
Is_Drop_Event);
type Events (Event_Type : Event_Selector := Is_Event) is
record
case Event_Type is
when Is_Window_Event =>
Window : SDL.Events.Windows.Window_Events;
when Is_Keyboard_Event =>
Keyboard : SDL.Events.Keyboards.Keyboard_Events;
when Is_Text_Editing_Event =>
Text_Editing : SDL.Events.Keyboards.Text_Editing_Events;
when Is_Text_Input_Event =>
Text_Input : SDL.Events.Keyboards.Text_Input_Events;
when Is_Mouse_Motion_Event =>
Mouse_Motion : SDL.Events.Mice.Motion_Events;
when Is_Mouse_Button_Event =>
Mouse_Button : SDL.Events.Mice.Button_Events;
when Is_Mouse_Wheel_Event =>
Mouse_Wheel : SDL.Events.Mice.Wheel_Events;
when Is_Joystick_Axis_Event =>
Joystick_Axis : SDL.Events.Joysticks.Axis_Events;
when Is_Joystick_Ball_Event =>
Joystick_Ball : SDL.Events.Joysticks.Ball_Events;
when Is_Joystick_Hat_Event =>
Joystick_Hat : SDL.Events.Joysticks.Hat_Events;
when Is_Joystick_Button_Event =>
Joystick_Button : SDL.Events.Joysticks.Button_Events;
when Is_Joystick_Device_Event =>
Joystick_Device : SDL.Events.Joysticks.Device_Events;
when Is_Controller_Axis_Event =>
Controller_Axis : SDL.Events.Controllers.Axis_Events;
when Is_Controller_Button_Event =>
Controller_Button : SDL.Events.Controllers.Button_Events;
when Is_Controller_Device_Event =>
Controller_Device : SDL.Events.Controllers.Device_Events;
when Is_Touch_Finger_Event =>
Touch_Finger : SDL.Events.Touches.Finger_Events;
when Is_Touch_Multi_Gesture_Event =>
Touch_Multi_Gesture : SDL.Events.Touches.Multi_Gesture_Events;
when Is_Touch_Dollar_Gesture =>
Touch_Dollar_Gesture : SDL.Events.Touches.Dollar_Events;
when Is_Drop_Event =>
Drop : SDL.Events.Files.Drop_Events;
when others =>
Common : Common_Events;
end case;
end record with
Unchecked_Union,
Convention => C;
-- Some error occurred while polling/waiting for events.
Event_Error : exception;
-- Poll for currently pending events.
--
-- If the are any pending events, the next event is removed from the queue
-- and stored in Event, and then this returns True. Otherwise, this does
-- nothing and returns False.
function Poll (Event : out Events) return Boolean;
-- Wait until an event is pending.
--
-- If there are any pending events, the next event is removed from
-- the queue and stored in Event.
procedure Wait (Event : out Events);
end SDL.Events.Events;