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,132 +1,132 @@
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_gfx_imagefilter_symbols()
26
- symbols = [
27
- :SDL_imageFilterMMXdetect,
28
- :SDL_imageFilterMMXoff,
29
- :SDL_imageFilterMMXon,
30
- :SDL_imageFilterAdd,
31
- :SDL_imageFilterMean,
32
- :SDL_imageFilterSub,
33
- :SDL_imageFilterAbsDiff,
34
- :SDL_imageFilterMult,
35
- :SDL_imageFilterMultNor,
36
- :SDL_imageFilterMultDivby2,
37
- :SDL_imageFilterMultDivby4,
38
- :SDL_imageFilterBitAnd,
39
- :SDL_imageFilterBitOr,
40
- :SDL_imageFilterDiv,
41
- :SDL_imageFilterBitNegation,
42
- :SDL_imageFilterAddByte,
43
- :SDL_imageFilterAddUint,
44
- :SDL_imageFilterAddByteToHalf,
45
- :SDL_imageFilterSubByte,
46
- :SDL_imageFilterSubUint,
47
- :SDL_imageFilterShiftRight,
48
- :SDL_imageFilterShiftRightUint,
49
- :SDL_imageFilterMultByByte,
50
- :SDL_imageFilterShiftRightAndMultByByte,
51
- :SDL_imageFilterShiftLeftByte,
52
- :SDL_imageFilterShiftLeftUint,
53
- :SDL_imageFilterShiftLeft,
54
- :SDL_imageFilterBinarizeUsingThreshold,
55
- :SDL_imageFilterClipToRange,
56
- :SDL_imageFilterNormalizeLinear,
57
- ]
58
- args = {
59
- :SDL_imageFilterMMXdetect => [],
60
- :SDL_imageFilterMMXoff => [],
61
- :SDL_imageFilterMMXon => [],
62
- :SDL_imageFilterAdd => [:pointer, :pointer, :pointer, :uint],
63
- :SDL_imageFilterMean => [:pointer, :pointer, :pointer, :uint],
64
- :SDL_imageFilterSub => [:pointer, :pointer, :pointer, :uint],
65
- :SDL_imageFilterAbsDiff => [:pointer, :pointer, :pointer, :uint],
66
- :SDL_imageFilterMult => [:pointer, :pointer, :pointer, :uint],
67
- :SDL_imageFilterMultNor => [:pointer, :pointer, :pointer, :uint],
68
- :SDL_imageFilterMultDivby2 => [:pointer, :pointer, :pointer, :uint],
69
- :SDL_imageFilterMultDivby4 => [:pointer, :pointer, :pointer, :uint],
70
- :SDL_imageFilterBitAnd => [:pointer, :pointer, :pointer, :uint],
71
- :SDL_imageFilterBitOr => [:pointer, :pointer, :pointer, :uint],
72
- :SDL_imageFilterDiv => [:pointer, :pointer, :pointer, :uint],
73
- :SDL_imageFilterBitNegation => [:pointer, :pointer, :uint],
74
- :SDL_imageFilterAddByte => [:pointer, :pointer, :uint, :uchar],
75
- :SDL_imageFilterAddUint => [:pointer, :pointer, :uint, :uint],
76
- :SDL_imageFilterAddByteToHalf => [:pointer, :pointer, :uint, :uchar],
77
- :SDL_imageFilterSubByte => [:pointer, :pointer, :uint, :uchar],
78
- :SDL_imageFilterSubUint => [:pointer, :pointer, :uint, :uint],
79
- :SDL_imageFilterShiftRight => [:pointer, :pointer, :uint, :uchar],
80
- :SDL_imageFilterShiftRightUint => [:pointer, :pointer, :uint, :uchar],
81
- :SDL_imageFilterMultByByte => [:pointer, :pointer, :uint, :uchar],
82
- :SDL_imageFilterShiftRightAndMultByByte => [:pointer, :pointer, :uint, :uchar, :uchar],
83
- :SDL_imageFilterShiftLeftByte => [:pointer, :pointer, :uint, :uchar],
84
- :SDL_imageFilterShiftLeftUint => [:pointer, :pointer, :uint, :uchar],
85
- :SDL_imageFilterShiftLeft => [:pointer, :pointer, :uint, :uchar],
86
- :SDL_imageFilterBinarizeUsingThreshold => [:pointer, :pointer, :uint, :uchar],
87
- :SDL_imageFilterClipToRange => [:pointer, :pointer, :uint, :uchar, :uchar],
88
- :SDL_imageFilterNormalizeLinear => [:pointer, :pointer, :uint, :int, :int, :int, :int],
89
- }
90
- retvals = {
91
- :SDL_imageFilterMMXdetect => :int,
92
- :SDL_imageFilterMMXoff => :void,
93
- :SDL_imageFilterMMXon => :void,
94
- :SDL_imageFilterAdd => :int,
95
- :SDL_imageFilterMean => :int,
96
- :SDL_imageFilterSub => :int,
97
- :SDL_imageFilterAbsDiff => :int,
98
- :SDL_imageFilterMult => :int,
99
- :SDL_imageFilterMultNor => :int,
100
- :SDL_imageFilterMultDivby2 => :int,
101
- :SDL_imageFilterMultDivby4 => :int,
102
- :SDL_imageFilterBitAnd => :int,
103
- :SDL_imageFilterBitOr => :int,
104
- :SDL_imageFilterDiv => :int,
105
- :SDL_imageFilterBitNegation => :int,
106
- :SDL_imageFilterAddByte => :int,
107
- :SDL_imageFilterAddUint => :int,
108
- :SDL_imageFilterAddByteToHalf => :int,
109
- :SDL_imageFilterSubByte => :int,
110
- :SDL_imageFilterSubUint => :int,
111
- :SDL_imageFilterShiftRight => :int,
112
- :SDL_imageFilterShiftRightUint => :int,
113
- :SDL_imageFilterMultByByte => :int,
114
- :SDL_imageFilterShiftRightAndMultByByte => :int,
115
- :SDL_imageFilterShiftLeftByte => :int,
116
- :SDL_imageFilterShiftLeftUint => :int,
117
- :SDL_imageFilterShiftLeft => :int,
118
- :SDL_imageFilterBinarizeUsingThreshold => :int,
119
- :SDL_imageFilterClipToRange => :int,
120
- :SDL_imageFilterNormalizeLinear => :int,
121
- }
122
- symbols.each do |sym|
123
- begin
124
- attach_function sym, args[sym], retvals[sym]
125
- rescue FFI::NotFoundError => error
126
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
127
- end
128
- end
129
- end
130
-
131
- end
132
-
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_gfx_imagefilter_symbols()
26
+ symbols = [
27
+ :SDL_imageFilterMMXdetect,
28
+ :SDL_imageFilterMMXoff,
29
+ :SDL_imageFilterMMXon,
30
+ :SDL_imageFilterAdd,
31
+ :SDL_imageFilterMean,
32
+ :SDL_imageFilterSub,
33
+ :SDL_imageFilterAbsDiff,
34
+ :SDL_imageFilterMult,
35
+ :SDL_imageFilterMultNor,
36
+ :SDL_imageFilterMultDivby2,
37
+ :SDL_imageFilterMultDivby4,
38
+ :SDL_imageFilterBitAnd,
39
+ :SDL_imageFilterBitOr,
40
+ :SDL_imageFilterDiv,
41
+ :SDL_imageFilterBitNegation,
42
+ :SDL_imageFilterAddByte,
43
+ :SDL_imageFilterAddUint,
44
+ :SDL_imageFilterAddByteToHalf,
45
+ :SDL_imageFilterSubByte,
46
+ :SDL_imageFilterSubUint,
47
+ :SDL_imageFilterShiftRight,
48
+ :SDL_imageFilterShiftRightUint,
49
+ :SDL_imageFilterMultByByte,
50
+ :SDL_imageFilterShiftRightAndMultByByte,
51
+ :SDL_imageFilterShiftLeftByte,
52
+ :SDL_imageFilterShiftLeftUint,
53
+ :SDL_imageFilterShiftLeft,
54
+ :SDL_imageFilterBinarizeUsingThreshold,
55
+ :SDL_imageFilterClipToRange,
56
+ :SDL_imageFilterNormalizeLinear,
57
+ ]
58
+ args = {
59
+ :SDL_imageFilterMMXdetect => [],
60
+ :SDL_imageFilterMMXoff => [],
61
+ :SDL_imageFilterMMXon => [],
62
+ :SDL_imageFilterAdd => [:pointer, :pointer, :pointer, :uint],
63
+ :SDL_imageFilterMean => [:pointer, :pointer, :pointer, :uint],
64
+ :SDL_imageFilterSub => [:pointer, :pointer, :pointer, :uint],
65
+ :SDL_imageFilterAbsDiff => [:pointer, :pointer, :pointer, :uint],
66
+ :SDL_imageFilterMult => [:pointer, :pointer, :pointer, :uint],
67
+ :SDL_imageFilterMultNor => [:pointer, :pointer, :pointer, :uint],
68
+ :SDL_imageFilterMultDivby2 => [:pointer, :pointer, :pointer, :uint],
69
+ :SDL_imageFilterMultDivby4 => [:pointer, :pointer, :pointer, :uint],
70
+ :SDL_imageFilterBitAnd => [:pointer, :pointer, :pointer, :uint],
71
+ :SDL_imageFilterBitOr => [:pointer, :pointer, :pointer, :uint],
72
+ :SDL_imageFilterDiv => [:pointer, :pointer, :pointer, :uint],
73
+ :SDL_imageFilterBitNegation => [:pointer, :pointer, :uint],
74
+ :SDL_imageFilterAddByte => [:pointer, :pointer, :uint, :uchar],
75
+ :SDL_imageFilterAddUint => [:pointer, :pointer, :uint, :uint],
76
+ :SDL_imageFilterAddByteToHalf => [:pointer, :pointer, :uint, :uchar],
77
+ :SDL_imageFilterSubByte => [:pointer, :pointer, :uint, :uchar],
78
+ :SDL_imageFilterSubUint => [:pointer, :pointer, :uint, :uint],
79
+ :SDL_imageFilterShiftRight => [:pointer, :pointer, :uint, :uchar],
80
+ :SDL_imageFilterShiftRightUint => [:pointer, :pointer, :uint, :uchar],
81
+ :SDL_imageFilterMultByByte => [:pointer, :pointer, :uint, :uchar],
82
+ :SDL_imageFilterShiftRightAndMultByByte => [:pointer, :pointer, :uint, :uchar, :uchar],
83
+ :SDL_imageFilterShiftLeftByte => [:pointer, :pointer, :uint, :uchar],
84
+ :SDL_imageFilterShiftLeftUint => [:pointer, :pointer, :uint, :uchar],
85
+ :SDL_imageFilterShiftLeft => [:pointer, :pointer, :uint, :uchar],
86
+ :SDL_imageFilterBinarizeUsingThreshold => [:pointer, :pointer, :uint, :uchar],
87
+ :SDL_imageFilterClipToRange => [:pointer, :pointer, :uint, :uchar, :uchar],
88
+ :SDL_imageFilterNormalizeLinear => [:pointer, :pointer, :uint, :int, :int, :int, :int],
89
+ }
90
+ retvals = {
91
+ :SDL_imageFilterMMXdetect => :int,
92
+ :SDL_imageFilterMMXoff => :void,
93
+ :SDL_imageFilterMMXon => :void,
94
+ :SDL_imageFilterAdd => :int,
95
+ :SDL_imageFilterMean => :int,
96
+ :SDL_imageFilterSub => :int,
97
+ :SDL_imageFilterAbsDiff => :int,
98
+ :SDL_imageFilterMult => :int,
99
+ :SDL_imageFilterMultNor => :int,
100
+ :SDL_imageFilterMultDivby2 => :int,
101
+ :SDL_imageFilterMultDivby4 => :int,
102
+ :SDL_imageFilterBitAnd => :int,
103
+ :SDL_imageFilterBitOr => :int,
104
+ :SDL_imageFilterDiv => :int,
105
+ :SDL_imageFilterBitNegation => :int,
106
+ :SDL_imageFilterAddByte => :int,
107
+ :SDL_imageFilterAddUint => :int,
108
+ :SDL_imageFilterAddByteToHalf => :int,
109
+ :SDL_imageFilterSubByte => :int,
110
+ :SDL_imageFilterSubUint => :int,
111
+ :SDL_imageFilterShiftRight => :int,
112
+ :SDL_imageFilterShiftRightUint => :int,
113
+ :SDL_imageFilterMultByByte => :int,
114
+ :SDL_imageFilterShiftRightAndMultByByte => :int,
115
+ :SDL_imageFilterShiftLeftByte => :int,
116
+ :SDL_imageFilterShiftLeftUint => :int,
117
+ :SDL_imageFilterShiftLeft => :int,
118
+ :SDL_imageFilterBinarizeUsingThreshold => :int,
119
+ :SDL_imageFilterClipToRange => :int,
120
+ :SDL_imageFilterNormalizeLinear => :int,
121
+ }
122
+ symbols.each do |sym|
123
+ begin
124
+ attach_function sym, args[sym], retvals[sym]
125
+ rescue FFI::NotFoundError => error
126
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
127
+ end
128
+ end
129
+ end
130
+
131
+ end
132
+
data/lib/sdl2_joystick.rb CHANGED
@@ -1,230 +1,230 @@
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_IPHONE_MAX_GFORCE = 5.0
14
- SDL_JOYSTICK_AXIS_MAX = 32767
15
- SDL_JOYSTICK_AXIS_MIN = -32768
16
- SDL_HAT_CENTERED = 0x00
17
- SDL_HAT_UP = 0x01
18
- SDL_HAT_RIGHT = 0x02
19
- SDL_HAT_DOWN = 0x04
20
- SDL_HAT_LEFT = 0x08
21
- SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT | SDL_HAT_UP)
22
- SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT | SDL_HAT_DOWN)
23
- SDL_HAT_LEFTUP = (SDL_HAT_LEFT | SDL_HAT_UP)
24
- SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT | SDL_HAT_DOWN)
25
-
26
- # Enum
27
-
28
- SDL_JOYSTICK_TYPE_UNKNOWN = 0
29
- SDL_JOYSTICK_TYPE_GAMECONTROLLER = 1
30
- SDL_JOYSTICK_TYPE_WHEEL = 2
31
- SDL_JOYSTICK_TYPE_ARCADE_STICK = 3
32
- SDL_JOYSTICK_TYPE_FLIGHT_STICK = 4
33
- SDL_JOYSTICK_TYPE_DANCE_PAD = 5
34
- SDL_JOYSTICK_TYPE_GUITAR = 6
35
- SDL_JOYSTICK_TYPE_DRUM_KIT = 7
36
- SDL_JOYSTICK_TYPE_ARCADE_PAD = 8
37
- SDL_JOYSTICK_TYPE_THROTTLE = 9
38
- SDL_JOYSTICK_POWER_UNKNOWN = -1
39
- SDL_JOYSTICK_POWER_EMPTY = 0
40
- SDL_JOYSTICK_POWER_LOW = 1
41
- SDL_JOYSTICK_POWER_MEDIUM = 2
42
- SDL_JOYSTICK_POWER_FULL = 3
43
- SDL_JOYSTICK_POWER_WIRED = 4
44
- SDL_JOYSTICK_POWER_MAX = 5
45
-
46
- # Typedef
47
-
48
- typedef :int, :SDL_JoystickID
49
- typedef :int, :SDL_JoystickType
50
- typedef :int, :SDL_JoystickPowerLevel
51
-
52
- # Struct
53
-
54
- class SDL_JoystickGUID < FFI::Struct
55
- layout(
56
- :data, [:uchar, 16],
57
- )
58
- end
59
-
60
-
61
- # Function
62
-
63
- def self.setup_joystick_symbols()
64
- symbols = [
65
- :SDL_LockJoysticks,
66
- :SDL_UnlockJoysticks,
67
- :SDL_NumJoysticks,
68
- :SDL_JoystickNameForIndex,
69
- :SDL_JoystickGetDevicePlayerIndex,
70
- :SDL_JoystickGetDeviceGUID,
71
- :SDL_JoystickGetDeviceVendor,
72
- :SDL_JoystickGetDeviceProduct,
73
- :SDL_JoystickGetDeviceProductVersion,
74
- :SDL_JoystickGetDeviceType,
75
- :SDL_JoystickGetDeviceInstanceID,
76
- :SDL_JoystickOpen,
77
- :SDL_JoystickFromInstanceID,
78
- :SDL_JoystickFromPlayerIndex,
79
- :SDL_JoystickAttachVirtual,
80
- :SDL_JoystickDetachVirtual,
81
- :SDL_JoystickIsVirtual,
82
- :SDL_JoystickSetVirtualAxis,
83
- :SDL_JoystickSetVirtualButton,
84
- :SDL_JoystickSetVirtualHat,
85
- :SDL_JoystickName,
86
- :SDL_JoystickGetPlayerIndex,
87
- :SDL_JoystickSetPlayerIndex,
88
- :SDL_JoystickGetGUID,
89
- :SDL_JoystickGetVendor,
90
- :SDL_JoystickGetProduct,
91
- :SDL_JoystickGetProductVersion,
92
- :SDL_JoystickGetSerial,
93
- :SDL_JoystickGetType,
94
- :SDL_JoystickGetGUIDString,
95
- :SDL_JoystickGetGUIDFromString,
96
- :SDL_JoystickGetAttached,
97
- :SDL_JoystickInstanceID,
98
- :SDL_JoystickNumAxes,
99
- :SDL_JoystickNumBalls,
100
- :SDL_JoystickNumHats,
101
- :SDL_JoystickNumButtons,
102
- :SDL_JoystickUpdate,
103
- :SDL_JoystickEventState,
104
- :SDL_JoystickGetAxis,
105
- :SDL_JoystickGetAxisInitialState,
106
- :SDL_JoystickGetHat,
107
- :SDL_JoystickGetBall,
108
- :SDL_JoystickGetButton,
109
- :SDL_JoystickRumble,
110
- :SDL_JoystickRumbleTriggers,
111
- :SDL_JoystickHasLED,
112
- :SDL_JoystickSetLED,
113
- :SDL_JoystickClose,
114
- :SDL_JoystickCurrentPowerLevel,
115
- ]
116
- args = {
117
- :SDL_LockJoysticks => [],
118
- :SDL_UnlockJoysticks => [],
119
- :SDL_NumJoysticks => [],
120
- :SDL_JoystickNameForIndex => [:int],
121
- :SDL_JoystickGetDevicePlayerIndex => [:int],
122
- :SDL_JoystickGetDeviceGUID => [:int],
123
- :SDL_JoystickGetDeviceVendor => [:int],
124
- :SDL_JoystickGetDeviceProduct => [:int],
125
- :SDL_JoystickGetDeviceProductVersion => [:int],
126
- :SDL_JoystickGetDeviceType => [:int],
127
- :SDL_JoystickGetDeviceInstanceID => [:int],
128
- :SDL_JoystickOpen => [:int],
129
- :SDL_JoystickFromInstanceID => [:int],
130
- :SDL_JoystickFromPlayerIndex => [:int],
131
- :SDL_JoystickAttachVirtual => [:int, :int, :int, :int],
132
- :SDL_JoystickDetachVirtual => [:int],
133
- :SDL_JoystickIsVirtual => [:int],
134
- :SDL_JoystickSetVirtualAxis => [:pointer, :int, :short],
135
- :SDL_JoystickSetVirtualButton => [:pointer, :int, :uchar],
136
- :SDL_JoystickSetVirtualHat => [:pointer, :int, :uchar],
137
- :SDL_JoystickName => [:pointer],
138
- :SDL_JoystickGetPlayerIndex => [:pointer],
139
- :SDL_JoystickSetPlayerIndex => [:pointer, :int],
140
- :SDL_JoystickGetGUID => [:pointer],
141
- :SDL_JoystickGetVendor => [:pointer],
142
- :SDL_JoystickGetProduct => [:pointer],
143
- :SDL_JoystickGetProductVersion => [:pointer],
144
- :SDL_JoystickGetSerial => [:pointer],
145
- :SDL_JoystickGetType => [:pointer],
146
- :SDL_JoystickGetGUIDString => [SDL_JoystickGUID, :pointer, :int],
147
- :SDL_JoystickGetGUIDFromString => [:pointer],
148
- :SDL_JoystickGetAttached => [:pointer],
149
- :SDL_JoystickInstanceID => [:pointer],
150
- :SDL_JoystickNumAxes => [:pointer],
151
- :SDL_JoystickNumBalls => [:pointer],
152
- :SDL_JoystickNumHats => [:pointer],
153
- :SDL_JoystickNumButtons => [:pointer],
154
- :SDL_JoystickUpdate => [],
155
- :SDL_JoystickEventState => [:int],
156
- :SDL_JoystickGetAxis => [:pointer, :int],
157
- :SDL_JoystickGetAxisInitialState => [:pointer, :int, :pointer],
158
- :SDL_JoystickGetHat => [:pointer, :int],
159
- :SDL_JoystickGetBall => [:pointer, :int, :pointer, :pointer],
160
- :SDL_JoystickGetButton => [:pointer, :int],
161
- :SDL_JoystickRumble => [:pointer, :ushort, :ushort, :uint],
162
- :SDL_JoystickRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
163
- :SDL_JoystickHasLED => [:pointer],
164
- :SDL_JoystickSetLED => [:pointer, :uchar, :uchar, :uchar],
165
- :SDL_JoystickClose => [:pointer],
166
- :SDL_JoystickCurrentPowerLevel => [:pointer],
167
- }
168
- retvals = {
169
- :SDL_LockJoysticks => :void,
170
- :SDL_UnlockJoysticks => :void,
171
- :SDL_NumJoysticks => :int,
172
- :SDL_JoystickNameForIndex => :pointer,
173
- :SDL_JoystickGetDevicePlayerIndex => :int,
174
- :SDL_JoystickGetDeviceGUID => SDL_JoystickGUID,
175
- :SDL_JoystickGetDeviceVendor => :ushort,
176
- :SDL_JoystickGetDeviceProduct => :ushort,
177
- :SDL_JoystickGetDeviceProductVersion => :ushort,
178
- :SDL_JoystickGetDeviceType => :int,
179
- :SDL_JoystickGetDeviceInstanceID => :int,
180
- :SDL_JoystickOpen => :pointer,
181
- :SDL_JoystickFromInstanceID => :pointer,
182
- :SDL_JoystickFromPlayerIndex => :pointer,
183
- :SDL_JoystickAttachVirtual => :int,
184
- :SDL_JoystickDetachVirtual => :int,
185
- :SDL_JoystickIsVirtual => :int,
186
- :SDL_JoystickSetVirtualAxis => :int,
187
- :SDL_JoystickSetVirtualButton => :int,
188
- :SDL_JoystickSetVirtualHat => :int,
189
- :SDL_JoystickName => :pointer,
190
- :SDL_JoystickGetPlayerIndex => :int,
191
- :SDL_JoystickSetPlayerIndex => :void,
192
- :SDL_JoystickGetGUID => SDL_JoystickGUID,
193
- :SDL_JoystickGetVendor => :ushort,
194
- :SDL_JoystickGetProduct => :ushort,
195
- :SDL_JoystickGetProductVersion => :ushort,
196
- :SDL_JoystickGetSerial => :pointer,
197
- :SDL_JoystickGetType => :int,
198
- :SDL_JoystickGetGUIDString => :void,
199
- :SDL_JoystickGetGUIDFromString => SDL_JoystickGUID,
200
- :SDL_JoystickGetAttached => :int,
201
- :SDL_JoystickInstanceID => :int,
202
- :SDL_JoystickNumAxes => :int,
203
- :SDL_JoystickNumBalls => :int,
204
- :SDL_JoystickNumHats => :int,
205
- :SDL_JoystickNumButtons => :int,
206
- :SDL_JoystickUpdate => :void,
207
- :SDL_JoystickEventState => :int,
208
- :SDL_JoystickGetAxis => :short,
209
- :SDL_JoystickGetAxisInitialState => :int,
210
- :SDL_JoystickGetHat => :uchar,
211
- :SDL_JoystickGetBall => :int,
212
- :SDL_JoystickGetButton => :uchar,
213
- :SDL_JoystickRumble => :int,
214
- :SDL_JoystickRumbleTriggers => :int,
215
- :SDL_JoystickHasLED => :int,
216
- :SDL_JoystickSetLED => :int,
217
- :SDL_JoystickClose => :void,
218
- :SDL_JoystickCurrentPowerLevel => :int,
219
- }
220
- symbols.each do |sym|
221
- begin
222
- attach_function sym, args[sym], retvals[sym]
223
- rescue FFI::NotFoundError => error
224
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
225
- end
226
- end
227
- end
228
-
229
- end
230
-
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_IPHONE_MAX_GFORCE = 5.0
14
+ SDL_JOYSTICK_AXIS_MAX = 32767
15
+ SDL_JOYSTICK_AXIS_MIN = -32768
16
+ SDL_HAT_CENTERED = 0x00
17
+ SDL_HAT_UP = 0x01
18
+ SDL_HAT_RIGHT = 0x02
19
+ SDL_HAT_DOWN = 0x04
20
+ SDL_HAT_LEFT = 0x08
21
+ SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT | SDL_HAT_UP)
22
+ SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT | SDL_HAT_DOWN)
23
+ SDL_HAT_LEFTUP = (SDL_HAT_LEFT | SDL_HAT_UP)
24
+ SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT | SDL_HAT_DOWN)
25
+
26
+ # Enum
27
+
28
+ SDL_JOYSTICK_TYPE_UNKNOWN = 0
29
+ SDL_JOYSTICK_TYPE_GAMECONTROLLER = 1
30
+ SDL_JOYSTICK_TYPE_WHEEL = 2
31
+ SDL_JOYSTICK_TYPE_ARCADE_STICK = 3
32
+ SDL_JOYSTICK_TYPE_FLIGHT_STICK = 4
33
+ SDL_JOYSTICK_TYPE_DANCE_PAD = 5
34
+ SDL_JOYSTICK_TYPE_GUITAR = 6
35
+ SDL_JOYSTICK_TYPE_DRUM_KIT = 7
36
+ SDL_JOYSTICK_TYPE_ARCADE_PAD = 8
37
+ SDL_JOYSTICK_TYPE_THROTTLE = 9
38
+ SDL_JOYSTICK_POWER_UNKNOWN = -1
39
+ SDL_JOYSTICK_POWER_EMPTY = 0
40
+ SDL_JOYSTICK_POWER_LOW = 1
41
+ SDL_JOYSTICK_POWER_MEDIUM = 2
42
+ SDL_JOYSTICK_POWER_FULL = 3
43
+ SDL_JOYSTICK_POWER_WIRED = 4
44
+ SDL_JOYSTICK_POWER_MAX = 5
45
+
46
+ # Typedef
47
+
48
+ typedef :int, :SDL_JoystickID
49
+ typedef :int, :SDL_JoystickType
50
+ typedef :int, :SDL_JoystickPowerLevel
51
+
52
+ # Struct
53
+
54
+ class SDL_JoystickGUID < FFI::Struct
55
+ layout(
56
+ :data, [:uchar, 16],
57
+ )
58
+ end
59
+
60
+
61
+ # Function
62
+
63
+ def self.setup_joystick_symbols()
64
+ symbols = [
65
+ :SDL_LockJoysticks,
66
+ :SDL_UnlockJoysticks,
67
+ :SDL_NumJoysticks,
68
+ :SDL_JoystickNameForIndex,
69
+ :SDL_JoystickGetDevicePlayerIndex,
70
+ :SDL_JoystickGetDeviceGUID,
71
+ :SDL_JoystickGetDeviceVendor,
72
+ :SDL_JoystickGetDeviceProduct,
73
+ :SDL_JoystickGetDeviceProductVersion,
74
+ :SDL_JoystickGetDeviceType,
75
+ :SDL_JoystickGetDeviceInstanceID,
76
+ :SDL_JoystickOpen,
77
+ :SDL_JoystickFromInstanceID,
78
+ :SDL_JoystickFromPlayerIndex,
79
+ :SDL_JoystickAttachVirtual,
80
+ :SDL_JoystickDetachVirtual,
81
+ :SDL_JoystickIsVirtual,
82
+ :SDL_JoystickSetVirtualAxis,
83
+ :SDL_JoystickSetVirtualButton,
84
+ :SDL_JoystickSetVirtualHat,
85
+ :SDL_JoystickName,
86
+ :SDL_JoystickGetPlayerIndex,
87
+ :SDL_JoystickSetPlayerIndex,
88
+ :SDL_JoystickGetGUID,
89
+ :SDL_JoystickGetVendor,
90
+ :SDL_JoystickGetProduct,
91
+ :SDL_JoystickGetProductVersion,
92
+ :SDL_JoystickGetSerial,
93
+ :SDL_JoystickGetType,
94
+ :SDL_JoystickGetGUIDString,
95
+ :SDL_JoystickGetGUIDFromString,
96
+ :SDL_JoystickGetAttached,
97
+ :SDL_JoystickInstanceID,
98
+ :SDL_JoystickNumAxes,
99
+ :SDL_JoystickNumBalls,
100
+ :SDL_JoystickNumHats,
101
+ :SDL_JoystickNumButtons,
102
+ :SDL_JoystickUpdate,
103
+ :SDL_JoystickEventState,
104
+ :SDL_JoystickGetAxis,
105
+ :SDL_JoystickGetAxisInitialState,
106
+ :SDL_JoystickGetHat,
107
+ :SDL_JoystickGetBall,
108
+ :SDL_JoystickGetButton,
109
+ :SDL_JoystickRumble,
110
+ :SDL_JoystickRumbleTriggers,
111
+ :SDL_JoystickHasLED,
112
+ :SDL_JoystickSetLED,
113
+ :SDL_JoystickClose,
114
+ :SDL_JoystickCurrentPowerLevel,
115
+ ]
116
+ args = {
117
+ :SDL_LockJoysticks => [],
118
+ :SDL_UnlockJoysticks => [],
119
+ :SDL_NumJoysticks => [],
120
+ :SDL_JoystickNameForIndex => [:int],
121
+ :SDL_JoystickGetDevicePlayerIndex => [:int],
122
+ :SDL_JoystickGetDeviceGUID => [:int],
123
+ :SDL_JoystickGetDeviceVendor => [:int],
124
+ :SDL_JoystickGetDeviceProduct => [:int],
125
+ :SDL_JoystickGetDeviceProductVersion => [:int],
126
+ :SDL_JoystickGetDeviceType => [:int],
127
+ :SDL_JoystickGetDeviceInstanceID => [:int],
128
+ :SDL_JoystickOpen => [:int],
129
+ :SDL_JoystickFromInstanceID => [:int],
130
+ :SDL_JoystickFromPlayerIndex => [:int],
131
+ :SDL_JoystickAttachVirtual => [:int, :int, :int, :int],
132
+ :SDL_JoystickDetachVirtual => [:int],
133
+ :SDL_JoystickIsVirtual => [:int],
134
+ :SDL_JoystickSetVirtualAxis => [:pointer, :int, :short],
135
+ :SDL_JoystickSetVirtualButton => [:pointer, :int, :uchar],
136
+ :SDL_JoystickSetVirtualHat => [:pointer, :int, :uchar],
137
+ :SDL_JoystickName => [:pointer],
138
+ :SDL_JoystickGetPlayerIndex => [:pointer],
139
+ :SDL_JoystickSetPlayerIndex => [:pointer, :int],
140
+ :SDL_JoystickGetGUID => [:pointer],
141
+ :SDL_JoystickGetVendor => [:pointer],
142
+ :SDL_JoystickGetProduct => [:pointer],
143
+ :SDL_JoystickGetProductVersion => [:pointer],
144
+ :SDL_JoystickGetSerial => [:pointer],
145
+ :SDL_JoystickGetType => [:pointer],
146
+ :SDL_JoystickGetGUIDString => [SDL_JoystickGUID, :pointer, :int],
147
+ :SDL_JoystickGetGUIDFromString => [:pointer],
148
+ :SDL_JoystickGetAttached => [:pointer],
149
+ :SDL_JoystickInstanceID => [:pointer],
150
+ :SDL_JoystickNumAxes => [:pointer],
151
+ :SDL_JoystickNumBalls => [:pointer],
152
+ :SDL_JoystickNumHats => [:pointer],
153
+ :SDL_JoystickNumButtons => [:pointer],
154
+ :SDL_JoystickUpdate => [],
155
+ :SDL_JoystickEventState => [:int],
156
+ :SDL_JoystickGetAxis => [:pointer, :int],
157
+ :SDL_JoystickGetAxisInitialState => [:pointer, :int, :pointer],
158
+ :SDL_JoystickGetHat => [:pointer, :int],
159
+ :SDL_JoystickGetBall => [:pointer, :int, :pointer, :pointer],
160
+ :SDL_JoystickGetButton => [:pointer, :int],
161
+ :SDL_JoystickRumble => [:pointer, :ushort, :ushort, :uint],
162
+ :SDL_JoystickRumbleTriggers => [:pointer, :ushort, :ushort, :uint],
163
+ :SDL_JoystickHasLED => [:pointer],
164
+ :SDL_JoystickSetLED => [:pointer, :uchar, :uchar, :uchar],
165
+ :SDL_JoystickClose => [:pointer],
166
+ :SDL_JoystickCurrentPowerLevel => [:pointer],
167
+ }
168
+ retvals = {
169
+ :SDL_LockJoysticks => :void,
170
+ :SDL_UnlockJoysticks => :void,
171
+ :SDL_NumJoysticks => :int,
172
+ :SDL_JoystickNameForIndex => :pointer,
173
+ :SDL_JoystickGetDevicePlayerIndex => :int,
174
+ :SDL_JoystickGetDeviceGUID => SDL_JoystickGUID,
175
+ :SDL_JoystickGetDeviceVendor => :ushort,
176
+ :SDL_JoystickGetDeviceProduct => :ushort,
177
+ :SDL_JoystickGetDeviceProductVersion => :ushort,
178
+ :SDL_JoystickGetDeviceType => :int,
179
+ :SDL_JoystickGetDeviceInstanceID => :int,
180
+ :SDL_JoystickOpen => :pointer,
181
+ :SDL_JoystickFromInstanceID => :pointer,
182
+ :SDL_JoystickFromPlayerIndex => :pointer,
183
+ :SDL_JoystickAttachVirtual => :int,
184
+ :SDL_JoystickDetachVirtual => :int,
185
+ :SDL_JoystickIsVirtual => :int,
186
+ :SDL_JoystickSetVirtualAxis => :int,
187
+ :SDL_JoystickSetVirtualButton => :int,
188
+ :SDL_JoystickSetVirtualHat => :int,
189
+ :SDL_JoystickName => :pointer,
190
+ :SDL_JoystickGetPlayerIndex => :int,
191
+ :SDL_JoystickSetPlayerIndex => :void,
192
+ :SDL_JoystickGetGUID => SDL_JoystickGUID,
193
+ :SDL_JoystickGetVendor => :ushort,
194
+ :SDL_JoystickGetProduct => :ushort,
195
+ :SDL_JoystickGetProductVersion => :ushort,
196
+ :SDL_JoystickGetSerial => :pointer,
197
+ :SDL_JoystickGetType => :int,
198
+ :SDL_JoystickGetGUIDString => :void,
199
+ :SDL_JoystickGetGUIDFromString => SDL_JoystickGUID,
200
+ :SDL_JoystickGetAttached => :int,
201
+ :SDL_JoystickInstanceID => :int,
202
+ :SDL_JoystickNumAxes => :int,
203
+ :SDL_JoystickNumBalls => :int,
204
+ :SDL_JoystickNumHats => :int,
205
+ :SDL_JoystickNumButtons => :int,
206
+ :SDL_JoystickUpdate => :void,
207
+ :SDL_JoystickEventState => :int,
208
+ :SDL_JoystickGetAxis => :short,
209
+ :SDL_JoystickGetAxisInitialState => :int,
210
+ :SDL_JoystickGetHat => :uchar,
211
+ :SDL_JoystickGetBall => :int,
212
+ :SDL_JoystickGetButton => :uchar,
213
+ :SDL_JoystickRumble => :int,
214
+ :SDL_JoystickRumbleTriggers => :int,
215
+ :SDL_JoystickHasLED => :int,
216
+ :SDL_JoystickSetLED => :int,
217
+ :SDL_JoystickClose => :void,
218
+ :SDL_JoystickCurrentPowerLevel => :int,
219
+ }
220
+ symbols.each do |sym|
221
+ begin
222
+ attach_function sym, args[sym], retvals[sym]
223
+ rescue FFI::NotFoundError => error
224
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
225
+ end
226
+ end
227
+ end
228
+
229
+ end
230
+