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_joystick.rb
CHANGED
@@ -6,42 +6,42 @@
|
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
IPHONE_MAX_GFORCE = 5.0
|
14
|
+
JOYSTICK_AXIS_MAX = 32767
|
15
|
+
JOYSTICK_AXIS_MIN = -32768
|
16
|
+
HAT_CENTERED = 0x00
|
17
|
+
HAT_UP = 0x01
|
18
|
+
HAT_RIGHT = 0x02
|
19
|
+
HAT_DOWN = 0x04
|
20
|
+
HAT_LEFT = 0x08
|
21
|
+
HAT_RIGHTUP = (HAT_RIGHT | HAT_UP)
|
22
|
+
HAT_RIGHTDOWN = (HAT_RIGHT | HAT_DOWN)
|
23
|
+
HAT_LEFTUP = (HAT_LEFT | HAT_UP)
|
24
|
+
HAT_LEFTDOWN = (HAT_LEFT | HAT_DOWN)
|
25
25
|
|
26
26
|
# Enum
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
JOYSTICK_TYPE_UNKNOWN = 0
|
29
|
+
JOYSTICK_TYPE_GAMECONTROLLER = 1
|
30
|
+
JOYSTICK_TYPE_WHEEL = 2
|
31
|
+
JOYSTICK_TYPE_ARCADE_STICK = 3
|
32
|
+
JOYSTICK_TYPE_FLIGHT_STICK = 4
|
33
|
+
JOYSTICK_TYPE_DANCE_PAD = 5
|
34
|
+
JOYSTICK_TYPE_GUITAR = 6
|
35
|
+
JOYSTICK_TYPE_DRUM_KIT = 7
|
36
|
+
JOYSTICK_TYPE_ARCADE_PAD = 8
|
37
|
+
JOYSTICK_TYPE_THROTTLE = 9
|
38
|
+
JOYSTICK_POWER_UNKNOWN = -1
|
39
|
+
JOYSTICK_POWER_EMPTY = 0
|
40
|
+
JOYSTICK_POWER_LOW = 1
|
41
|
+
JOYSTICK_POWER_MEDIUM = 2
|
42
|
+
JOYSTICK_POWER_FULL = 3
|
43
|
+
JOYSTICK_POWER_WIRED = 4
|
44
|
+
JOYSTICK_POWER_MAX = 5
|
45
45
|
|
46
46
|
# Typedef
|
47
47
|
|
@@ -51,7 +51,7 @@ module SDL2
|
|
51
51
|
|
52
52
|
# Struct
|
53
53
|
|
54
|
-
class
|
54
|
+
class JoystickGUID < FFI::Struct
|
55
55
|
layout(
|
56
56
|
:data, [:uchar, 16],
|
57
57
|
)
|
@@ -60,7 +60,7 @@ module SDL2
|
|
60
60
|
|
61
61
|
# Function
|
62
62
|
|
63
|
-
def self.setup_joystick_symbols()
|
63
|
+
def self.setup_joystick_symbols(output_error = false)
|
64
64
|
symbols = [
|
65
65
|
:SDL_LockJoysticks,
|
66
66
|
:SDL_UnlockJoysticks,
|
@@ -116,6 +116,61 @@ module SDL2
|
|
116
116
|
:SDL_JoystickClose,
|
117
117
|
:SDL_JoystickCurrentPowerLevel,
|
118
118
|
]
|
119
|
+
apis = {
|
120
|
+
:SDL_LockJoysticks => :LockJoysticks,
|
121
|
+
:SDL_UnlockJoysticks => :UnlockJoysticks,
|
122
|
+
:SDL_NumJoysticks => :NumJoysticks,
|
123
|
+
:SDL_JoystickNameForIndex => :JoystickNameForIndex,
|
124
|
+
:SDL_JoystickGetDevicePlayerIndex => :JoystickGetDevicePlayerIndex,
|
125
|
+
:SDL_JoystickGetDeviceGUID => :JoystickGetDeviceGUID,
|
126
|
+
:SDL_JoystickGetDeviceVendor => :JoystickGetDeviceVendor,
|
127
|
+
:SDL_JoystickGetDeviceProduct => :JoystickGetDeviceProduct,
|
128
|
+
:SDL_JoystickGetDeviceProductVersion => :JoystickGetDeviceProductVersion,
|
129
|
+
:SDL_JoystickGetDeviceType => :JoystickGetDeviceType,
|
130
|
+
:SDL_JoystickGetDeviceInstanceID => :JoystickGetDeviceInstanceID,
|
131
|
+
:SDL_JoystickOpen => :JoystickOpen,
|
132
|
+
:SDL_JoystickFromInstanceID => :JoystickFromInstanceID,
|
133
|
+
:SDL_JoystickFromPlayerIndex => :JoystickFromPlayerIndex,
|
134
|
+
:SDL_JoystickAttachVirtual => :JoystickAttachVirtual,
|
135
|
+
:SDL_JoystickDetachVirtual => :JoystickDetachVirtual,
|
136
|
+
:SDL_JoystickIsVirtual => :JoystickIsVirtual,
|
137
|
+
:SDL_JoystickSetVirtualAxis => :JoystickSetVirtualAxis,
|
138
|
+
:SDL_JoystickSetVirtualButton => :JoystickSetVirtualButton,
|
139
|
+
:SDL_JoystickSetVirtualHat => :JoystickSetVirtualHat,
|
140
|
+
:SDL_JoystickName => :JoystickName,
|
141
|
+
:SDL_JoystickGetPlayerIndex => :JoystickGetPlayerIndex,
|
142
|
+
:SDL_JoystickSetPlayerIndex => :JoystickSetPlayerIndex,
|
143
|
+
:SDL_JoystickGetGUID => :JoystickGetGUID,
|
144
|
+
:SDL_JoystickGetVendor => :JoystickGetVendor,
|
145
|
+
:SDL_JoystickGetProduct => :JoystickGetProduct,
|
146
|
+
:SDL_JoystickGetProductVersion => :JoystickGetProductVersion,
|
147
|
+
:SDL_JoystickGetSerial => :JoystickGetSerial,
|
148
|
+
:SDL_JoystickGetType => :JoystickGetType,
|
149
|
+
:SDL_JoystickGetGUIDString => :JoystickGetGUIDString,
|
150
|
+
:SDL_JoystickGetGUIDFromString => :JoystickGetGUIDFromString,
|
151
|
+
:SDL_JoystickGetAttached => :JoystickGetAttached,
|
152
|
+
:SDL_JoystickInstanceID => :JoystickInstanceID,
|
153
|
+
:SDL_JoystickNumAxes => :JoystickNumAxes,
|
154
|
+
:SDL_JoystickNumBalls => :JoystickNumBalls,
|
155
|
+
:SDL_JoystickNumHats => :JoystickNumHats,
|
156
|
+
:SDL_JoystickNumButtons => :JoystickNumButtons,
|
157
|
+
:SDL_JoystickUpdate => :JoystickUpdate,
|
158
|
+
:SDL_JoystickEventState => :JoystickEventState,
|
159
|
+
:SDL_JoystickGetAxis => :JoystickGetAxis,
|
160
|
+
:SDL_JoystickGetAxisInitialState => :JoystickGetAxisInitialState,
|
161
|
+
:SDL_JoystickGetHat => :JoystickGetHat,
|
162
|
+
:SDL_JoystickGetBall => :JoystickGetBall,
|
163
|
+
:SDL_JoystickGetButton => :JoystickGetButton,
|
164
|
+
:SDL_JoystickRumble => :JoystickRumble,
|
165
|
+
:SDL_JoystickRumbleTriggers => :JoystickRumbleTriggers,
|
166
|
+
:SDL_JoystickHasLED => :JoystickHasLED,
|
167
|
+
:SDL_JoystickHasRumble => :JoystickHasRumble,
|
168
|
+
:SDL_JoystickHasRumbleTriggers => :JoystickHasRumbleTriggers,
|
169
|
+
:SDL_JoystickSetLED => :JoystickSetLED,
|
170
|
+
:SDL_JoystickSendEffect => :JoystickSendEffect,
|
171
|
+
:SDL_JoystickClose => :JoystickClose,
|
172
|
+
:SDL_JoystickCurrentPowerLevel => :JoystickCurrentPowerLevel,
|
173
|
+
}
|
119
174
|
args = {
|
120
175
|
:SDL_LockJoysticks => [],
|
121
176
|
:SDL_UnlockJoysticks => [],
|
@@ -146,7 +201,7 @@ module SDL2
|
|
146
201
|
:SDL_JoystickGetProductVersion => [:pointer],
|
147
202
|
:SDL_JoystickGetSerial => [:pointer],
|
148
203
|
:SDL_JoystickGetType => [:pointer],
|
149
|
-
:SDL_JoystickGetGUIDString => [
|
204
|
+
:SDL_JoystickGetGUIDString => [JoystickGUID.by_value, :pointer, :int],
|
150
205
|
:SDL_JoystickGetGUIDFromString => [:pointer],
|
151
206
|
:SDL_JoystickGetAttached => [:pointer],
|
152
207
|
:SDL_JoystickInstanceID => [:pointer],
|
@@ -177,7 +232,7 @@ module SDL2
|
|
177
232
|
:SDL_NumJoysticks => :int,
|
178
233
|
:SDL_JoystickNameForIndex => :pointer,
|
179
234
|
:SDL_JoystickGetDevicePlayerIndex => :int,
|
180
|
-
:SDL_JoystickGetDeviceGUID =>
|
235
|
+
:SDL_JoystickGetDeviceGUID => JoystickGUID.by_value,
|
181
236
|
:SDL_JoystickGetDeviceVendor => :ushort,
|
182
237
|
:SDL_JoystickGetDeviceProduct => :ushort,
|
183
238
|
:SDL_JoystickGetDeviceProductVersion => :ushort,
|
@@ -195,14 +250,14 @@ module SDL2
|
|
195
250
|
:SDL_JoystickName => :pointer,
|
196
251
|
:SDL_JoystickGetPlayerIndex => :int,
|
197
252
|
:SDL_JoystickSetPlayerIndex => :void,
|
198
|
-
:SDL_JoystickGetGUID =>
|
253
|
+
:SDL_JoystickGetGUID => JoystickGUID.by_value,
|
199
254
|
:SDL_JoystickGetVendor => :ushort,
|
200
255
|
:SDL_JoystickGetProduct => :ushort,
|
201
256
|
:SDL_JoystickGetProductVersion => :ushort,
|
202
257
|
:SDL_JoystickGetSerial => :pointer,
|
203
258
|
:SDL_JoystickGetType => :int,
|
204
259
|
:SDL_JoystickGetGUIDString => :void,
|
205
|
-
:SDL_JoystickGetGUIDFromString =>
|
260
|
+
:SDL_JoystickGetGUIDFromString => JoystickGUID.by_value,
|
206
261
|
:SDL_JoystickGetAttached => :int,
|
207
262
|
:SDL_JoystickInstanceID => :int,
|
208
263
|
:SDL_JoystickNumAxes => :int,
|
@@ -228,9 +283,9 @@ module SDL2
|
|
228
283
|
}
|
229
284
|
symbols.each do |sym|
|
230
285
|
begin
|
231
|
-
attach_function sym, args[sym], retvals[sym]
|
286
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
232
287
|
rescue FFI::NotFoundError => error
|
233
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
288
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
234
289
|
end
|
235
290
|
end
|
236
291
|
end
|
data/lib/sdl2_keyboard.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
@@ -19,7 +19,7 @@ module SDL2
|
|
19
19
|
|
20
20
|
# Struct
|
21
21
|
|
22
|
-
class
|
22
|
+
class Keysym < FFI::Struct
|
23
23
|
layout(
|
24
24
|
:scancode, :int,
|
25
25
|
:sym, :int,
|
@@ -31,7 +31,7 @@ module SDL2
|
|
31
31
|
|
32
32
|
# Function
|
33
33
|
|
34
|
-
def self.setup_keyboard_symbols()
|
34
|
+
def self.setup_keyboard_symbols(output_error = false)
|
35
35
|
symbols = [
|
36
36
|
:SDL_GetKeyboardFocus,
|
37
37
|
:SDL_GetKeyboardState,
|
@@ -50,6 +50,24 @@ module SDL2
|
|
50
50
|
:SDL_HasScreenKeyboardSupport,
|
51
51
|
:SDL_IsScreenKeyboardShown,
|
52
52
|
]
|
53
|
+
apis = {
|
54
|
+
:SDL_GetKeyboardFocus => :GetKeyboardFocus,
|
55
|
+
:SDL_GetKeyboardState => :GetKeyboardState,
|
56
|
+
:SDL_GetModState => :GetModState,
|
57
|
+
:SDL_SetModState => :SetModState,
|
58
|
+
:SDL_GetKeyFromScancode => :GetKeyFromScancode,
|
59
|
+
:SDL_GetScancodeFromKey => :GetScancodeFromKey,
|
60
|
+
:SDL_GetScancodeName => :GetScancodeName,
|
61
|
+
:SDL_GetScancodeFromName => :GetScancodeFromName,
|
62
|
+
:SDL_GetKeyName => :GetKeyName,
|
63
|
+
:SDL_GetKeyFromName => :GetKeyFromName,
|
64
|
+
:SDL_StartTextInput => :StartTextInput,
|
65
|
+
:SDL_IsTextInputActive => :IsTextInputActive,
|
66
|
+
:SDL_StopTextInput => :StopTextInput,
|
67
|
+
:SDL_SetTextInputRect => :SetTextInputRect,
|
68
|
+
:SDL_HasScreenKeyboardSupport => :HasScreenKeyboardSupport,
|
69
|
+
:SDL_IsScreenKeyboardShown => :IsScreenKeyboardShown,
|
70
|
+
}
|
53
71
|
args = {
|
54
72
|
:SDL_GetKeyboardFocus => [],
|
55
73
|
:SDL_GetKeyboardState => [:pointer],
|
@@ -88,9 +106,9 @@ module SDL2
|
|
88
106
|
}
|
89
107
|
symbols.each do |sym|
|
90
108
|
begin
|
91
|
-
attach_function sym, args[sym], retvals[sym]
|
109
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
92
110
|
rescue FFI::NotFoundError => error
|
93
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
111
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
94
112
|
end
|
95
113
|
end
|
96
114
|
end
|
data/lib/sdl2_keycode.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
@@ -283,18 +283,20 @@ module SDL2
|
|
283
283
|
|
284
284
|
# Function
|
285
285
|
|
286
|
-
def self.setup_keycode_symbols()
|
286
|
+
def self.setup_keycode_symbols(output_error = false)
|
287
287
|
symbols = [
|
288
288
|
]
|
289
|
+
apis = {
|
290
|
+
}
|
289
291
|
args = {
|
290
292
|
}
|
291
293
|
retvals = {
|
292
294
|
}
|
293
295
|
symbols.each do |sym|
|
294
296
|
begin
|
295
|
-
attach_function sym, args[sym], retvals[sym]
|
297
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
296
298
|
rescue FFI::NotFoundError => error
|
297
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
299
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
298
300
|
end
|
299
301
|
end
|
300
302
|
end
|
data/lib/sdl2_log.rb
CHANGED
@@ -6,41 +6,41 @@
|
|
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
|
+
MAX_LOG_MESSAGE = 4096
|
14
14
|
|
15
15
|
# Enum
|
16
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
|
-
|
17
|
+
LOG_CATEGORY_APPLICATION = 0
|
18
|
+
LOG_CATEGORY_ERROR = 1
|
19
|
+
LOG_CATEGORY_ASSERT = 2
|
20
|
+
LOG_CATEGORY_SYSTEM = 3
|
21
|
+
LOG_CATEGORY_AUDIO = 4
|
22
|
+
LOG_CATEGORY_VIDEO = 5
|
23
|
+
LOG_CATEGORY_RENDER = 6
|
24
|
+
LOG_CATEGORY_INPUT = 7
|
25
|
+
LOG_CATEGORY_TEST = 8
|
26
|
+
LOG_CATEGORY_RESERVED1 = 9
|
27
|
+
LOG_CATEGORY_RESERVED2 = 10
|
28
|
+
LOG_CATEGORY_RESERVED3 = 11
|
29
|
+
LOG_CATEGORY_RESERVED4 = 12
|
30
|
+
LOG_CATEGORY_RESERVED5 = 13
|
31
|
+
LOG_CATEGORY_RESERVED6 = 14
|
32
|
+
LOG_CATEGORY_RESERVED7 = 15
|
33
|
+
LOG_CATEGORY_RESERVED8 = 16
|
34
|
+
LOG_CATEGORY_RESERVED9 = 17
|
35
|
+
LOG_CATEGORY_RESERVED10 = 18
|
36
|
+
LOG_CATEGORY_CUSTOM = 19
|
37
|
+
LOG_PRIORITY_VERBOSE = 1
|
38
|
+
LOG_PRIORITY_DEBUG = 2
|
39
|
+
LOG_PRIORITY_INFO = 3
|
40
|
+
LOG_PRIORITY_WARN = 4
|
41
|
+
LOG_PRIORITY_ERROR = 5
|
42
|
+
LOG_PRIORITY_CRITICAL = 6
|
43
|
+
NUM_LOG_PRIORITIES = 7
|
44
44
|
|
45
45
|
# Typedef
|
46
46
|
|
@@ -53,7 +53,7 @@ module SDL2
|
|
53
53
|
|
54
54
|
# Function
|
55
55
|
|
56
|
-
def self.setup_log_symbols()
|
56
|
+
def self.setup_log_symbols(output_error = false)
|
57
57
|
symbols = [
|
58
58
|
:SDL_LogSetAllPriority,
|
59
59
|
:SDL_LogSetPriority,
|
@@ -70,6 +70,22 @@ module SDL2
|
|
70
70
|
:SDL_LogGetOutputFunction,
|
71
71
|
:SDL_LogSetOutputFunction,
|
72
72
|
]
|
73
|
+
apis = {
|
74
|
+
:SDL_LogSetAllPriority => :LogSetAllPriority,
|
75
|
+
:SDL_LogSetPriority => :LogSetPriority,
|
76
|
+
:SDL_LogGetPriority => :LogGetPriority,
|
77
|
+
:SDL_LogResetPriorities => :LogResetPriorities,
|
78
|
+
:SDL_Log => :Log,
|
79
|
+
:SDL_LogVerbose => :LogVerbose,
|
80
|
+
:SDL_LogDebug => :LogDebug,
|
81
|
+
:SDL_LogInfo => :LogInfo,
|
82
|
+
:SDL_LogWarn => :LogWarn,
|
83
|
+
:SDL_LogError => :LogError,
|
84
|
+
:SDL_LogCritical => :LogCritical,
|
85
|
+
:SDL_LogMessage => :LogMessage,
|
86
|
+
:SDL_LogGetOutputFunction => :LogGetOutputFunction,
|
87
|
+
:SDL_LogSetOutputFunction => :LogSetOutputFunction,
|
88
|
+
}
|
73
89
|
args = {
|
74
90
|
:SDL_LogSetAllPriority => [:int],
|
75
91
|
:SDL_LogSetPriority => [:int, :int],
|
@@ -104,9 +120,9 @@ module SDL2
|
|
104
120
|
}
|
105
121
|
symbols.each do |sym|
|
106
122
|
begin
|
107
|
-
attach_function sym, args[sym], retvals[sym]
|
123
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
108
124
|
rescue FFI::NotFoundError => error
|
109
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
125
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
110
126
|
end
|
111
127
|
end
|
112
128
|
end
|
data/lib/sdl2_main.rb
CHANGED
@@ -6,20 +6,20 @@
|
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
INIT_TIMER = 0x00000001
|
14
|
+
INIT_AUDIO = 0x00000010
|
15
|
+
INIT_VIDEO = 0x00000020
|
16
|
+
INIT_JOYSTICK = 0x00000200
|
17
|
+
INIT_HAPTIC = 0x00001000
|
18
|
+
INIT_GAMECONTROLLER = 0x00002000
|
19
|
+
INIT_EVENTS = 0x00004000
|
20
|
+
INIT_SENSOR = 0x00008000
|
21
|
+
INIT_NOPARACHUTE = 0x00100000
|
22
|
+
INIT_EVERYTHING = ( INIT_TIMER | INIT_AUDIO | INIT_VIDEO | INIT_EVENTS | INIT_JOYSTICK | INIT_HAPTIC | INIT_GAMECONTROLLER | INIT_SENSOR )
|
23
23
|
|
24
24
|
# Enum
|
25
25
|
|
@@ -32,7 +32,7 @@ module SDL2
|
|
32
32
|
|
33
33
|
# Function
|
34
34
|
|
35
|
-
def self.setup_main_symbols()
|
35
|
+
def self.setup_main_symbols(output_error = false)
|
36
36
|
symbols = [
|
37
37
|
:SDL_Init,
|
38
38
|
:SDL_InitSubSystem,
|
@@ -40,6 +40,13 @@ module SDL2
|
|
40
40
|
:SDL_WasInit,
|
41
41
|
:SDL_Quit,
|
42
42
|
]
|
43
|
+
apis = {
|
44
|
+
:SDL_Init => :Init,
|
45
|
+
:SDL_InitSubSystem => :InitSubSystem,
|
46
|
+
:SDL_QuitSubSystem => :QuitSubSystem,
|
47
|
+
:SDL_WasInit => :WasInit,
|
48
|
+
:SDL_Quit => :Quit,
|
49
|
+
}
|
43
50
|
args = {
|
44
51
|
:SDL_Init => [:uint],
|
45
52
|
:SDL_InitSubSystem => [:uint],
|
@@ -56,9 +63,9 @@ module SDL2
|
|
56
63
|
}
|
57
64
|
symbols.each do |sym|
|
58
65
|
begin
|
59
|
-
attach_function sym, args[sym], retvals[sym]
|
66
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
60
67
|
rescue FFI::NotFoundError => error
|
61
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
68
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
62
69
|
end
|
63
70
|
end
|
64
71
|
end
|
data/lib/sdl2_messagebox.rb
CHANGED
@@ -6,26 +6,26 @@
|
|
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
|
-
|
16
|
+
MESSAGEBOX_ERROR = 16
|
17
|
+
MESSAGEBOX_WARNING = 32
|
18
|
+
MESSAGEBOX_INFORMATION = 64
|
19
|
+
MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 128
|
20
|
+
MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 256
|
21
|
+
MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 1
|
22
|
+
MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 2
|
23
|
+
MESSAGEBOX_COLOR_BACKGROUND = 0
|
24
|
+
MESSAGEBOX_COLOR_TEXT = 1
|
25
|
+
MESSAGEBOX_COLOR_BUTTON_BORDER = 2
|
26
|
+
MESSAGEBOX_COLOR_BUTTON_BACKGROUND = 3
|
27
|
+
MESSAGEBOX_COLOR_BUTTON_SELECTED = 4
|
28
|
+
MESSAGEBOX_COLOR_MAX = 5
|
29
29
|
|
30
30
|
# Typedef
|
31
31
|
|
@@ -35,7 +35,7 @@ module SDL2
|
|
35
35
|
|
36
36
|
# Struct
|
37
37
|
|
38
|
-
class
|
38
|
+
class MessageBoxButtonData < FFI::Struct
|
39
39
|
layout(
|
40
40
|
:flags, :uint,
|
41
41
|
:buttonid, :int,
|
@@ -43,7 +43,7 @@ module SDL2
|
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
|
-
class
|
46
|
+
class MessageBoxColor < FFI::Struct
|
47
47
|
layout(
|
48
48
|
:r, :uchar,
|
49
49
|
:g, :uchar,
|
@@ -51,13 +51,13 @@ module SDL2
|
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
54
|
-
class
|
54
|
+
class MessageBoxColorScheme < FFI::Struct
|
55
55
|
layout(
|
56
|
-
:colors, [
|
56
|
+
:colors, [MessageBoxColor, 5],
|
57
57
|
)
|
58
58
|
end
|
59
59
|
|
60
|
-
class
|
60
|
+
class MessageBoxData < FFI::Struct
|
61
61
|
layout(
|
62
62
|
:flags, :uint,
|
63
63
|
:window, :pointer,
|
@@ -72,11 +72,15 @@ module SDL2
|
|
72
72
|
|
73
73
|
# Function
|
74
74
|
|
75
|
-
def self.setup_messagebox_symbols()
|
75
|
+
def self.setup_messagebox_symbols(output_error = false)
|
76
76
|
symbols = [
|
77
77
|
:SDL_ShowMessageBox,
|
78
78
|
:SDL_ShowSimpleMessageBox,
|
79
79
|
]
|
80
|
+
apis = {
|
81
|
+
:SDL_ShowMessageBox => :ShowMessageBox,
|
82
|
+
:SDL_ShowSimpleMessageBox => :ShowSimpleMessageBox,
|
83
|
+
}
|
80
84
|
args = {
|
81
85
|
:SDL_ShowMessageBox => [:pointer, :pointer],
|
82
86
|
:SDL_ShowSimpleMessageBox => [:uint, :pointer, :pointer, :pointer],
|
@@ -87,9 +91,9 @@ module SDL2
|
|
87
91
|
}
|
88
92
|
symbols.each do |sym|
|
89
93
|
begin
|
90
|
-
attach_function sym, args[sym], retvals[sym]
|
94
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
91
95
|
rescue FFI::NotFoundError => error
|
92
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
96
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
93
97
|
end
|
94
98
|
end
|
95
99
|
end
|
data/lib/sdl2_misc.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
@@ -22,10 +22,13 @@ module SDL2
|
|
22
22
|
|
23
23
|
# Function
|
24
24
|
|
25
|
-
def self.setup_misc_symbols()
|
25
|
+
def self.setup_misc_symbols(output_error = false)
|
26
26
|
symbols = [
|
27
27
|
:SDL_OpenURL,
|
28
28
|
]
|
29
|
+
apis = {
|
30
|
+
:SDL_OpenURL => :OpenURL,
|
31
|
+
}
|
29
32
|
args = {
|
30
33
|
:SDL_OpenURL => [:pointer],
|
31
34
|
}
|
@@ -34,9 +37,9 @@ module SDL2
|
|
34
37
|
}
|
35
38
|
symbols.each do |sym|
|
36
39
|
begin
|
37
|
-
attach_function sym, args[sym], retvals[sym]
|
40
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
38
41
|
rescue FFI::NotFoundError => error
|
39
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
42
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|