sdl2-bindings 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +83 -79
  3. data/LICENSE.txt +1 -1
  4. data/README.md +49 -49
  5. data/lib/sdl2.rb +170 -170
  6. data/lib/sdl2_audio.rb +219 -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 +530 -530
  12. data/lib/sdl2_filesystem.rb +48 -48
  13. data/lib/sdl2_framerate.rb +67 -67
  14. data/lib/sdl2_gamecontroller.rb +254 -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_hints.rb +174 -174
  19. data/lib/sdl2_image.rb +185 -185
  20. data/lib/sdl2_imageFilter.rb +132 -132
  21. data/lib/sdl2_joystick.rb +230 -230
  22. data/lib/sdl2_keyboard.rb +99 -99
  23. data/lib/sdl2_keycode.rb +304 -304
  24. data/lib/sdl2_log.rb +115 -115
  25. data/lib/sdl2_main.rb +67 -67
  26. data/lib/sdl2_messagebox.rb +98 -98
  27. data/lib/sdl2_mixer.rb +317 -307
  28. data/lib/sdl2_mouse.rb +117 -117
  29. data/lib/sdl2_pixels.rb +224 -224
  30. data/lib/sdl2_platform.rb +45 -45
  31. data/lib/sdl2_power.rb +51 -51
  32. data/lib/sdl2_rect.rb +102 -102
  33. data/lib/sdl2_render.rb +290 -290
  34. data/lib/sdl2_rotozoom.rb +66 -66
  35. data/lib/sdl2_rwops.rb +208 -208
  36. data/lib/sdl2_scancode.rb +287 -287
  37. data/lib/sdl2_shape.rb +77 -77
  38. data/lib/sdl2_stdinc.rb +393 -393
  39. data/lib/sdl2_surface.rb +182 -182
  40. data/lib/sdl2_syswm.rb +154 -154
  41. data/lib/sdl2_timer.rb +62 -62
  42. data/lib/sdl2_touch.rb +73 -73
  43. data/lib/sdl2_ttf.rb +202 -190
  44. data/lib/sdl2_version.rb +62 -62
  45. data/lib/sdl2_video.rb +411 -411
  46. data/lib/sdl2_vulkan.rb +64 -64
  47. metadata +6 -6
@@ -1,48 +1,48 @@
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
-
23
- # Function
24
-
25
- def self.setup_filesystem_symbols()
26
- symbols = [
27
- :SDL_GetBasePath,
28
- :SDL_GetPrefPath,
29
- ]
30
- args = {
31
- :SDL_GetBasePath => [],
32
- :SDL_GetPrefPath => [:pointer, :pointer],
33
- }
34
- retvals = {
35
- :SDL_GetBasePath => :pointer,
36
- :SDL_GetPrefPath => :pointer,
37
- }
38
- symbols.each do |sym|
39
- begin
40
- attach_function sym, args[sym], retvals[sym]
41
- rescue FFI::NotFoundError => error
42
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
43
- end
44
- end
45
- end
46
-
47
- end
48
-
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
+
23
+ # Function
24
+
25
+ def self.setup_filesystem_symbols()
26
+ symbols = [
27
+ :SDL_GetBasePath,
28
+ :SDL_GetPrefPath,
29
+ ]
30
+ args = {
31
+ :SDL_GetBasePath => [],
32
+ :SDL_GetPrefPath => [:pointer, :pointer],
33
+ }
34
+ retvals = {
35
+ :SDL_GetBasePath => :pointer,
36
+ :SDL_GetPrefPath => :pointer,
37
+ }
38
+ symbols.each do |sym|
39
+ begin
40
+ attach_function sym, args[sym], retvals[sym]
41
+ rescue FFI::NotFoundError => error
42
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
43
+ end
44
+ end
45
+ end
46
+
47
+ end
48
+
@@ -1,67 +1,67 @@
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 FPSmanager < FFI::Struct
23
- layout(
24
- :framecount, :uint,
25
- :rateticks, :float,
26
- :baseticks, :uint,
27
- :lastticks, :uint,
28
- :rate, :uint,
29
- )
30
- end
31
-
32
-
33
- # Function
34
-
35
- def self.setup_gfx_framerate_symbols()
36
- symbols = [
37
- :SDL_initFramerate,
38
- :SDL_setFramerate,
39
- :SDL_getFramerate,
40
- :SDL_getFramecount,
41
- :SDL_framerateDelay,
42
- ]
43
- args = {
44
- :SDL_initFramerate => [:pointer],
45
- :SDL_setFramerate => [:pointer, :uint],
46
- :SDL_getFramerate => [:pointer],
47
- :SDL_getFramecount => [:pointer],
48
- :SDL_framerateDelay => [:pointer],
49
- }
50
- retvals = {
51
- :SDL_initFramerate => :void,
52
- :SDL_setFramerate => :int,
53
- :SDL_getFramerate => :int,
54
- :SDL_getFramecount => :int,
55
- :SDL_framerateDelay => :uint,
56
- }
57
- symbols.each do |sym|
58
- begin
59
- attach_function sym, args[sym], retvals[sym]
60
- rescue FFI::NotFoundError => error
61
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
62
- end
63
- end
64
- end
65
-
66
- end
67
-
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 FPSmanager < FFI::Struct
23
+ layout(
24
+ :framecount, :uint,
25
+ :rateticks, :float,
26
+ :baseticks, :uint,
27
+ :lastticks, :uint,
28
+ :rate, :uint,
29
+ )
30
+ end
31
+
32
+
33
+ # Function
34
+
35
+ def self.setup_gfx_framerate_symbols()
36
+ symbols = [
37
+ :SDL_initFramerate,
38
+ :SDL_setFramerate,
39
+ :SDL_getFramerate,
40
+ :SDL_getFramecount,
41
+ :SDL_framerateDelay,
42
+ ]
43
+ args = {
44
+ :SDL_initFramerate => [:pointer],
45
+ :SDL_setFramerate => [:pointer, :uint],
46
+ :SDL_getFramerate => [:pointer],
47
+ :SDL_getFramecount => [:pointer],
48
+ :SDL_framerateDelay => [:pointer],
49
+ }
50
+ retvals = {
51
+ :SDL_initFramerate => :void,
52
+ :SDL_setFramerate => :int,
53
+ :SDL_getFramerate => :int,
54
+ :SDL_getFramecount => :int,
55
+ :SDL_framerateDelay => :uint,
56
+ }
57
+ symbols.each do |sym|
58
+ begin
59
+ attach_function sym, args[sym], retvals[sym]
60
+ rescue FFI::NotFoundError => error
61
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
62
+ end
63
+ end
64
+ end
65
+
66
+ end
67
+
@@ -1,254 +1,254 @@
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_BINDTYPE_NONE = 0
26
- SDL_CONTROLLER_BINDTYPE_BUTTON = 1
27
- SDL_CONTROLLER_BINDTYPE_AXIS = 2
28
- SDL_CONTROLLER_BINDTYPE_HAT = 3
29
- SDL_CONTROLLER_AXIS_INVALID = -1
30
- SDL_CONTROLLER_AXIS_LEFTX = 0
31
- SDL_CONTROLLER_AXIS_LEFTY = 1
32
- SDL_CONTROLLER_AXIS_RIGHTX = 2
33
- SDL_CONTROLLER_AXIS_RIGHTY = 3
34
- SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
35
- SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
36
- SDL_CONTROLLER_AXIS_MAX = 6
37
- SDL_CONTROLLER_BUTTON_INVALID = -1
38
- SDL_CONTROLLER_BUTTON_A = 0
39
- SDL_CONTROLLER_BUTTON_B = 1
40
- SDL_CONTROLLER_BUTTON_X = 2
41
- SDL_CONTROLLER_BUTTON_Y = 3
42
- SDL_CONTROLLER_BUTTON_BACK = 4
43
- SDL_CONTROLLER_BUTTON_GUIDE = 5
44
- SDL_CONTROLLER_BUTTON_START = 6
45
- SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
46
- SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
47
- SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
48
- SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
49
- SDL_CONTROLLER_BUTTON_DPAD_UP = 11
50
- SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
51
- SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
52
- SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
53
- SDL_CONTROLLER_BUTTON_MISC1 = 15
54
- SDL_CONTROLLER_BUTTON_PADDLE1 = 16
55
- SDL_CONTROLLER_BUTTON_PADDLE2 = 17
56
- SDL_CONTROLLER_BUTTON_PADDLE3 = 18
57
- SDL_CONTROLLER_BUTTON_PADDLE4 = 19
58
- SDL_CONTROLLER_BUTTON_TOUCHPAD = 20
59
- SDL_CONTROLLER_BUTTON_MAX = 21
60
-
61
- # Typedef
62
-
63
-
64
- class SDL_GameControllerButtonBind_value_hat < FFI::Struct
65
- layout(
66
- :hat, :int,
67
- :hat_mask, :int,
68
- )
69
- end
70
-
71
- class SDL_GameControllerButtonBind_value < FFI::Struct
72
- layout(
73
- :button, :int,
74
- :axis, :int,
75
- :hat, SDL_GameControllerButtonBind_value_hat.by_value,
76
- )
77
- end
78
-
79
- class SDL_GameControllerButtonBind < FFI::Struct
80
- layout(
81
- :bindType, :int,
82
- :value, SDL_GameControllerButtonBind_value.by_value,
83
- )
84
- end
85
-
86
- typedef :int, :SDL_GameControllerType
87
- typedef :int, :SDL_GameControllerBindType
88
- typedef :int, :SDL_GameControllerAxis
89
- typedef :int, :SDL_GameControllerButton
90
-
91
- # Struct
92
-
93
-
94
- # Function
95
-
96
- def self.setup_gamecontroller_symbols()
97
- symbols = [
98
- :SDL_GameControllerAddMappingsFromRW,
99
- :SDL_GameControllerAddMapping,
100
- :SDL_GameControllerNumMappings,
101
- :SDL_GameControllerMappingForIndex,
102
- :SDL_GameControllerMappingForGUID,
103
- :SDL_GameControllerMapping,
104
- :SDL_IsGameController,
105
- :SDL_GameControllerNameForIndex,
106
- :SDL_GameControllerTypeForIndex,
107
- :SDL_GameControllerMappingForDeviceIndex,
108
- :SDL_GameControllerOpen,
109
- :SDL_GameControllerFromInstanceID,
110
- :SDL_GameControllerFromPlayerIndex,
111
- :SDL_GameControllerName,
112
- :SDL_GameControllerGetType,
113
- :SDL_GameControllerGetPlayerIndex,
114
- :SDL_GameControllerSetPlayerIndex,
115
- :SDL_GameControllerGetVendor,
116
- :SDL_GameControllerGetProduct,
117
- :SDL_GameControllerGetProductVersion,
118
- :SDL_GameControllerGetSerial,
119
- :SDL_GameControllerGetAttached,
120
- :SDL_GameControllerGetJoystick,
121
- :SDL_GameControllerEventState,
122
- :SDL_GameControllerUpdate,
123
- :SDL_GameControllerGetAxisFromString,
124
- :SDL_GameControllerGetStringForAxis,
125
- :SDL_GameControllerGetBindForAxis,
126
- :SDL_GameControllerHasAxis,
127
- :SDL_GameControllerGetAxis,
128
- :SDL_GameControllerGetButtonFromString,
129
- :SDL_GameControllerGetStringForButton,
130
- :SDL_GameControllerGetBindForButton,
131
- :SDL_GameControllerHasButton,
132
- :SDL_GameControllerGetButton,
133
- :SDL_GameControllerGetNumTouchpads,
134
- :SDL_GameControllerGetNumTouchpadFingers,
135
- :SDL_GameControllerGetTouchpadFinger,
136
- :SDL_GameControllerHasSensor,
137
- :SDL_GameControllerSetSensorEnabled,
138
- :SDL_GameControllerIsSensorEnabled,
139
- :SDL_GameControllerGetSensorData,
140
- :SDL_GameControllerRumble,
141
- :SDL_GameControllerRumbleTriggers,
142
- :SDL_GameControllerHasLED,
143
- :SDL_GameControllerSetLED,
144
- :SDL_GameControllerClose,
145
- ]
146
- args = {
147
- :SDL_GameControllerAddMappingsFromRW => [:pointer, :int],
148
- :SDL_GameControllerAddMapping => [:pointer],
149
- :SDL_GameControllerNumMappings => [],
150
- :SDL_GameControllerMappingForIndex => [:int],
151
- :SDL_GameControllerMappingForGUID => [SDL_JoystickGUID],
152
- :SDL_GameControllerMapping => [:pointer],
153
- :SDL_IsGameController => [:int],
154
- :SDL_GameControllerNameForIndex => [:int],
155
- :SDL_GameControllerTypeForIndex => [:int],
156
- :SDL_GameControllerMappingForDeviceIndex => [:int],
157
- :SDL_GameControllerOpen => [:int],
158
- :SDL_GameControllerFromInstanceID => [:int],
159
- :SDL_GameControllerFromPlayerIndex => [:int],
160
- :SDL_GameControllerName => [:pointer],
161
- :SDL_GameControllerGetType => [:pointer],
162
- :SDL_GameControllerGetPlayerIndex => [:pointer],
163
- :SDL_GameControllerSetPlayerIndex => [:pointer, :int],
164
- :SDL_GameControllerGetVendor => [:pointer],
165
- :SDL_GameControllerGetProduct => [:pointer],
166
- :SDL_GameControllerGetProductVersion => [:pointer],
167
- :SDL_GameControllerGetSerial => [:pointer],
168
- :SDL_GameControllerGetAttached => [:pointer],
169
- :SDL_GameControllerGetJoystick => [:pointer],
170
- :SDL_GameControllerEventState => [:int],
171
- :SDL_GameControllerUpdate => [],
172
- :SDL_GameControllerGetAxisFromString => [:pointer],
173
- :SDL_GameControllerGetStringForAxis => [:int],
174
- :SDL_GameControllerGetBindForAxis => [:pointer, :int],
175
- :SDL_GameControllerHasAxis => [:pointer, :int],
176
- :SDL_GameControllerGetAxis => [:pointer, :int],
177
- :SDL_GameControllerGetButtonFromString => [:pointer],
178
- :SDL_GameControllerGetStringForButton => [:int],
179
- :SDL_GameControllerGetBindForButton => [:pointer, :int],
180
- :SDL_GameControllerHasButton => [:pointer, :int],
181
- :SDL_GameControllerGetButton => [:pointer, :int],
182
- :SDL_GameControllerGetNumTouchpads => [:pointer],
183
- :SDL_GameControllerGetNumTouchpadFingers => [:pointer, :int],
184
- :SDL_GameControllerGetTouchpadFinger => [:pointer, :int, :int, :pointer, :pointer, :pointer, :pointer],
185
- :SDL_GameControllerHasSensor => [:pointer, :int],
186
- :SDL_GameControllerSetSensorEnabled => [:pointer, :int, :int],
187
- :SDL_GameControllerIsSensorEnabled => [:pointer, :int],
188
- :SDL_GameControllerGetSensorData => [:pointer, :int, :pointer, :int],
189
- :SDL_GameControllerRumble => [:pointer, :ushort, :ushort, :uint],
190
- :SDL_GameControllerRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
191
- :SDL_GameControllerHasLED => [:pointer],
192
- :SDL_GameControllerSetLED => [:pointer, :uchar, :uchar, :uchar],
193
- :SDL_GameControllerClose => [:pointer],
194
- }
195
- retvals = {
196
- :SDL_GameControllerAddMappingsFromRW => :int,
197
- :SDL_GameControllerAddMapping => :int,
198
- :SDL_GameControllerNumMappings => :int,
199
- :SDL_GameControllerMappingForIndex => :pointer,
200
- :SDL_GameControllerMappingForGUID => :pointer,
201
- :SDL_GameControllerMapping => :pointer,
202
- :SDL_IsGameController => :int,
203
- :SDL_GameControllerNameForIndex => :pointer,
204
- :SDL_GameControllerTypeForIndex => :int,
205
- :SDL_GameControllerMappingForDeviceIndex => :pointer,
206
- :SDL_GameControllerOpen => :pointer,
207
- :SDL_GameControllerFromInstanceID => :pointer,
208
- :SDL_GameControllerFromPlayerIndex => :pointer,
209
- :SDL_GameControllerName => :pointer,
210
- :SDL_GameControllerGetType => :int,
211
- :SDL_GameControllerGetPlayerIndex => :int,
212
- :SDL_GameControllerSetPlayerIndex => :void,
213
- :SDL_GameControllerGetVendor => :ushort,
214
- :SDL_GameControllerGetProduct => :ushort,
215
- :SDL_GameControllerGetProductVersion => :ushort,
216
- :SDL_GameControllerGetSerial => :pointer,
217
- :SDL_GameControllerGetAttached => :int,
218
- :SDL_GameControllerGetJoystick => :pointer,
219
- :SDL_GameControllerEventState => :int,
220
- :SDL_GameControllerUpdate => :void,
221
- :SDL_GameControllerGetAxisFromString => :int,
222
- :SDL_GameControllerGetStringForAxis => :pointer,
223
- :SDL_GameControllerGetBindForAxis => SDL_GameControllerButtonBind,
224
- :SDL_GameControllerHasAxis => :int,
225
- :SDL_GameControllerGetAxis => :short,
226
- :SDL_GameControllerGetButtonFromString => :int,
227
- :SDL_GameControllerGetStringForButton => :pointer,
228
- :SDL_GameControllerGetBindForButton => SDL_GameControllerButtonBind,
229
- :SDL_GameControllerHasButton => :int,
230
- :SDL_GameControllerGetButton => :uchar,
231
- :SDL_GameControllerGetNumTouchpads => :int,
232
- :SDL_GameControllerGetNumTouchpadFingers => :int,
233
- :SDL_GameControllerGetTouchpadFinger => :int,
234
- :SDL_GameControllerHasSensor => :int,
235
- :SDL_GameControllerSetSensorEnabled => :int,
236
- :SDL_GameControllerIsSensorEnabled => :int,
237
- :SDL_GameControllerGetSensorData => :int,
238
- :SDL_GameControllerRumble => :int,
239
- :SDL_GameControllerRumbleTriggers => :int,
240
- :SDL_GameControllerHasLED => :int,
241
- :SDL_GameControllerSetLED => :int,
242
- :SDL_GameControllerClose => :void,
243
- }
244
- symbols.each do |sym|
245
- begin
246
- attach_function sym, args[sym], retvals[sym]
247
- rescue FFI::NotFoundError => error
248
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
249
- end
250
- end
251
- end
252
-
253
- end
254
-
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_BINDTYPE_NONE = 0
26
+ SDL_CONTROLLER_BINDTYPE_BUTTON = 1
27
+ SDL_CONTROLLER_BINDTYPE_AXIS = 2
28
+ SDL_CONTROLLER_BINDTYPE_HAT = 3
29
+ SDL_CONTROLLER_AXIS_INVALID = -1
30
+ SDL_CONTROLLER_AXIS_LEFTX = 0
31
+ SDL_CONTROLLER_AXIS_LEFTY = 1
32
+ SDL_CONTROLLER_AXIS_RIGHTX = 2
33
+ SDL_CONTROLLER_AXIS_RIGHTY = 3
34
+ SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
35
+ SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
36
+ SDL_CONTROLLER_AXIS_MAX = 6
37
+ SDL_CONTROLLER_BUTTON_INVALID = -1
38
+ SDL_CONTROLLER_BUTTON_A = 0
39
+ SDL_CONTROLLER_BUTTON_B = 1
40
+ SDL_CONTROLLER_BUTTON_X = 2
41
+ SDL_CONTROLLER_BUTTON_Y = 3
42
+ SDL_CONTROLLER_BUTTON_BACK = 4
43
+ SDL_CONTROLLER_BUTTON_GUIDE = 5
44
+ SDL_CONTROLLER_BUTTON_START = 6
45
+ SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
46
+ SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
47
+ SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
48
+ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
49
+ SDL_CONTROLLER_BUTTON_DPAD_UP = 11
50
+ SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
51
+ SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
52
+ SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
53
+ SDL_CONTROLLER_BUTTON_MISC1 = 15
54
+ SDL_CONTROLLER_BUTTON_PADDLE1 = 16
55
+ SDL_CONTROLLER_BUTTON_PADDLE2 = 17
56
+ SDL_CONTROLLER_BUTTON_PADDLE3 = 18
57
+ SDL_CONTROLLER_BUTTON_PADDLE4 = 19
58
+ SDL_CONTROLLER_BUTTON_TOUCHPAD = 20
59
+ SDL_CONTROLLER_BUTTON_MAX = 21
60
+
61
+ # Typedef
62
+
63
+
64
+ class SDL_GameControllerButtonBind_value_hat < FFI::Struct
65
+ layout(
66
+ :hat, :int,
67
+ :hat_mask, :int,
68
+ )
69
+ end
70
+
71
+ class SDL_GameControllerButtonBind_value < FFI::Struct
72
+ layout(
73
+ :button, :int,
74
+ :axis, :int,
75
+ :hat, SDL_GameControllerButtonBind_value_hat.by_value,
76
+ )
77
+ end
78
+
79
+ class SDL_GameControllerButtonBind < FFI::Struct
80
+ layout(
81
+ :bindType, :int,
82
+ :value, SDL_GameControllerButtonBind_value.by_value,
83
+ )
84
+ end
85
+
86
+ typedef :int, :SDL_GameControllerType
87
+ typedef :int, :SDL_GameControllerBindType
88
+ typedef :int, :SDL_GameControllerAxis
89
+ typedef :int, :SDL_GameControllerButton
90
+
91
+ # Struct
92
+
93
+
94
+ # Function
95
+
96
+ def self.setup_gamecontroller_symbols()
97
+ symbols = [
98
+ :SDL_GameControllerAddMappingsFromRW,
99
+ :SDL_GameControllerAddMapping,
100
+ :SDL_GameControllerNumMappings,
101
+ :SDL_GameControllerMappingForIndex,
102
+ :SDL_GameControllerMappingForGUID,
103
+ :SDL_GameControllerMapping,
104
+ :SDL_IsGameController,
105
+ :SDL_GameControllerNameForIndex,
106
+ :SDL_GameControllerTypeForIndex,
107
+ :SDL_GameControllerMappingForDeviceIndex,
108
+ :SDL_GameControllerOpen,
109
+ :SDL_GameControllerFromInstanceID,
110
+ :SDL_GameControllerFromPlayerIndex,
111
+ :SDL_GameControllerName,
112
+ :SDL_GameControllerGetType,
113
+ :SDL_GameControllerGetPlayerIndex,
114
+ :SDL_GameControllerSetPlayerIndex,
115
+ :SDL_GameControllerGetVendor,
116
+ :SDL_GameControllerGetProduct,
117
+ :SDL_GameControllerGetProductVersion,
118
+ :SDL_GameControllerGetSerial,
119
+ :SDL_GameControllerGetAttached,
120
+ :SDL_GameControllerGetJoystick,
121
+ :SDL_GameControllerEventState,
122
+ :SDL_GameControllerUpdate,
123
+ :SDL_GameControllerGetAxisFromString,
124
+ :SDL_GameControllerGetStringForAxis,
125
+ :SDL_GameControllerGetBindForAxis,
126
+ :SDL_GameControllerHasAxis,
127
+ :SDL_GameControllerGetAxis,
128
+ :SDL_GameControllerGetButtonFromString,
129
+ :SDL_GameControllerGetStringForButton,
130
+ :SDL_GameControllerGetBindForButton,
131
+ :SDL_GameControllerHasButton,
132
+ :SDL_GameControllerGetButton,
133
+ :SDL_GameControllerGetNumTouchpads,
134
+ :SDL_GameControllerGetNumTouchpadFingers,
135
+ :SDL_GameControllerGetTouchpadFinger,
136
+ :SDL_GameControllerHasSensor,
137
+ :SDL_GameControllerSetSensorEnabled,
138
+ :SDL_GameControllerIsSensorEnabled,
139
+ :SDL_GameControllerGetSensorData,
140
+ :SDL_GameControllerRumble,
141
+ :SDL_GameControllerRumbleTriggers,
142
+ :SDL_GameControllerHasLED,
143
+ :SDL_GameControllerSetLED,
144
+ :SDL_GameControllerClose,
145
+ ]
146
+ args = {
147
+ :SDL_GameControllerAddMappingsFromRW => [:pointer, :int],
148
+ :SDL_GameControllerAddMapping => [:pointer],
149
+ :SDL_GameControllerNumMappings => [],
150
+ :SDL_GameControllerMappingForIndex => [:int],
151
+ :SDL_GameControllerMappingForGUID => [SDL_JoystickGUID],
152
+ :SDL_GameControllerMapping => [:pointer],
153
+ :SDL_IsGameController => [:int],
154
+ :SDL_GameControllerNameForIndex => [:int],
155
+ :SDL_GameControllerTypeForIndex => [:int],
156
+ :SDL_GameControllerMappingForDeviceIndex => [:int],
157
+ :SDL_GameControllerOpen => [:int],
158
+ :SDL_GameControllerFromInstanceID => [:int],
159
+ :SDL_GameControllerFromPlayerIndex => [:int],
160
+ :SDL_GameControllerName => [:pointer],
161
+ :SDL_GameControllerGetType => [:pointer],
162
+ :SDL_GameControllerGetPlayerIndex => [:pointer],
163
+ :SDL_GameControllerSetPlayerIndex => [:pointer, :int],
164
+ :SDL_GameControllerGetVendor => [:pointer],
165
+ :SDL_GameControllerGetProduct => [:pointer],
166
+ :SDL_GameControllerGetProductVersion => [:pointer],
167
+ :SDL_GameControllerGetSerial => [:pointer],
168
+ :SDL_GameControllerGetAttached => [:pointer],
169
+ :SDL_GameControllerGetJoystick => [:pointer],
170
+ :SDL_GameControllerEventState => [:int],
171
+ :SDL_GameControllerUpdate => [],
172
+ :SDL_GameControllerGetAxisFromString => [:pointer],
173
+ :SDL_GameControllerGetStringForAxis => [:int],
174
+ :SDL_GameControllerGetBindForAxis => [:pointer, :int],
175
+ :SDL_GameControllerHasAxis => [:pointer, :int],
176
+ :SDL_GameControllerGetAxis => [:pointer, :int],
177
+ :SDL_GameControllerGetButtonFromString => [:pointer],
178
+ :SDL_GameControllerGetStringForButton => [:int],
179
+ :SDL_GameControllerGetBindForButton => [:pointer, :int],
180
+ :SDL_GameControllerHasButton => [:pointer, :int],
181
+ :SDL_GameControllerGetButton => [:pointer, :int],
182
+ :SDL_GameControllerGetNumTouchpads => [:pointer],
183
+ :SDL_GameControllerGetNumTouchpadFingers => [:pointer, :int],
184
+ :SDL_GameControllerGetTouchpadFinger => [:pointer, :int, :int, :pointer, :pointer, :pointer, :pointer],
185
+ :SDL_GameControllerHasSensor => [:pointer, :int],
186
+ :SDL_GameControllerSetSensorEnabled => [:pointer, :int, :int],
187
+ :SDL_GameControllerIsSensorEnabled => [:pointer, :int],
188
+ :SDL_GameControllerGetSensorData => [:pointer, :int, :pointer, :int],
189
+ :SDL_GameControllerRumble => [:pointer, :ushort, :ushort, :uint],
190
+ :SDL_GameControllerRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
191
+ :SDL_GameControllerHasLED => [:pointer],
192
+ :SDL_GameControllerSetLED => [:pointer, :uchar, :uchar, :uchar],
193
+ :SDL_GameControllerClose => [:pointer],
194
+ }
195
+ retvals = {
196
+ :SDL_GameControllerAddMappingsFromRW => :int,
197
+ :SDL_GameControllerAddMapping => :int,
198
+ :SDL_GameControllerNumMappings => :int,
199
+ :SDL_GameControllerMappingForIndex => :pointer,
200
+ :SDL_GameControllerMappingForGUID => :pointer,
201
+ :SDL_GameControllerMapping => :pointer,
202
+ :SDL_IsGameController => :int,
203
+ :SDL_GameControllerNameForIndex => :pointer,
204
+ :SDL_GameControllerTypeForIndex => :int,
205
+ :SDL_GameControllerMappingForDeviceIndex => :pointer,
206
+ :SDL_GameControllerOpen => :pointer,
207
+ :SDL_GameControllerFromInstanceID => :pointer,
208
+ :SDL_GameControllerFromPlayerIndex => :pointer,
209
+ :SDL_GameControllerName => :pointer,
210
+ :SDL_GameControllerGetType => :int,
211
+ :SDL_GameControllerGetPlayerIndex => :int,
212
+ :SDL_GameControllerSetPlayerIndex => :void,
213
+ :SDL_GameControllerGetVendor => :ushort,
214
+ :SDL_GameControllerGetProduct => :ushort,
215
+ :SDL_GameControllerGetProductVersion => :ushort,
216
+ :SDL_GameControllerGetSerial => :pointer,
217
+ :SDL_GameControllerGetAttached => :int,
218
+ :SDL_GameControllerGetJoystick => :pointer,
219
+ :SDL_GameControllerEventState => :int,
220
+ :SDL_GameControllerUpdate => :void,
221
+ :SDL_GameControllerGetAxisFromString => :int,
222
+ :SDL_GameControllerGetStringForAxis => :pointer,
223
+ :SDL_GameControllerGetBindForAxis => SDL_GameControllerButtonBind,
224
+ :SDL_GameControllerHasAxis => :int,
225
+ :SDL_GameControllerGetAxis => :short,
226
+ :SDL_GameControllerGetButtonFromString => :int,
227
+ :SDL_GameControllerGetStringForButton => :pointer,
228
+ :SDL_GameControllerGetBindForButton => SDL_GameControllerButtonBind,
229
+ :SDL_GameControllerHasButton => :int,
230
+ :SDL_GameControllerGetButton => :uchar,
231
+ :SDL_GameControllerGetNumTouchpads => :int,
232
+ :SDL_GameControllerGetNumTouchpadFingers => :int,
233
+ :SDL_GameControllerGetTouchpadFinger => :int,
234
+ :SDL_GameControllerHasSensor => :int,
235
+ :SDL_GameControllerSetSensorEnabled => :int,
236
+ :SDL_GameControllerIsSensorEnabled => :int,
237
+ :SDL_GameControllerGetSensorData => :int,
238
+ :SDL_GameControllerRumble => :int,
239
+ :SDL_GameControllerRumbleTriggers => :int,
240
+ :SDL_GameControllerHasLED => :int,
241
+ :SDL_GameControllerSetLED => :int,
242
+ :SDL_GameControllerClose => :void,
243
+ }
244
+ symbols.each do |sym|
245
+ begin
246
+ attach_function sym, args[sym], retvals[sym]
247
+ rescue FFI::NotFoundError => error
248
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
249
+ end
250
+ end
251
+ end
252
+
253
+ end
254
+