sdl2-bindings 0.0.5 → 0.0.9

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +96 -79
  3. data/LICENSE.txt +1 -1
  4. data/README.md +55 -49
  5. data/lib/sdl2.rb +172 -170
  6. data/lib/sdl2_audio.rb +222 -201
  7. data/lib/sdl2_blendmode.rb +69 -69
  8. data/lib/sdl2_clipboard.rb +51 -51
  9. data/lib/sdl2_cpuinfo.rb +106 -106
  10. data/lib/sdl2_error.rb +64 -64
  11. data/lib/sdl2_events.rb +533 -530
  12. data/lib/sdl2_filesystem.rb +48 -48
  13. data/lib/sdl2_framerate.rb +67 -67
  14. data/lib/sdl2_gamecontroller.rb +274 -254
  15. data/lib/sdl2_gesture.rb +55 -55
  16. data/lib/sdl2_gfxPrimitives.rb +222 -222
  17. data/lib/sdl2_haptic.rb +269 -269
  18. data/lib/sdl2_hidapi.rb +118 -0
  19. data/lib/sdl2_hints.rb +198 -174
  20. data/lib/sdl2_image.rb +185 -185
  21. data/lib/sdl2_imageFilter.rb +132 -132
  22. data/lib/sdl2_joystick.rb +239 -230
  23. data/lib/sdl2_keyboard.rb +99 -99
  24. data/lib/sdl2_keycode.rb +305 -304
  25. data/lib/sdl2_log.rb +115 -115
  26. data/lib/sdl2_main.rb +67 -67
  27. data/lib/sdl2_messagebox.rb +98 -98
  28. data/lib/sdl2_misc.rb +45 -0
  29. data/lib/sdl2_mixer.rb +317 -307
  30. data/lib/sdl2_mouse.rb +117 -117
  31. data/lib/sdl2_pixels.rb +224 -224
  32. data/lib/sdl2_platform.rb +45 -45
  33. data/lib/sdl2_power.rb +51 -51
  34. data/lib/sdl2_rect.rb +102 -102
  35. data/lib/sdl2_render.rb +322 -290
  36. data/lib/sdl2_rotozoom.rb +66 -66
  37. data/lib/sdl2_rwops.rb +208 -208
  38. data/lib/sdl2_scancode.rb +287 -287
  39. data/lib/sdl2_sensor.rb +97 -0
  40. data/lib/sdl2_shape.rb +77 -77
  41. data/lib/sdl2_stdinc.rb +439 -393
  42. data/lib/sdl2_surface.rb +188 -182
  43. data/lib/sdl2_syswm.rb +157 -154
  44. data/lib/sdl2_timer.rb +65 -62
  45. data/lib/sdl2_touch.rb +75 -73
  46. data/lib/sdl2_ttf.rb +202 -190
  47. data/lib/sdl2_version.rb +62 -62
  48. data/lib/sdl2_video.rb +446 -411
  49. data/lib/sdl2_vulkan.rb +64 -64
  50. metadata +9 -6
data/lib/sdl2_haptic.rb CHANGED
@@ -1,269 +1,269 @@
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 SDL2
10
- extend FFI::Library
11
- # Define/Macro
12
-
13
- SDL_HAPTIC_CONSTANT = (1 << 0)
14
- SDL_HAPTIC_SINE = (1 << 1)
15
- SDL_HAPTIC_LEFTRIGHT = (1 << 2)
16
- SDL_HAPTIC_TRIANGLE = (1 << 3)
17
- SDL_HAPTIC_SAWTOOTHUP = (1 << 4)
18
- SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5)
19
- SDL_HAPTIC_RAMP = (1 << 6)
20
- SDL_HAPTIC_SPRING = (1 << 7)
21
- SDL_HAPTIC_DAMPER = (1 << 8)
22
- SDL_HAPTIC_INERTIA = (1 << 9)
23
- SDL_HAPTIC_FRICTION = (1 << 10)
24
- SDL_HAPTIC_CUSTOM = (1 << 11)
25
- SDL_HAPTIC_GAIN = (1 << 12)
26
- SDL_HAPTIC_AUTOCENTER = (1 << 13)
27
- SDL_HAPTIC_STATUS = (1 << 14)
28
- SDL_HAPTIC_PAUSE = (1 << 15)
29
- SDL_HAPTIC_POLAR = 0
30
- SDL_HAPTIC_CARTESIAN = 1
31
- SDL_HAPTIC_SPHERICAL = 2
32
- SDL_HAPTIC_STEERING_AXIS = 3
33
- SDL_HAPTIC_INFINITY = 4294967295
34
-
35
- # Enum
36
-
37
-
38
- # Typedef
39
-
40
-
41
- # Struct
42
-
43
- class SDL_HapticDirection < FFI::Struct
44
- layout(
45
- :type, :uchar,
46
- :dir, [:int, 3],
47
- )
48
- end
49
-
50
- class SDL_HapticConstant < FFI::Struct
51
- layout(
52
- :type, :ushort,
53
- :direction, SDL_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 SDL_HapticPeriodic < FFI::Struct
67
- layout(
68
- :type, :ushort,
69
- :direction, SDL_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 SDL_HapticCondition < FFI::Struct
86
- layout(
87
- :type, :ushort,
88
- :direction, SDL_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 SDL_HapticRamp < FFI::Struct
103
- layout(
104
- :type, :ushort,
105
- :direction, SDL_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 SDL_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 SDL_HapticCustom < FFI::Struct
129
- layout(
130
- :type, :ushort,
131
- :direction, SDL_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 SDL_HapticEffect < FFI::Union
148
- layout(
149
- :type, :ushort,
150
- :constant, SDL_HapticConstant,
151
- :periodic, SDL_HapticPeriodic,
152
- :condition, SDL_HapticCondition,
153
- :ramp, SDL_HapticRamp,
154
- :leftright, SDL_HapticLeftRight,
155
- :custom, SDL_HapticCustom,
156
- )
157
- end
158
-
159
-
160
- # Function
161
-
162
- def self.setup_haptic_symbols()
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
- args = {
196
- :SDL_NumHaptics => [],
197
- :SDL_HapticName => [:int],
198
- :SDL_HapticOpen => [:int],
199
- :SDL_HapticOpened => [:int],
200
- :SDL_HapticIndex => [:pointer],
201
- :SDL_MouseIsHaptic => [],
202
- :SDL_HapticOpenFromMouse => [],
203
- :SDL_JoystickIsHaptic => [:pointer],
204
- :SDL_HapticOpenFromJoystick => [:pointer],
205
- :SDL_HapticClose => [:pointer],
206
- :SDL_HapticNumEffects => [:pointer],
207
- :SDL_HapticNumEffectsPlaying => [:pointer],
208
- :SDL_HapticQuery => [:pointer],
209
- :SDL_HapticNumAxes => [:pointer],
210
- :SDL_HapticEffectSupported => [:pointer, :pointer],
211
- :SDL_HapticNewEffect => [:pointer, :pointer],
212
- :SDL_HapticUpdateEffect => [:pointer, :int, :pointer],
213
- :SDL_HapticRunEffect => [:pointer, :int, :uint],
214
- :SDL_HapticStopEffect => [:pointer, :int],
215
- :SDL_HapticDestroyEffect => [:pointer, :int],
216
- :SDL_HapticGetEffectStatus => [:pointer, :int],
217
- :SDL_HapticSetGain => [:pointer, :int],
218
- :SDL_HapticSetAutocenter => [:pointer, :int],
219
- :SDL_HapticPause => [:pointer],
220
- :SDL_HapticUnpause => [:pointer],
221
- :SDL_HapticStopAll => [:pointer],
222
- :SDL_HapticRumbleSupported => [:pointer],
223
- :SDL_HapticRumbleInit => [:pointer],
224
- :SDL_HapticRumblePlay => [:pointer, :float, :uint],
225
- :SDL_HapticRumbleStop => [:pointer],
226
- }
227
- retvals = {
228
- :SDL_NumHaptics => :int,
229
- :SDL_HapticName => :pointer,
230
- :SDL_HapticOpen => :pointer,
231
- :SDL_HapticOpened => :int,
232
- :SDL_HapticIndex => :int,
233
- :SDL_MouseIsHaptic => :int,
234
- :SDL_HapticOpenFromMouse => :pointer,
235
- :SDL_JoystickIsHaptic => :int,
236
- :SDL_HapticOpenFromJoystick => :pointer,
237
- :SDL_HapticClose => :void,
238
- :SDL_HapticNumEffects => :int,
239
- :SDL_HapticNumEffectsPlaying => :int,
240
- :SDL_HapticQuery => :uint,
241
- :SDL_HapticNumAxes => :int,
242
- :SDL_HapticEffectSupported => :int,
243
- :SDL_HapticNewEffect => :int,
244
- :SDL_HapticUpdateEffect => :int,
245
- :SDL_HapticRunEffect => :int,
246
- :SDL_HapticStopEffect => :int,
247
- :SDL_HapticDestroyEffect => :void,
248
- :SDL_HapticGetEffectStatus => :int,
249
- :SDL_HapticSetGain => :int,
250
- :SDL_HapticSetAutocenter => :int,
251
- :SDL_HapticPause => :int,
252
- :SDL_HapticUnpause => :int,
253
- :SDL_HapticStopAll => :int,
254
- :SDL_HapticRumbleSupported => :int,
255
- :SDL_HapticRumbleInit => :int,
256
- :SDL_HapticRumblePlay => :int,
257
- :SDL_HapticRumbleStop => :int,
258
- }
259
- symbols.each do |sym|
260
- begin
261
- attach_function sym, args[sym], retvals[sym]
262
- rescue FFI::NotFoundError => error
263
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
264
- end
265
- end
266
- end
267
-
268
- end
269
-
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 SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ SDL_HAPTIC_CONSTANT = (1 << 0)
14
+ SDL_HAPTIC_SINE = (1 << 1)
15
+ SDL_HAPTIC_LEFTRIGHT = (1 << 2)
16
+ SDL_HAPTIC_TRIANGLE = (1 << 3)
17
+ SDL_HAPTIC_SAWTOOTHUP = (1 << 4)
18
+ SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5)
19
+ SDL_HAPTIC_RAMP = (1 << 6)
20
+ SDL_HAPTIC_SPRING = (1 << 7)
21
+ SDL_HAPTIC_DAMPER = (1 << 8)
22
+ SDL_HAPTIC_INERTIA = (1 << 9)
23
+ SDL_HAPTIC_FRICTION = (1 << 10)
24
+ SDL_HAPTIC_CUSTOM = (1 << 11)
25
+ SDL_HAPTIC_GAIN = (1 << 12)
26
+ SDL_HAPTIC_AUTOCENTER = (1 << 13)
27
+ SDL_HAPTIC_STATUS = (1 << 14)
28
+ SDL_HAPTIC_PAUSE = (1 << 15)
29
+ SDL_HAPTIC_POLAR = 0
30
+ SDL_HAPTIC_CARTESIAN = 1
31
+ SDL_HAPTIC_SPHERICAL = 2
32
+ SDL_HAPTIC_STEERING_AXIS = 3
33
+ SDL_HAPTIC_INFINITY = 4294967295
34
+
35
+ # Enum
36
+
37
+
38
+ # Typedef
39
+
40
+
41
+ # Struct
42
+
43
+ class SDL_HapticDirection < FFI::Struct
44
+ layout(
45
+ :type, :uchar,
46
+ :dir, [:int, 3],
47
+ )
48
+ end
49
+
50
+ class SDL_HapticConstant < FFI::Struct
51
+ layout(
52
+ :type, :ushort,
53
+ :direction, SDL_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 SDL_HapticPeriodic < FFI::Struct
67
+ layout(
68
+ :type, :ushort,
69
+ :direction, SDL_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 SDL_HapticCondition < FFI::Struct
86
+ layout(
87
+ :type, :ushort,
88
+ :direction, SDL_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 SDL_HapticRamp < FFI::Struct
103
+ layout(
104
+ :type, :ushort,
105
+ :direction, SDL_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 SDL_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 SDL_HapticCustom < FFI::Struct
129
+ layout(
130
+ :type, :ushort,
131
+ :direction, SDL_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 SDL_HapticEffect < FFI::Union
148
+ layout(
149
+ :type, :ushort,
150
+ :constant, SDL_HapticConstant,
151
+ :periodic, SDL_HapticPeriodic,
152
+ :condition, SDL_HapticCondition,
153
+ :ramp, SDL_HapticRamp,
154
+ :leftright, SDL_HapticLeftRight,
155
+ :custom, SDL_HapticCustom,
156
+ )
157
+ end
158
+
159
+
160
+ # Function
161
+
162
+ def self.setup_haptic_symbols()
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
+ args = {
196
+ :SDL_NumHaptics => [],
197
+ :SDL_HapticName => [:int],
198
+ :SDL_HapticOpen => [:int],
199
+ :SDL_HapticOpened => [:int],
200
+ :SDL_HapticIndex => [:pointer],
201
+ :SDL_MouseIsHaptic => [],
202
+ :SDL_HapticOpenFromMouse => [],
203
+ :SDL_JoystickIsHaptic => [:pointer],
204
+ :SDL_HapticOpenFromJoystick => [:pointer],
205
+ :SDL_HapticClose => [:pointer],
206
+ :SDL_HapticNumEffects => [:pointer],
207
+ :SDL_HapticNumEffectsPlaying => [:pointer],
208
+ :SDL_HapticQuery => [:pointer],
209
+ :SDL_HapticNumAxes => [:pointer],
210
+ :SDL_HapticEffectSupported => [:pointer, :pointer],
211
+ :SDL_HapticNewEffect => [:pointer, :pointer],
212
+ :SDL_HapticUpdateEffect => [:pointer, :int, :pointer],
213
+ :SDL_HapticRunEffect => [:pointer, :int, :uint],
214
+ :SDL_HapticStopEffect => [:pointer, :int],
215
+ :SDL_HapticDestroyEffect => [:pointer, :int],
216
+ :SDL_HapticGetEffectStatus => [:pointer, :int],
217
+ :SDL_HapticSetGain => [:pointer, :int],
218
+ :SDL_HapticSetAutocenter => [:pointer, :int],
219
+ :SDL_HapticPause => [:pointer],
220
+ :SDL_HapticUnpause => [:pointer],
221
+ :SDL_HapticStopAll => [:pointer],
222
+ :SDL_HapticRumbleSupported => [:pointer],
223
+ :SDL_HapticRumbleInit => [:pointer],
224
+ :SDL_HapticRumblePlay => [:pointer, :float, :uint],
225
+ :SDL_HapticRumbleStop => [:pointer],
226
+ }
227
+ retvals = {
228
+ :SDL_NumHaptics => :int,
229
+ :SDL_HapticName => :pointer,
230
+ :SDL_HapticOpen => :pointer,
231
+ :SDL_HapticOpened => :int,
232
+ :SDL_HapticIndex => :int,
233
+ :SDL_MouseIsHaptic => :int,
234
+ :SDL_HapticOpenFromMouse => :pointer,
235
+ :SDL_JoystickIsHaptic => :int,
236
+ :SDL_HapticOpenFromJoystick => :pointer,
237
+ :SDL_HapticClose => :void,
238
+ :SDL_HapticNumEffects => :int,
239
+ :SDL_HapticNumEffectsPlaying => :int,
240
+ :SDL_HapticQuery => :uint,
241
+ :SDL_HapticNumAxes => :int,
242
+ :SDL_HapticEffectSupported => :int,
243
+ :SDL_HapticNewEffect => :int,
244
+ :SDL_HapticUpdateEffect => :int,
245
+ :SDL_HapticRunEffect => :int,
246
+ :SDL_HapticStopEffect => :int,
247
+ :SDL_HapticDestroyEffect => :void,
248
+ :SDL_HapticGetEffectStatus => :int,
249
+ :SDL_HapticSetGain => :int,
250
+ :SDL_HapticSetAutocenter => :int,
251
+ :SDL_HapticPause => :int,
252
+ :SDL_HapticUnpause => :int,
253
+ :SDL_HapticStopAll => :int,
254
+ :SDL_HapticRumbleSupported => :int,
255
+ :SDL_HapticRumbleInit => :int,
256
+ :SDL_HapticRumblePlay => :int,
257
+ :SDL_HapticRumbleStop => :int,
258
+ }
259
+ symbols.each do |sym|
260
+ begin
261
+ attach_function sym, args[sym], retvals[sym]
262
+ rescue FFI::NotFoundError => error
263
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
264
+ end
265
+ end
266
+ end
267
+
268
+ end
269
+
@@ -0,0 +1,118 @@
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 SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+
20
+ # Struct
21
+
22
+ class SDL_hid_device_info < FFI::Struct
23
+ layout(
24
+ :path, :pointer,
25
+ :vendor_id, :ushort,
26
+ :product_id, :ushort,
27
+ :serial_number, :pointer,
28
+ :release_number, :ushort,
29
+ :manufacturer_string, :pointer,
30
+ :product_string, :pointer,
31
+ :usage_page, :ushort,
32
+ :usage, :ushort,
33
+ :interface_number, :int,
34
+ :interface_class, :int,
35
+ :interface_subclass, :int,
36
+ :interface_protocol, :int,
37
+ :next, :pointer,
38
+ )
39
+ end
40
+
41
+
42
+ # Function
43
+
44
+ def self.setup_hidapi_symbols()
45
+ symbols = [
46
+ :SDL_hid_init,
47
+ :SDL_hid_exit,
48
+ :SDL_hid_device_change_count,
49
+ :SDL_hid_enumerate,
50
+ :SDL_hid_free_enumeration,
51
+ :SDL_hid_open,
52
+ :SDL_hid_open_path,
53
+ :SDL_hid_write,
54
+ :SDL_hid_read_timeout,
55
+ :SDL_hid_read,
56
+ :SDL_hid_set_nonblocking,
57
+ :SDL_hid_send_feature_report,
58
+ :SDL_hid_get_feature_report,
59
+ :SDL_hid_close,
60
+ :SDL_hid_get_manufacturer_string,
61
+ :SDL_hid_get_product_string,
62
+ :SDL_hid_get_serial_number_string,
63
+ :SDL_hid_get_indexed_string,
64
+ :SDL_hid_ble_scan,
65
+ ]
66
+ args = {
67
+ :SDL_hid_init => [],
68
+ :SDL_hid_exit => [],
69
+ :SDL_hid_device_change_count => [],
70
+ :SDL_hid_enumerate => [:ushort, :ushort],
71
+ :SDL_hid_free_enumeration => [:pointer],
72
+ :SDL_hid_open => [:ushort, :ushort, :pointer],
73
+ :SDL_hid_open_path => [:pointer, :int],
74
+ :SDL_hid_write => [:pointer, :pointer, :int],
75
+ :SDL_hid_read_timeout => [:pointer, :pointer, :int, :int],
76
+ :SDL_hid_read => [:pointer, :pointer, :int],
77
+ :SDL_hid_set_nonblocking => [:pointer, :int],
78
+ :SDL_hid_send_feature_report => [:pointer, :pointer, :int],
79
+ :SDL_hid_get_feature_report => [:pointer, :pointer, :int],
80
+ :SDL_hid_close => [:pointer],
81
+ :SDL_hid_get_manufacturer_string => [:pointer, :pointer, :int],
82
+ :SDL_hid_get_product_string => [:pointer, :pointer, :int],
83
+ :SDL_hid_get_serial_number_string => [:pointer, :pointer, :int],
84
+ :SDL_hid_get_indexed_string => [:pointer, :int, :pointer, :int],
85
+ :SDL_hid_ble_scan => [:int],
86
+ }
87
+ retvals = {
88
+ :SDL_hid_init => :int,
89
+ :SDL_hid_exit => :int,
90
+ :SDL_hid_device_change_count => :uint,
91
+ :SDL_hid_enumerate => :pointer,
92
+ :SDL_hid_free_enumeration => :void,
93
+ :SDL_hid_open => :pointer,
94
+ :SDL_hid_open_path => :pointer,
95
+ :SDL_hid_write => :int,
96
+ :SDL_hid_read_timeout => :int,
97
+ :SDL_hid_read => :int,
98
+ :SDL_hid_set_nonblocking => :int,
99
+ :SDL_hid_send_feature_report => :int,
100
+ :SDL_hid_get_feature_report => :int,
101
+ :SDL_hid_close => :void,
102
+ :SDL_hid_get_manufacturer_string => :int,
103
+ :SDL_hid_get_product_string => :int,
104
+ :SDL_hid_get_serial_number_string => :int,
105
+ :SDL_hid_get_indexed_string => :int,
106
+ :SDL_hid_ble_scan => :void,
107
+ }
108
+ symbols.each do |sym|
109
+ begin
110
+ attach_function sym, args[sym], retvals[sym]
111
+ rescue FFI::NotFoundError => error
112
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
113
+ end
114
+ end
115
+ end
116
+
117
+ end
118
+