sdl3 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE +21 -0
- data/README.md +188 -0
- data/Rakefile +12 -0
- data/examples/01_hello_window.rb +24 -0
- data/examples/02_basic_rendering.rb +45 -0
- data/examples/03_keyboard_input.rb +52 -0
- data/examples/04_mouse_input.rb +56 -0
- data/examples/05_simple_game.rb +107 -0
- data/lib/sdl3/high_level/audio_device.rb +202 -0
- data/lib/sdl3/high_level/camera.rb +118 -0
- data/lib/sdl3/high_level/clipboard.rb +59 -0
- data/lib/sdl3/high_level/event.rb +240 -0
- data/lib/sdl3/high_level/gamepad.rb +190 -0
- data/lib/sdl3/high_level/gpu.rb +194 -0
- data/lib/sdl3/high_level/haptic.rb +213 -0
- data/lib/sdl3/high_level/joystick.rb +165 -0
- data/lib/sdl3/high_level/renderer.rb +163 -0
- data/lib/sdl3/high_level/sensor.rb +105 -0
- data/lib/sdl3/high_level/surface.rb +143 -0
- data/lib/sdl3/high_level/texture.rb +111 -0
- data/lib/sdl3/high_level/timer.rb +88 -0
- data/lib/sdl3/high_level/window.rb +151 -0
- data/lib/sdl3/library_loader.rb +63 -0
- data/lib/sdl3/raw/assert.rb +32 -0
- data/lib/sdl3/raw/asyncio.rb +36 -0
- data/lib/sdl3/raw/atomic.rb +40 -0
- data/lib/sdl3/raw/audio.rb +95 -0
- data/lib/sdl3/raw/base.rb +12 -0
- data/lib/sdl3/raw/bits.rb +17 -0
- data/lib/sdl3/raw/blendmode.rb +36 -0
- data/lib/sdl3/raw/camera.rb +38 -0
- data/lib/sdl3/raw/clipboard.rb +20 -0
- data/lib/sdl3/raw/cpuinfo.rb +29 -0
- data/lib/sdl3/raw/dialog.rb +33 -0
- data/lib/sdl3/raw/endian.rb +8 -0
- data/lib/sdl3/raw/error.rb +15 -0
- data/lib/sdl3/raw/events.rb +563 -0
- data/lib/sdl3/raw/filesystem.rb +47 -0
- data/lib/sdl3/raw/gamepad.rb +135 -0
- data/lib/sdl3/raw/gpu.rb +734 -0
- data/lib/sdl3/raw/guid.rb +12 -0
- data/lib/sdl3/raw/haptic.rb +167 -0
- data/lib/sdl3/raw/hidapi.rb +57 -0
- data/lib/sdl3/raw/hints.rb +20 -0
- data/lib/sdl3/raw/init.rb +27 -0
- data/lib/sdl3/raw/iostream.rb +88 -0
- data/lib/sdl3/raw/joystick.rb +101 -0
- data/lib/sdl3/raw/keyboard.rb +30 -0
- data/lib/sdl3/raw/keycode.rb +132 -0
- data/lib/sdl3/raw/loadso.rb +9 -0
- data/lib/sdl3/raw/locale.rb +12 -0
- data/lib/sdl3/raw/log.rb +61 -0
- data/lib/sdl3/raw/main.rb +23 -0
- data/lib/sdl3/raw/messagebox.rb +50 -0
- data/lib/sdl3/raw/metal.rb +9 -0
- data/lib/sdl3/raw/misc.rb +7 -0
- data/lib/sdl3/raw/mouse.rb +82 -0
- data/lib/sdl3/raw/mutex.rb +48 -0
- data/lib/sdl3/raw/openxr.rb +21 -0
- data/lib/sdl3/raw/pen.rb +38 -0
- data/lib/sdl3/raw/pixels.rb +180 -0
- data/lib/sdl3/raw/platform.rb +7 -0
- data/lib/sdl3/raw/power.rb +14 -0
- data/lib/sdl3/raw/process.rb +15 -0
- data/lib/sdl3/raw/properties.rb +39 -0
- data/lib/sdl3/raw/rect.rb +41 -0
- data/lib/sdl3/raw/render.rb +153 -0
- data/lib/sdl3/raw/scancode.rb +112 -0
- data/lib/sdl3/raw/sensor.rb +31 -0
- data/lib/sdl3/raw/stdinc.rb +209 -0
- data/lib/sdl3/raw/storage.rb +50 -0
- data/lib/sdl3/raw/surface.rb +106 -0
- data/lib/sdl3/raw/system.rb +77 -0
- data/lib/sdl3/raw/thread.rb +40 -0
- data/lib/sdl3/raw/time.rb +36 -0
- data/lib/sdl3/raw/timer.rb +19 -0
- data/lib/sdl3/raw/touch.rb +22 -0
- data/lib/sdl3/raw/tray.rb +42 -0
- data/lib/sdl3/raw/types.rb +21 -0
- data/lib/sdl3/raw/version.rb +8 -0
- data/lib/sdl3/raw/video.rb +208 -0
- data/lib/sdl3/raw/vulkan.rb +13 -0
- data/lib/sdl3/version.rb +5 -0
- data/lib/sdl3.rb +128 -0
- data/sdl3.gemspec +30 -0
- metadata +143 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SDL3
|
|
4
|
+
module Raw
|
|
5
|
+
class SDL_DialogFileFilter < FFI::Struct
|
|
6
|
+
layout :name, :string,
|
|
7
|
+
:pattern, :string
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
SDL_FileDialogType = enum :SDL_FILEDIALOG_OPENFILE, 0,
|
|
11
|
+
:SDL_FILEDIALOG_SAVEFILE, 1,
|
|
12
|
+
:SDL_FILEDIALOG_OPENFOLDER, 2
|
|
13
|
+
|
|
14
|
+
callback :SDL_DialogFileCallback, %i[pointer pointer int], :void
|
|
15
|
+
|
|
16
|
+
begin
|
|
17
|
+
attach_function :SDL_ShowOpenFileDialog,
|
|
18
|
+
[:SDL_DialogFileCallback, :pointer, :pointer, SDL_DialogFileFilter.ptr, :int, :string, :bool],
|
|
19
|
+
:void
|
|
20
|
+
attach_function :SDL_ShowSaveFileDialog,
|
|
21
|
+
[:SDL_DialogFileCallback, :pointer, :pointer, SDL_DialogFileFilter.ptr, :int, :string],
|
|
22
|
+
:void
|
|
23
|
+
attach_function :SDL_ShowOpenFolderDialog,
|
|
24
|
+
[:SDL_DialogFileCallback, :pointer, :pointer, :string, :bool],
|
|
25
|
+
:void
|
|
26
|
+
attach_function :SDL_ShowFileDialogWithProperties,
|
|
27
|
+
[SDL_FileDialogType, :SDL_DialogFileCallback, :pointer, :SDL_PropertiesID],
|
|
28
|
+
:void
|
|
29
|
+
rescue FFI::NotFoundError
|
|
30
|
+
# Dialog API may not be available in all SDL3 versions
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SDL3
|
|
4
|
+
module Raw
|
|
5
|
+
attach_function :SDL_SetError, [:string], :bool
|
|
6
|
+
begin
|
|
7
|
+
attach_function :SDL_SetErrorV, [:string, :pointer], :bool
|
|
8
|
+
rescue FFI::NotFoundError
|
|
9
|
+
# Added in newer SDL3 versions.
|
|
10
|
+
end
|
|
11
|
+
attach_function :SDL_OutOfMemory, [], :bool
|
|
12
|
+
attach_function :SDL_GetError, [], :string
|
|
13
|
+
attach_function :SDL_ClearError, [], :bool
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SDL3
|
|
4
|
+
module Raw
|
|
5
|
+
SDL_EVENT_FIRST = 0
|
|
6
|
+
SDL_EVENT_QUIT = 0x100
|
|
7
|
+
SDL_EVENT_TERMINATING = 0x101
|
|
8
|
+
SDL_EVENT_LOW_MEMORY = 0x102
|
|
9
|
+
SDL_EVENT_WILL_ENTER_BACKGROUND = 0x103
|
|
10
|
+
SDL_EVENT_DID_ENTER_BACKGROUND = 0x104
|
|
11
|
+
SDL_EVENT_WILL_ENTER_FOREGROUND = 0x105
|
|
12
|
+
SDL_EVENT_DID_ENTER_FOREGROUND = 0x106
|
|
13
|
+
SDL_EVENT_LOCALE_CHANGED = 0x107
|
|
14
|
+
SDL_EVENT_SYSTEM_THEME_CHANGED = 0x108
|
|
15
|
+
|
|
16
|
+
SDL_EVENT_DISPLAY_ORIENTATION = 0x151
|
|
17
|
+
SDL_EVENT_DISPLAY_ADDED = 0x152
|
|
18
|
+
SDL_EVENT_DISPLAY_REMOVED = 0x153
|
|
19
|
+
SDL_EVENT_DISPLAY_MOVED = 0x154
|
|
20
|
+
SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED = 0x155
|
|
21
|
+
SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED = 0x156
|
|
22
|
+
SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED = 0x157
|
|
23
|
+
|
|
24
|
+
SDL_EVENT_WINDOW_SHOWN = 0x202
|
|
25
|
+
SDL_EVENT_WINDOW_HIDDEN = 0x203
|
|
26
|
+
SDL_EVENT_WINDOW_EXPOSED = 0x204
|
|
27
|
+
SDL_EVENT_WINDOW_MOVED = 0x205
|
|
28
|
+
SDL_EVENT_WINDOW_RESIZED = 0x206
|
|
29
|
+
SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED = 0x207
|
|
30
|
+
SDL_EVENT_WINDOW_METAL_VIEW_RESIZED = 0x208
|
|
31
|
+
SDL_EVENT_WINDOW_MINIMIZED = 0x209
|
|
32
|
+
SDL_EVENT_WINDOW_MAXIMIZED = 0x20A
|
|
33
|
+
SDL_EVENT_WINDOW_RESTORED = 0x20B
|
|
34
|
+
SDL_EVENT_WINDOW_MOUSE_ENTER = 0x20C
|
|
35
|
+
SDL_EVENT_WINDOW_MOUSE_LEAVE = 0x20D
|
|
36
|
+
SDL_EVENT_WINDOW_FOCUS_GAINED = 0x20E
|
|
37
|
+
SDL_EVENT_WINDOW_FOCUS_LOST = 0x20F
|
|
38
|
+
SDL_EVENT_WINDOW_CLOSE_REQUESTED = 0x210
|
|
39
|
+
SDL_EVENT_WINDOW_HIT_TEST = 0x211
|
|
40
|
+
SDL_EVENT_WINDOW_ICCPROF_CHANGED = 0x212
|
|
41
|
+
SDL_EVENT_WINDOW_DISPLAY_CHANGED = 0x213
|
|
42
|
+
SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED = 0x214
|
|
43
|
+
SDL_EVENT_WINDOW_SAFE_AREA_CHANGED = 0x215
|
|
44
|
+
SDL_EVENT_WINDOW_OCCLUDED = 0x216
|
|
45
|
+
SDL_EVENT_WINDOW_ENTER_FULLSCREEN = 0x217
|
|
46
|
+
SDL_EVENT_WINDOW_LEAVE_FULLSCREEN = 0x218
|
|
47
|
+
SDL_EVENT_WINDOW_DESTROYED = 0x219
|
|
48
|
+
SDL_EVENT_WINDOW_HDR_STATE_CHANGED = 0x21A
|
|
49
|
+
|
|
50
|
+
SDL_EVENT_KEY_DOWN = 0x300
|
|
51
|
+
SDL_EVENT_KEY_UP = 0x301
|
|
52
|
+
SDL_EVENT_TEXT_EDITING = 0x302
|
|
53
|
+
SDL_EVENT_TEXT_INPUT = 0x303
|
|
54
|
+
SDL_EVENT_KEYMAP_CHANGED = 0x304
|
|
55
|
+
SDL_EVENT_KEYBOARD_ADDED = 0x305
|
|
56
|
+
SDL_EVENT_KEYBOARD_REMOVED = 0x306
|
|
57
|
+
SDL_EVENT_TEXT_EDITING_CANDIDATES = 0x307
|
|
58
|
+
|
|
59
|
+
SDL_EVENT_MOUSE_MOTION = 0x400
|
|
60
|
+
SDL_EVENT_MOUSE_BUTTON_DOWN = 0x401
|
|
61
|
+
SDL_EVENT_MOUSE_BUTTON_UP = 0x402
|
|
62
|
+
SDL_EVENT_MOUSE_WHEEL = 0x403
|
|
63
|
+
SDL_EVENT_MOUSE_ADDED = 0x404
|
|
64
|
+
SDL_EVENT_MOUSE_REMOVED = 0x405
|
|
65
|
+
|
|
66
|
+
SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600
|
|
67
|
+
SDL_EVENT_JOYSTICK_BALL_MOTION = 0x601
|
|
68
|
+
SDL_EVENT_JOYSTICK_HAT_MOTION = 0x602
|
|
69
|
+
SDL_EVENT_JOYSTICK_BUTTON_DOWN = 0x603
|
|
70
|
+
SDL_EVENT_JOYSTICK_BUTTON_UP = 0x604
|
|
71
|
+
SDL_EVENT_JOYSTICK_ADDED = 0x605
|
|
72
|
+
SDL_EVENT_JOYSTICK_REMOVED = 0x606
|
|
73
|
+
SDL_EVENT_JOYSTICK_BATTERY_UPDATED = 0x607
|
|
74
|
+
SDL_EVENT_JOYSTICK_UPDATE_COMPLETE = 0x608
|
|
75
|
+
|
|
76
|
+
SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650
|
|
77
|
+
SDL_EVENT_GAMEPAD_BUTTON_DOWN = 0x651
|
|
78
|
+
SDL_EVENT_GAMEPAD_BUTTON_UP = 0x652
|
|
79
|
+
SDL_EVENT_GAMEPAD_ADDED = 0x653
|
|
80
|
+
SDL_EVENT_GAMEPAD_REMOVED = 0x654
|
|
81
|
+
SDL_EVENT_GAMEPAD_REMAPPED = 0x655
|
|
82
|
+
SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN = 0x656
|
|
83
|
+
SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION = 0x657
|
|
84
|
+
SDL_EVENT_GAMEPAD_TOUCHPAD_UP = 0x658
|
|
85
|
+
SDL_EVENT_GAMEPAD_SENSOR_UPDATE = 0x659
|
|
86
|
+
SDL_EVENT_GAMEPAD_UPDATE_COMPLETE = 0x65A
|
|
87
|
+
SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED = 0x65B
|
|
88
|
+
|
|
89
|
+
SDL_EVENT_FINGER_DOWN = 0x700
|
|
90
|
+
SDL_EVENT_FINGER_UP = 0x701
|
|
91
|
+
SDL_EVENT_FINGER_MOTION = 0x702
|
|
92
|
+
|
|
93
|
+
SDL_EVENT_CLIPBOARD_UPDATE = 0x900
|
|
94
|
+
|
|
95
|
+
SDL_EVENT_DROP_FILE = 0x1000
|
|
96
|
+
SDL_EVENT_DROP_TEXT = 0x1001
|
|
97
|
+
SDL_EVENT_DROP_BEGIN = 0x1002
|
|
98
|
+
SDL_EVENT_DROP_COMPLETE = 0x1003
|
|
99
|
+
SDL_EVENT_DROP_POSITION = 0x1004
|
|
100
|
+
|
|
101
|
+
SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100
|
|
102
|
+
SDL_EVENT_AUDIO_DEVICE_REMOVED = 0x1101
|
|
103
|
+
SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED = 0x1102
|
|
104
|
+
|
|
105
|
+
SDL_EVENT_SENSOR_UPDATE = 0x1200
|
|
106
|
+
|
|
107
|
+
SDL_EVENT_PEN_PROXIMITY_IN = 0x1300
|
|
108
|
+
SDL_EVENT_PEN_PROXIMITY_OUT = 0x1301
|
|
109
|
+
SDL_EVENT_PEN_DOWN = 0x1302
|
|
110
|
+
SDL_EVENT_PEN_UP = 0x1303
|
|
111
|
+
SDL_EVENT_PEN_BUTTON_DOWN = 0x1304
|
|
112
|
+
SDL_EVENT_PEN_BUTTON_UP = 0x1305
|
|
113
|
+
SDL_EVENT_PEN_MOTION = 0x1306
|
|
114
|
+
SDL_EVENT_PEN_AXIS = 0x1307
|
|
115
|
+
|
|
116
|
+
SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400
|
|
117
|
+
SDL_EVENT_CAMERA_DEVICE_REMOVED = 0x1401
|
|
118
|
+
SDL_EVENT_CAMERA_DEVICE_APPROVED = 0x1402
|
|
119
|
+
SDL_EVENT_CAMERA_DEVICE_DENIED = 0x1403
|
|
120
|
+
|
|
121
|
+
SDL_EVENT_RENDER_TARGETS_RESET = 0x2000
|
|
122
|
+
SDL_EVENT_RENDER_DEVICE_RESET = 0x2001
|
|
123
|
+
SDL_EVENT_RENDER_DEVICE_LOST = 0x2002
|
|
124
|
+
|
|
125
|
+
SDL_EVENT_POLL_SENTINEL = 0x7F00
|
|
126
|
+
|
|
127
|
+
SDL_EVENT_USER = 0x8000
|
|
128
|
+
|
|
129
|
+
SDL_EVENT_LAST = 0xFFFF
|
|
130
|
+
|
|
131
|
+
class SDL_CommonEvent < FFI::Struct
|
|
132
|
+
layout :type, :uint32,
|
|
133
|
+
:reserved, :uint32,
|
|
134
|
+
:timestamp, :uint64
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
class SDL_DisplayEvent < FFI::Struct
|
|
138
|
+
layout :type, :uint32,
|
|
139
|
+
:reserved, :uint32,
|
|
140
|
+
:timestamp, :uint64,
|
|
141
|
+
:displayID, :SDL_DisplayID,
|
|
142
|
+
:data1, :int32,
|
|
143
|
+
:data2, :int32
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
class SDL_WindowEvent < FFI::Struct
|
|
147
|
+
layout :type, :uint32,
|
|
148
|
+
:reserved, :uint32,
|
|
149
|
+
:timestamp, :uint64,
|
|
150
|
+
:windowID, :SDL_WindowID,
|
|
151
|
+
:data1, :int32,
|
|
152
|
+
:data2, :int32
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
class SDL_KeyboardDeviceEvent < FFI::Struct
|
|
156
|
+
layout :type, :uint32,
|
|
157
|
+
:reserved, :uint32,
|
|
158
|
+
:timestamp, :uint64,
|
|
159
|
+
:which, :SDL_KeyboardID
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
class SDL_KeyboardEvent < FFI::Struct
|
|
163
|
+
layout :type, :uint32,
|
|
164
|
+
:reserved, :uint32,
|
|
165
|
+
:timestamp, :uint64,
|
|
166
|
+
:windowID, :SDL_WindowID,
|
|
167
|
+
:which, :SDL_KeyboardID,
|
|
168
|
+
:scancode, :SDL_Scancode,
|
|
169
|
+
:key, :SDL_Keycode,
|
|
170
|
+
:mod, :uint16,
|
|
171
|
+
:raw, :uint16,
|
|
172
|
+
:down, :bool,
|
|
173
|
+
:repeat, :bool
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
class SDL_TextEditingEvent < FFI::Struct
|
|
177
|
+
layout :type, :uint32,
|
|
178
|
+
:reserved, :uint32,
|
|
179
|
+
:timestamp, :uint64,
|
|
180
|
+
:windowID, :SDL_WindowID,
|
|
181
|
+
:text, :pointer,
|
|
182
|
+
:start, :int32,
|
|
183
|
+
:length, :int32
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
class SDL_TextInputEvent < FFI::Struct
|
|
187
|
+
layout :type, :uint32,
|
|
188
|
+
:reserved, :uint32,
|
|
189
|
+
:timestamp, :uint64,
|
|
190
|
+
:windowID, :SDL_WindowID,
|
|
191
|
+
:text, :pointer
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class SDL_MouseDeviceEvent < FFI::Struct
|
|
195
|
+
layout :type, :uint32,
|
|
196
|
+
:reserved, :uint32,
|
|
197
|
+
:timestamp, :uint64,
|
|
198
|
+
:which, :SDL_MouseID
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
class SDL_MouseMotionEvent < FFI::Struct
|
|
202
|
+
layout :type, :uint32,
|
|
203
|
+
:reserved, :uint32,
|
|
204
|
+
:timestamp, :uint64,
|
|
205
|
+
:windowID, :SDL_WindowID,
|
|
206
|
+
:which, :SDL_MouseID,
|
|
207
|
+
:state, :uint32,
|
|
208
|
+
:x, :float,
|
|
209
|
+
:y, :float,
|
|
210
|
+
:xrel, :float,
|
|
211
|
+
:yrel, :float
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
class SDL_MouseButtonEvent < FFI::Struct
|
|
215
|
+
layout :type, :uint32,
|
|
216
|
+
:reserved, :uint32,
|
|
217
|
+
:timestamp, :uint64,
|
|
218
|
+
:windowID, :SDL_WindowID,
|
|
219
|
+
:which, :SDL_MouseID,
|
|
220
|
+
:button, :uint8,
|
|
221
|
+
:down, :bool,
|
|
222
|
+
:clicks, :uint8,
|
|
223
|
+
:padding, :uint8,
|
|
224
|
+
:x, :float,
|
|
225
|
+
:y, :float
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
class SDL_MouseWheelEvent < FFI::Struct
|
|
229
|
+
layout :type, :uint32,
|
|
230
|
+
:reserved, :uint32,
|
|
231
|
+
:timestamp, :uint64,
|
|
232
|
+
:windowID, :SDL_WindowID,
|
|
233
|
+
:which, :SDL_MouseID,
|
|
234
|
+
:x, :float,
|
|
235
|
+
:y, :float,
|
|
236
|
+
:direction, :int32,
|
|
237
|
+
:mouse_x, :float,
|
|
238
|
+
:mouse_y, :float
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
class SDL_JoyAxisEvent < FFI::Struct
|
|
242
|
+
layout :type, :uint32,
|
|
243
|
+
:reserved, :uint32,
|
|
244
|
+
:timestamp, :uint64,
|
|
245
|
+
:which, :SDL_JoystickID,
|
|
246
|
+
:axis, :uint8,
|
|
247
|
+
:padding1, :uint8,
|
|
248
|
+
:padding2, :uint8,
|
|
249
|
+
:padding3, :uint8,
|
|
250
|
+
:value, :int16,
|
|
251
|
+
:padding4, :uint16
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
class SDL_JoyBallEvent < FFI::Struct
|
|
255
|
+
layout :type, :uint32,
|
|
256
|
+
:reserved, :uint32,
|
|
257
|
+
:timestamp, :uint64,
|
|
258
|
+
:which, :SDL_JoystickID,
|
|
259
|
+
:ball, :uint8,
|
|
260
|
+
:padding1, :uint8,
|
|
261
|
+
:padding2, :uint8,
|
|
262
|
+
:padding3, :uint8,
|
|
263
|
+
:xrel, :int16,
|
|
264
|
+
:yrel, :int16
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
class SDL_JoyHatEvent < FFI::Struct
|
|
268
|
+
layout :type, :uint32,
|
|
269
|
+
:reserved, :uint32,
|
|
270
|
+
:timestamp, :uint64,
|
|
271
|
+
:which, :SDL_JoystickID,
|
|
272
|
+
:hat, :uint8,
|
|
273
|
+
:value, :uint8,
|
|
274
|
+
:padding1, :uint8,
|
|
275
|
+
:padding2, :uint8
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
class SDL_JoyButtonEvent < FFI::Struct
|
|
279
|
+
layout :type, :uint32,
|
|
280
|
+
:reserved, :uint32,
|
|
281
|
+
:timestamp, :uint64,
|
|
282
|
+
:which, :SDL_JoystickID,
|
|
283
|
+
:button, :uint8,
|
|
284
|
+
:down, :bool,
|
|
285
|
+
:padding1, :uint8,
|
|
286
|
+
:padding2, :uint8
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
class SDL_JoyDeviceEvent < FFI::Struct
|
|
290
|
+
layout :type, :uint32,
|
|
291
|
+
:reserved, :uint32,
|
|
292
|
+
:timestamp, :uint64,
|
|
293
|
+
:which, :SDL_JoystickID
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
class SDL_JoyBatteryEvent < FFI::Struct
|
|
297
|
+
layout :type, :uint32,
|
|
298
|
+
:reserved, :uint32,
|
|
299
|
+
:timestamp, :uint64,
|
|
300
|
+
:which, :SDL_JoystickID,
|
|
301
|
+
:state, :int32,
|
|
302
|
+
:percent, :int32
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
class SDL_GamepadAxisEvent < FFI::Struct
|
|
306
|
+
layout :type, :uint32,
|
|
307
|
+
:reserved, :uint32,
|
|
308
|
+
:timestamp, :uint64,
|
|
309
|
+
:which, :SDL_JoystickID,
|
|
310
|
+
:axis, :uint8,
|
|
311
|
+
:padding1, :uint8,
|
|
312
|
+
:padding2, :uint8,
|
|
313
|
+
:padding3, :uint8,
|
|
314
|
+
:value, :int16,
|
|
315
|
+
:padding4, :uint16
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
class SDL_GamepadButtonEvent < FFI::Struct
|
|
319
|
+
layout :type, :uint32,
|
|
320
|
+
:reserved, :uint32,
|
|
321
|
+
:timestamp, :uint64,
|
|
322
|
+
:which, :SDL_JoystickID,
|
|
323
|
+
:button, :uint8,
|
|
324
|
+
:down, :bool,
|
|
325
|
+
:padding1, :uint8,
|
|
326
|
+
:padding2, :uint8
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
class SDL_GamepadDeviceEvent < FFI::Struct
|
|
330
|
+
layout :type, :uint32,
|
|
331
|
+
:reserved, :uint32,
|
|
332
|
+
:timestamp, :uint64,
|
|
333
|
+
:which, :SDL_JoystickID
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
class SDL_GamepadTouchpadEvent < FFI::Struct
|
|
337
|
+
layout :type, :uint32,
|
|
338
|
+
:reserved, :uint32,
|
|
339
|
+
:timestamp, :uint64,
|
|
340
|
+
:which, :SDL_JoystickID,
|
|
341
|
+
:touchpad, :int32,
|
|
342
|
+
:finger, :int32,
|
|
343
|
+
:x, :float,
|
|
344
|
+
:y, :float,
|
|
345
|
+
:pressure, :float
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
class SDL_GamepadSensorEvent < FFI::Struct
|
|
349
|
+
layout :type, :uint32,
|
|
350
|
+
:reserved, :uint32,
|
|
351
|
+
:timestamp, :uint64,
|
|
352
|
+
:which, :SDL_JoystickID,
|
|
353
|
+
:sensor, :int32,
|
|
354
|
+
:data, [:float, 3],
|
|
355
|
+
:sensor_timestamp, :uint64
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
class SDL_AudioDeviceEvent < FFI::Struct
|
|
359
|
+
layout :type, :uint32,
|
|
360
|
+
:reserved, :uint32,
|
|
361
|
+
:timestamp, :uint64,
|
|
362
|
+
:which, :SDL_AudioDeviceID,
|
|
363
|
+
:recording, :bool,
|
|
364
|
+
:padding1, :uint8,
|
|
365
|
+
:padding2, :uint8,
|
|
366
|
+
:padding3, :uint8
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
class SDL_CameraDeviceEvent < FFI::Struct
|
|
370
|
+
layout :type, :uint32,
|
|
371
|
+
:reserved, :uint32,
|
|
372
|
+
:timestamp, :uint64,
|
|
373
|
+
:which, :SDL_CameraID
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
class SDL_TouchFingerEvent < FFI::Struct
|
|
377
|
+
layout :type, :uint32,
|
|
378
|
+
:reserved, :uint32,
|
|
379
|
+
:timestamp, :uint64,
|
|
380
|
+
:touchID, :SDL_TouchID,
|
|
381
|
+
:fingerID, :SDL_FingerID,
|
|
382
|
+
:x, :float,
|
|
383
|
+
:y, :float,
|
|
384
|
+
:dx, :float,
|
|
385
|
+
:dy, :float,
|
|
386
|
+
:pressure, :float,
|
|
387
|
+
:windowID, :SDL_WindowID
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
class SDL_PenProximityEvent < FFI::Struct
|
|
391
|
+
layout :type, :uint32,
|
|
392
|
+
:reserved, :uint32,
|
|
393
|
+
:timestamp, :uint64,
|
|
394
|
+
:windowID, :SDL_WindowID,
|
|
395
|
+
:which, :SDL_PenID
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
class SDL_PenMotionEvent < FFI::Struct
|
|
399
|
+
layout :type, :uint32,
|
|
400
|
+
:reserved, :uint32,
|
|
401
|
+
:timestamp, :uint64,
|
|
402
|
+
:windowID, :SDL_WindowID,
|
|
403
|
+
:which, :SDL_PenID,
|
|
404
|
+
:pen_state, :uint32,
|
|
405
|
+
:x, :float,
|
|
406
|
+
:y, :float
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
class SDL_PenTouchEvent < FFI::Struct
|
|
410
|
+
layout :type, :uint32,
|
|
411
|
+
:reserved, :uint32,
|
|
412
|
+
:timestamp, :uint64,
|
|
413
|
+
:windowID, :SDL_WindowID,
|
|
414
|
+
:which, :SDL_PenID,
|
|
415
|
+
:pen_state, :uint32,
|
|
416
|
+
:x, :float,
|
|
417
|
+
:y, :float,
|
|
418
|
+
:eraser, :bool,
|
|
419
|
+
:down, :bool
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
class SDL_PenButtonEvent < FFI::Struct
|
|
423
|
+
layout :type, :uint32,
|
|
424
|
+
:reserved, :uint32,
|
|
425
|
+
:timestamp, :uint64,
|
|
426
|
+
:windowID, :SDL_WindowID,
|
|
427
|
+
:which, :SDL_PenID,
|
|
428
|
+
:pen_state, :uint32,
|
|
429
|
+
:x, :float,
|
|
430
|
+
:y, :float,
|
|
431
|
+
:button, :uint8,
|
|
432
|
+
:down, :bool
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
class SDL_PenAxisEvent < FFI::Struct
|
|
436
|
+
layout :type, :uint32,
|
|
437
|
+
:reserved, :uint32,
|
|
438
|
+
:timestamp, :uint64,
|
|
439
|
+
:windowID, :SDL_WindowID,
|
|
440
|
+
:which, :SDL_PenID,
|
|
441
|
+
:pen_state, :uint32,
|
|
442
|
+
:x, :float,
|
|
443
|
+
:y, :float,
|
|
444
|
+
:axis, :int32,
|
|
445
|
+
:value, :float
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
class SDL_DropEvent < FFI::Struct
|
|
449
|
+
layout :type, :uint32,
|
|
450
|
+
:reserved, :uint32,
|
|
451
|
+
:timestamp, :uint64,
|
|
452
|
+
:windowID, :SDL_WindowID,
|
|
453
|
+
:x, :float,
|
|
454
|
+
:y, :float,
|
|
455
|
+
:source, :pointer,
|
|
456
|
+
:data, :pointer
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
class SDL_ClipboardEvent < FFI::Struct
|
|
460
|
+
layout :type, :uint32,
|
|
461
|
+
:reserved, :uint32,
|
|
462
|
+
:timestamp, :uint64,
|
|
463
|
+
:owner, :bool,
|
|
464
|
+
:n_mime_types, :int32,
|
|
465
|
+
:mime_types, :pointer
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
class SDL_SensorEvent < FFI::Struct
|
|
469
|
+
layout :type, :uint32,
|
|
470
|
+
:reserved, :uint32,
|
|
471
|
+
:timestamp, :uint64,
|
|
472
|
+
:which, :SDL_SensorID,
|
|
473
|
+
:data, [:float, 6],
|
|
474
|
+
:sensor_timestamp, :uint64
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
class SDL_QuitEvent < FFI::Struct
|
|
478
|
+
layout :type, :uint32,
|
|
479
|
+
:reserved, :uint32,
|
|
480
|
+
:timestamp, :uint64
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
class SDL_UserEvent < FFI::Struct
|
|
484
|
+
layout :type, :uint32,
|
|
485
|
+
:reserved, :uint32,
|
|
486
|
+
:timestamp, :uint64,
|
|
487
|
+
:windowID, :SDL_WindowID,
|
|
488
|
+
:code, :int32,
|
|
489
|
+
:data1, :pointer,
|
|
490
|
+
:data2, :pointer
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
class SDL_Event < FFI::Union
|
|
494
|
+
layout :type, :uint32,
|
|
495
|
+
:common, SDL_CommonEvent,
|
|
496
|
+
:display, SDL_DisplayEvent,
|
|
497
|
+
:window, SDL_WindowEvent,
|
|
498
|
+
:kdevice, SDL_KeyboardDeviceEvent,
|
|
499
|
+
:key, SDL_KeyboardEvent,
|
|
500
|
+
:edit, SDL_TextEditingEvent,
|
|
501
|
+
:text, SDL_TextInputEvent,
|
|
502
|
+
:mdevice, SDL_MouseDeviceEvent,
|
|
503
|
+
:motion, SDL_MouseMotionEvent,
|
|
504
|
+
:button, SDL_MouseButtonEvent,
|
|
505
|
+
:wheel, SDL_MouseWheelEvent,
|
|
506
|
+
:jdevice, SDL_JoyDeviceEvent,
|
|
507
|
+
:jaxis, SDL_JoyAxisEvent,
|
|
508
|
+
:jball, SDL_JoyBallEvent,
|
|
509
|
+
:jhat, SDL_JoyHatEvent,
|
|
510
|
+
:jbutton, SDL_JoyButtonEvent,
|
|
511
|
+
:jbattery, SDL_JoyBatteryEvent,
|
|
512
|
+
:gdevice, SDL_GamepadDeviceEvent,
|
|
513
|
+
:gaxis, SDL_GamepadAxisEvent,
|
|
514
|
+
:gbutton, SDL_GamepadButtonEvent,
|
|
515
|
+
:gtouchpad, SDL_GamepadTouchpadEvent,
|
|
516
|
+
:gsensor, SDL_GamepadSensorEvent,
|
|
517
|
+
:adevice, SDL_AudioDeviceEvent,
|
|
518
|
+
:cdevice, SDL_CameraDeviceEvent,
|
|
519
|
+
:sensor, SDL_SensorEvent,
|
|
520
|
+
:quit, SDL_QuitEvent,
|
|
521
|
+
:user, SDL_UserEvent,
|
|
522
|
+
:tfinger, SDL_TouchFingerEvent,
|
|
523
|
+
:pproximity, SDL_PenProximityEvent,
|
|
524
|
+
:ptouch, SDL_PenTouchEvent,
|
|
525
|
+
:pmotion, SDL_PenMotionEvent,
|
|
526
|
+
:pbutton, SDL_PenButtonEvent,
|
|
527
|
+
:paxis, SDL_PenAxisEvent,
|
|
528
|
+
:drop, SDL_DropEvent,
|
|
529
|
+
:clipboard, SDL_ClipboardEvent,
|
|
530
|
+
:padding, [:uint8, 128]
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
SDL_EventAction = enum :SDL_ADDEVENT, 0,
|
|
534
|
+
:SDL_PEEKEVENT, 1,
|
|
535
|
+
:SDL_GETEVENT, 2
|
|
536
|
+
|
|
537
|
+
attach_function :SDL_PumpEvents, [], :void
|
|
538
|
+
attach_function :SDL_PeepEvents, [SDL_Event.ptr, :int, SDL_EventAction, :uint32, :uint32], :int
|
|
539
|
+
attach_function :SDL_HasEvent, [:uint32], :bool
|
|
540
|
+
attach_function :SDL_HasEvents, %i[uint32 uint32], :bool
|
|
541
|
+
attach_function :SDL_FlushEvent, [:uint32], :void
|
|
542
|
+
attach_function :SDL_FlushEvents, %i[uint32 uint32], :void
|
|
543
|
+
attach_function :SDL_PollEvent, [SDL_Event.ptr], :bool
|
|
544
|
+
attach_function :SDL_WaitEvent, [SDL_Event.ptr], :bool
|
|
545
|
+
attach_function :SDL_WaitEventTimeout, [SDL_Event.ptr, :int32], :bool
|
|
546
|
+
attach_function :SDL_PushEvent, [SDL_Event.ptr], :bool
|
|
547
|
+
callback :SDL_EventFilter, [SDL_Event.ptr, :pointer], :bool
|
|
548
|
+
attach_function :SDL_SetEventFilter, [:SDL_EventFilter, :pointer], :void
|
|
549
|
+
attach_function :SDL_GetEventFilter, %i[pointer pointer], :bool
|
|
550
|
+
attach_function :SDL_AddEventWatch, [:SDL_EventFilter, :pointer], :bool
|
|
551
|
+
attach_function :SDL_RemoveEventWatch, [:SDL_EventFilter, :pointer], :void
|
|
552
|
+
attach_function :SDL_FilterEvents, [:SDL_EventFilter, :pointer], :void
|
|
553
|
+
attach_function :SDL_SetEventEnabled, %i[uint32 bool], :void
|
|
554
|
+
attach_function :SDL_EventEnabled, [:uint32], :bool
|
|
555
|
+
attach_function :SDL_RegisterEvents, [:int], :uint32
|
|
556
|
+
begin
|
|
557
|
+
attach_function :SDL_GetEventDescription, [SDL_Event.ptr, :pointer, :int], :int
|
|
558
|
+
rescue FFI::NotFoundError
|
|
559
|
+
# Added in newer SDL3 versions.
|
|
560
|
+
end
|
|
561
|
+
attach_function :SDL_GetWindowFromEvent, [SDL_Event.ptr], :pointer
|
|
562
|
+
end
|
|
563
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SDL3
|
|
4
|
+
module Raw
|
|
5
|
+
SDL_Folder = enum :SDL_FOLDER_HOME, 0,
|
|
6
|
+
:SDL_FOLDER_DESKTOP, 1,
|
|
7
|
+
:SDL_FOLDER_DOCUMENTS, 2,
|
|
8
|
+
:SDL_FOLDER_DOWNLOADS, 3,
|
|
9
|
+
:SDL_FOLDER_MUSIC, 4,
|
|
10
|
+
:SDL_FOLDER_PICTURES, 5,
|
|
11
|
+
:SDL_FOLDER_PUBLICSHARE, 6,
|
|
12
|
+
:SDL_FOLDER_SAVEDGAMES, 7,
|
|
13
|
+
:SDL_FOLDER_SCREENSHOTS, 8,
|
|
14
|
+
:SDL_FOLDER_TEMPLATES, 9,
|
|
15
|
+
:SDL_FOLDER_VIDEOS, 10,
|
|
16
|
+
:SDL_FOLDER_COUNT, 11
|
|
17
|
+
|
|
18
|
+
SDL_PathType = enum :SDL_PATHTYPE_NONE, 0,
|
|
19
|
+
:SDL_PATHTYPE_FILE, 1,
|
|
20
|
+
:SDL_PATHTYPE_DIRECTORY, 2,
|
|
21
|
+
:SDL_PATHTYPE_OTHER, 3
|
|
22
|
+
|
|
23
|
+
SDL_GLOB_CASEINSENSITIVE = 1 << 0
|
|
24
|
+
|
|
25
|
+
class SDL_PathInfo < FFI::Struct
|
|
26
|
+
layout :type, SDL_PathType,
|
|
27
|
+
:size, :uint64,
|
|
28
|
+
:create_time, :int64,
|
|
29
|
+
:modify_time, :int64,
|
|
30
|
+
:access_time, :int64
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
callback :SDL_EnumerateDirectoryCallback, %i[pointer string string], :int
|
|
34
|
+
|
|
35
|
+
attach_function :SDL_GetBasePath, [], :string
|
|
36
|
+
attach_function :SDL_GetPrefPath, %i[string string], :string
|
|
37
|
+
attach_function :SDL_GetUserFolder, [SDL_Folder], :string
|
|
38
|
+
attach_function :SDL_CreateDirectory, [:string], :bool
|
|
39
|
+
attach_function :SDL_EnumerateDirectory, [:string, :SDL_EnumerateDirectoryCallback, :pointer], :bool
|
|
40
|
+
attach_function :SDL_RemovePath, [:string], :bool
|
|
41
|
+
attach_function :SDL_RenamePath, %i[string string], :bool
|
|
42
|
+
attach_function :SDL_CopyFile, %i[string string], :bool
|
|
43
|
+
attach_function :SDL_GetPathInfo, [:string, SDL_PathInfo.ptr], :bool
|
|
44
|
+
attach_function :SDL_GlobDirectory, %i[string string uint32 pointer], :pointer
|
|
45
|
+
attach_function :SDL_GetCurrentDirectory, [], :string
|
|
46
|
+
end
|
|
47
|
+
end
|