sdl2-bindings 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +134 -108
- data/LICENSE.txt +0 -0
- data/README.md +86 -68
- data/lib/sdl2.rb +131 -127
- data/lib/sdl2_audio.rb +261 -261
- data/lib/sdl2_blendmode.rb +72 -72
- data/lib/sdl2_clipboard.rb +56 -56
- data/lib/sdl2_cpuinfo.rb +129 -129
- data/lib/sdl2_error.rb +71 -71
- data/lib/sdl2_events.rb +564 -552
- data/lib/sdl2_filesystem.rb +52 -52
- data/lib/sdl2_framerate.rb +74 -74
- data/lib/sdl2_gamecontroller.rb +329 -329
- data/lib/sdl2_gesture.rb +61 -61
- data/lib/sdl2_gfxPrimitives.rb +283 -283
- data/lib/sdl2_haptic.rb +301 -301
- data/lib/sdl2_hidapi.rb +139 -139
- data/lib/sdl2_hints.rb +221 -207
- data/lib/sdl2_image.rb +296 -232
- data/lib/sdl2_imageFilter.rb +164 -164
- data/lib/sdl2_joystick.rb +294 -294
- data/lib/sdl2_keyboard.rb +125 -117
- data/lib/sdl2_keycode.rb +307 -307
- data/lib/sdl2_log.rb +131 -131
- data/lib/sdl2_main.rb +74 -74
- data/lib/sdl2_messagebox.rb +102 -102
- data/lib/sdl2_misc.rb +48 -48
- data/lib/sdl2_mixer.rb +464 -392
- data/lib/sdl2_mouse.rb +136 -136
- data/lib/sdl2_pixels.rb +240 -240
- data/lib/sdl2_platform.rb +48 -48
- data/lib/sdl2_power.rb +54 -54
- data/lib/sdl2_rect.rb +145 -109
- data/lib/sdl2_render.rb +408 -404
- data/lib/sdl2_rotozoom.rb +76 -76
- data/lib/sdl2_rwops.rb +242 -238
- data/lib/sdl2_scancode.rb +289 -289
- data/lib/sdl2_sensor.rb +115 -115
- data/lib/sdl2_shape.rb +83 -83
- data/lib/sdl2_sound.rb +154 -0
- data/lib/sdl2_stdinc.rb +548 -564
- data/lib/sdl2_surface.rb +229 -229
- data/lib/sdl2_syswm.rb +160 -160
- data/lib/sdl2_timer.rb +74 -74
- data/lib/sdl2_touch.rb +86 -82
- data/lib/sdl2_ttf.rb +414 -357
- data/lib/sdl2_version.rb +67 -67
- data/lib/sdl2_video.rb +540 -540
- data/lib/sdl2_vulkan.rb +72 -72
- metadata +3 -2
data/lib/sdl2_haptic.rb
CHANGED
@@ -1,301 +1,301 @@
|
|
1
|
-
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
-
#
|
3
|
-
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
-
#
|
5
|
-
# [NOTICE] This is an automatically generated file.
|
6
|
-
|
7
|
-
require 'ffi'
|
8
|
-
|
9
|
-
module SDL
|
10
|
-
extend FFI::Library
|
11
|
-
# Define/Macro
|
12
|
-
|
13
|
-
HAPTIC_CONSTANT = (1 << 0)
|
14
|
-
HAPTIC_SINE = (1 << 1)
|
15
|
-
HAPTIC_LEFTRIGHT = (1 << 2)
|
16
|
-
HAPTIC_TRIANGLE = (1 << 3)
|
17
|
-
HAPTIC_SAWTOOTHUP = (1 << 4)
|
18
|
-
HAPTIC_SAWTOOTHDOWN = (1 << 5)
|
19
|
-
HAPTIC_RAMP = (1 << 6)
|
20
|
-
HAPTIC_SPRING = (1 << 7)
|
21
|
-
HAPTIC_DAMPER = (1 << 8)
|
22
|
-
HAPTIC_INERTIA = (1 << 9)
|
23
|
-
HAPTIC_FRICTION = (1 << 10)
|
24
|
-
HAPTIC_CUSTOM = (1 << 11)
|
25
|
-
HAPTIC_GAIN = (1 << 12)
|
26
|
-
HAPTIC_AUTOCENTER = (1 << 13)
|
27
|
-
HAPTIC_STATUS = (1 << 14)
|
28
|
-
HAPTIC_PAUSE = (1 << 15)
|
29
|
-
HAPTIC_POLAR = 0
|
30
|
-
HAPTIC_CARTESIAN = 1
|
31
|
-
HAPTIC_SPHERICAL = 2
|
32
|
-
HAPTIC_STEERING_AXIS = 3
|
33
|
-
HAPTIC_INFINITY = 4294967295
|
34
|
-
|
35
|
-
# Enum
|
36
|
-
|
37
|
-
|
38
|
-
# Typedef
|
39
|
-
|
40
|
-
|
41
|
-
# Struct
|
42
|
-
|
43
|
-
class HapticDirection < FFI::Struct
|
44
|
-
layout(
|
45
|
-
:type, :uchar,
|
46
|
-
:dir, [:int, 3],
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
class HapticConstant < FFI::Struct
|
51
|
-
layout(
|
52
|
-
:type, :ushort,
|
53
|
-
:direction, HapticDirection,
|
54
|
-
:length, :uint,
|
55
|
-
:delay, :ushort,
|
56
|
-
:button, :ushort,
|
57
|
-
:interval, :ushort,
|
58
|
-
:level, :short,
|
59
|
-
:attack_length, :ushort,
|
60
|
-
:attack_level, :ushort,
|
61
|
-
:fade_length, :ushort,
|
62
|
-
:fade_level, :ushort,
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
class HapticPeriodic < FFI::Struct
|
67
|
-
layout(
|
68
|
-
:type, :ushort,
|
69
|
-
:direction, HapticDirection,
|
70
|
-
:length, :uint,
|
71
|
-
:delay, :ushort,
|
72
|
-
:button, :ushort,
|
73
|
-
:interval, :ushort,
|
74
|
-
:period, :ushort,
|
75
|
-
:magnitude, :short,
|
76
|
-
:offset, :short,
|
77
|
-
:phase, :ushort,
|
78
|
-
:attack_length, :ushort,
|
79
|
-
:attack_level, :ushort,
|
80
|
-
:fade_length, :ushort,
|
81
|
-
:fade_level, :ushort,
|
82
|
-
)
|
83
|
-
end
|
84
|
-
|
85
|
-
class HapticCondition < FFI::Struct
|
86
|
-
layout(
|
87
|
-
:type, :ushort,
|
88
|
-
:direction, HapticDirection,
|
89
|
-
:length, :uint,
|
90
|
-
:delay, :ushort,
|
91
|
-
:button, :ushort,
|
92
|
-
:interval, :ushort,
|
93
|
-
:right_sat, [:ushort, 3],
|
94
|
-
:left_sat, [:ushort, 3],
|
95
|
-
:right_coeff, [:short, 3],
|
96
|
-
:left_coeff, [:short, 3],
|
97
|
-
:deadband, [:ushort, 3],
|
98
|
-
:center, [:short, 3],
|
99
|
-
)
|
100
|
-
end
|
101
|
-
|
102
|
-
class HapticRamp < FFI::Struct
|
103
|
-
layout(
|
104
|
-
:type, :ushort,
|
105
|
-
:direction, HapticDirection,
|
106
|
-
:length, :uint,
|
107
|
-
:delay, :ushort,
|
108
|
-
:button, :ushort,
|
109
|
-
:interval, :ushort,
|
110
|
-
:start, :short,
|
111
|
-
:end, :short,
|
112
|
-
:attack_length, :ushort,
|
113
|
-
:attack_level, :ushort,
|
114
|
-
:fade_length, :ushort,
|
115
|
-
:fade_level, :ushort,
|
116
|
-
)
|
117
|
-
end
|
118
|
-
|
119
|
-
class HapticLeftRight < FFI::Struct
|
120
|
-
layout(
|
121
|
-
:type, :ushort,
|
122
|
-
:length, :uint,
|
123
|
-
:large_magnitude, :ushort,
|
124
|
-
:small_magnitude, :ushort,
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
class HapticCustom < FFI::Struct
|
129
|
-
layout(
|
130
|
-
:type, :ushort,
|
131
|
-
:direction, HapticDirection,
|
132
|
-
:length, :uint,
|
133
|
-
:delay, :ushort,
|
134
|
-
:button, :ushort,
|
135
|
-
:interval, :ushort,
|
136
|
-
:channels, :uchar,
|
137
|
-
:period, :ushort,
|
138
|
-
:samples, :ushort,
|
139
|
-
:data, :pointer,
|
140
|
-
:attack_length, :ushort,
|
141
|
-
:attack_level, :ushort,
|
142
|
-
:fade_length, :ushort,
|
143
|
-
:fade_level, :ushort,
|
144
|
-
)
|
145
|
-
end
|
146
|
-
|
147
|
-
class HapticEffect < FFI::Union
|
148
|
-
layout(
|
149
|
-
:type, :ushort,
|
150
|
-
:constant, HapticConstant,
|
151
|
-
:periodic, HapticPeriodic,
|
152
|
-
:condition, HapticCondition,
|
153
|
-
:ramp, HapticRamp,
|
154
|
-
:leftright, HapticLeftRight,
|
155
|
-
:custom, HapticCustom,
|
156
|
-
)
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
# Function
|
161
|
-
|
162
|
-
def self.setup_haptic_symbols(output_error = false)
|
163
|
-
symbols = [
|
164
|
-
:SDL_NumHaptics,
|
165
|
-
:SDL_HapticName,
|
166
|
-
:SDL_HapticOpen,
|
167
|
-
:SDL_HapticOpened,
|
168
|
-
:SDL_HapticIndex,
|
169
|
-
:SDL_MouseIsHaptic,
|
170
|
-
:SDL_HapticOpenFromMouse,
|
171
|
-
:SDL_JoystickIsHaptic,
|
172
|
-
:SDL_HapticOpenFromJoystick,
|
173
|
-
:SDL_HapticClose,
|
174
|
-
:SDL_HapticNumEffects,
|
175
|
-
:SDL_HapticNumEffectsPlaying,
|
176
|
-
:SDL_HapticQuery,
|
177
|
-
:SDL_HapticNumAxes,
|
178
|
-
:SDL_HapticEffectSupported,
|
179
|
-
:SDL_HapticNewEffect,
|
180
|
-
:SDL_HapticUpdateEffect,
|
181
|
-
:SDL_HapticRunEffect,
|
182
|
-
:SDL_HapticStopEffect,
|
183
|
-
:SDL_HapticDestroyEffect,
|
184
|
-
:SDL_HapticGetEffectStatus,
|
185
|
-
:SDL_HapticSetGain,
|
186
|
-
:SDL_HapticSetAutocenter,
|
187
|
-
:SDL_HapticPause,
|
188
|
-
:SDL_HapticUnpause,
|
189
|
-
:SDL_HapticStopAll,
|
190
|
-
:SDL_HapticRumbleSupported,
|
191
|
-
:SDL_HapticRumbleInit,
|
192
|
-
:SDL_HapticRumblePlay,
|
193
|
-
:SDL_HapticRumbleStop,
|
194
|
-
]
|
195
|
-
apis = {
|
196
|
-
:SDL_NumHaptics => :NumHaptics,
|
197
|
-
:SDL_HapticName => :HapticName,
|
198
|
-
:SDL_HapticOpen => :HapticOpen,
|
199
|
-
:SDL_HapticOpened => :HapticOpened,
|
200
|
-
:SDL_HapticIndex => :HapticIndex,
|
201
|
-
:SDL_MouseIsHaptic => :MouseIsHaptic,
|
202
|
-
:SDL_HapticOpenFromMouse => :HapticOpenFromMouse,
|
203
|
-
:SDL_JoystickIsHaptic => :JoystickIsHaptic,
|
204
|
-
:SDL_HapticOpenFromJoystick => :HapticOpenFromJoystick,
|
205
|
-
:SDL_HapticClose => :HapticClose,
|
206
|
-
:SDL_HapticNumEffects => :HapticNumEffects,
|
207
|
-
:SDL_HapticNumEffectsPlaying => :HapticNumEffectsPlaying,
|
208
|
-
:SDL_HapticQuery => :HapticQuery,
|
209
|
-
:SDL_HapticNumAxes => :HapticNumAxes,
|
210
|
-
:SDL_HapticEffectSupported => :HapticEffectSupported,
|
211
|
-
:SDL_HapticNewEffect => :HapticNewEffect,
|
212
|
-
:SDL_HapticUpdateEffect => :HapticUpdateEffect,
|
213
|
-
:SDL_HapticRunEffect => :HapticRunEffect,
|
214
|
-
:SDL_HapticStopEffect => :HapticStopEffect,
|
215
|
-
:SDL_HapticDestroyEffect => :HapticDestroyEffect,
|
216
|
-
:SDL_HapticGetEffectStatus => :HapticGetEffectStatus,
|
217
|
-
:SDL_HapticSetGain => :HapticSetGain,
|
218
|
-
:SDL_HapticSetAutocenter => :HapticSetAutocenter,
|
219
|
-
:SDL_HapticPause => :HapticPause,
|
220
|
-
:SDL_HapticUnpause => :HapticUnpause,
|
221
|
-
:SDL_HapticStopAll => :HapticStopAll,
|
222
|
-
:SDL_HapticRumbleSupported => :HapticRumbleSupported,
|
223
|
-
:SDL_HapticRumbleInit => :HapticRumbleInit,
|
224
|
-
:SDL_HapticRumblePlay => :HapticRumblePlay,
|
225
|
-
:SDL_HapticRumbleStop => :HapticRumbleStop,
|
226
|
-
}
|
227
|
-
args = {
|
228
|
-
:SDL_NumHaptics => [],
|
229
|
-
:SDL_HapticName => [:int],
|
230
|
-
:SDL_HapticOpen => [:int],
|
231
|
-
:SDL_HapticOpened => [:int],
|
232
|
-
:SDL_HapticIndex => [:pointer],
|
233
|
-
:SDL_MouseIsHaptic => [],
|
234
|
-
:SDL_HapticOpenFromMouse => [],
|
235
|
-
:SDL_JoystickIsHaptic => [:pointer],
|
236
|
-
:SDL_HapticOpenFromJoystick => [:pointer],
|
237
|
-
:SDL_HapticClose => [:pointer],
|
238
|
-
:SDL_HapticNumEffects => [:pointer],
|
239
|
-
:SDL_HapticNumEffectsPlaying => [:pointer],
|
240
|
-
:SDL_HapticQuery => [:pointer],
|
241
|
-
:SDL_HapticNumAxes => [:pointer],
|
242
|
-
:SDL_HapticEffectSupported => [:pointer, :pointer],
|
243
|
-
:SDL_HapticNewEffect => [:pointer, :pointer],
|
244
|
-
:SDL_HapticUpdateEffect => [:pointer, :int, :pointer],
|
245
|
-
:SDL_HapticRunEffect => [:pointer, :int, :uint],
|
246
|
-
:SDL_HapticStopEffect => [:pointer, :int],
|
247
|
-
:SDL_HapticDestroyEffect => [:pointer, :int],
|
248
|
-
:SDL_HapticGetEffectStatus => [:pointer, :int],
|
249
|
-
:SDL_HapticSetGain => [:pointer, :int],
|
250
|
-
:SDL_HapticSetAutocenter => [:pointer, :int],
|
251
|
-
:SDL_HapticPause => [:pointer],
|
252
|
-
:SDL_HapticUnpause => [:pointer],
|
253
|
-
:SDL_HapticStopAll => [:pointer],
|
254
|
-
:SDL_HapticRumbleSupported => [:pointer],
|
255
|
-
:SDL_HapticRumbleInit => [:pointer],
|
256
|
-
:SDL_HapticRumblePlay => [:pointer, :float, :uint],
|
257
|
-
:SDL_HapticRumbleStop => [:pointer],
|
258
|
-
}
|
259
|
-
retvals = {
|
260
|
-
:SDL_NumHaptics => :int,
|
261
|
-
:SDL_HapticName => :pointer,
|
262
|
-
:SDL_HapticOpen => :pointer,
|
263
|
-
:SDL_HapticOpened => :int,
|
264
|
-
:SDL_HapticIndex => :int,
|
265
|
-
:SDL_MouseIsHaptic => :int,
|
266
|
-
:SDL_HapticOpenFromMouse => :pointer,
|
267
|
-
:SDL_JoystickIsHaptic => :int,
|
268
|
-
:SDL_HapticOpenFromJoystick => :pointer,
|
269
|
-
:SDL_HapticClose => :void,
|
270
|
-
:SDL_HapticNumEffects => :int,
|
271
|
-
:SDL_HapticNumEffectsPlaying => :int,
|
272
|
-
:SDL_HapticQuery => :uint,
|
273
|
-
:SDL_HapticNumAxes => :int,
|
274
|
-
:SDL_HapticEffectSupported => :int,
|
275
|
-
:SDL_HapticNewEffect => :int,
|
276
|
-
:SDL_HapticUpdateEffect => :int,
|
277
|
-
:SDL_HapticRunEffect => :int,
|
278
|
-
:SDL_HapticStopEffect => :int,
|
279
|
-
:SDL_HapticDestroyEffect => :void,
|
280
|
-
:SDL_HapticGetEffectStatus => :int,
|
281
|
-
:SDL_HapticSetGain => :int,
|
282
|
-
:SDL_HapticSetAutocenter => :int,
|
283
|
-
:SDL_HapticPause => :int,
|
284
|
-
:SDL_HapticUnpause => :int,
|
285
|
-
:SDL_HapticStopAll => :int,
|
286
|
-
:SDL_HapticRumbleSupported => :int,
|
287
|
-
:SDL_HapticRumbleInit => :int,
|
288
|
-
:SDL_HapticRumblePlay => :int,
|
289
|
-
:SDL_HapticRumbleStop => :int,
|
290
|
-
}
|
291
|
-
symbols.each do |sym|
|
292
|
-
begin
|
293
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
294
|
-
rescue FFI::NotFoundError => error
|
295
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
end
|
301
|
-
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] This is an automatically generated file.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module SDL
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
HAPTIC_CONSTANT = (1 << 0)
|
14
|
+
HAPTIC_SINE = (1 << 1)
|
15
|
+
HAPTIC_LEFTRIGHT = (1 << 2)
|
16
|
+
HAPTIC_TRIANGLE = (1 << 3)
|
17
|
+
HAPTIC_SAWTOOTHUP = (1 << 4)
|
18
|
+
HAPTIC_SAWTOOTHDOWN = (1 << 5)
|
19
|
+
HAPTIC_RAMP = (1 << 6)
|
20
|
+
HAPTIC_SPRING = (1 << 7)
|
21
|
+
HAPTIC_DAMPER = (1 << 8)
|
22
|
+
HAPTIC_INERTIA = (1 << 9)
|
23
|
+
HAPTIC_FRICTION = (1 << 10)
|
24
|
+
HAPTIC_CUSTOM = (1 << 11)
|
25
|
+
HAPTIC_GAIN = (1 << 12)
|
26
|
+
HAPTIC_AUTOCENTER = (1 << 13)
|
27
|
+
HAPTIC_STATUS = (1 << 14)
|
28
|
+
HAPTIC_PAUSE = (1 << 15)
|
29
|
+
HAPTIC_POLAR = 0
|
30
|
+
HAPTIC_CARTESIAN = 1
|
31
|
+
HAPTIC_SPHERICAL = 2
|
32
|
+
HAPTIC_STEERING_AXIS = 3
|
33
|
+
HAPTIC_INFINITY = 4294967295
|
34
|
+
|
35
|
+
# Enum
|
36
|
+
|
37
|
+
|
38
|
+
# Typedef
|
39
|
+
|
40
|
+
|
41
|
+
# Struct
|
42
|
+
|
43
|
+
class HapticDirection < FFI::Struct
|
44
|
+
layout(
|
45
|
+
:type, :uchar,
|
46
|
+
:dir, [:int, 3],
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
class HapticConstant < FFI::Struct
|
51
|
+
layout(
|
52
|
+
:type, :ushort,
|
53
|
+
:direction, HapticDirection,
|
54
|
+
:length, :uint,
|
55
|
+
:delay, :ushort,
|
56
|
+
:button, :ushort,
|
57
|
+
:interval, :ushort,
|
58
|
+
:level, :short,
|
59
|
+
:attack_length, :ushort,
|
60
|
+
:attack_level, :ushort,
|
61
|
+
:fade_length, :ushort,
|
62
|
+
:fade_level, :ushort,
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
class HapticPeriodic < FFI::Struct
|
67
|
+
layout(
|
68
|
+
:type, :ushort,
|
69
|
+
:direction, HapticDirection,
|
70
|
+
:length, :uint,
|
71
|
+
:delay, :ushort,
|
72
|
+
:button, :ushort,
|
73
|
+
:interval, :ushort,
|
74
|
+
:period, :ushort,
|
75
|
+
:magnitude, :short,
|
76
|
+
:offset, :short,
|
77
|
+
:phase, :ushort,
|
78
|
+
:attack_length, :ushort,
|
79
|
+
:attack_level, :ushort,
|
80
|
+
:fade_length, :ushort,
|
81
|
+
:fade_level, :ushort,
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
class HapticCondition < FFI::Struct
|
86
|
+
layout(
|
87
|
+
:type, :ushort,
|
88
|
+
:direction, HapticDirection,
|
89
|
+
:length, :uint,
|
90
|
+
:delay, :ushort,
|
91
|
+
:button, :ushort,
|
92
|
+
:interval, :ushort,
|
93
|
+
:right_sat, [:ushort, 3],
|
94
|
+
:left_sat, [:ushort, 3],
|
95
|
+
:right_coeff, [:short, 3],
|
96
|
+
:left_coeff, [:short, 3],
|
97
|
+
:deadband, [:ushort, 3],
|
98
|
+
:center, [:short, 3],
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
class HapticRamp < FFI::Struct
|
103
|
+
layout(
|
104
|
+
:type, :ushort,
|
105
|
+
:direction, HapticDirection,
|
106
|
+
:length, :uint,
|
107
|
+
:delay, :ushort,
|
108
|
+
:button, :ushort,
|
109
|
+
:interval, :ushort,
|
110
|
+
:start, :short,
|
111
|
+
:end, :short,
|
112
|
+
:attack_length, :ushort,
|
113
|
+
:attack_level, :ushort,
|
114
|
+
:fade_length, :ushort,
|
115
|
+
:fade_level, :ushort,
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
class HapticLeftRight < FFI::Struct
|
120
|
+
layout(
|
121
|
+
:type, :ushort,
|
122
|
+
:length, :uint,
|
123
|
+
:large_magnitude, :ushort,
|
124
|
+
:small_magnitude, :ushort,
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
class HapticCustom < FFI::Struct
|
129
|
+
layout(
|
130
|
+
:type, :ushort,
|
131
|
+
:direction, HapticDirection,
|
132
|
+
:length, :uint,
|
133
|
+
:delay, :ushort,
|
134
|
+
:button, :ushort,
|
135
|
+
:interval, :ushort,
|
136
|
+
:channels, :uchar,
|
137
|
+
:period, :ushort,
|
138
|
+
:samples, :ushort,
|
139
|
+
:data, :pointer,
|
140
|
+
:attack_length, :ushort,
|
141
|
+
:attack_level, :ushort,
|
142
|
+
:fade_length, :ushort,
|
143
|
+
:fade_level, :ushort,
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
class HapticEffect < FFI::Union
|
148
|
+
layout(
|
149
|
+
:type, :ushort,
|
150
|
+
:constant, HapticConstant,
|
151
|
+
:periodic, HapticPeriodic,
|
152
|
+
:condition, HapticCondition,
|
153
|
+
:ramp, HapticRamp,
|
154
|
+
:leftright, HapticLeftRight,
|
155
|
+
:custom, HapticCustom,
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
# Function
|
161
|
+
|
162
|
+
def self.setup_haptic_symbols(output_error = false)
|
163
|
+
symbols = [
|
164
|
+
:SDL_NumHaptics,
|
165
|
+
:SDL_HapticName,
|
166
|
+
:SDL_HapticOpen,
|
167
|
+
:SDL_HapticOpened,
|
168
|
+
:SDL_HapticIndex,
|
169
|
+
:SDL_MouseIsHaptic,
|
170
|
+
:SDL_HapticOpenFromMouse,
|
171
|
+
:SDL_JoystickIsHaptic,
|
172
|
+
:SDL_HapticOpenFromJoystick,
|
173
|
+
:SDL_HapticClose,
|
174
|
+
:SDL_HapticNumEffects,
|
175
|
+
:SDL_HapticNumEffectsPlaying,
|
176
|
+
:SDL_HapticQuery,
|
177
|
+
:SDL_HapticNumAxes,
|
178
|
+
:SDL_HapticEffectSupported,
|
179
|
+
:SDL_HapticNewEffect,
|
180
|
+
:SDL_HapticUpdateEffect,
|
181
|
+
:SDL_HapticRunEffect,
|
182
|
+
:SDL_HapticStopEffect,
|
183
|
+
:SDL_HapticDestroyEffect,
|
184
|
+
:SDL_HapticGetEffectStatus,
|
185
|
+
:SDL_HapticSetGain,
|
186
|
+
:SDL_HapticSetAutocenter,
|
187
|
+
:SDL_HapticPause,
|
188
|
+
:SDL_HapticUnpause,
|
189
|
+
:SDL_HapticStopAll,
|
190
|
+
:SDL_HapticRumbleSupported,
|
191
|
+
:SDL_HapticRumbleInit,
|
192
|
+
:SDL_HapticRumblePlay,
|
193
|
+
:SDL_HapticRumbleStop,
|
194
|
+
]
|
195
|
+
apis = {
|
196
|
+
:SDL_NumHaptics => :NumHaptics,
|
197
|
+
:SDL_HapticName => :HapticName,
|
198
|
+
:SDL_HapticOpen => :HapticOpen,
|
199
|
+
:SDL_HapticOpened => :HapticOpened,
|
200
|
+
:SDL_HapticIndex => :HapticIndex,
|
201
|
+
:SDL_MouseIsHaptic => :MouseIsHaptic,
|
202
|
+
:SDL_HapticOpenFromMouse => :HapticOpenFromMouse,
|
203
|
+
:SDL_JoystickIsHaptic => :JoystickIsHaptic,
|
204
|
+
:SDL_HapticOpenFromJoystick => :HapticOpenFromJoystick,
|
205
|
+
:SDL_HapticClose => :HapticClose,
|
206
|
+
:SDL_HapticNumEffects => :HapticNumEffects,
|
207
|
+
:SDL_HapticNumEffectsPlaying => :HapticNumEffectsPlaying,
|
208
|
+
:SDL_HapticQuery => :HapticQuery,
|
209
|
+
:SDL_HapticNumAxes => :HapticNumAxes,
|
210
|
+
:SDL_HapticEffectSupported => :HapticEffectSupported,
|
211
|
+
:SDL_HapticNewEffect => :HapticNewEffect,
|
212
|
+
:SDL_HapticUpdateEffect => :HapticUpdateEffect,
|
213
|
+
:SDL_HapticRunEffect => :HapticRunEffect,
|
214
|
+
:SDL_HapticStopEffect => :HapticStopEffect,
|
215
|
+
:SDL_HapticDestroyEffect => :HapticDestroyEffect,
|
216
|
+
:SDL_HapticGetEffectStatus => :HapticGetEffectStatus,
|
217
|
+
:SDL_HapticSetGain => :HapticSetGain,
|
218
|
+
:SDL_HapticSetAutocenter => :HapticSetAutocenter,
|
219
|
+
:SDL_HapticPause => :HapticPause,
|
220
|
+
:SDL_HapticUnpause => :HapticUnpause,
|
221
|
+
:SDL_HapticStopAll => :HapticStopAll,
|
222
|
+
:SDL_HapticRumbleSupported => :HapticRumbleSupported,
|
223
|
+
:SDL_HapticRumbleInit => :HapticRumbleInit,
|
224
|
+
:SDL_HapticRumblePlay => :HapticRumblePlay,
|
225
|
+
:SDL_HapticRumbleStop => :HapticRumbleStop,
|
226
|
+
}
|
227
|
+
args = {
|
228
|
+
:SDL_NumHaptics => [],
|
229
|
+
:SDL_HapticName => [:int],
|
230
|
+
:SDL_HapticOpen => [:int],
|
231
|
+
:SDL_HapticOpened => [:int],
|
232
|
+
:SDL_HapticIndex => [:pointer],
|
233
|
+
:SDL_MouseIsHaptic => [],
|
234
|
+
:SDL_HapticOpenFromMouse => [],
|
235
|
+
:SDL_JoystickIsHaptic => [:pointer],
|
236
|
+
:SDL_HapticOpenFromJoystick => [:pointer],
|
237
|
+
:SDL_HapticClose => [:pointer],
|
238
|
+
:SDL_HapticNumEffects => [:pointer],
|
239
|
+
:SDL_HapticNumEffectsPlaying => [:pointer],
|
240
|
+
:SDL_HapticQuery => [:pointer],
|
241
|
+
:SDL_HapticNumAxes => [:pointer],
|
242
|
+
:SDL_HapticEffectSupported => [:pointer, :pointer],
|
243
|
+
:SDL_HapticNewEffect => [:pointer, :pointer],
|
244
|
+
:SDL_HapticUpdateEffect => [:pointer, :int, :pointer],
|
245
|
+
:SDL_HapticRunEffect => [:pointer, :int, :uint],
|
246
|
+
:SDL_HapticStopEffect => [:pointer, :int],
|
247
|
+
:SDL_HapticDestroyEffect => [:pointer, :int],
|
248
|
+
:SDL_HapticGetEffectStatus => [:pointer, :int],
|
249
|
+
:SDL_HapticSetGain => [:pointer, :int],
|
250
|
+
:SDL_HapticSetAutocenter => [:pointer, :int],
|
251
|
+
:SDL_HapticPause => [:pointer],
|
252
|
+
:SDL_HapticUnpause => [:pointer],
|
253
|
+
:SDL_HapticStopAll => [:pointer],
|
254
|
+
:SDL_HapticRumbleSupported => [:pointer],
|
255
|
+
:SDL_HapticRumbleInit => [:pointer],
|
256
|
+
:SDL_HapticRumblePlay => [:pointer, :float, :uint],
|
257
|
+
:SDL_HapticRumbleStop => [:pointer],
|
258
|
+
}
|
259
|
+
retvals = {
|
260
|
+
:SDL_NumHaptics => :int,
|
261
|
+
:SDL_HapticName => :pointer,
|
262
|
+
:SDL_HapticOpen => :pointer,
|
263
|
+
:SDL_HapticOpened => :int,
|
264
|
+
:SDL_HapticIndex => :int,
|
265
|
+
:SDL_MouseIsHaptic => :int,
|
266
|
+
:SDL_HapticOpenFromMouse => :pointer,
|
267
|
+
:SDL_JoystickIsHaptic => :int,
|
268
|
+
:SDL_HapticOpenFromJoystick => :pointer,
|
269
|
+
:SDL_HapticClose => :void,
|
270
|
+
:SDL_HapticNumEffects => :int,
|
271
|
+
:SDL_HapticNumEffectsPlaying => :int,
|
272
|
+
:SDL_HapticQuery => :uint,
|
273
|
+
:SDL_HapticNumAxes => :int,
|
274
|
+
:SDL_HapticEffectSupported => :int,
|
275
|
+
:SDL_HapticNewEffect => :int,
|
276
|
+
:SDL_HapticUpdateEffect => :int,
|
277
|
+
:SDL_HapticRunEffect => :int,
|
278
|
+
:SDL_HapticStopEffect => :int,
|
279
|
+
:SDL_HapticDestroyEffect => :void,
|
280
|
+
:SDL_HapticGetEffectStatus => :int,
|
281
|
+
:SDL_HapticSetGain => :int,
|
282
|
+
:SDL_HapticSetAutocenter => :int,
|
283
|
+
:SDL_HapticPause => :int,
|
284
|
+
:SDL_HapticUnpause => :int,
|
285
|
+
:SDL_HapticStopAll => :int,
|
286
|
+
:SDL_HapticRumbleSupported => :int,
|
287
|
+
:SDL_HapticRumbleInit => :int,
|
288
|
+
:SDL_HapticRumblePlay => :int,
|
289
|
+
:SDL_HapticRumbleStop => :int,
|
290
|
+
}
|
291
|
+
symbols.each do |sym|
|
292
|
+
begin
|
293
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
294
|
+
rescue FFI::NotFoundError => error
|
295
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|