sdl2-bindings 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +12 -0
- data/README.md +39 -26
- data/lib/sdl2.rb +54 -99
- data/lib/sdl2_audio.rb +59 -20
- data/lib/sdl2_blendmode.rb +28 -25
- data/lib/sdl2_clipboard.rb +9 -4
- data/lib/sdl2_cpuinfo.rb +28 -5
- data/lib/sdl2_error.rb +17 -10
- data/lib/sdl2_events.rb +150 -131
- data/lib/sdl2_filesystem.rb +8 -4
- data/lib/sdl2_framerate.rb +11 -4
- data/lib/sdl2_gamecontroller.rb +112 -57
- data/lib/sdl2_gesture.rb +10 -4
- data/lib/sdl2_gfxPrimitives.rb +65 -4
- data/lib/sdl2_haptic.rb +76 -44
- data/lib/sdl2_hidapi.rb +26 -5
- data/lib/sdl2_hints.rb +146 -137
- data/lib/sdl2_image.rb +54 -7
- data/lib/sdl2_imageFilter.rb +36 -4
- data/lib/sdl2_joystick.rb +93 -38
- data/lib/sdl2_keyboard.rb +23 -5
- data/lib/sdl2_keycode.rb +6 -4
- data/lib/sdl2_log.rb +48 -32
- data/lib/sdl2_main.rb +21 -14
- data/lib/sdl2_messagebox.rb +26 -22
- data/lib/sdl2_misc.rb +7 -4
- data/lib/sdl2_mixer.rb +86 -11
- data/lib/sdl2_mouse.rb +44 -25
- data/lib/sdl2_pixels.rb +115 -99
- data/lib/sdl2_platform.rb +7 -4
- data/lib/sdl2_power.rb +12 -9
- data/lib/sdl2_rect.rb +18 -11
- data/lib/sdl2_render.rb +107 -25
- data/lib/sdl2_rotozoom.rb +14 -4
- data/lib/sdl2_rwops.rb +58 -28
- data/lib/sdl2_scancode.rb +250 -248
- data/lib/sdl2_sensor.rb +27 -9
- data/lib/sdl2_shape.rb +17 -11
- data/lib/sdl2_stdinc.rb +135 -10
- data/lib/sdl2_surface.rb +56 -15
- data/lib/sdl2_syswm.rb +47 -44
- data/lib/sdl2_timer.rb +13 -4
- data/lib/sdl2_touch.rb +18 -11
- data/lib/sdl2_ttf.rb +180 -25
- data/lib/sdl2_version.rb +13 -8
- data/lib/sdl2_video.rb +204 -110
- data/lib/sdl2_vulkan.rb +12 -4
- metadata +17 -3
data/lib/sdl2_scancode.rb
CHANGED
@@ -6,257 +6,257 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
13
|
|
14
14
|
# Enum
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
16
|
+
SCANCODE_UNKNOWN = 0
|
17
|
+
SCANCODE_A = 4
|
18
|
+
SCANCODE_B = 5
|
19
|
+
SCANCODE_C = 6
|
20
|
+
SCANCODE_D = 7
|
21
|
+
SCANCODE_E = 8
|
22
|
+
SCANCODE_F = 9
|
23
|
+
SCANCODE_G = 10
|
24
|
+
SCANCODE_H = 11
|
25
|
+
SCANCODE_I = 12
|
26
|
+
SCANCODE_J = 13
|
27
|
+
SCANCODE_K = 14
|
28
|
+
SCANCODE_L = 15
|
29
|
+
SCANCODE_M = 16
|
30
|
+
SCANCODE_N = 17
|
31
|
+
SCANCODE_O = 18
|
32
|
+
SCANCODE_P = 19
|
33
|
+
SCANCODE_Q = 20
|
34
|
+
SCANCODE_R = 21
|
35
|
+
SCANCODE_S = 22
|
36
|
+
SCANCODE_T = 23
|
37
|
+
SCANCODE_U = 24
|
38
|
+
SCANCODE_V = 25
|
39
|
+
SCANCODE_W = 26
|
40
|
+
SCANCODE_X = 27
|
41
|
+
SCANCODE_Y = 28
|
42
|
+
SCANCODE_Z = 29
|
43
|
+
SCANCODE_1 = 30
|
44
|
+
SCANCODE_2 = 31
|
45
|
+
SCANCODE_3 = 32
|
46
|
+
SCANCODE_4 = 33
|
47
|
+
SCANCODE_5 = 34
|
48
|
+
SCANCODE_6 = 35
|
49
|
+
SCANCODE_7 = 36
|
50
|
+
SCANCODE_8 = 37
|
51
|
+
SCANCODE_9 = 38
|
52
|
+
SCANCODE_0 = 39
|
53
|
+
SCANCODE_RETURN = 40
|
54
|
+
SCANCODE_ESCAPE = 41
|
55
|
+
SCANCODE_BACKSPACE = 42
|
56
|
+
SCANCODE_TAB = 43
|
57
|
+
SCANCODE_SPACE = 44
|
58
|
+
SCANCODE_MINUS = 45
|
59
|
+
SCANCODE_EQUALS = 46
|
60
|
+
SCANCODE_LEFTBRACKET = 47
|
61
|
+
SCANCODE_RIGHTBRACKET = 48
|
62
|
+
SCANCODE_BACKSLASH = 49
|
63
|
+
SCANCODE_NONUSHASH = 50
|
64
|
+
SCANCODE_SEMICOLON = 51
|
65
|
+
SCANCODE_APOSTROPHE = 52
|
66
|
+
SCANCODE_GRAVE = 53
|
67
|
+
SCANCODE_COMMA = 54
|
68
|
+
SCANCODE_PERIOD = 55
|
69
|
+
SCANCODE_SLASH = 56
|
70
|
+
SCANCODE_CAPSLOCK = 57
|
71
|
+
SCANCODE_F1 = 58
|
72
|
+
SCANCODE_F2 = 59
|
73
|
+
SCANCODE_F3 = 60
|
74
|
+
SCANCODE_F4 = 61
|
75
|
+
SCANCODE_F5 = 62
|
76
|
+
SCANCODE_F6 = 63
|
77
|
+
SCANCODE_F7 = 64
|
78
|
+
SCANCODE_F8 = 65
|
79
|
+
SCANCODE_F9 = 66
|
80
|
+
SCANCODE_F10 = 67
|
81
|
+
SCANCODE_F11 = 68
|
82
|
+
SCANCODE_F12 = 69
|
83
|
+
SCANCODE_PRINTSCREEN = 70
|
84
|
+
SCANCODE_SCROLLLOCK = 71
|
85
|
+
SCANCODE_PAUSE = 72
|
86
|
+
SCANCODE_INSERT = 73
|
87
|
+
SCANCODE_HOME = 74
|
88
|
+
SCANCODE_PAGEUP = 75
|
89
|
+
SCANCODE_DELETE = 76
|
90
|
+
SCANCODE_END = 77
|
91
|
+
SCANCODE_PAGEDOWN = 78
|
92
|
+
SCANCODE_RIGHT = 79
|
93
|
+
SCANCODE_LEFT = 80
|
94
|
+
SCANCODE_DOWN = 81
|
95
|
+
SCANCODE_UP = 82
|
96
|
+
SCANCODE_NUMLOCKCLEAR = 83
|
97
|
+
SCANCODE_KP_DIVIDE = 84
|
98
|
+
SCANCODE_KP_MULTIPLY = 85
|
99
|
+
SCANCODE_KP_MINUS = 86
|
100
|
+
SCANCODE_KP_PLUS = 87
|
101
|
+
SCANCODE_KP_ENTER = 88
|
102
|
+
SCANCODE_KP_1 = 89
|
103
|
+
SCANCODE_KP_2 = 90
|
104
|
+
SCANCODE_KP_3 = 91
|
105
|
+
SCANCODE_KP_4 = 92
|
106
|
+
SCANCODE_KP_5 = 93
|
107
|
+
SCANCODE_KP_6 = 94
|
108
|
+
SCANCODE_KP_7 = 95
|
109
|
+
SCANCODE_KP_8 = 96
|
110
|
+
SCANCODE_KP_9 = 97
|
111
|
+
SCANCODE_KP_0 = 98
|
112
|
+
SCANCODE_KP_PERIOD = 99
|
113
|
+
SCANCODE_NONUSBACKSLASH = 100
|
114
|
+
SCANCODE_APPLICATION = 101
|
115
|
+
SCANCODE_POWER = 102
|
116
|
+
SCANCODE_KP_EQUALS = 103
|
117
|
+
SCANCODE_F13 = 104
|
118
|
+
SCANCODE_F14 = 105
|
119
|
+
SCANCODE_F15 = 106
|
120
|
+
SCANCODE_F16 = 107
|
121
|
+
SCANCODE_F17 = 108
|
122
|
+
SCANCODE_F18 = 109
|
123
|
+
SCANCODE_F19 = 110
|
124
|
+
SCANCODE_F20 = 111
|
125
|
+
SCANCODE_F21 = 112
|
126
|
+
SCANCODE_F22 = 113
|
127
|
+
SCANCODE_F23 = 114
|
128
|
+
SCANCODE_F24 = 115
|
129
|
+
SCANCODE_EXECUTE = 116
|
130
|
+
SCANCODE_HELP = 117
|
131
|
+
SCANCODE_MENU = 118
|
132
|
+
SCANCODE_SELECT = 119
|
133
|
+
SCANCODE_STOP = 120
|
134
|
+
SCANCODE_AGAIN = 121
|
135
|
+
SCANCODE_UNDO = 122
|
136
|
+
SCANCODE_CUT = 123
|
137
|
+
SCANCODE_COPY = 124
|
138
|
+
SCANCODE_PASTE = 125
|
139
|
+
SCANCODE_FIND = 126
|
140
|
+
SCANCODE_MUTE = 127
|
141
|
+
SCANCODE_VOLUMEUP = 128
|
142
|
+
SCANCODE_VOLUMEDOWN = 129
|
143
|
+
SCANCODE_KP_COMMA = 133
|
144
|
+
SCANCODE_KP_EQUALSAS400 = 134
|
145
|
+
SCANCODE_INTERNATIONAL1 = 135
|
146
|
+
SCANCODE_INTERNATIONAL2 = 136
|
147
|
+
SCANCODE_INTERNATIONAL3 = 137
|
148
|
+
SCANCODE_INTERNATIONAL4 = 138
|
149
|
+
SCANCODE_INTERNATIONAL5 = 139
|
150
|
+
SCANCODE_INTERNATIONAL6 = 140
|
151
|
+
SCANCODE_INTERNATIONAL7 = 141
|
152
|
+
SCANCODE_INTERNATIONAL8 = 142
|
153
|
+
SCANCODE_INTERNATIONAL9 = 143
|
154
|
+
SCANCODE_LANG1 = 144
|
155
|
+
SCANCODE_LANG2 = 145
|
156
|
+
SCANCODE_LANG3 = 146
|
157
|
+
SCANCODE_LANG4 = 147
|
158
|
+
SCANCODE_LANG5 = 148
|
159
|
+
SCANCODE_LANG6 = 149
|
160
|
+
SCANCODE_LANG7 = 150
|
161
|
+
SCANCODE_LANG8 = 151
|
162
|
+
SCANCODE_LANG9 = 152
|
163
|
+
SCANCODE_ALTERASE = 153
|
164
|
+
SCANCODE_SYSREQ = 154
|
165
|
+
SCANCODE_CANCEL = 155
|
166
|
+
SCANCODE_CLEAR = 156
|
167
|
+
SCANCODE_PRIOR = 157
|
168
|
+
SCANCODE_RETURN2 = 158
|
169
|
+
SCANCODE_SEPARATOR = 159
|
170
|
+
SCANCODE_OUT = 160
|
171
|
+
SCANCODE_OPER = 161
|
172
|
+
SCANCODE_CLEARAGAIN = 162
|
173
|
+
SCANCODE_CRSEL = 163
|
174
|
+
SCANCODE_EXSEL = 164
|
175
|
+
SCANCODE_KP_00 = 176
|
176
|
+
SCANCODE_KP_000 = 177
|
177
|
+
SCANCODE_THOUSANDSSEPARATOR = 178
|
178
|
+
SCANCODE_DECIMALSEPARATOR = 179
|
179
|
+
SCANCODE_CURRENCYUNIT = 180
|
180
|
+
SCANCODE_CURRENCYSUBUNIT = 181
|
181
|
+
SCANCODE_KP_LEFTPAREN = 182
|
182
|
+
SCANCODE_KP_RIGHTPAREN = 183
|
183
|
+
SCANCODE_KP_LEFTBRACE = 184
|
184
|
+
SCANCODE_KP_RIGHTBRACE = 185
|
185
|
+
SCANCODE_KP_TAB = 186
|
186
|
+
SCANCODE_KP_BACKSPACE = 187
|
187
|
+
SCANCODE_KP_A = 188
|
188
|
+
SCANCODE_KP_B = 189
|
189
|
+
SCANCODE_KP_C = 190
|
190
|
+
SCANCODE_KP_D = 191
|
191
|
+
SCANCODE_KP_E = 192
|
192
|
+
SCANCODE_KP_F = 193
|
193
|
+
SCANCODE_KP_XOR = 194
|
194
|
+
SCANCODE_KP_POWER = 195
|
195
|
+
SCANCODE_KP_PERCENT = 196
|
196
|
+
SCANCODE_KP_LESS = 197
|
197
|
+
SCANCODE_KP_GREATER = 198
|
198
|
+
SCANCODE_KP_AMPERSAND = 199
|
199
|
+
SCANCODE_KP_DBLAMPERSAND = 200
|
200
|
+
SCANCODE_KP_VERTICALBAR = 201
|
201
|
+
SCANCODE_KP_DBLVERTICALBAR = 202
|
202
|
+
SCANCODE_KP_COLON = 203
|
203
|
+
SCANCODE_KP_HASH = 204
|
204
|
+
SCANCODE_KP_SPACE = 205
|
205
|
+
SCANCODE_KP_AT = 206
|
206
|
+
SCANCODE_KP_EXCLAM = 207
|
207
|
+
SCANCODE_KP_MEMSTORE = 208
|
208
|
+
SCANCODE_KP_MEMRECALL = 209
|
209
|
+
SCANCODE_KP_MEMCLEAR = 210
|
210
|
+
SCANCODE_KP_MEMADD = 211
|
211
|
+
SCANCODE_KP_MEMSUBTRACT = 212
|
212
|
+
SCANCODE_KP_MEMMULTIPLY = 213
|
213
|
+
SCANCODE_KP_MEMDIVIDE = 214
|
214
|
+
SCANCODE_KP_PLUSMINUS = 215
|
215
|
+
SCANCODE_KP_CLEAR = 216
|
216
|
+
SCANCODE_KP_CLEARENTRY = 217
|
217
|
+
SCANCODE_KP_BINARY = 218
|
218
|
+
SCANCODE_KP_OCTAL = 219
|
219
|
+
SCANCODE_KP_DECIMAL = 220
|
220
|
+
SCANCODE_KP_HEXADECIMAL = 221
|
221
|
+
SCANCODE_LCTRL = 224
|
222
|
+
SCANCODE_LSHIFT = 225
|
223
|
+
SCANCODE_LALT = 226
|
224
|
+
SCANCODE_LGUI = 227
|
225
|
+
SCANCODE_RCTRL = 228
|
226
|
+
SCANCODE_RSHIFT = 229
|
227
|
+
SCANCODE_RALT = 230
|
228
|
+
SCANCODE_RGUI = 231
|
229
|
+
SCANCODE_MODE = 257
|
230
|
+
SCANCODE_AUDIONEXT = 258
|
231
|
+
SCANCODE_AUDIOPREV = 259
|
232
|
+
SCANCODE_AUDIOSTOP = 260
|
233
|
+
SCANCODE_AUDIOPLAY = 261
|
234
|
+
SCANCODE_AUDIOMUTE = 262
|
235
|
+
SCANCODE_MEDIASELECT = 263
|
236
|
+
SCANCODE_WWW = 264
|
237
|
+
SCANCODE_MAIL = 265
|
238
|
+
SCANCODE_CALCULATOR = 266
|
239
|
+
SCANCODE_COMPUTER = 267
|
240
|
+
SCANCODE_AC_SEARCH = 268
|
241
|
+
SCANCODE_AC_HOME = 269
|
242
|
+
SCANCODE_AC_BACK = 270
|
243
|
+
SCANCODE_AC_FORWARD = 271
|
244
|
+
SCANCODE_AC_STOP = 272
|
245
|
+
SCANCODE_AC_REFRESH = 273
|
246
|
+
SCANCODE_AC_BOOKMARKS = 274
|
247
|
+
SCANCODE_BRIGHTNESSDOWN = 275
|
248
|
+
SCANCODE_BRIGHTNESSUP = 276
|
249
|
+
SCANCODE_DISPLAYSWITCH = 277
|
250
|
+
SCANCODE_KBDILLUMTOGGLE = 278
|
251
|
+
SCANCODE_KBDILLUMDOWN = 279
|
252
|
+
SCANCODE_KBDILLUMUP = 280
|
253
|
+
SCANCODE_EJECT = 281
|
254
|
+
SCANCODE_SLEEP = 282
|
255
|
+
SCANCODE_APP1 = 283
|
256
|
+
SCANCODE_APP2 = 284
|
257
|
+
SCANCODE_AUDIOREWIND = 285
|
258
|
+
SCANCODE_AUDIOFASTFORWARD = 286
|
259
|
+
NUM_SCANCODES = 512
|
260
260
|
|
261
261
|
# Typedef
|
262
262
|
|
@@ -267,18 +267,20 @@ module SDL2
|
|
267
267
|
|
268
268
|
# Function
|
269
269
|
|
270
|
-
def self.setup_scancode_symbols()
|
270
|
+
def self.setup_scancode_symbols(output_error = false)
|
271
271
|
symbols = [
|
272
272
|
]
|
273
|
+
apis = {
|
274
|
+
}
|
273
275
|
args = {
|
274
276
|
}
|
275
277
|
retvals = {
|
276
278
|
}
|
277
279
|
symbols.each do |sym|
|
278
280
|
begin
|
279
|
-
attach_function sym, args[sym], retvals[sym]
|
281
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
280
282
|
rescue FFI::NotFoundError => error
|
281
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
283
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
282
284
|
end
|
283
285
|
end
|
284
286
|
end
|
data/lib/sdl2_sensor.rb
CHANGED
@@ -6,18 +6,18 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
|
-
|
13
|
+
STANDARD_GRAVITY = 9.80665
|
14
14
|
|
15
15
|
# Enum
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
SENSOR_INVALID = -1
|
18
|
+
SENSOR_UNKNOWN = 0
|
19
|
+
SENSOR_ACCEL = 1
|
20
|
+
SENSOR_GYRO = 2
|
21
21
|
|
22
22
|
# Typedef
|
23
23
|
|
@@ -29,7 +29,7 @@ module SDL2
|
|
29
29
|
|
30
30
|
# Function
|
31
31
|
|
32
|
-
def self.setup_sensor_symbols()
|
32
|
+
def self.setup_sensor_symbols(output_error = false)
|
33
33
|
symbols = [
|
34
34
|
:SDL_LockSensors,
|
35
35
|
:SDL_UnlockSensors,
|
@@ -48,6 +48,24 @@ module SDL2
|
|
48
48
|
:SDL_SensorClose,
|
49
49
|
:SDL_SensorUpdate,
|
50
50
|
]
|
51
|
+
apis = {
|
52
|
+
:SDL_LockSensors => :LockSensors,
|
53
|
+
:SDL_UnlockSensors => :UnlockSensors,
|
54
|
+
:SDL_NumSensors => :NumSensors,
|
55
|
+
:SDL_SensorGetDeviceName => :SensorGetDeviceName,
|
56
|
+
:SDL_SensorGetDeviceType => :SensorGetDeviceType,
|
57
|
+
:SDL_SensorGetDeviceNonPortableType => :SensorGetDeviceNonPortableType,
|
58
|
+
:SDL_SensorGetDeviceInstanceID => :SensorGetDeviceInstanceID,
|
59
|
+
:SDL_SensorOpen => :SensorOpen,
|
60
|
+
:SDL_SensorFromInstanceID => :SensorFromInstanceID,
|
61
|
+
:SDL_SensorGetName => :SensorGetName,
|
62
|
+
:SDL_SensorGetType => :SensorGetType,
|
63
|
+
:SDL_SensorGetNonPortableType => :SensorGetNonPortableType,
|
64
|
+
:SDL_SensorGetInstanceID => :SensorGetInstanceID,
|
65
|
+
:SDL_SensorGetData => :SensorGetData,
|
66
|
+
:SDL_SensorClose => :SensorClose,
|
67
|
+
:SDL_SensorUpdate => :SensorUpdate,
|
68
|
+
}
|
51
69
|
args = {
|
52
70
|
:SDL_LockSensors => [],
|
53
71
|
:SDL_UnlockSensors => [],
|
@@ -86,9 +104,9 @@ module SDL2
|
|
86
104
|
}
|
87
105
|
symbols.each do |sym|
|
88
106
|
begin
|
89
|
-
attach_function sym, args[sym], retvals[sym]
|
107
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
90
108
|
rescue FFI::NotFoundError => error
|
91
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
109
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
92
110
|
end
|
93
111
|
end
|
94
112
|
end
|
data/lib/sdl2_shape.rb
CHANGED
@@ -7,13 +7,13 @@
|
|
7
7
|
require 'ffi'
|
8
8
|
require_relative 'sdl2_pixels'
|
9
9
|
|
10
|
-
module
|
10
|
+
module SDL
|
11
11
|
extend FFI::Library
|
12
12
|
# Define/Macro
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
NONSHAPEABLE_WINDOW = -1
|
15
|
+
INVALID_SHAPE_ARGUMENT = -2
|
16
|
+
WINDOW_LACKS_SHAPE = -3
|
17
17
|
|
18
18
|
# Enum
|
19
19
|
|
@@ -28,30 +28,36 @@ module SDL2
|
|
28
28
|
|
29
29
|
# Struct
|
30
30
|
|
31
|
-
class
|
31
|
+
class WindowShapeParams < FFI::Union
|
32
32
|
layout(
|
33
33
|
:binarizationCutoff, :uchar,
|
34
|
-
:colorKey,
|
34
|
+
:colorKey, Color,
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
38
|
-
class
|
38
|
+
class WindowShapeMode < FFI::Struct
|
39
39
|
layout(
|
40
40
|
:mode, :int,
|
41
|
-
:parameters,
|
41
|
+
:parameters, WindowShapeParams,
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
45
45
|
|
46
46
|
# Function
|
47
47
|
|
48
|
-
def self.setup_shape_symbols()
|
48
|
+
def self.setup_shape_symbols(output_error = false)
|
49
49
|
symbols = [
|
50
50
|
:SDL_CreateShapedWindow,
|
51
51
|
:SDL_IsShapedWindow,
|
52
52
|
:SDL_SetWindowShape,
|
53
53
|
:SDL_GetShapedWindowMode,
|
54
54
|
]
|
55
|
+
apis = {
|
56
|
+
:SDL_CreateShapedWindow => :CreateShapedWindow,
|
57
|
+
:SDL_IsShapedWindow => :IsShapedWindow,
|
58
|
+
:SDL_SetWindowShape => :SetWindowShape,
|
59
|
+
:SDL_GetShapedWindowMode => :GetShapedWindowMode,
|
60
|
+
}
|
55
61
|
args = {
|
56
62
|
:SDL_CreateShapedWindow => [:pointer, :uint, :uint, :uint, :uint, :uint],
|
57
63
|
:SDL_IsShapedWindow => [:pointer],
|
@@ -66,9 +72,9 @@ module SDL2
|
|
66
72
|
}
|
67
73
|
symbols.each do |sym|
|
68
74
|
begin
|
69
|
-
attach_function sym, args[sym], retvals[sym]
|
75
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
70
76
|
rescue FFI::NotFoundError => error
|
71
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
77
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
72
78
|
end
|
73
79
|
end
|
74
80
|
end
|