sdl2-bindings 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +145 -134
- data/LICENSE.txt +0 -0
- data/README.md +108 -86
- data/lib/sdl2.rb +131 -131
- data/lib/sdl2_audio.rb +265 -261
- data/lib/sdl2_blendmode.rb +72 -72
- data/lib/sdl2_clipboard.rb +56 -56
- data/lib/sdl2_cpuinfo.rb +137 -129
- data/lib/sdl2_error.rb +71 -71
- data/lib/sdl2_events.rb +575 -564
- data/lib/sdl2_filesystem.rb +52 -52
- data/lib/sdl2_framerate.rb +74 -74
- data/lib/sdl2_gamecontroller.rb +345 -329
- data/lib/sdl2_gesture.rb +61 -61
- data/lib/sdl2_gfxPrimitives.rb +283 -283
- data/lib/sdl2_guid.rb +58 -0
- data/lib/sdl2_haptic.rb +301 -301
- data/lib/sdl2_hidapi.rb +139 -139
- data/lib/sdl2_hints.rb +240 -221
- data/lib/sdl2_image.rb +296 -296
- data/lib/sdl2_imageFilter.rb +164 -164
- data/lib/sdl2_joystick.rb +332 -294
- data/lib/sdl2_keyboard.rb +129 -125
- data/lib/sdl2_keycode.rb +311 -307
- data/lib/sdl2_log.rb +131 -131
- data/lib/sdl2_main.rb +74 -74
- data/lib/sdl2_messagebox.rb +102 -102
- data/lib/sdl2_misc.rb +48 -48
- data/lib/sdl2_mixer.rb +464 -464
- data/lib/sdl2_mouse.rb +136 -136
- data/lib/sdl2_pixels.rb +240 -240
- data/lib/sdl2_platform.rb +48 -48
- data/lib/sdl2_power.rb +54 -54
- data/lib/sdl2_rect.rb +145 -145
- data/lib/sdl2_render.rb +408 -408
- data/lib/sdl2_rotozoom.rb +76 -76
- data/lib/sdl2_rwops.rb +242 -242
- data/lib/sdl2_scancode.rb +293 -289
- data/lib/sdl2_sensor.rb +115 -115
- data/lib/sdl2_shape.rb +83 -83
- data/lib/sdl2_sound.rb +154 -154
- data/lib/sdl2_stdinc.rb +572 -548
- data/lib/sdl2_surface.rb +229 -229
- data/lib/sdl2_syswm.rb +160 -160
- data/lib/sdl2_timer.rb +74 -74
- data/lib/sdl2_touch.rb +86 -86
- data/lib/sdl2_ttf.rb +414 -414
- data/lib/sdl2_version.rb +67 -67
- data/lib/sdl2_video.rb +549 -540
- data/lib/sdl2_vulkan.rb +72 -72
- metadata +4 -3
data/lib/sdl2_syswm.rb
CHANGED
@@ -1,160 +1,160 @@
|
|
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_version'
|
9
|
-
|
10
|
-
module SDL
|
11
|
-
extend FFI::Library
|
12
|
-
# Define/Macro
|
13
|
-
|
14
|
-
METALVIEW_TAG = 255
|
15
|
-
|
16
|
-
# Enum
|
17
|
-
|
18
|
-
SYSWM_UNKNOWN = 0
|
19
|
-
SYSWM_WINDOWS = 1
|
20
|
-
SYSWM_X11 = 2
|
21
|
-
SYSWM_DIRECTFB = 3
|
22
|
-
SYSWM_COCOA = 4
|
23
|
-
SYSWM_UIKIT = 5
|
24
|
-
SYSWM_WAYLAND = 6
|
25
|
-
SYSWM_MIR = 7
|
26
|
-
SYSWM_WINRT = 8
|
27
|
-
SYSWM_ANDROID = 9
|
28
|
-
SYSWM_VIVANTE = 10
|
29
|
-
SYSWM_OS2 = 11
|
30
|
-
SYSWM_HAIKU = 12
|
31
|
-
SYSWM_KMSDRM = 13
|
32
|
-
SYSWM_RISCOS = 14
|
33
|
-
|
34
|
-
# Typedef
|
35
|
-
|
36
|
-
typedef :int, :SDL_SYSWM_TYPE
|
37
|
-
|
38
|
-
class SysWMmsg_def_win < FFI::Struct
|
39
|
-
layout(
|
40
|
-
:hwnd, :pointer,
|
41
|
-
:msg, :uint32,
|
42
|
-
:wParam, :uint64,
|
43
|
-
:lParam, :int64
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
class SysWMmsg_value_win < FFI::Union
|
48
|
-
layout(
|
49
|
-
:win, SysWMmsg_def_win.by_value,
|
50
|
-
:dummy, :int
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
class SysWMmsg_win < FFI::Struct
|
55
|
-
layout(
|
56
|
-
:version, Version.by_value,
|
57
|
-
:subsystem, :int,
|
58
|
-
:msg, SysWMmsg_value_win.by_value
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
class SysWMmsg_def_cocoa < FFI::Struct
|
64
|
-
layout(
|
65
|
-
:dummy, :int
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
class SysWMmsg_value_cocoa < FFI::Union
|
70
|
-
layout(
|
71
|
-
:cocoa, SysWMmsg_def_cocoa.by_value,
|
72
|
-
:dummy, :int
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
class SysWMmsg_cocoa < FFI::Struct
|
77
|
-
layout(
|
78
|
-
:version, Version.by_value,
|
79
|
-
:subsystem, :int,
|
80
|
-
:msg, SysWMmsg_value_cocoa.by_value
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
################################################################################
|
85
|
-
|
86
|
-
class SysWMinfo_def_win < FFI::Struct
|
87
|
-
layout(
|
88
|
-
:window, :pointer,
|
89
|
-
:hdc, :pointer,
|
90
|
-
:hinstance, :pointer
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
class SysWMinfo_value_win < FFI::Union
|
95
|
-
layout(
|
96
|
-
:win, SysWMinfo_def_win.by_value,
|
97
|
-
:dummy, [:uint8, 64]
|
98
|
-
)
|
99
|
-
end
|
100
|
-
|
101
|
-
class SysWMinfo_win < FFI::Struct
|
102
|
-
layout(
|
103
|
-
:version, Version.by_value,
|
104
|
-
:subsystem, :int,
|
105
|
-
:info, SysWMinfo_value_win.by_value
|
106
|
-
)
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
class SysWMinfo_def_cocoa < FFI::Struct
|
111
|
-
layout(
|
112
|
-
:window, :pointer
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
|
-
class SysWMinfo_value_cocoa < FFI::Union
|
117
|
-
layout(
|
118
|
-
:cocoa, SysWMinfo_def_cocoa.by_value,
|
119
|
-
:dummy, [:uint8, 64]
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
class SysWMinfo_cocoa < FFI::Struct
|
124
|
-
layout(
|
125
|
-
:version, Version.by_value,
|
126
|
-
:subsystem, :int,
|
127
|
-
:info, SysWMinfo_value_cocoa.by_value
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
# Struct
|
133
|
-
|
134
|
-
|
135
|
-
# Function
|
136
|
-
|
137
|
-
def self.setup_syswm_symbols(output_error = false)
|
138
|
-
symbols = [
|
139
|
-
:SDL_GetWindowWMInfo,
|
140
|
-
]
|
141
|
-
apis = {
|
142
|
-
:SDL_GetWindowWMInfo => :GetWindowWMInfo,
|
143
|
-
}
|
144
|
-
args = {
|
145
|
-
:SDL_GetWindowWMInfo => [:pointer, :pointer],
|
146
|
-
}
|
147
|
-
retvals = {
|
148
|
-
:SDL_GetWindowWMInfo => :int,
|
149
|
-
}
|
150
|
-
symbols.each do |sym|
|
151
|
-
begin
|
152
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
153
|
-
rescue FFI::NotFoundError => error
|
154
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
160
|
-
|
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_version'
|
9
|
+
|
10
|
+
module SDL
|
11
|
+
extend FFI::Library
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
METALVIEW_TAG = 255
|
15
|
+
|
16
|
+
# Enum
|
17
|
+
|
18
|
+
SYSWM_UNKNOWN = 0
|
19
|
+
SYSWM_WINDOWS = 1
|
20
|
+
SYSWM_X11 = 2
|
21
|
+
SYSWM_DIRECTFB = 3
|
22
|
+
SYSWM_COCOA = 4
|
23
|
+
SYSWM_UIKIT = 5
|
24
|
+
SYSWM_WAYLAND = 6
|
25
|
+
SYSWM_MIR = 7
|
26
|
+
SYSWM_WINRT = 8
|
27
|
+
SYSWM_ANDROID = 9
|
28
|
+
SYSWM_VIVANTE = 10
|
29
|
+
SYSWM_OS2 = 11
|
30
|
+
SYSWM_HAIKU = 12
|
31
|
+
SYSWM_KMSDRM = 13
|
32
|
+
SYSWM_RISCOS = 14
|
33
|
+
|
34
|
+
# Typedef
|
35
|
+
|
36
|
+
typedef :int, :SDL_SYSWM_TYPE
|
37
|
+
|
38
|
+
class SysWMmsg_def_win < FFI::Struct
|
39
|
+
layout(
|
40
|
+
:hwnd, :pointer,
|
41
|
+
:msg, :uint32,
|
42
|
+
:wParam, :uint64,
|
43
|
+
:lParam, :int64
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
class SysWMmsg_value_win < FFI::Union
|
48
|
+
layout(
|
49
|
+
:win, SysWMmsg_def_win.by_value,
|
50
|
+
:dummy, :int
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
class SysWMmsg_win < FFI::Struct
|
55
|
+
layout(
|
56
|
+
:version, Version.by_value,
|
57
|
+
:subsystem, :int,
|
58
|
+
:msg, SysWMmsg_value_win.by_value
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
class SysWMmsg_def_cocoa < FFI::Struct
|
64
|
+
layout(
|
65
|
+
:dummy, :int
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
class SysWMmsg_value_cocoa < FFI::Union
|
70
|
+
layout(
|
71
|
+
:cocoa, SysWMmsg_def_cocoa.by_value,
|
72
|
+
:dummy, :int
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
class SysWMmsg_cocoa < FFI::Struct
|
77
|
+
layout(
|
78
|
+
:version, Version.by_value,
|
79
|
+
:subsystem, :int,
|
80
|
+
:msg, SysWMmsg_value_cocoa.by_value
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
################################################################################
|
85
|
+
|
86
|
+
class SysWMinfo_def_win < FFI::Struct
|
87
|
+
layout(
|
88
|
+
:window, :pointer,
|
89
|
+
:hdc, :pointer,
|
90
|
+
:hinstance, :pointer
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
class SysWMinfo_value_win < FFI::Union
|
95
|
+
layout(
|
96
|
+
:win, SysWMinfo_def_win.by_value,
|
97
|
+
:dummy, [:uint8, 64]
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
class SysWMinfo_win < FFI::Struct
|
102
|
+
layout(
|
103
|
+
:version, Version.by_value,
|
104
|
+
:subsystem, :int,
|
105
|
+
:info, SysWMinfo_value_win.by_value
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
class SysWMinfo_def_cocoa < FFI::Struct
|
111
|
+
layout(
|
112
|
+
:window, :pointer
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
class SysWMinfo_value_cocoa < FFI::Union
|
117
|
+
layout(
|
118
|
+
:cocoa, SysWMinfo_def_cocoa.by_value,
|
119
|
+
:dummy, [:uint8, 64]
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
class SysWMinfo_cocoa < FFI::Struct
|
124
|
+
layout(
|
125
|
+
:version, Version.by_value,
|
126
|
+
:subsystem, :int,
|
127
|
+
:info, SysWMinfo_value_cocoa.by_value
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
# Struct
|
133
|
+
|
134
|
+
|
135
|
+
# Function
|
136
|
+
|
137
|
+
def self.setup_syswm_symbols(output_error = false)
|
138
|
+
symbols = [
|
139
|
+
:SDL_GetWindowWMInfo,
|
140
|
+
]
|
141
|
+
apis = {
|
142
|
+
:SDL_GetWindowWMInfo => :GetWindowWMInfo,
|
143
|
+
}
|
144
|
+
args = {
|
145
|
+
:SDL_GetWindowWMInfo => [:pointer, :pointer],
|
146
|
+
}
|
147
|
+
retvals = {
|
148
|
+
:SDL_GetWindowWMInfo => :int,
|
149
|
+
}
|
150
|
+
symbols.each do |sym|
|
151
|
+
begin
|
152
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
153
|
+
rescue FFI::NotFoundError => error
|
154
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
data/lib/sdl2_timer.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
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 SDL
|
10
|
-
extend FFI::Library
|
11
|
-
# Define/Macro
|
12
|
-
|
13
|
-
|
14
|
-
# Enum
|
15
|
-
|
16
|
-
|
17
|
-
# Typedef
|
18
|
-
|
19
|
-
callback :SDL_TimerCallback, [:uint, :pointer], :uint
|
20
|
-
typedef :int, :SDL_TimerID
|
21
|
-
|
22
|
-
# Struct
|
23
|
-
|
24
|
-
|
25
|
-
# Function
|
26
|
-
|
27
|
-
def self.setup_timer_symbols(output_error = false)
|
28
|
-
symbols = [
|
29
|
-
:SDL_GetTicks,
|
30
|
-
:SDL_GetTicks64,
|
31
|
-
:SDL_GetPerformanceCounter,
|
32
|
-
:SDL_GetPerformanceFrequency,
|
33
|
-
:SDL_Delay,
|
34
|
-
:SDL_AddTimer,
|
35
|
-
:SDL_RemoveTimer,
|
36
|
-
]
|
37
|
-
apis = {
|
38
|
-
:SDL_GetTicks => :GetTicks,
|
39
|
-
:SDL_GetTicks64 => :GetTicks64,
|
40
|
-
:SDL_GetPerformanceCounter => :GetPerformanceCounter,
|
41
|
-
:SDL_GetPerformanceFrequency => :GetPerformanceFrequency,
|
42
|
-
:SDL_Delay => :Delay,
|
43
|
-
:SDL_AddTimer => :AddTimer,
|
44
|
-
:SDL_RemoveTimer => :RemoveTimer,
|
45
|
-
}
|
46
|
-
args = {
|
47
|
-
:SDL_GetTicks => [],
|
48
|
-
:SDL_GetTicks64 => [],
|
49
|
-
:SDL_GetPerformanceCounter => [],
|
50
|
-
:SDL_GetPerformanceFrequency => [],
|
51
|
-
:SDL_Delay => [:uint],
|
52
|
-
:SDL_AddTimer => [:uint, :SDL_TimerCallback, :pointer],
|
53
|
-
:SDL_RemoveTimer => [:int],
|
54
|
-
}
|
55
|
-
retvals = {
|
56
|
-
:SDL_GetTicks => :uint,
|
57
|
-
:SDL_GetTicks64 => :ulong_long,
|
58
|
-
:SDL_GetPerformanceCounter => :ulong_long,
|
59
|
-
:SDL_GetPerformanceFrequency => :ulong_long,
|
60
|
-
:SDL_Delay => :void,
|
61
|
-
:SDL_AddTimer => :int,
|
62
|
-
:SDL_RemoveTimer => :int,
|
63
|
-
}
|
64
|
-
symbols.each do |sym|
|
65
|
-
begin
|
66
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
67
|
-
rescue FFI::NotFoundError => error
|
68
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
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 SDL
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
|
14
|
+
# Enum
|
15
|
+
|
16
|
+
|
17
|
+
# Typedef
|
18
|
+
|
19
|
+
callback :SDL_TimerCallback, [:uint, :pointer], :uint
|
20
|
+
typedef :int, :SDL_TimerID
|
21
|
+
|
22
|
+
# Struct
|
23
|
+
|
24
|
+
|
25
|
+
# Function
|
26
|
+
|
27
|
+
def self.setup_timer_symbols(output_error = false)
|
28
|
+
symbols = [
|
29
|
+
:SDL_GetTicks,
|
30
|
+
:SDL_GetTicks64,
|
31
|
+
:SDL_GetPerformanceCounter,
|
32
|
+
:SDL_GetPerformanceFrequency,
|
33
|
+
:SDL_Delay,
|
34
|
+
:SDL_AddTimer,
|
35
|
+
:SDL_RemoveTimer,
|
36
|
+
]
|
37
|
+
apis = {
|
38
|
+
:SDL_GetTicks => :GetTicks,
|
39
|
+
:SDL_GetTicks64 => :GetTicks64,
|
40
|
+
:SDL_GetPerformanceCounter => :GetPerformanceCounter,
|
41
|
+
:SDL_GetPerformanceFrequency => :GetPerformanceFrequency,
|
42
|
+
:SDL_Delay => :Delay,
|
43
|
+
:SDL_AddTimer => :AddTimer,
|
44
|
+
:SDL_RemoveTimer => :RemoveTimer,
|
45
|
+
}
|
46
|
+
args = {
|
47
|
+
:SDL_GetTicks => [],
|
48
|
+
:SDL_GetTicks64 => [],
|
49
|
+
:SDL_GetPerformanceCounter => [],
|
50
|
+
:SDL_GetPerformanceFrequency => [],
|
51
|
+
:SDL_Delay => [:uint],
|
52
|
+
:SDL_AddTimer => [:uint, :SDL_TimerCallback, :pointer],
|
53
|
+
:SDL_RemoveTimer => [:int],
|
54
|
+
}
|
55
|
+
retvals = {
|
56
|
+
:SDL_GetTicks => :uint,
|
57
|
+
:SDL_GetTicks64 => :ulong_long,
|
58
|
+
:SDL_GetPerformanceCounter => :ulong_long,
|
59
|
+
:SDL_GetPerformanceFrequency => :ulong_long,
|
60
|
+
:SDL_Delay => :void,
|
61
|
+
:SDL_AddTimer => :int,
|
62
|
+
:SDL_RemoveTimer => :int,
|
63
|
+
}
|
64
|
+
symbols.each do |sym|
|
65
|
+
begin
|
66
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
67
|
+
rescue FFI::NotFoundError => error
|
68
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
data/lib/sdl2_touch.rb
CHANGED
@@ -1,86 +1,86 @@
|
|
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 SDL
|
10
|
-
extend FFI::Library
|
11
|
-
# Define/Macro
|
12
|
-
|
13
|
-
TOUCH_MOUSEID =
|
14
|
-
MOUSE_TOUCHID = -1
|
15
|
-
|
16
|
-
# Enum
|
17
|
-
|
18
|
-
TOUCH_DEVICE_INVALID = -1
|
19
|
-
TOUCH_DEVICE_DIRECT = 0
|
20
|
-
TOUCH_DEVICE_INDIRECT_ABSOLUTE = 1
|
21
|
-
TOUCH_DEVICE_INDIRECT_RELATIVE = 2
|
22
|
-
|
23
|
-
# Typedef
|
24
|
-
|
25
|
-
typedef :long_long, :SDL_TouchID
|
26
|
-
typedef :long_long, :SDL_FingerID
|
27
|
-
typedef :int, :SDL_TouchDeviceType
|
28
|
-
|
29
|
-
# Struct
|
30
|
-
|
31
|
-
class Finger < FFI::Struct
|
32
|
-
layout(
|
33
|
-
:id, :long_long,
|
34
|
-
:x, :float,
|
35
|
-
:y, :float,
|
36
|
-
:pressure, :float,
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
# Function
|
42
|
-
|
43
|
-
def self.setup_touch_symbols(output_error = false)
|
44
|
-
symbols = [
|
45
|
-
:SDL_GetNumTouchDevices,
|
46
|
-
:SDL_GetTouchDevice,
|
47
|
-
:SDL_GetTouchName,
|
48
|
-
:SDL_GetTouchDeviceType,
|
49
|
-
:SDL_GetNumTouchFingers,
|
50
|
-
:SDL_GetTouchFinger,
|
51
|
-
]
|
52
|
-
apis = {
|
53
|
-
:SDL_GetNumTouchDevices => :GetNumTouchDevices,
|
54
|
-
:SDL_GetTouchDevice => :GetTouchDevice,
|
55
|
-
:SDL_GetTouchName => :GetTouchName,
|
56
|
-
:SDL_GetTouchDeviceType => :GetTouchDeviceType,
|
57
|
-
:SDL_GetNumTouchFingers => :GetNumTouchFingers,
|
58
|
-
:SDL_GetTouchFinger => :GetTouchFinger,
|
59
|
-
}
|
60
|
-
args = {
|
61
|
-
:SDL_GetNumTouchDevices => [],
|
62
|
-
:SDL_GetTouchDevice => [:int],
|
63
|
-
:SDL_GetTouchName => [:int],
|
64
|
-
:SDL_GetTouchDeviceType => [:long_long],
|
65
|
-
:SDL_GetNumTouchFingers => [:long_long],
|
66
|
-
:SDL_GetTouchFinger => [:long_long, :int],
|
67
|
-
}
|
68
|
-
retvals = {
|
69
|
-
:SDL_GetNumTouchDevices => :int,
|
70
|
-
:SDL_GetTouchDevice => :long_long,
|
71
|
-
:SDL_GetTouchName => :pointer,
|
72
|
-
:SDL_GetTouchDeviceType => :int,
|
73
|
-
:SDL_GetNumTouchFingers => :int,
|
74
|
-
:SDL_GetTouchFinger => :pointer,
|
75
|
-
}
|
76
|
-
symbols.each do |sym|
|
77
|
-
begin
|
78
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
79
|
-
rescue FFI::NotFoundError => error
|
80
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
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 SDL
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
TOUCH_MOUSEID = 4294967295
|
14
|
+
MOUSE_TOUCHID = -1
|
15
|
+
|
16
|
+
# Enum
|
17
|
+
|
18
|
+
TOUCH_DEVICE_INVALID = -1
|
19
|
+
TOUCH_DEVICE_DIRECT = 0
|
20
|
+
TOUCH_DEVICE_INDIRECT_ABSOLUTE = 1
|
21
|
+
TOUCH_DEVICE_INDIRECT_RELATIVE = 2
|
22
|
+
|
23
|
+
# Typedef
|
24
|
+
|
25
|
+
typedef :long_long, :SDL_TouchID
|
26
|
+
typedef :long_long, :SDL_FingerID
|
27
|
+
typedef :int, :SDL_TouchDeviceType
|
28
|
+
|
29
|
+
# Struct
|
30
|
+
|
31
|
+
class Finger < FFI::Struct
|
32
|
+
layout(
|
33
|
+
:id, :long_long,
|
34
|
+
:x, :float,
|
35
|
+
:y, :float,
|
36
|
+
:pressure, :float,
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
# Function
|
42
|
+
|
43
|
+
def self.setup_touch_symbols(output_error = false)
|
44
|
+
symbols = [
|
45
|
+
:SDL_GetNumTouchDevices,
|
46
|
+
:SDL_GetTouchDevice,
|
47
|
+
:SDL_GetTouchName,
|
48
|
+
:SDL_GetTouchDeviceType,
|
49
|
+
:SDL_GetNumTouchFingers,
|
50
|
+
:SDL_GetTouchFinger,
|
51
|
+
]
|
52
|
+
apis = {
|
53
|
+
:SDL_GetNumTouchDevices => :GetNumTouchDevices,
|
54
|
+
:SDL_GetTouchDevice => :GetTouchDevice,
|
55
|
+
:SDL_GetTouchName => :GetTouchName,
|
56
|
+
:SDL_GetTouchDeviceType => :GetTouchDeviceType,
|
57
|
+
:SDL_GetNumTouchFingers => :GetNumTouchFingers,
|
58
|
+
:SDL_GetTouchFinger => :GetTouchFinger,
|
59
|
+
}
|
60
|
+
args = {
|
61
|
+
:SDL_GetNumTouchDevices => [],
|
62
|
+
:SDL_GetTouchDevice => [:int],
|
63
|
+
:SDL_GetTouchName => [:int],
|
64
|
+
:SDL_GetTouchDeviceType => [:long_long],
|
65
|
+
:SDL_GetNumTouchFingers => [:long_long],
|
66
|
+
:SDL_GetTouchFinger => [:long_long, :int],
|
67
|
+
}
|
68
|
+
retvals = {
|
69
|
+
:SDL_GetNumTouchDevices => :int,
|
70
|
+
:SDL_GetTouchDevice => :long_long,
|
71
|
+
:SDL_GetTouchName => :pointer,
|
72
|
+
:SDL_GetTouchDeviceType => :int,
|
73
|
+
:SDL_GetNumTouchFingers => :int,
|
74
|
+
:SDL_GetTouchFinger => :pointer,
|
75
|
+
}
|
76
|
+
symbols.each do |sym|
|
77
|
+
begin
|
78
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
79
|
+
rescue FFI::NotFoundError => error
|
80
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|