sdl2-bindings 0.0.8 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +124 -92
  3. data/LICENSE.txt +1 -1
  4. data/README.md +77 -53
  5. data/lib/sdl2.rb +131 -172
  6. data/lib/sdl2_audio.rb +261 -222
  7. data/lib/sdl2_blendmode.rb +72 -69
  8. data/lib/sdl2_clipboard.rb +56 -51
  9. data/lib/sdl2_cpuinfo.rb +129 -106
  10. data/lib/sdl2_error.rb +71 -64
  11. data/lib/sdl2_events.rb +564 -533
  12. data/lib/sdl2_filesystem.rb +52 -48
  13. data/lib/sdl2_framerate.rb +74 -67
  14. data/lib/sdl2_gamecontroller.rb +329 -274
  15. data/lib/sdl2_gesture.rb +61 -55
  16. data/lib/sdl2_gfxPrimitives.rb +283 -222
  17. data/lib/sdl2_haptic.rb +301 -269
  18. data/lib/sdl2_hidapi.rb +139 -118
  19. data/lib/sdl2_hints.rb +221 -197
  20. data/lib/sdl2_image.rb +232 -185
  21. data/lib/sdl2_imageFilter.rb +164 -132
  22. data/lib/sdl2_joystick.rb +294 -239
  23. data/lib/sdl2_keyboard.rb +125 -99
  24. data/lib/sdl2_keycode.rb +307 -305
  25. data/lib/sdl2_log.rb +131 -115
  26. data/lib/sdl2_main.rb +74 -67
  27. data/lib/sdl2_messagebox.rb +102 -98
  28. data/lib/sdl2_misc.rb +48 -45
  29. data/lib/sdl2_mixer.rb +392 -317
  30. data/lib/sdl2_mouse.rb +136 -117
  31. data/lib/sdl2_pixels.rb +240 -224
  32. data/lib/sdl2_platform.rb +48 -45
  33. data/lib/sdl2_power.rb +54 -51
  34. data/lib/sdl2_rect.rb +145 -102
  35. data/lib/sdl2_render.rb +408 -322
  36. data/lib/sdl2_rotozoom.rb +76 -66
  37. data/lib/sdl2_rwops.rb +238 -208
  38. data/lib/sdl2_scancode.rb +289 -287
  39. data/lib/sdl2_sensor.rb +115 -97
  40. data/lib/sdl2_shape.rb +83 -77
  41. data/lib/sdl2_sound.rb +154 -0
  42. data/lib/sdl2_stdinc.rb +556 -439
  43. data/lib/sdl2_surface.rb +229 -188
  44. data/lib/sdl2_syswm.rb +160 -156
  45. data/lib/sdl2_timer.rb +74 -65
  46. data/lib/sdl2_touch.rb +86 -75
  47. data/lib/sdl2_ttf.rb +358 -202
  48. data/lib/sdl2_version.rb +67 -62
  49. data/lib/sdl2_video.rb +540 -446
  50. data/lib/sdl2_vulkan.rb +72 -64
  51. metadata +19 -4
@@ -1,274 +1,329 @@
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
- require_relative 'sdl2_joystick'
9
-
10
- module SDL2
11
- extend FFI::Library
12
- # Define/Macro
13
-
14
-
15
- # Enum
16
-
17
- SDL_CONTROLLER_TYPE_UNKNOWN = 0
18
- SDL_CONTROLLER_TYPE_XBOX360 = 1
19
- SDL_CONTROLLER_TYPE_XBOXONE = 2
20
- SDL_CONTROLLER_TYPE_PS3 = 3
21
- SDL_CONTROLLER_TYPE_PS4 = 4
22
- SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO = 5
23
- SDL_CONTROLLER_TYPE_VIRTUAL = 6
24
- SDL_CONTROLLER_TYPE_PS5 = 7
25
- SDL_CONTROLLER_TYPE_AMAZON_LUNA = 8
26
- SDL_CONTROLLER_TYPE_GOOGLE_STADIA = 9
27
- SDL_CONTROLLER_BINDTYPE_NONE = 0
28
- SDL_CONTROLLER_BINDTYPE_BUTTON = 1
29
- SDL_CONTROLLER_BINDTYPE_AXIS = 2
30
- SDL_CONTROLLER_BINDTYPE_HAT = 3
31
- SDL_CONTROLLER_AXIS_INVALID = -1
32
- SDL_CONTROLLER_AXIS_LEFTX = 0
33
- SDL_CONTROLLER_AXIS_LEFTY = 1
34
- SDL_CONTROLLER_AXIS_RIGHTX = 2
35
- SDL_CONTROLLER_AXIS_RIGHTY = 3
36
- SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
37
- SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
38
- SDL_CONTROLLER_AXIS_MAX = 6
39
- SDL_CONTROLLER_BUTTON_INVALID = -1
40
- SDL_CONTROLLER_BUTTON_A = 0
41
- SDL_CONTROLLER_BUTTON_B = 1
42
- SDL_CONTROLLER_BUTTON_X = 2
43
- SDL_CONTROLLER_BUTTON_Y = 3
44
- SDL_CONTROLLER_BUTTON_BACK = 4
45
- SDL_CONTROLLER_BUTTON_GUIDE = 5
46
- SDL_CONTROLLER_BUTTON_START = 6
47
- SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
48
- SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
49
- SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
50
- SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
51
- SDL_CONTROLLER_BUTTON_DPAD_UP = 11
52
- SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
53
- SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
54
- SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
55
- SDL_CONTROLLER_BUTTON_MISC1 = 15
56
- SDL_CONTROLLER_BUTTON_PADDLE1 = 16
57
- SDL_CONTROLLER_BUTTON_PADDLE2 = 17
58
- SDL_CONTROLLER_BUTTON_PADDLE3 = 18
59
- SDL_CONTROLLER_BUTTON_PADDLE4 = 19
60
- SDL_CONTROLLER_BUTTON_TOUCHPAD = 20
61
- SDL_CONTROLLER_BUTTON_MAX = 21
62
-
63
- # Typedef
64
-
65
-
66
- class SDL_GameControllerButtonBind_value_hat < FFI::Struct
67
- layout(
68
- :hat, :int,
69
- :hat_mask, :int,
70
- )
71
- end
72
-
73
- class SDL_GameControllerButtonBind_value < FFI::Struct
74
- layout(
75
- :button, :int,
76
- :axis, :int,
77
- :hat, SDL_GameControllerButtonBind_value_hat.by_value,
78
- )
79
- end
80
-
81
- class SDL_GameControllerButtonBind < FFI::Struct
82
- layout(
83
- :bindType, :int,
84
- :value, SDL_GameControllerButtonBind_value.by_value,
85
- )
86
- end
87
-
88
- typedef :int, :SDL_GameControllerType
89
- typedef :int, :SDL_GameControllerBindType
90
- typedef :int, :SDL_GameControllerAxis
91
- typedef :int, :SDL_GameControllerButton
92
-
93
- # Struct
94
-
95
-
96
- # Function
97
-
98
- def self.setup_gamecontroller_symbols()
99
- symbols = [
100
- :SDL_GameControllerAddMappingsFromRW,
101
- :SDL_GameControllerAddMapping,
102
- :SDL_GameControllerNumMappings,
103
- :SDL_GameControllerMappingForIndex,
104
- :SDL_GameControllerMappingForGUID,
105
- :SDL_GameControllerMapping,
106
- :SDL_IsGameController,
107
- :SDL_GameControllerNameForIndex,
108
- :SDL_GameControllerTypeForIndex,
109
- :SDL_GameControllerMappingForDeviceIndex,
110
- :SDL_GameControllerOpen,
111
- :SDL_GameControllerFromInstanceID,
112
- :SDL_GameControllerFromPlayerIndex,
113
- :SDL_GameControllerName,
114
- :SDL_GameControllerGetType,
115
- :SDL_GameControllerGetPlayerIndex,
116
- :SDL_GameControllerSetPlayerIndex,
117
- :SDL_GameControllerGetVendor,
118
- :SDL_GameControllerGetProduct,
119
- :SDL_GameControllerGetProductVersion,
120
- :SDL_GameControllerGetSerial,
121
- :SDL_GameControllerGetAttached,
122
- :SDL_GameControllerGetJoystick,
123
- :SDL_GameControllerEventState,
124
- :SDL_GameControllerUpdate,
125
- :SDL_GameControllerGetAxisFromString,
126
- :SDL_GameControllerGetStringForAxis,
127
- :SDL_GameControllerGetBindForAxis,
128
- :SDL_GameControllerHasAxis,
129
- :SDL_GameControllerGetAxis,
130
- :SDL_GameControllerGetButtonFromString,
131
- :SDL_GameControllerGetStringForButton,
132
- :SDL_GameControllerGetBindForButton,
133
- :SDL_GameControllerHasButton,
134
- :SDL_GameControllerGetButton,
135
- :SDL_GameControllerGetNumTouchpads,
136
- :SDL_GameControllerGetNumTouchpadFingers,
137
- :SDL_GameControllerGetTouchpadFinger,
138
- :SDL_GameControllerHasSensor,
139
- :SDL_GameControllerSetSensorEnabled,
140
- :SDL_GameControllerIsSensorEnabled,
141
- :SDL_GameControllerGetSensorDataRate,
142
- :SDL_GameControllerGetSensorData,
143
- :SDL_GameControllerRumble,
144
- :SDL_GameControllerRumbleTriggers,
145
- :SDL_GameControllerHasLED,
146
- :SDL_GameControllerHasRumble,
147
- :SDL_GameControllerHasRumbleTriggers,
148
- :SDL_GameControllerSetLED,
149
- :SDL_GameControllerSendEffect,
150
- :SDL_GameControllerClose,
151
- :SDL_GameControllerGetAppleSFSymbolsNameForButton,
152
- :SDL_GameControllerGetAppleSFSymbolsNameForAxis,
153
- ]
154
- args = {
155
- :SDL_GameControllerAddMappingsFromRW => [:pointer, :int],
156
- :SDL_GameControllerAddMapping => [:pointer],
157
- :SDL_GameControllerNumMappings => [],
158
- :SDL_GameControllerMappingForIndex => [:int],
159
- :SDL_GameControllerMappingForGUID => [SDL_JoystickGUID.by_value],
160
- :SDL_GameControllerMapping => [:pointer],
161
- :SDL_IsGameController => [:int],
162
- :SDL_GameControllerNameForIndex => [:int],
163
- :SDL_GameControllerTypeForIndex => [:int],
164
- :SDL_GameControllerMappingForDeviceIndex => [:int],
165
- :SDL_GameControllerOpen => [:int],
166
- :SDL_GameControllerFromInstanceID => [:int],
167
- :SDL_GameControllerFromPlayerIndex => [:int],
168
- :SDL_GameControllerName => [:pointer],
169
- :SDL_GameControllerGetType => [:pointer],
170
- :SDL_GameControllerGetPlayerIndex => [:pointer],
171
- :SDL_GameControllerSetPlayerIndex => [:pointer, :int],
172
- :SDL_GameControllerGetVendor => [:pointer],
173
- :SDL_GameControllerGetProduct => [:pointer],
174
- :SDL_GameControllerGetProductVersion => [:pointer],
175
- :SDL_GameControllerGetSerial => [:pointer],
176
- :SDL_GameControllerGetAttached => [:pointer],
177
- :SDL_GameControllerGetJoystick => [:pointer],
178
- :SDL_GameControllerEventState => [:int],
179
- :SDL_GameControllerUpdate => [],
180
- :SDL_GameControllerGetAxisFromString => [:pointer],
181
- :SDL_GameControllerGetStringForAxis => [:int],
182
- :SDL_GameControllerGetBindForAxis => [:pointer, :int],
183
- :SDL_GameControllerHasAxis => [:pointer, :int],
184
- :SDL_GameControllerGetAxis => [:pointer, :int],
185
- :SDL_GameControllerGetButtonFromString => [:pointer],
186
- :SDL_GameControllerGetStringForButton => [:int],
187
- :SDL_GameControllerGetBindForButton => [:pointer, :int],
188
- :SDL_GameControllerHasButton => [:pointer, :int],
189
- :SDL_GameControllerGetButton => [:pointer, :int],
190
- :SDL_GameControllerGetNumTouchpads => [:pointer],
191
- :SDL_GameControllerGetNumTouchpadFingers => [:pointer, :int],
192
- :SDL_GameControllerGetTouchpadFinger => [:pointer, :int, :int, :pointer, :pointer, :pointer, :pointer],
193
- :SDL_GameControllerHasSensor => [:pointer, :int],
194
- :SDL_GameControllerSetSensorEnabled => [:pointer, :int, :int],
195
- :SDL_GameControllerIsSensorEnabled => [:pointer, :int],
196
- :SDL_GameControllerGetSensorDataRate => [:pointer, :int],
197
- :SDL_GameControllerGetSensorData => [:pointer, :int, :pointer, :int],
198
- :SDL_GameControllerRumble => [:pointer, :ushort, :ushort, :uint],
199
- :SDL_GameControllerRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
200
- :SDL_GameControllerHasLED => [:pointer],
201
- :SDL_GameControllerHasRumble => [:pointer],
202
- :SDL_GameControllerHasRumbleTriggers => [:pointer],
203
- :SDL_GameControllerSetLED => [:pointer, :uchar, :uchar, :uchar],
204
- :SDL_GameControllerSendEffect => [:pointer, :pointer, :int],
205
- :SDL_GameControllerClose => [:pointer],
206
- :SDL_GameControllerGetAppleSFSymbolsNameForButton => [:pointer, :int],
207
- :SDL_GameControllerGetAppleSFSymbolsNameForAxis => [:pointer, :int],
208
- }
209
- retvals = {
210
- :SDL_GameControllerAddMappingsFromRW => :int,
211
- :SDL_GameControllerAddMapping => :int,
212
- :SDL_GameControllerNumMappings => :int,
213
- :SDL_GameControllerMappingForIndex => :pointer,
214
- :SDL_GameControllerMappingForGUID => :pointer,
215
- :SDL_GameControllerMapping => :pointer,
216
- :SDL_IsGameController => :int,
217
- :SDL_GameControllerNameForIndex => :pointer,
218
- :SDL_GameControllerTypeForIndex => :int,
219
- :SDL_GameControllerMappingForDeviceIndex => :pointer,
220
- :SDL_GameControllerOpen => :pointer,
221
- :SDL_GameControllerFromInstanceID => :pointer,
222
- :SDL_GameControllerFromPlayerIndex => :pointer,
223
- :SDL_GameControllerName => :pointer,
224
- :SDL_GameControllerGetType => :int,
225
- :SDL_GameControllerGetPlayerIndex => :int,
226
- :SDL_GameControllerSetPlayerIndex => :void,
227
- :SDL_GameControllerGetVendor => :ushort,
228
- :SDL_GameControllerGetProduct => :ushort,
229
- :SDL_GameControllerGetProductVersion => :ushort,
230
- :SDL_GameControllerGetSerial => :pointer,
231
- :SDL_GameControllerGetAttached => :int,
232
- :SDL_GameControllerGetJoystick => :pointer,
233
- :SDL_GameControllerEventState => :int,
234
- :SDL_GameControllerUpdate => :void,
235
- :SDL_GameControllerGetAxisFromString => :int,
236
- :SDL_GameControllerGetStringForAxis => :pointer,
237
- :SDL_GameControllerGetBindForAxis => SDL_GameControllerButtonBind,
238
- :SDL_GameControllerHasAxis => :int,
239
- :SDL_GameControllerGetAxis => :short,
240
- :SDL_GameControllerGetButtonFromString => :int,
241
- :SDL_GameControllerGetStringForButton => :pointer,
242
- :SDL_GameControllerGetBindForButton => SDL_GameControllerButtonBind,
243
- :SDL_GameControllerHasButton => :int,
244
- :SDL_GameControllerGetButton => :uchar,
245
- :SDL_GameControllerGetNumTouchpads => :int,
246
- :SDL_GameControllerGetNumTouchpadFingers => :int,
247
- :SDL_GameControllerGetTouchpadFinger => :int,
248
- :SDL_GameControllerHasSensor => :int,
249
- :SDL_GameControllerSetSensorEnabled => :int,
250
- :SDL_GameControllerIsSensorEnabled => :int,
251
- :SDL_GameControllerGetSensorDataRate => :float,
252
- :SDL_GameControllerGetSensorData => :int,
253
- :SDL_GameControllerRumble => :int,
254
- :SDL_GameControllerRumbleTriggers => :int,
255
- :SDL_GameControllerHasLED => :int,
256
- :SDL_GameControllerHasRumble => :int,
257
- :SDL_GameControllerHasRumbleTriggers => :int,
258
- :SDL_GameControllerSetLED => :int,
259
- :SDL_GameControllerSendEffect => :int,
260
- :SDL_GameControllerClose => :void,
261
- :SDL_GameControllerGetAppleSFSymbolsNameForButton => :pointer,
262
- :SDL_GameControllerGetAppleSFSymbolsNameForAxis => :pointer,
263
- }
264
- symbols.each do |sym|
265
- begin
266
- attach_function sym, args[sym], retvals[sym]
267
- rescue FFI::NotFoundError => error
268
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
269
- end
270
- end
271
- end
272
-
273
- end
274
-
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
+ require_relative 'sdl2_joystick'
9
+
10
+ module SDL
11
+ extend FFI::Library
12
+ # Define/Macro
13
+
14
+
15
+ # Enum
16
+
17
+ CONTROLLER_TYPE_UNKNOWN = 0
18
+ CONTROLLER_TYPE_XBOX360 = 1
19
+ CONTROLLER_TYPE_XBOXONE = 2
20
+ CONTROLLER_TYPE_PS3 = 3
21
+ CONTROLLER_TYPE_PS4 = 4
22
+ CONTROLLER_TYPE_NINTENDO_SWITCH_PRO = 5
23
+ CONTROLLER_TYPE_VIRTUAL = 6
24
+ CONTROLLER_TYPE_PS5 = 7
25
+ CONTROLLER_TYPE_AMAZON_LUNA = 8
26
+ CONTROLLER_TYPE_GOOGLE_STADIA = 9
27
+ CONTROLLER_BINDTYPE_NONE = 0
28
+ CONTROLLER_BINDTYPE_BUTTON = 1
29
+ CONTROLLER_BINDTYPE_AXIS = 2
30
+ CONTROLLER_BINDTYPE_HAT = 3
31
+ CONTROLLER_AXIS_INVALID = -1
32
+ CONTROLLER_AXIS_LEFTX = 0
33
+ CONTROLLER_AXIS_LEFTY = 1
34
+ CONTROLLER_AXIS_RIGHTX = 2
35
+ CONTROLLER_AXIS_RIGHTY = 3
36
+ CONTROLLER_AXIS_TRIGGERLEFT = 4
37
+ CONTROLLER_AXIS_TRIGGERRIGHT = 5
38
+ CONTROLLER_AXIS_MAX = 6
39
+ CONTROLLER_BUTTON_INVALID = -1
40
+ CONTROLLER_BUTTON_A = 0
41
+ CONTROLLER_BUTTON_B = 1
42
+ CONTROLLER_BUTTON_X = 2
43
+ CONTROLLER_BUTTON_Y = 3
44
+ CONTROLLER_BUTTON_BACK = 4
45
+ CONTROLLER_BUTTON_GUIDE = 5
46
+ CONTROLLER_BUTTON_START = 6
47
+ CONTROLLER_BUTTON_LEFTSTICK = 7
48
+ CONTROLLER_BUTTON_RIGHTSTICK = 8
49
+ CONTROLLER_BUTTON_LEFTSHOULDER = 9
50
+ CONTROLLER_BUTTON_RIGHTSHOULDER = 10
51
+ CONTROLLER_BUTTON_DPAD_UP = 11
52
+ CONTROLLER_BUTTON_DPAD_DOWN = 12
53
+ CONTROLLER_BUTTON_DPAD_LEFT = 13
54
+ CONTROLLER_BUTTON_DPAD_RIGHT = 14
55
+ CONTROLLER_BUTTON_MISC1 = 15
56
+ CONTROLLER_BUTTON_PADDLE1 = 16
57
+ CONTROLLER_BUTTON_PADDLE2 = 17
58
+ CONTROLLER_BUTTON_PADDLE3 = 18
59
+ CONTROLLER_BUTTON_PADDLE4 = 19
60
+ CONTROLLER_BUTTON_TOUCHPAD = 20
61
+ CONTROLLER_BUTTON_MAX = 21
62
+
63
+ # Typedef
64
+
65
+
66
+ class GameControllerButtonBind_value_hat < FFI::Struct
67
+ layout(
68
+ :hat, :int,
69
+ :hat_mask, :int,
70
+ )
71
+ end
72
+
73
+ class GameControllerButtonBind_value < FFI::Struct
74
+ layout(
75
+ :button, :int,
76
+ :axis, :int,
77
+ :hat, GameControllerButtonBind_value_hat,
78
+ )
79
+ end
80
+
81
+ class GameControllerButtonBind < FFI::Struct
82
+ layout(
83
+ :bindType, :int,
84
+ :value, GameControllerButtonBind_value,
85
+ )
86
+ end
87
+
88
+ typedef :int, :SDL_GameControllerType
89
+ typedef :int, :SDL_GameControllerBindType
90
+ typedef :int, :SDL_GameControllerAxis
91
+ typedef :int, :SDL_GameControllerButton
92
+
93
+ # Struct
94
+
95
+
96
+ # Function
97
+
98
+ def self.setup_gamecontroller_symbols(output_error = false)
99
+ symbols = [
100
+ :SDL_GameControllerAddMappingsFromRW,
101
+ :SDL_GameControllerAddMapping,
102
+ :SDL_GameControllerNumMappings,
103
+ :SDL_GameControllerMappingForIndex,
104
+ :SDL_GameControllerMappingForGUID,
105
+ :SDL_GameControllerMapping,
106
+ :SDL_IsGameController,
107
+ :SDL_GameControllerNameForIndex,
108
+ :SDL_GameControllerTypeForIndex,
109
+ :SDL_GameControllerMappingForDeviceIndex,
110
+ :SDL_GameControllerOpen,
111
+ :SDL_GameControllerFromInstanceID,
112
+ :SDL_GameControllerFromPlayerIndex,
113
+ :SDL_GameControllerName,
114
+ :SDL_GameControllerGetType,
115
+ :SDL_GameControllerGetPlayerIndex,
116
+ :SDL_GameControllerSetPlayerIndex,
117
+ :SDL_GameControllerGetVendor,
118
+ :SDL_GameControllerGetProduct,
119
+ :SDL_GameControllerGetProductVersion,
120
+ :SDL_GameControllerGetSerial,
121
+ :SDL_GameControllerGetAttached,
122
+ :SDL_GameControllerGetJoystick,
123
+ :SDL_GameControllerEventState,
124
+ :SDL_GameControllerUpdate,
125
+ :SDL_GameControllerGetAxisFromString,
126
+ :SDL_GameControllerGetStringForAxis,
127
+ :SDL_GameControllerGetBindForAxis,
128
+ :SDL_GameControllerHasAxis,
129
+ :SDL_GameControllerGetAxis,
130
+ :SDL_GameControllerGetButtonFromString,
131
+ :SDL_GameControllerGetStringForButton,
132
+ :SDL_GameControllerGetBindForButton,
133
+ :SDL_GameControllerHasButton,
134
+ :SDL_GameControllerGetButton,
135
+ :SDL_GameControllerGetNumTouchpads,
136
+ :SDL_GameControllerGetNumTouchpadFingers,
137
+ :SDL_GameControllerGetTouchpadFinger,
138
+ :SDL_GameControllerHasSensor,
139
+ :SDL_GameControllerSetSensorEnabled,
140
+ :SDL_GameControllerIsSensorEnabled,
141
+ :SDL_GameControllerGetSensorDataRate,
142
+ :SDL_GameControllerGetSensorData,
143
+ :SDL_GameControllerRumble,
144
+ :SDL_GameControllerRumbleTriggers,
145
+ :SDL_GameControllerHasLED,
146
+ :SDL_GameControllerHasRumble,
147
+ :SDL_GameControllerHasRumbleTriggers,
148
+ :SDL_GameControllerSetLED,
149
+ :SDL_GameControllerSendEffect,
150
+ :SDL_GameControllerClose,
151
+ :SDL_GameControllerGetAppleSFSymbolsNameForButton,
152
+ :SDL_GameControllerGetAppleSFSymbolsNameForAxis,
153
+ ]
154
+ apis = {
155
+ :SDL_GameControllerAddMappingsFromRW => :GameControllerAddMappingsFromRW,
156
+ :SDL_GameControllerAddMapping => :GameControllerAddMapping,
157
+ :SDL_GameControllerNumMappings => :GameControllerNumMappings,
158
+ :SDL_GameControllerMappingForIndex => :GameControllerMappingForIndex,
159
+ :SDL_GameControllerMappingForGUID => :GameControllerMappingForGUID,
160
+ :SDL_GameControllerMapping => :GameControllerMapping,
161
+ :SDL_IsGameController => :IsGameController,
162
+ :SDL_GameControllerNameForIndex => :GameControllerNameForIndex,
163
+ :SDL_GameControllerTypeForIndex => :GameControllerTypeForIndex,
164
+ :SDL_GameControllerMappingForDeviceIndex => :GameControllerMappingForDeviceIndex,
165
+ :SDL_GameControllerOpen => :GameControllerOpen,
166
+ :SDL_GameControllerFromInstanceID => :GameControllerFromInstanceID,
167
+ :SDL_GameControllerFromPlayerIndex => :GameControllerFromPlayerIndex,
168
+ :SDL_GameControllerName => :GameControllerName,
169
+ :SDL_GameControllerGetType => :GameControllerGetType,
170
+ :SDL_GameControllerGetPlayerIndex => :GameControllerGetPlayerIndex,
171
+ :SDL_GameControllerSetPlayerIndex => :GameControllerSetPlayerIndex,
172
+ :SDL_GameControllerGetVendor => :GameControllerGetVendor,
173
+ :SDL_GameControllerGetProduct => :GameControllerGetProduct,
174
+ :SDL_GameControllerGetProductVersion => :GameControllerGetProductVersion,
175
+ :SDL_GameControllerGetSerial => :GameControllerGetSerial,
176
+ :SDL_GameControllerGetAttached => :GameControllerGetAttached,
177
+ :SDL_GameControllerGetJoystick => :GameControllerGetJoystick,
178
+ :SDL_GameControllerEventState => :GameControllerEventState,
179
+ :SDL_GameControllerUpdate => :GameControllerUpdate,
180
+ :SDL_GameControllerGetAxisFromString => :GameControllerGetAxisFromString,
181
+ :SDL_GameControllerGetStringForAxis => :GameControllerGetStringForAxis,
182
+ :SDL_GameControllerGetBindForAxis => :GameControllerGetBindForAxis,
183
+ :SDL_GameControllerHasAxis => :GameControllerHasAxis,
184
+ :SDL_GameControllerGetAxis => :GameControllerGetAxis,
185
+ :SDL_GameControllerGetButtonFromString => :GameControllerGetButtonFromString,
186
+ :SDL_GameControllerGetStringForButton => :GameControllerGetStringForButton,
187
+ :SDL_GameControllerGetBindForButton => :GameControllerGetBindForButton,
188
+ :SDL_GameControllerHasButton => :GameControllerHasButton,
189
+ :SDL_GameControllerGetButton => :GameControllerGetButton,
190
+ :SDL_GameControllerGetNumTouchpads => :GameControllerGetNumTouchpads,
191
+ :SDL_GameControllerGetNumTouchpadFingers => :GameControllerGetNumTouchpadFingers,
192
+ :SDL_GameControllerGetTouchpadFinger => :GameControllerGetTouchpadFinger,
193
+ :SDL_GameControllerHasSensor => :GameControllerHasSensor,
194
+ :SDL_GameControllerSetSensorEnabled => :GameControllerSetSensorEnabled,
195
+ :SDL_GameControllerIsSensorEnabled => :GameControllerIsSensorEnabled,
196
+ :SDL_GameControllerGetSensorDataRate => :GameControllerGetSensorDataRate,
197
+ :SDL_GameControllerGetSensorData => :GameControllerGetSensorData,
198
+ :SDL_GameControllerRumble => :GameControllerRumble,
199
+ :SDL_GameControllerRumbleTriggers => :GameControllerRumbleTriggers,
200
+ :SDL_GameControllerHasLED => :GameControllerHasLED,
201
+ :SDL_GameControllerHasRumble => :GameControllerHasRumble,
202
+ :SDL_GameControllerHasRumbleTriggers => :GameControllerHasRumbleTriggers,
203
+ :SDL_GameControllerSetLED => :GameControllerSetLED,
204
+ :SDL_GameControllerSendEffect => :GameControllerSendEffect,
205
+ :SDL_GameControllerClose => :GameControllerClose,
206
+ :SDL_GameControllerGetAppleSFSymbolsNameForButton => :GameControllerGetAppleSFSymbolsNameForButton,
207
+ :SDL_GameControllerGetAppleSFSymbolsNameForAxis => :GameControllerGetAppleSFSymbolsNameForAxis,
208
+ }
209
+ args = {
210
+ :SDL_GameControllerAddMappingsFromRW => [:pointer, :int],
211
+ :SDL_GameControllerAddMapping => [:pointer],
212
+ :SDL_GameControllerNumMappings => [],
213
+ :SDL_GameControllerMappingForIndex => [:int],
214
+ :SDL_GameControllerMappingForGUID => [JoystickGUID.by_value],
215
+ :SDL_GameControllerMapping => [:pointer],
216
+ :SDL_IsGameController => [:int],
217
+ :SDL_GameControllerNameForIndex => [:int],
218
+ :SDL_GameControllerTypeForIndex => [:int],
219
+ :SDL_GameControllerMappingForDeviceIndex => [:int],
220
+ :SDL_GameControllerOpen => [:int],
221
+ :SDL_GameControllerFromInstanceID => [:int],
222
+ :SDL_GameControllerFromPlayerIndex => [:int],
223
+ :SDL_GameControllerName => [:pointer],
224
+ :SDL_GameControllerGetType => [:pointer],
225
+ :SDL_GameControllerGetPlayerIndex => [:pointer],
226
+ :SDL_GameControllerSetPlayerIndex => [:pointer, :int],
227
+ :SDL_GameControllerGetVendor => [:pointer],
228
+ :SDL_GameControllerGetProduct => [:pointer],
229
+ :SDL_GameControllerGetProductVersion => [:pointer],
230
+ :SDL_GameControllerGetSerial => [:pointer],
231
+ :SDL_GameControllerGetAttached => [:pointer],
232
+ :SDL_GameControllerGetJoystick => [:pointer],
233
+ :SDL_GameControllerEventState => [:int],
234
+ :SDL_GameControllerUpdate => [],
235
+ :SDL_GameControllerGetAxisFromString => [:pointer],
236
+ :SDL_GameControllerGetStringForAxis => [:int],
237
+ :SDL_GameControllerGetBindForAxis => [:pointer, :int],
238
+ :SDL_GameControllerHasAxis => [:pointer, :int],
239
+ :SDL_GameControllerGetAxis => [:pointer, :int],
240
+ :SDL_GameControllerGetButtonFromString => [:pointer],
241
+ :SDL_GameControllerGetStringForButton => [:int],
242
+ :SDL_GameControllerGetBindForButton => [:pointer, :int],
243
+ :SDL_GameControllerHasButton => [:pointer, :int],
244
+ :SDL_GameControllerGetButton => [:pointer, :int],
245
+ :SDL_GameControllerGetNumTouchpads => [:pointer],
246
+ :SDL_GameControllerGetNumTouchpadFingers => [:pointer, :int],
247
+ :SDL_GameControllerGetTouchpadFinger => [:pointer, :int, :int, :pointer, :pointer, :pointer, :pointer],
248
+ :SDL_GameControllerHasSensor => [:pointer, :int],
249
+ :SDL_GameControllerSetSensorEnabled => [:pointer, :int, :int],
250
+ :SDL_GameControllerIsSensorEnabled => [:pointer, :int],
251
+ :SDL_GameControllerGetSensorDataRate => [:pointer, :int],
252
+ :SDL_GameControllerGetSensorData => [:pointer, :int, :pointer, :int],
253
+ :SDL_GameControllerRumble => [:pointer, :ushort, :ushort, :uint],
254
+ :SDL_GameControllerRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
255
+ :SDL_GameControllerHasLED => [:pointer],
256
+ :SDL_GameControllerHasRumble => [:pointer],
257
+ :SDL_GameControllerHasRumbleTriggers => [:pointer],
258
+ :SDL_GameControllerSetLED => [:pointer, :uchar, :uchar, :uchar],
259
+ :SDL_GameControllerSendEffect => [:pointer, :pointer, :int],
260
+ :SDL_GameControllerClose => [:pointer],
261
+ :SDL_GameControllerGetAppleSFSymbolsNameForButton => [:pointer, :int],
262
+ :SDL_GameControllerGetAppleSFSymbolsNameForAxis => [:pointer, :int],
263
+ }
264
+ retvals = {
265
+ :SDL_GameControllerAddMappingsFromRW => :int,
266
+ :SDL_GameControllerAddMapping => :int,
267
+ :SDL_GameControllerNumMappings => :int,
268
+ :SDL_GameControllerMappingForIndex => :pointer,
269
+ :SDL_GameControllerMappingForGUID => :pointer,
270
+ :SDL_GameControllerMapping => :pointer,
271
+ :SDL_IsGameController => :int,
272
+ :SDL_GameControllerNameForIndex => :pointer,
273
+ :SDL_GameControllerTypeForIndex => :int,
274
+ :SDL_GameControllerMappingForDeviceIndex => :pointer,
275
+ :SDL_GameControllerOpen => :pointer,
276
+ :SDL_GameControllerFromInstanceID => :pointer,
277
+ :SDL_GameControllerFromPlayerIndex => :pointer,
278
+ :SDL_GameControllerName => :pointer,
279
+ :SDL_GameControllerGetType => :int,
280
+ :SDL_GameControllerGetPlayerIndex => :int,
281
+ :SDL_GameControllerSetPlayerIndex => :void,
282
+ :SDL_GameControllerGetVendor => :ushort,
283
+ :SDL_GameControllerGetProduct => :ushort,
284
+ :SDL_GameControllerGetProductVersion => :ushort,
285
+ :SDL_GameControllerGetSerial => :pointer,
286
+ :SDL_GameControllerGetAttached => :int,
287
+ :SDL_GameControllerGetJoystick => :pointer,
288
+ :SDL_GameControllerEventState => :int,
289
+ :SDL_GameControllerUpdate => :void,
290
+ :SDL_GameControllerGetAxisFromString => :int,
291
+ :SDL_GameControllerGetStringForAxis => :pointer,
292
+ :SDL_GameControllerGetBindForAxis => GameControllerButtonBind.by_value,
293
+ :SDL_GameControllerHasAxis => :int,
294
+ :SDL_GameControllerGetAxis => :short,
295
+ :SDL_GameControllerGetButtonFromString => :int,
296
+ :SDL_GameControllerGetStringForButton => :pointer,
297
+ :SDL_GameControllerGetBindForButton => GameControllerButtonBind.by_value,
298
+ :SDL_GameControllerHasButton => :int,
299
+ :SDL_GameControllerGetButton => :uchar,
300
+ :SDL_GameControllerGetNumTouchpads => :int,
301
+ :SDL_GameControllerGetNumTouchpadFingers => :int,
302
+ :SDL_GameControllerGetTouchpadFinger => :int,
303
+ :SDL_GameControllerHasSensor => :int,
304
+ :SDL_GameControllerSetSensorEnabled => :int,
305
+ :SDL_GameControllerIsSensorEnabled => :int,
306
+ :SDL_GameControllerGetSensorDataRate => :float,
307
+ :SDL_GameControllerGetSensorData => :int,
308
+ :SDL_GameControllerRumble => :int,
309
+ :SDL_GameControllerRumbleTriggers => :int,
310
+ :SDL_GameControllerHasLED => :int,
311
+ :SDL_GameControllerHasRumble => :int,
312
+ :SDL_GameControllerHasRumbleTriggers => :int,
313
+ :SDL_GameControllerSetLED => :int,
314
+ :SDL_GameControllerSendEffect => :int,
315
+ :SDL_GameControllerClose => :void,
316
+ :SDL_GameControllerGetAppleSFSymbolsNameForButton => :pointer,
317
+ :SDL_GameControllerGetAppleSFSymbolsNameForAxis => :pointer,
318
+ }
319
+ symbols.each do |sym|
320
+ begin
321
+ attach_function apis[sym], sym, args[sym], retvals[sym]
322
+ rescue FFI::NotFoundError => error
323
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
324
+ end
325
+ end
326
+ end
327
+
328
+ end
329
+