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.
- checksums.yaml +4 -4
- data/ChangeLog +83 -79
- data/LICENSE.txt +1 -1
- data/README.md +49 -49
- data/lib/sdl2.rb +170 -170
- data/lib/sdl2_audio.rb +219 -201
- data/lib/sdl2_blendmode.rb +69 -69
- data/lib/sdl2_clipboard.rb +51 -51
- data/lib/sdl2_cpuinfo.rb +106 -106
- data/lib/sdl2_error.rb +64 -64
- data/lib/sdl2_events.rb +530 -530
- data/lib/sdl2_filesystem.rb +48 -48
- data/lib/sdl2_framerate.rb +67 -67
- data/lib/sdl2_gamecontroller.rb +254 -254
- data/lib/sdl2_gesture.rb +55 -55
- data/lib/sdl2_gfxPrimitives.rb +222 -222
- data/lib/sdl2_haptic.rb +269 -269
- data/lib/sdl2_hints.rb +174 -174
- data/lib/sdl2_image.rb +185 -185
- data/lib/sdl2_imageFilter.rb +132 -132
- data/lib/sdl2_joystick.rb +230 -230
- data/lib/sdl2_keyboard.rb +99 -99
- data/lib/sdl2_keycode.rb +304 -304
- data/lib/sdl2_log.rb +115 -115
- data/lib/sdl2_main.rb +67 -67
- data/lib/sdl2_messagebox.rb +98 -98
- data/lib/sdl2_mixer.rb +317 -307
- data/lib/sdl2_mouse.rb +117 -117
- data/lib/sdl2_pixels.rb +224 -224
- data/lib/sdl2_platform.rb +45 -45
- data/lib/sdl2_power.rb +51 -51
- data/lib/sdl2_rect.rb +102 -102
- data/lib/sdl2_render.rb +290 -290
- data/lib/sdl2_rotozoom.rb +66 -66
- data/lib/sdl2_rwops.rb +208 -208
- data/lib/sdl2_scancode.rb +287 -287
- data/lib/sdl2_shape.rb +77 -77
- data/lib/sdl2_stdinc.rb +393 -393
- data/lib/sdl2_surface.rb +182 -182
- data/lib/sdl2_syswm.rb +154 -154
- data/lib/sdl2_timer.rb +62 -62
- data/lib/sdl2_touch.rb +73 -73
- data/lib/sdl2_ttf.rb +202 -190
- data/lib/sdl2_version.rb +62 -62
- data/lib/sdl2_video.rb +411 -411
- data/lib/sdl2_vulkan.rb +64 -64
- metadata +6 -6
data/lib/sdl2_clipboard.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
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_clipboard_symbols()
|
26
|
-
symbols = [
|
27
|
-
:SDL_SetClipboardText,
|
28
|
-
:SDL_GetClipboardText,
|
29
|
-
:SDL_HasClipboardText,
|
30
|
-
]
|
31
|
-
args = {
|
32
|
-
:SDL_SetClipboardText => [:pointer],
|
33
|
-
:SDL_GetClipboardText => [],
|
34
|
-
:SDL_HasClipboardText => [],
|
35
|
-
}
|
36
|
-
retvals = {
|
37
|
-
:SDL_SetClipboardText => :int,
|
38
|
-
:SDL_GetClipboardText => :pointer,
|
39
|
-
:SDL_HasClipboardText => :int,
|
40
|
-
}
|
41
|
-
symbols.each do |sym|
|
42
|
-
begin
|
43
|
-
attach_function sym, args[sym], retvals[sym]
|
44
|
-
rescue FFI::NotFoundError => error
|
45
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
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_clipboard_symbols()
|
26
|
+
symbols = [
|
27
|
+
:SDL_SetClipboardText,
|
28
|
+
:SDL_GetClipboardText,
|
29
|
+
:SDL_HasClipboardText,
|
30
|
+
]
|
31
|
+
args = {
|
32
|
+
:SDL_SetClipboardText => [:pointer],
|
33
|
+
:SDL_GetClipboardText => [],
|
34
|
+
:SDL_HasClipboardText => [],
|
35
|
+
}
|
36
|
+
retvals = {
|
37
|
+
:SDL_SetClipboardText => :int,
|
38
|
+
:SDL_GetClipboardText => :pointer,
|
39
|
+
:SDL_HasClipboardText => :int,
|
40
|
+
}
|
41
|
+
symbols.each do |sym|
|
42
|
+
begin
|
43
|
+
attach_function sym, args[sym], retvals[sym]
|
44
|
+
rescue FFI::NotFoundError => error
|
45
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
data/lib/sdl2_cpuinfo.rb
CHANGED
@@ -1,106 +1,106 @@
|
|
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_CACHELINE_SIZE = 128
|
14
|
-
|
15
|
-
# Enum
|
16
|
-
|
17
|
-
|
18
|
-
# Typedef
|
19
|
-
|
20
|
-
|
21
|
-
# Struct
|
22
|
-
|
23
|
-
|
24
|
-
# Function
|
25
|
-
|
26
|
-
def self.setup_cpuinfo_symbols()
|
27
|
-
symbols = [
|
28
|
-
:SDL_GetCPUCount,
|
29
|
-
:SDL_GetCPUCacheLineSize,
|
30
|
-
:SDL_HasRDTSC,
|
31
|
-
:SDL_HasAltiVec,
|
32
|
-
:SDL_HasMMX,
|
33
|
-
:SDL_Has3DNow,
|
34
|
-
:SDL_HasSSE,
|
35
|
-
:SDL_HasSSE2,
|
36
|
-
:SDL_HasSSE3,
|
37
|
-
:SDL_HasSSE41,
|
38
|
-
:SDL_HasSSE42,
|
39
|
-
:SDL_HasAVX,
|
40
|
-
:SDL_HasAVX2,
|
41
|
-
:SDL_HasAVX512F,
|
42
|
-
:SDL_HasARMSIMD,
|
43
|
-
:SDL_HasNEON,
|
44
|
-
:SDL_GetSystemRAM,
|
45
|
-
:SDL_SIMDGetAlignment,
|
46
|
-
:SDL_SIMDAlloc,
|
47
|
-
:SDL_SIMDRealloc,
|
48
|
-
:SDL_SIMDFree,
|
49
|
-
]
|
50
|
-
args = {
|
51
|
-
:SDL_GetCPUCount => [],
|
52
|
-
:SDL_GetCPUCacheLineSize => [],
|
53
|
-
:SDL_HasRDTSC => [],
|
54
|
-
:SDL_HasAltiVec => [],
|
55
|
-
:SDL_HasMMX => [],
|
56
|
-
:SDL_Has3DNow => [],
|
57
|
-
:SDL_HasSSE => [],
|
58
|
-
:SDL_HasSSE2 => [],
|
59
|
-
:SDL_HasSSE3 => [],
|
60
|
-
:SDL_HasSSE41 => [],
|
61
|
-
:SDL_HasSSE42 => [],
|
62
|
-
:SDL_HasAVX => [],
|
63
|
-
:SDL_HasAVX2 => [],
|
64
|
-
:SDL_HasAVX512F => [],
|
65
|
-
:SDL_HasARMSIMD => [],
|
66
|
-
:SDL_HasNEON => [],
|
67
|
-
:SDL_GetSystemRAM => [],
|
68
|
-
:SDL_SIMDGetAlignment => [],
|
69
|
-
:SDL_SIMDAlloc => [:ulong],
|
70
|
-
:SDL_SIMDRealloc => [:pointer, :ulong],
|
71
|
-
:SDL_SIMDFree => [:pointer],
|
72
|
-
}
|
73
|
-
retvals = {
|
74
|
-
:SDL_GetCPUCount => :int,
|
75
|
-
:SDL_GetCPUCacheLineSize => :int,
|
76
|
-
:SDL_HasRDTSC => :int,
|
77
|
-
:SDL_HasAltiVec => :int,
|
78
|
-
:SDL_HasMMX => :int,
|
79
|
-
:SDL_Has3DNow => :int,
|
80
|
-
:SDL_HasSSE => :int,
|
81
|
-
:SDL_HasSSE2 => :int,
|
82
|
-
:SDL_HasSSE3 => :int,
|
83
|
-
:SDL_HasSSE41 => :int,
|
84
|
-
:SDL_HasSSE42 => :int,
|
85
|
-
:SDL_HasAVX => :int,
|
86
|
-
:SDL_HasAVX2 => :int,
|
87
|
-
:SDL_HasAVX512F => :int,
|
88
|
-
:SDL_HasARMSIMD => :int,
|
89
|
-
:SDL_HasNEON => :int,
|
90
|
-
:SDL_GetSystemRAM => :int,
|
91
|
-
:SDL_SIMDGetAlignment => :size_t,
|
92
|
-
:SDL_SIMDAlloc => :pointer,
|
93
|
-
:SDL_SIMDRealloc => :pointer,
|
94
|
-
:SDL_SIMDFree => :void,
|
95
|
-
}
|
96
|
-
symbols.each do |sym|
|
97
|
-
begin
|
98
|
-
attach_function sym, args[sym], retvals[sym]
|
99
|
-
rescue FFI::NotFoundError => error
|
100
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
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_CACHELINE_SIZE = 128
|
14
|
+
|
15
|
+
# Enum
|
16
|
+
|
17
|
+
|
18
|
+
# Typedef
|
19
|
+
|
20
|
+
|
21
|
+
# Struct
|
22
|
+
|
23
|
+
|
24
|
+
# Function
|
25
|
+
|
26
|
+
def self.setup_cpuinfo_symbols()
|
27
|
+
symbols = [
|
28
|
+
:SDL_GetCPUCount,
|
29
|
+
:SDL_GetCPUCacheLineSize,
|
30
|
+
:SDL_HasRDTSC,
|
31
|
+
:SDL_HasAltiVec,
|
32
|
+
:SDL_HasMMX,
|
33
|
+
:SDL_Has3DNow,
|
34
|
+
:SDL_HasSSE,
|
35
|
+
:SDL_HasSSE2,
|
36
|
+
:SDL_HasSSE3,
|
37
|
+
:SDL_HasSSE41,
|
38
|
+
:SDL_HasSSE42,
|
39
|
+
:SDL_HasAVX,
|
40
|
+
:SDL_HasAVX2,
|
41
|
+
:SDL_HasAVX512F,
|
42
|
+
:SDL_HasARMSIMD,
|
43
|
+
:SDL_HasNEON,
|
44
|
+
:SDL_GetSystemRAM,
|
45
|
+
:SDL_SIMDGetAlignment,
|
46
|
+
:SDL_SIMDAlloc,
|
47
|
+
:SDL_SIMDRealloc,
|
48
|
+
:SDL_SIMDFree,
|
49
|
+
]
|
50
|
+
args = {
|
51
|
+
:SDL_GetCPUCount => [],
|
52
|
+
:SDL_GetCPUCacheLineSize => [],
|
53
|
+
:SDL_HasRDTSC => [],
|
54
|
+
:SDL_HasAltiVec => [],
|
55
|
+
:SDL_HasMMX => [],
|
56
|
+
:SDL_Has3DNow => [],
|
57
|
+
:SDL_HasSSE => [],
|
58
|
+
:SDL_HasSSE2 => [],
|
59
|
+
:SDL_HasSSE3 => [],
|
60
|
+
:SDL_HasSSE41 => [],
|
61
|
+
:SDL_HasSSE42 => [],
|
62
|
+
:SDL_HasAVX => [],
|
63
|
+
:SDL_HasAVX2 => [],
|
64
|
+
:SDL_HasAVX512F => [],
|
65
|
+
:SDL_HasARMSIMD => [],
|
66
|
+
:SDL_HasNEON => [],
|
67
|
+
:SDL_GetSystemRAM => [],
|
68
|
+
:SDL_SIMDGetAlignment => [],
|
69
|
+
:SDL_SIMDAlloc => [:ulong],
|
70
|
+
:SDL_SIMDRealloc => [:pointer, :ulong],
|
71
|
+
:SDL_SIMDFree => [:pointer],
|
72
|
+
}
|
73
|
+
retvals = {
|
74
|
+
:SDL_GetCPUCount => :int,
|
75
|
+
:SDL_GetCPUCacheLineSize => :int,
|
76
|
+
:SDL_HasRDTSC => :int,
|
77
|
+
:SDL_HasAltiVec => :int,
|
78
|
+
:SDL_HasMMX => :int,
|
79
|
+
:SDL_Has3DNow => :int,
|
80
|
+
:SDL_HasSSE => :int,
|
81
|
+
:SDL_HasSSE2 => :int,
|
82
|
+
:SDL_HasSSE3 => :int,
|
83
|
+
:SDL_HasSSE41 => :int,
|
84
|
+
:SDL_HasSSE42 => :int,
|
85
|
+
:SDL_HasAVX => :int,
|
86
|
+
:SDL_HasAVX2 => :int,
|
87
|
+
:SDL_HasAVX512F => :int,
|
88
|
+
:SDL_HasARMSIMD => :int,
|
89
|
+
:SDL_HasNEON => :int,
|
90
|
+
:SDL_GetSystemRAM => :int,
|
91
|
+
:SDL_SIMDGetAlignment => :size_t,
|
92
|
+
:SDL_SIMDAlloc => :pointer,
|
93
|
+
:SDL_SIMDRealloc => :pointer,
|
94
|
+
:SDL_SIMDFree => :void,
|
95
|
+
}
|
96
|
+
symbols.each do |sym|
|
97
|
+
begin
|
98
|
+
attach_function sym, args[sym], retvals[sym]
|
99
|
+
rescue FFI::NotFoundError => error
|
100
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
data/lib/sdl2_error.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
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
|
-
SDL_ENOMEM = 0
|
17
|
-
SDL_EFREAD = 1
|
18
|
-
SDL_EFWRITE = 2
|
19
|
-
SDL_EFSEEK = 3
|
20
|
-
SDL_UNSUPPORTED = 4
|
21
|
-
SDL_LASTERROR = 5
|
22
|
-
|
23
|
-
# Typedef
|
24
|
-
|
25
|
-
typedef :int, :SDL_errorcode
|
26
|
-
|
27
|
-
# Struct
|
28
|
-
|
29
|
-
|
30
|
-
# Function
|
31
|
-
|
32
|
-
def self.setup_error_symbols()
|
33
|
-
symbols = [
|
34
|
-
:SDL_SetError,
|
35
|
-
:SDL_GetError,
|
36
|
-
:SDL_GetErrorMsg,
|
37
|
-
:SDL_ClearError,
|
38
|
-
:SDL_Error,
|
39
|
-
]
|
40
|
-
args = {
|
41
|
-
:SDL_SetError => [:pointer],
|
42
|
-
:SDL_GetError => [],
|
43
|
-
:SDL_GetErrorMsg => [:pointer, :int],
|
44
|
-
:SDL_ClearError => [],
|
45
|
-
:SDL_Error => [:int],
|
46
|
-
}
|
47
|
-
retvals = {
|
48
|
-
:SDL_SetError => :int,
|
49
|
-
:SDL_GetError => :pointer,
|
50
|
-
:SDL_GetErrorMsg => :pointer,
|
51
|
-
:SDL_ClearError => :void,
|
52
|
-
:SDL_Error => :int,
|
53
|
-
}
|
54
|
-
symbols.each do |sym|
|
55
|
-
begin
|
56
|
-
attach_function sym, args[sym], retvals[sym]
|
57
|
-
rescue FFI::NotFoundError => error
|
58
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
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
|
+
SDL_ENOMEM = 0
|
17
|
+
SDL_EFREAD = 1
|
18
|
+
SDL_EFWRITE = 2
|
19
|
+
SDL_EFSEEK = 3
|
20
|
+
SDL_UNSUPPORTED = 4
|
21
|
+
SDL_LASTERROR = 5
|
22
|
+
|
23
|
+
# Typedef
|
24
|
+
|
25
|
+
typedef :int, :SDL_errorcode
|
26
|
+
|
27
|
+
# Struct
|
28
|
+
|
29
|
+
|
30
|
+
# Function
|
31
|
+
|
32
|
+
def self.setup_error_symbols()
|
33
|
+
symbols = [
|
34
|
+
:SDL_SetError,
|
35
|
+
:SDL_GetError,
|
36
|
+
:SDL_GetErrorMsg,
|
37
|
+
:SDL_ClearError,
|
38
|
+
:SDL_Error,
|
39
|
+
]
|
40
|
+
args = {
|
41
|
+
:SDL_SetError => [:pointer],
|
42
|
+
:SDL_GetError => [],
|
43
|
+
:SDL_GetErrorMsg => [:pointer, :int],
|
44
|
+
:SDL_ClearError => [],
|
45
|
+
:SDL_Error => [:int],
|
46
|
+
}
|
47
|
+
retvals = {
|
48
|
+
:SDL_SetError => :int,
|
49
|
+
:SDL_GetError => :pointer,
|
50
|
+
:SDL_GetErrorMsg => :pointer,
|
51
|
+
:SDL_ClearError => :void,
|
52
|
+
:SDL_Error => :int,
|
53
|
+
}
|
54
|
+
symbols.each do |sym|
|
55
|
+
begin
|
56
|
+
attach_function sym, args[sym], retvals[sym]
|
57
|
+
rescue FFI::NotFoundError => error
|
58
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
data/lib/sdl2_events.rb
CHANGED
@@ -1,530 +1,530 @@
|
|
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_keyboard'
|
9
|
-
|
10
|
-
module SDL2
|
11
|
-
extend FFI::Library
|
12
|
-
# Define/Macro
|
13
|
-
|
14
|
-
SDL_RELEASED = 0
|
15
|
-
SDL_PRESSED = 1
|
16
|
-
SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
|
17
|
-
SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
|
18
|
-
SDL_QUERY = -1
|
19
|
-
SDL_IGNORE = 0
|
20
|
-
SDL_DISABLE = 0
|
21
|
-
SDL_ENABLE = 1
|
22
|
-
|
23
|
-
# Enum
|
24
|
-
|
25
|
-
SDL_FIRSTEVENT = 0
|
26
|
-
SDL_QUIT = 256
|
27
|
-
SDL_APP_TERMINATING = 257
|
28
|
-
SDL_APP_LOWMEMORY = 258
|
29
|
-
SDL_APP_WILLENTERBACKGROUND = 259
|
30
|
-
SDL_APP_DIDENTERBACKGROUND = 260
|
31
|
-
SDL_APP_WILLENTERFOREGROUND = 261
|
32
|
-
SDL_APP_DIDENTERFOREGROUND = 262
|
33
|
-
SDL_LOCALECHANGED = 263
|
34
|
-
SDL_DISPLAYEVENT = 336
|
35
|
-
SDL_WINDOWEVENT = 512
|
36
|
-
SDL_SYSWMEVENT = 513
|
37
|
-
SDL_KEYDOWN = 768
|
38
|
-
SDL_KEYUP = 769
|
39
|
-
SDL_TEXTEDITING = 770
|
40
|
-
SDL_TEXTINPUT = 771
|
41
|
-
SDL_KEYMAPCHANGED = 772
|
42
|
-
SDL_MOUSEMOTION = 1024
|
43
|
-
SDL_MOUSEBUTTONDOWN = 1025
|
44
|
-
SDL_MOUSEBUTTONUP = 1026
|
45
|
-
SDL_MOUSEWHEEL = 1027
|
46
|
-
SDL_JOYAXISMOTION = 1536
|
47
|
-
SDL_JOYBALLMOTION = 1537
|
48
|
-
SDL_JOYHATMOTION = 1538
|
49
|
-
SDL_JOYBUTTONDOWN = 1539
|
50
|
-
SDL_JOYBUTTONUP = 1540
|
51
|
-
SDL_JOYDEVICEADDED = 1541
|
52
|
-
SDL_JOYDEVICEREMOVED = 1542
|
53
|
-
SDL_CONTROLLERAXISMOTION = 1616
|
54
|
-
SDL_CONTROLLERBUTTONDOWN = 1617
|
55
|
-
SDL_CONTROLLERBUTTONUP = 1618
|
56
|
-
SDL_CONTROLLERDEVICEADDED = 1619
|
57
|
-
SDL_CONTROLLERDEVICEREMOVED = 1620
|
58
|
-
SDL_CONTROLLERDEVICEREMAPPED = 1621
|
59
|
-
SDL_CONTROLLERTOUCHPADDOWN = 1622
|
60
|
-
SDL_CONTROLLERTOUCHPADMOTION = 1623
|
61
|
-
SDL_CONTROLLERTOUCHPADUP = 1624
|
62
|
-
SDL_CONTROLLERSENSORUPDATE = 1625
|
63
|
-
SDL_FINGERDOWN = 1792
|
64
|
-
SDL_FINGERUP = 1793
|
65
|
-
SDL_FINGERMOTION = 1794
|
66
|
-
SDL_DOLLARGESTURE = 2048
|
67
|
-
SDL_DOLLARRECORD = 2049
|
68
|
-
SDL_MULTIGESTURE = 2050
|
69
|
-
SDL_CLIPBOARDUPDATE = 2304
|
70
|
-
SDL_DROPFILE = 4096
|
71
|
-
SDL_DROPTEXT = 4097
|
72
|
-
SDL_DROPBEGIN = 4098
|
73
|
-
SDL_DROPCOMPLETE = 4099
|
74
|
-
SDL_AUDIODEVICEADDED = 4352
|
75
|
-
SDL_AUDIODEVICEREMOVED = 4353
|
76
|
-
SDL_SENSORUPDATE = 4608
|
77
|
-
SDL_RENDER_TARGETS_RESET = 8192
|
78
|
-
SDL_RENDER_DEVICE_RESET = 8193
|
79
|
-
SDL_USEREVENT = 32768
|
80
|
-
SDL_LASTEVENT = 65535
|
81
|
-
SDL_ADDEVENT = 0
|
82
|
-
SDL_PEEKEVENT = 1
|
83
|
-
SDL_GETEVENT = 2
|
84
|
-
|
85
|
-
# Typedef
|
86
|
-
|
87
|
-
typedef :int, :SDL_EventType
|
88
|
-
typedef :int, :SDL_compile_time_assert_SDL_Event
|
89
|
-
typedef :int, :SDL_eventaction
|
90
|
-
callback :SDL_EventFilter, [:pointer, :pointer], :int
|
91
|
-
|
92
|
-
# Struct
|
93
|
-
|
94
|
-
class SDL_CommonEvent < FFI::Struct
|
95
|
-
layout(
|
96
|
-
:type, :uint,
|
97
|
-
:timestamp, :uint,
|
98
|
-
)
|
99
|
-
end
|
100
|
-
|
101
|
-
class SDL_DisplayEvent < FFI::Struct
|
102
|
-
layout(
|
103
|
-
:type, :uint,
|
104
|
-
:timestamp, :uint,
|
105
|
-
:display, :uint,
|
106
|
-
:event, :uchar,
|
107
|
-
:padding1, :uchar,
|
108
|
-
:padding2, :uchar,
|
109
|
-
:padding3, :uchar,
|
110
|
-
:data1, :int,
|
111
|
-
)
|
112
|
-
end
|
113
|
-
|
114
|
-
class SDL_WindowEvent < FFI::Struct
|
115
|
-
layout(
|
116
|
-
:type, :uint,
|
117
|
-
:timestamp, :uint,
|
118
|
-
:windowID, :uint,
|
119
|
-
:event, :uchar,
|
120
|
-
:padding1, :uchar,
|
121
|
-
:padding2, :uchar,
|
122
|
-
:padding3, :uchar,
|
123
|
-
:data1, :int,
|
124
|
-
:data2, :int,
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
class SDL_KeyboardEvent < FFI::Struct
|
129
|
-
layout(
|
130
|
-
:type, :uint,
|
131
|
-
:timestamp, :uint,
|
132
|
-
:windowID, :uint,
|
133
|
-
:state, :uchar,
|
134
|
-
:repeat, :uchar,
|
135
|
-
:padding2, :uchar,
|
136
|
-
:padding3, :uchar,
|
137
|
-
:keysym, SDL_Keysym,
|
138
|
-
)
|
139
|
-
end
|
140
|
-
|
141
|
-
class SDL_TextEditingEvent < FFI::Struct
|
142
|
-
layout(
|
143
|
-
:type, :uint,
|
144
|
-
:timestamp, :uint,
|
145
|
-
:windowID, :uint,
|
146
|
-
:text, [:char, 32],
|
147
|
-
:start, :int,
|
148
|
-
:length, :int,
|
149
|
-
)
|
150
|
-
end
|
151
|
-
|
152
|
-
class SDL_TextInputEvent < FFI::Struct
|
153
|
-
layout(
|
154
|
-
:type, :uint,
|
155
|
-
:timestamp, :uint,
|
156
|
-
:windowID, :uint,
|
157
|
-
:text, [:char, 32],
|
158
|
-
)
|
159
|
-
end
|
160
|
-
|
161
|
-
class SDL_MouseMotionEvent < FFI::Struct
|
162
|
-
layout(
|
163
|
-
:type, :uint,
|
164
|
-
:timestamp, :uint,
|
165
|
-
:windowID, :uint,
|
166
|
-
:which, :uint,
|
167
|
-
:state, :uint,
|
168
|
-
:x, :int,
|
169
|
-
:y, :int,
|
170
|
-
:xrel, :int,
|
171
|
-
:yrel, :int,
|
172
|
-
)
|
173
|
-
end
|
174
|
-
|
175
|
-
class SDL_MouseButtonEvent < FFI::Struct
|
176
|
-
layout(
|
177
|
-
:type, :uint,
|
178
|
-
:timestamp, :uint,
|
179
|
-
:windowID, :uint,
|
180
|
-
:which, :uint,
|
181
|
-
:button, :uchar,
|
182
|
-
:state, :uchar,
|
183
|
-
:clicks, :uchar,
|
184
|
-
:padding1, :uchar,
|
185
|
-
:x, :int,
|
186
|
-
:y, :int,
|
187
|
-
)
|
188
|
-
end
|
189
|
-
|
190
|
-
class SDL_MouseWheelEvent < FFI::Struct
|
191
|
-
layout(
|
192
|
-
:type, :uint,
|
193
|
-
:timestamp, :uint,
|
194
|
-
:windowID, :uint,
|
195
|
-
:which, :uint,
|
196
|
-
:x, :int,
|
197
|
-
:y, :int,
|
198
|
-
:direction, :uint,
|
199
|
-
)
|
200
|
-
end
|
201
|
-
|
202
|
-
class SDL_JoyAxisEvent < FFI::Struct
|
203
|
-
layout(
|
204
|
-
:type, :uint,
|
205
|
-
:timestamp, :uint,
|
206
|
-
:which, :int,
|
207
|
-
:axis, :uchar,
|
208
|
-
:padding1, :uchar,
|
209
|
-
:padding2, :uchar,
|
210
|
-
:padding3, :uchar,
|
211
|
-
:value, :short,
|
212
|
-
:padding4, :ushort,
|
213
|
-
)
|
214
|
-
end
|
215
|
-
|
216
|
-
class SDL_JoyBallEvent < FFI::Struct
|
217
|
-
layout(
|
218
|
-
:type, :uint,
|
219
|
-
:timestamp, :uint,
|
220
|
-
:which, :int,
|
221
|
-
:ball, :uchar,
|
222
|
-
:padding1, :uchar,
|
223
|
-
:padding2, :uchar,
|
224
|
-
:padding3, :uchar,
|
225
|
-
:xrel, :short,
|
226
|
-
:yrel, :short,
|
227
|
-
)
|
228
|
-
end
|
229
|
-
|
230
|
-
class SDL_JoyHatEvent < FFI::Struct
|
231
|
-
layout(
|
232
|
-
:type, :uint,
|
233
|
-
:timestamp, :uint,
|
234
|
-
:which, :int,
|
235
|
-
:hat, :uchar,
|
236
|
-
:value, :uchar,
|
237
|
-
:padding1, :uchar,
|
238
|
-
:padding2, :uchar,
|
239
|
-
)
|
240
|
-
end
|
241
|
-
|
242
|
-
class SDL_JoyButtonEvent < FFI::Struct
|
243
|
-
layout(
|
244
|
-
:type, :uint,
|
245
|
-
:timestamp, :uint,
|
246
|
-
:which, :int,
|
247
|
-
:button, :uchar,
|
248
|
-
:state, :uchar,
|
249
|
-
:padding1, :uchar,
|
250
|
-
:padding2, :uchar,
|
251
|
-
)
|
252
|
-
end
|
253
|
-
|
254
|
-
class SDL_JoyDeviceEvent < FFI::Struct
|
255
|
-
layout(
|
256
|
-
:type, :uint,
|
257
|
-
:timestamp, :uint,
|
258
|
-
:which, :int,
|
259
|
-
)
|
260
|
-
end
|
261
|
-
|
262
|
-
class SDL_ControllerAxisEvent < FFI::Struct
|
263
|
-
layout(
|
264
|
-
:type, :uint,
|
265
|
-
:timestamp, :uint,
|
266
|
-
:which, :int,
|
267
|
-
:axis, :uchar,
|
268
|
-
:padding1, :uchar,
|
269
|
-
:padding2, :uchar,
|
270
|
-
:padding3, :uchar,
|
271
|
-
:value, :short,
|
272
|
-
:padding4, :ushort,
|
273
|
-
)
|
274
|
-
end
|
275
|
-
|
276
|
-
class SDL_ControllerButtonEvent < FFI::Struct
|
277
|
-
layout(
|
278
|
-
:type, :uint,
|
279
|
-
:timestamp, :uint,
|
280
|
-
:which, :int,
|
281
|
-
:button, :uchar,
|
282
|
-
:state, :uchar,
|
283
|
-
:padding1, :uchar,
|
284
|
-
:padding2, :uchar,
|
285
|
-
)
|
286
|
-
end
|
287
|
-
|
288
|
-
class SDL_ControllerDeviceEvent < FFI::Struct
|
289
|
-
layout(
|
290
|
-
:type, :uint,
|
291
|
-
:timestamp, :uint,
|
292
|
-
:which, :int,
|
293
|
-
)
|
294
|
-
end
|
295
|
-
|
296
|
-
class SDL_ControllerTouchpadEvent < FFI::Struct
|
297
|
-
layout(
|
298
|
-
:type, :uint,
|
299
|
-
:timestamp, :uint,
|
300
|
-
:which, :int,
|
301
|
-
:touchpad, :int,
|
302
|
-
:finger, :int,
|
303
|
-
:x, :float,
|
304
|
-
:y, :float,
|
305
|
-
:pressure, :float,
|
306
|
-
)
|
307
|
-
end
|
308
|
-
|
309
|
-
class SDL_ControllerSensorEvent < FFI::Struct
|
310
|
-
layout(
|
311
|
-
:type, :uint,
|
312
|
-
:timestamp, :uint,
|
313
|
-
:which, :int,
|
314
|
-
:sensor, :int,
|
315
|
-
:data, [:float, 3],
|
316
|
-
)
|
317
|
-
end
|
318
|
-
|
319
|
-
class SDL_AudioDeviceEvent < FFI::Struct
|
320
|
-
layout(
|
321
|
-
:type, :uint,
|
322
|
-
:timestamp, :uint,
|
323
|
-
:which, :uint,
|
324
|
-
:iscapture, :uchar,
|
325
|
-
:padding1, :uchar,
|
326
|
-
:padding2, :uchar,
|
327
|
-
:padding3, :uchar,
|
328
|
-
)
|
329
|
-
end
|
330
|
-
|
331
|
-
class SDL_TouchFingerEvent < FFI::Struct
|
332
|
-
layout(
|
333
|
-
:type, :uint,
|
334
|
-
:timestamp, :uint,
|
335
|
-
:touchId, :long_long,
|
336
|
-
:fingerId, :long_long,
|
337
|
-
:x, :float,
|
338
|
-
:y, :float,
|
339
|
-
:dx, :float,
|
340
|
-
:dy, :float,
|
341
|
-
:pressure, :float,
|
342
|
-
:windowID, :uint,
|
343
|
-
)
|
344
|
-
end
|
345
|
-
|
346
|
-
class SDL_MultiGestureEvent < FFI::Struct
|
347
|
-
layout(
|
348
|
-
:type, :uint,
|
349
|
-
:timestamp, :uint,
|
350
|
-
:touchId, :long_long,
|
351
|
-
:dTheta, :float,
|
352
|
-
:dDist, :float,
|
353
|
-
:x, :float,
|
354
|
-
:y, :float,
|
355
|
-
:numFingers, :ushort,
|
356
|
-
:padding, :ushort,
|
357
|
-
)
|
358
|
-
end
|
359
|
-
|
360
|
-
class SDL_DollarGestureEvent < FFI::Struct
|
361
|
-
layout(
|
362
|
-
:type, :uint,
|
363
|
-
:timestamp, :uint,
|
364
|
-
:touchId, :long_long,
|
365
|
-
:gestureId, :long_long,
|
366
|
-
:numFingers, :uint,
|
367
|
-
:error, :float,
|
368
|
-
:x, :float,
|
369
|
-
:y, :float,
|
370
|
-
)
|
371
|
-
end
|
372
|
-
|
373
|
-
class SDL_DropEvent < FFI::Struct
|
374
|
-
layout(
|
375
|
-
:type, :uint,
|
376
|
-
:timestamp, :uint,
|
377
|
-
:file, :pointer,
|
378
|
-
:windowID, :uint,
|
379
|
-
)
|
380
|
-
end
|
381
|
-
|
382
|
-
class SDL_SensorEvent < FFI::Struct
|
383
|
-
layout(
|
384
|
-
:type, :uint,
|
385
|
-
:timestamp, :uint,
|
386
|
-
:which, :int,
|
387
|
-
:data, [:float, 6],
|
388
|
-
)
|
389
|
-
end
|
390
|
-
|
391
|
-
class SDL_QuitEvent < FFI::Struct
|
392
|
-
layout(
|
393
|
-
:type, :uint,
|
394
|
-
:timestamp, :uint,
|
395
|
-
)
|
396
|
-
end
|
397
|
-
|
398
|
-
class SDL_OSEvent < FFI::Struct
|
399
|
-
layout(
|
400
|
-
:type, :uint,
|
401
|
-
:timestamp, :uint,
|
402
|
-
)
|
403
|
-
end
|
404
|
-
|
405
|
-
class SDL_UserEvent < FFI::Struct
|
406
|
-
layout(
|
407
|
-
:type, :uint,
|
408
|
-
:timestamp, :uint,
|
409
|
-
:windowID, :uint,
|
410
|
-
:code, :int,
|
411
|
-
:data1, :pointer,
|
412
|
-
:data2, :pointer,
|
413
|
-
)
|
414
|
-
end
|
415
|
-
|
416
|
-
class SDL_SysWMEvent < FFI::Struct
|
417
|
-
layout(
|
418
|
-
:type, :uint,
|
419
|
-
:timestamp, :uint,
|
420
|
-
:msg, :pointer,
|
421
|
-
)
|
422
|
-
end
|
423
|
-
|
424
|
-
class SDL_Event < FFI::Union
|
425
|
-
layout(
|
426
|
-
:type, :uint,
|
427
|
-
:common, SDL_CommonEvent,
|
428
|
-
:display, SDL_DisplayEvent,
|
429
|
-
:window, SDL_WindowEvent,
|
430
|
-
:key, SDL_KeyboardEvent,
|
431
|
-
:edit, SDL_TextEditingEvent,
|
432
|
-
:text, SDL_TextInputEvent,
|
433
|
-
:motion, SDL_MouseMotionEvent,
|
434
|
-
:button, SDL_MouseButtonEvent,
|
435
|
-
:wheel, SDL_MouseWheelEvent,
|
436
|
-
:jaxis, SDL_JoyAxisEvent,
|
437
|
-
:jball, SDL_JoyBallEvent,
|
438
|
-
:jhat, SDL_JoyHatEvent,
|
439
|
-
:jbutton, SDL_JoyButtonEvent,
|
440
|
-
:jdevice, SDL_JoyDeviceEvent,
|
441
|
-
:caxis, SDL_ControllerAxisEvent,
|
442
|
-
:cbutton, SDL_ControllerButtonEvent,
|
443
|
-
:cdevice, SDL_ControllerDeviceEvent,
|
444
|
-
:ctouchpad, SDL_ControllerTouchpadEvent,
|
445
|
-
:csensor, SDL_ControllerSensorEvent,
|
446
|
-
:adevice, SDL_AudioDeviceEvent,
|
447
|
-
:sensor, SDL_SensorEvent,
|
448
|
-
:quit, SDL_QuitEvent,
|
449
|
-
:user, SDL_UserEvent,
|
450
|
-
:syswm, SDL_SysWMEvent,
|
451
|
-
:tfinger, SDL_TouchFingerEvent,
|
452
|
-
:mgesture, SDL_MultiGestureEvent,
|
453
|
-
:dgesture, SDL_DollarGestureEvent,
|
454
|
-
:drop, SDL_DropEvent,
|
455
|
-
:padding, [:uchar, 56],
|
456
|
-
)
|
457
|
-
end
|
458
|
-
|
459
|
-
|
460
|
-
# Function
|
461
|
-
|
462
|
-
def self.setup_events_symbols()
|
463
|
-
symbols = [
|
464
|
-
:SDL_PumpEvents,
|
465
|
-
:SDL_PeepEvents,
|
466
|
-
:SDL_HasEvent,
|
467
|
-
:SDL_HasEvents,
|
468
|
-
:SDL_FlushEvent,
|
469
|
-
:SDL_FlushEvents,
|
470
|
-
:SDL_PollEvent,
|
471
|
-
:SDL_WaitEvent,
|
472
|
-
:SDL_WaitEventTimeout,
|
473
|
-
:SDL_PushEvent,
|
474
|
-
:SDL_SetEventFilter,
|
475
|
-
:SDL_GetEventFilter,
|
476
|
-
:SDL_AddEventWatch,
|
477
|
-
:SDL_DelEventWatch,
|
478
|
-
:SDL_FilterEvents,
|
479
|
-
:SDL_EventState,
|
480
|
-
:SDL_RegisterEvents,
|
481
|
-
]
|
482
|
-
args = {
|
483
|
-
:SDL_PumpEvents => [],
|
484
|
-
:SDL_PeepEvents => [:pointer, :int, :int, :uint, :uint],
|
485
|
-
:SDL_HasEvent => [:uint],
|
486
|
-
:SDL_HasEvents => [:uint, :uint],
|
487
|
-
:SDL_FlushEvent => [:uint],
|
488
|
-
:SDL_FlushEvents => [:uint, :uint],
|
489
|
-
:SDL_PollEvent => [:pointer],
|
490
|
-
:SDL_WaitEvent => [:pointer],
|
491
|
-
:SDL_WaitEventTimeout => [:pointer, :int],
|
492
|
-
:SDL_PushEvent => [:pointer],
|
493
|
-
:SDL_SetEventFilter => [:SDL_EventFilter, :pointer],
|
494
|
-
:SDL_GetEventFilter => [:pointer, :pointer],
|
495
|
-
:SDL_AddEventWatch => [:SDL_EventFilter, :pointer],
|
496
|
-
:SDL_DelEventWatch => [:SDL_EventFilter, :pointer],
|
497
|
-
:SDL_FilterEvents => [:SDL_EventFilter, :pointer],
|
498
|
-
:SDL_EventState => [:uint, :int],
|
499
|
-
:SDL_RegisterEvents => [:int],
|
500
|
-
}
|
501
|
-
retvals = {
|
502
|
-
:SDL_PumpEvents => :void,
|
503
|
-
:SDL_PeepEvents => :int,
|
504
|
-
:SDL_HasEvent => :int,
|
505
|
-
:SDL_HasEvents => :int,
|
506
|
-
:SDL_FlushEvent => :void,
|
507
|
-
:SDL_FlushEvents => :void,
|
508
|
-
:SDL_PollEvent => :int,
|
509
|
-
:SDL_WaitEvent => :int,
|
510
|
-
:SDL_WaitEventTimeout => :int,
|
511
|
-
:SDL_PushEvent => :int,
|
512
|
-
:SDL_SetEventFilter => :void,
|
513
|
-
:SDL_GetEventFilter => :int,
|
514
|
-
:SDL_AddEventWatch => :void,
|
515
|
-
:SDL_DelEventWatch => :void,
|
516
|
-
:SDL_FilterEvents => :void,
|
517
|
-
:SDL_EventState => :uchar,
|
518
|
-
:SDL_RegisterEvents => :uint,
|
519
|
-
}
|
520
|
-
symbols.each do |sym|
|
521
|
-
begin
|
522
|
-
attach_function sym, args[sym], retvals[sym]
|
523
|
-
rescue FFI::NotFoundError => error
|
524
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
525
|
-
end
|
526
|
-
end
|
527
|
-
end
|
528
|
-
|
529
|
-
end
|
530
|
-
|
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_keyboard'
|
9
|
+
|
10
|
+
module SDL2
|
11
|
+
extend FFI::Library
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
SDL_RELEASED = 0
|
15
|
+
SDL_PRESSED = 1
|
16
|
+
SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
|
17
|
+
SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
|
18
|
+
SDL_QUERY = -1
|
19
|
+
SDL_IGNORE = 0
|
20
|
+
SDL_DISABLE = 0
|
21
|
+
SDL_ENABLE = 1
|
22
|
+
|
23
|
+
# Enum
|
24
|
+
|
25
|
+
SDL_FIRSTEVENT = 0
|
26
|
+
SDL_QUIT = 256
|
27
|
+
SDL_APP_TERMINATING = 257
|
28
|
+
SDL_APP_LOWMEMORY = 258
|
29
|
+
SDL_APP_WILLENTERBACKGROUND = 259
|
30
|
+
SDL_APP_DIDENTERBACKGROUND = 260
|
31
|
+
SDL_APP_WILLENTERFOREGROUND = 261
|
32
|
+
SDL_APP_DIDENTERFOREGROUND = 262
|
33
|
+
SDL_LOCALECHANGED = 263
|
34
|
+
SDL_DISPLAYEVENT = 336
|
35
|
+
SDL_WINDOWEVENT = 512
|
36
|
+
SDL_SYSWMEVENT = 513
|
37
|
+
SDL_KEYDOWN = 768
|
38
|
+
SDL_KEYUP = 769
|
39
|
+
SDL_TEXTEDITING = 770
|
40
|
+
SDL_TEXTINPUT = 771
|
41
|
+
SDL_KEYMAPCHANGED = 772
|
42
|
+
SDL_MOUSEMOTION = 1024
|
43
|
+
SDL_MOUSEBUTTONDOWN = 1025
|
44
|
+
SDL_MOUSEBUTTONUP = 1026
|
45
|
+
SDL_MOUSEWHEEL = 1027
|
46
|
+
SDL_JOYAXISMOTION = 1536
|
47
|
+
SDL_JOYBALLMOTION = 1537
|
48
|
+
SDL_JOYHATMOTION = 1538
|
49
|
+
SDL_JOYBUTTONDOWN = 1539
|
50
|
+
SDL_JOYBUTTONUP = 1540
|
51
|
+
SDL_JOYDEVICEADDED = 1541
|
52
|
+
SDL_JOYDEVICEREMOVED = 1542
|
53
|
+
SDL_CONTROLLERAXISMOTION = 1616
|
54
|
+
SDL_CONTROLLERBUTTONDOWN = 1617
|
55
|
+
SDL_CONTROLLERBUTTONUP = 1618
|
56
|
+
SDL_CONTROLLERDEVICEADDED = 1619
|
57
|
+
SDL_CONTROLLERDEVICEREMOVED = 1620
|
58
|
+
SDL_CONTROLLERDEVICEREMAPPED = 1621
|
59
|
+
SDL_CONTROLLERTOUCHPADDOWN = 1622
|
60
|
+
SDL_CONTROLLERTOUCHPADMOTION = 1623
|
61
|
+
SDL_CONTROLLERTOUCHPADUP = 1624
|
62
|
+
SDL_CONTROLLERSENSORUPDATE = 1625
|
63
|
+
SDL_FINGERDOWN = 1792
|
64
|
+
SDL_FINGERUP = 1793
|
65
|
+
SDL_FINGERMOTION = 1794
|
66
|
+
SDL_DOLLARGESTURE = 2048
|
67
|
+
SDL_DOLLARRECORD = 2049
|
68
|
+
SDL_MULTIGESTURE = 2050
|
69
|
+
SDL_CLIPBOARDUPDATE = 2304
|
70
|
+
SDL_DROPFILE = 4096
|
71
|
+
SDL_DROPTEXT = 4097
|
72
|
+
SDL_DROPBEGIN = 4098
|
73
|
+
SDL_DROPCOMPLETE = 4099
|
74
|
+
SDL_AUDIODEVICEADDED = 4352
|
75
|
+
SDL_AUDIODEVICEREMOVED = 4353
|
76
|
+
SDL_SENSORUPDATE = 4608
|
77
|
+
SDL_RENDER_TARGETS_RESET = 8192
|
78
|
+
SDL_RENDER_DEVICE_RESET = 8193
|
79
|
+
SDL_USEREVENT = 32768
|
80
|
+
SDL_LASTEVENT = 65535
|
81
|
+
SDL_ADDEVENT = 0
|
82
|
+
SDL_PEEKEVENT = 1
|
83
|
+
SDL_GETEVENT = 2
|
84
|
+
|
85
|
+
# Typedef
|
86
|
+
|
87
|
+
typedef :int, :SDL_EventType
|
88
|
+
typedef :int, :SDL_compile_time_assert_SDL_Event
|
89
|
+
typedef :int, :SDL_eventaction
|
90
|
+
callback :SDL_EventFilter, [:pointer, :pointer], :int
|
91
|
+
|
92
|
+
# Struct
|
93
|
+
|
94
|
+
class SDL_CommonEvent < FFI::Struct
|
95
|
+
layout(
|
96
|
+
:type, :uint,
|
97
|
+
:timestamp, :uint,
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
class SDL_DisplayEvent < FFI::Struct
|
102
|
+
layout(
|
103
|
+
:type, :uint,
|
104
|
+
:timestamp, :uint,
|
105
|
+
:display, :uint,
|
106
|
+
:event, :uchar,
|
107
|
+
:padding1, :uchar,
|
108
|
+
:padding2, :uchar,
|
109
|
+
:padding3, :uchar,
|
110
|
+
:data1, :int,
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
class SDL_WindowEvent < FFI::Struct
|
115
|
+
layout(
|
116
|
+
:type, :uint,
|
117
|
+
:timestamp, :uint,
|
118
|
+
:windowID, :uint,
|
119
|
+
:event, :uchar,
|
120
|
+
:padding1, :uchar,
|
121
|
+
:padding2, :uchar,
|
122
|
+
:padding3, :uchar,
|
123
|
+
:data1, :int,
|
124
|
+
:data2, :int,
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
class SDL_KeyboardEvent < FFI::Struct
|
129
|
+
layout(
|
130
|
+
:type, :uint,
|
131
|
+
:timestamp, :uint,
|
132
|
+
:windowID, :uint,
|
133
|
+
:state, :uchar,
|
134
|
+
:repeat, :uchar,
|
135
|
+
:padding2, :uchar,
|
136
|
+
:padding3, :uchar,
|
137
|
+
:keysym, SDL_Keysym,
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
class SDL_TextEditingEvent < FFI::Struct
|
142
|
+
layout(
|
143
|
+
:type, :uint,
|
144
|
+
:timestamp, :uint,
|
145
|
+
:windowID, :uint,
|
146
|
+
:text, [:char, 32],
|
147
|
+
:start, :int,
|
148
|
+
:length, :int,
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
class SDL_TextInputEvent < FFI::Struct
|
153
|
+
layout(
|
154
|
+
:type, :uint,
|
155
|
+
:timestamp, :uint,
|
156
|
+
:windowID, :uint,
|
157
|
+
:text, [:char, 32],
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
class SDL_MouseMotionEvent < FFI::Struct
|
162
|
+
layout(
|
163
|
+
:type, :uint,
|
164
|
+
:timestamp, :uint,
|
165
|
+
:windowID, :uint,
|
166
|
+
:which, :uint,
|
167
|
+
:state, :uint,
|
168
|
+
:x, :int,
|
169
|
+
:y, :int,
|
170
|
+
:xrel, :int,
|
171
|
+
:yrel, :int,
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
class SDL_MouseButtonEvent < FFI::Struct
|
176
|
+
layout(
|
177
|
+
:type, :uint,
|
178
|
+
:timestamp, :uint,
|
179
|
+
:windowID, :uint,
|
180
|
+
:which, :uint,
|
181
|
+
:button, :uchar,
|
182
|
+
:state, :uchar,
|
183
|
+
:clicks, :uchar,
|
184
|
+
:padding1, :uchar,
|
185
|
+
:x, :int,
|
186
|
+
:y, :int,
|
187
|
+
)
|
188
|
+
end
|
189
|
+
|
190
|
+
class SDL_MouseWheelEvent < FFI::Struct
|
191
|
+
layout(
|
192
|
+
:type, :uint,
|
193
|
+
:timestamp, :uint,
|
194
|
+
:windowID, :uint,
|
195
|
+
:which, :uint,
|
196
|
+
:x, :int,
|
197
|
+
:y, :int,
|
198
|
+
:direction, :uint,
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
class SDL_JoyAxisEvent < FFI::Struct
|
203
|
+
layout(
|
204
|
+
:type, :uint,
|
205
|
+
:timestamp, :uint,
|
206
|
+
:which, :int,
|
207
|
+
:axis, :uchar,
|
208
|
+
:padding1, :uchar,
|
209
|
+
:padding2, :uchar,
|
210
|
+
:padding3, :uchar,
|
211
|
+
:value, :short,
|
212
|
+
:padding4, :ushort,
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
class SDL_JoyBallEvent < FFI::Struct
|
217
|
+
layout(
|
218
|
+
:type, :uint,
|
219
|
+
:timestamp, :uint,
|
220
|
+
:which, :int,
|
221
|
+
:ball, :uchar,
|
222
|
+
:padding1, :uchar,
|
223
|
+
:padding2, :uchar,
|
224
|
+
:padding3, :uchar,
|
225
|
+
:xrel, :short,
|
226
|
+
:yrel, :short,
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
class SDL_JoyHatEvent < FFI::Struct
|
231
|
+
layout(
|
232
|
+
:type, :uint,
|
233
|
+
:timestamp, :uint,
|
234
|
+
:which, :int,
|
235
|
+
:hat, :uchar,
|
236
|
+
:value, :uchar,
|
237
|
+
:padding1, :uchar,
|
238
|
+
:padding2, :uchar,
|
239
|
+
)
|
240
|
+
end
|
241
|
+
|
242
|
+
class SDL_JoyButtonEvent < FFI::Struct
|
243
|
+
layout(
|
244
|
+
:type, :uint,
|
245
|
+
:timestamp, :uint,
|
246
|
+
:which, :int,
|
247
|
+
:button, :uchar,
|
248
|
+
:state, :uchar,
|
249
|
+
:padding1, :uchar,
|
250
|
+
:padding2, :uchar,
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
class SDL_JoyDeviceEvent < FFI::Struct
|
255
|
+
layout(
|
256
|
+
:type, :uint,
|
257
|
+
:timestamp, :uint,
|
258
|
+
:which, :int,
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
class SDL_ControllerAxisEvent < FFI::Struct
|
263
|
+
layout(
|
264
|
+
:type, :uint,
|
265
|
+
:timestamp, :uint,
|
266
|
+
:which, :int,
|
267
|
+
:axis, :uchar,
|
268
|
+
:padding1, :uchar,
|
269
|
+
:padding2, :uchar,
|
270
|
+
:padding3, :uchar,
|
271
|
+
:value, :short,
|
272
|
+
:padding4, :ushort,
|
273
|
+
)
|
274
|
+
end
|
275
|
+
|
276
|
+
class SDL_ControllerButtonEvent < FFI::Struct
|
277
|
+
layout(
|
278
|
+
:type, :uint,
|
279
|
+
:timestamp, :uint,
|
280
|
+
:which, :int,
|
281
|
+
:button, :uchar,
|
282
|
+
:state, :uchar,
|
283
|
+
:padding1, :uchar,
|
284
|
+
:padding2, :uchar,
|
285
|
+
)
|
286
|
+
end
|
287
|
+
|
288
|
+
class SDL_ControllerDeviceEvent < FFI::Struct
|
289
|
+
layout(
|
290
|
+
:type, :uint,
|
291
|
+
:timestamp, :uint,
|
292
|
+
:which, :int,
|
293
|
+
)
|
294
|
+
end
|
295
|
+
|
296
|
+
class SDL_ControllerTouchpadEvent < FFI::Struct
|
297
|
+
layout(
|
298
|
+
:type, :uint,
|
299
|
+
:timestamp, :uint,
|
300
|
+
:which, :int,
|
301
|
+
:touchpad, :int,
|
302
|
+
:finger, :int,
|
303
|
+
:x, :float,
|
304
|
+
:y, :float,
|
305
|
+
:pressure, :float,
|
306
|
+
)
|
307
|
+
end
|
308
|
+
|
309
|
+
class SDL_ControllerSensorEvent < FFI::Struct
|
310
|
+
layout(
|
311
|
+
:type, :uint,
|
312
|
+
:timestamp, :uint,
|
313
|
+
:which, :int,
|
314
|
+
:sensor, :int,
|
315
|
+
:data, [:float, 3],
|
316
|
+
)
|
317
|
+
end
|
318
|
+
|
319
|
+
class SDL_AudioDeviceEvent < FFI::Struct
|
320
|
+
layout(
|
321
|
+
:type, :uint,
|
322
|
+
:timestamp, :uint,
|
323
|
+
:which, :uint,
|
324
|
+
:iscapture, :uchar,
|
325
|
+
:padding1, :uchar,
|
326
|
+
:padding2, :uchar,
|
327
|
+
:padding3, :uchar,
|
328
|
+
)
|
329
|
+
end
|
330
|
+
|
331
|
+
class SDL_TouchFingerEvent < FFI::Struct
|
332
|
+
layout(
|
333
|
+
:type, :uint,
|
334
|
+
:timestamp, :uint,
|
335
|
+
:touchId, :long_long,
|
336
|
+
:fingerId, :long_long,
|
337
|
+
:x, :float,
|
338
|
+
:y, :float,
|
339
|
+
:dx, :float,
|
340
|
+
:dy, :float,
|
341
|
+
:pressure, :float,
|
342
|
+
:windowID, :uint,
|
343
|
+
)
|
344
|
+
end
|
345
|
+
|
346
|
+
class SDL_MultiGestureEvent < FFI::Struct
|
347
|
+
layout(
|
348
|
+
:type, :uint,
|
349
|
+
:timestamp, :uint,
|
350
|
+
:touchId, :long_long,
|
351
|
+
:dTheta, :float,
|
352
|
+
:dDist, :float,
|
353
|
+
:x, :float,
|
354
|
+
:y, :float,
|
355
|
+
:numFingers, :ushort,
|
356
|
+
:padding, :ushort,
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
class SDL_DollarGestureEvent < FFI::Struct
|
361
|
+
layout(
|
362
|
+
:type, :uint,
|
363
|
+
:timestamp, :uint,
|
364
|
+
:touchId, :long_long,
|
365
|
+
:gestureId, :long_long,
|
366
|
+
:numFingers, :uint,
|
367
|
+
:error, :float,
|
368
|
+
:x, :float,
|
369
|
+
:y, :float,
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
class SDL_DropEvent < FFI::Struct
|
374
|
+
layout(
|
375
|
+
:type, :uint,
|
376
|
+
:timestamp, :uint,
|
377
|
+
:file, :pointer,
|
378
|
+
:windowID, :uint,
|
379
|
+
)
|
380
|
+
end
|
381
|
+
|
382
|
+
class SDL_SensorEvent < FFI::Struct
|
383
|
+
layout(
|
384
|
+
:type, :uint,
|
385
|
+
:timestamp, :uint,
|
386
|
+
:which, :int,
|
387
|
+
:data, [:float, 6],
|
388
|
+
)
|
389
|
+
end
|
390
|
+
|
391
|
+
class SDL_QuitEvent < FFI::Struct
|
392
|
+
layout(
|
393
|
+
:type, :uint,
|
394
|
+
:timestamp, :uint,
|
395
|
+
)
|
396
|
+
end
|
397
|
+
|
398
|
+
class SDL_OSEvent < FFI::Struct
|
399
|
+
layout(
|
400
|
+
:type, :uint,
|
401
|
+
:timestamp, :uint,
|
402
|
+
)
|
403
|
+
end
|
404
|
+
|
405
|
+
class SDL_UserEvent < FFI::Struct
|
406
|
+
layout(
|
407
|
+
:type, :uint,
|
408
|
+
:timestamp, :uint,
|
409
|
+
:windowID, :uint,
|
410
|
+
:code, :int,
|
411
|
+
:data1, :pointer,
|
412
|
+
:data2, :pointer,
|
413
|
+
)
|
414
|
+
end
|
415
|
+
|
416
|
+
class SDL_SysWMEvent < FFI::Struct
|
417
|
+
layout(
|
418
|
+
:type, :uint,
|
419
|
+
:timestamp, :uint,
|
420
|
+
:msg, :pointer,
|
421
|
+
)
|
422
|
+
end
|
423
|
+
|
424
|
+
class SDL_Event < FFI::Union
|
425
|
+
layout(
|
426
|
+
:type, :uint,
|
427
|
+
:common, SDL_CommonEvent,
|
428
|
+
:display, SDL_DisplayEvent,
|
429
|
+
:window, SDL_WindowEvent,
|
430
|
+
:key, SDL_KeyboardEvent,
|
431
|
+
:edit, SDL_TextEditingEvent,
|
432
|
+
:text, SDL_TextInputEvent,
|
433
|
+
:motion, SDL_MouseMotionEvent,
|
434
|
+
:button, SDL_MouseButtonEvent,
|
435
|
+
:wheel, SDL_MouseWheelEvent,
|
436
|
+
:jaxis, SDL_JoyAxisEvent,
|
437
|
+
:jball, SDL_JoyBallEvent,
|
438
|
+
:jhat, SDL_JoyHatEvent,
|
439
|
+
:jbutton, SDL_JoyButtonEvent,
|
440
|
+
:jdevice, SDL_JoyDeviceEvent,
|
441
|
+
:caxis, SDL_ControllerAxisEvent,
|
442
|
+
:cbutton, SDL_ControllerButtonEvent,
|
443
|
+
:cdevice, SDL_ControllerDeviceEvent,
|
444
|
+
:ctouchpad, SDL_ControllerTouchpadEvent,
|
445
|
+
:csensor, SDL_ControllerSensorEvent,
|
446
|
+
:adevice, SDL_AudioDeviceEvent,
|
447
|
+
:sensor, SDL_SensorEvent,
|
448
|
+
:quit, SDL_QuitEvent,
|
449
|
+
:user, SDL_UserEvent,
|
450
|
+
:syswm, SDL_SysWMEvent,
|
451
|
+
:tfinger, SDL_TouchFingerEvent,
|
452
|
+
:mgesture, SDL_MultiGestureEvent,
|
453
|
+
:dgesture, SDL_DollarGestureEvent,
|
454
|
+
:drop, SDL_DropEvent,
|
455
|
+
:padding, [:uchar, 56],
|
456
|
+
)
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
# Function
|
461
|
+
|
462
|
+
def self.setup_events_symbols()
|
463
|
+
symbols = [
|
464
|
+
:SDL_PumpEvents,
|
465
|
+
:SDL_PeepEvents,
|
466
|
+
:SDL_HasEvent,
|
467
|
+
:SDL_HasEvents,
|
468
|
+
:SDL_FlushEvent,
|
469
|
+
:SDL_FlushEvents,
|
470
|
+
:SDL_PollEvent,
|
471
|
+
:SDL_WaitEvent,
|
472
|
+
:SDL_WaitEventTimeout,
|
473
|
+
:SDL_PushEvent,
|
474
|
+
:SDL_SetEventFilter,
|
475
|
+
:SDL_GetEventFilter,
|
476
|
+
:SDL_AddEventWatch,
|
477
|
+
:SDL_DelEventWatch,
|
478
|
+
:SDL_FilterEvents,
|
479
|
+
:SDL_EventState,
|
480
|
+
:SDL_RegisterEvents,
|
481
|
+
]
|
482
|
+
args = {
|
483
|
+
:SDL_PumpEvents => [],
|
484
|
+
:SDL_PeepEvents => [:pointer, :int, :int, :uint, :uint],
|
485
|
+
:SDL_HasEvent => [:uint],
|
486
|
+
:SDL_HasEvents => [:uint, :uint],
|
487
|
+
:SDL_FlushEvent => [:uint],
|
488
|
+
:SDL_FlushEvents => [:uint, :uint],
|
489
|
+
:SDL_PollEvent => [:pointer],
|
490
|
+
:SDL_WaitEvent => [:pointer],
|
491
|
+
:SDL_WaitEventTimeout => [:pointer, :int],
|
492
|
+
:SDL_PushEvent => [:pointer],
|
493
|
+
:SDL_SetEventFilter => [:SDL_EventFilter, :pointer],
|
494
|
+
:SDL_GetEventFilter => [:pointer, :pointer],
|
495
|
+
:SDL_AddEventWatch => [:SDL_EventFilter, :pointer],
|
496
|
+
:SDL_DelEventWatch => [:SDL_EventFilter, :pointer],
|
497
|
+
:SDL_FilterEvents => [:SDL_EventFilter, :pointer],
|
498
|
+
:SDL_EventState => [:uint, :int],
|
499
|
+
:SDL_RegisterEvents => [:int],
|
500
|
+
}
|
501
|
+
retvals = {
|
502
|
+
:SDL_PumpEvents => :void,
|
503
|
+
:SDL_PeepEvents => :int,
|
504
|
+
:SDL_HasEvent => :int,
|
505
|
+
:SDL_HasEvents => :int,
|
506
|
+
:SDL_FlushEvent => :void,
|
507
|
+
:SDL_FlushEvents => :void,
|
508
|
+
:SDL_PollEvent => :int,
|
509
|
+
:SDL_WaitEvent => :int,
|
510
|
+
:SDL_WaitEventTimeout => :int,
|
511
|
+
:SDL_PushEvent => :int,
|
512
|
+
:SDL_SetEventFilter => :void,
|
513
|
+
:SDL_GetEventFilter => :int,
|
514
|
+
:SDL_AddEventWatch => :void,
|
515
|
+
:SDL_DelEventWatch => :void,
|
516
|
+
:SDL_FilterEvents => :void,
|
517
|
+
:SDL_EventState => :uchar,
|
518
|
+
:SDL_RegisterEvents => :uint,
|
519
|
+
}
|
520
|
+
symbols.each do |sym|
|
521
|
+
begin
|
522
|
+
attach_function sym, args[sym], retvals[sym]
|
523
|
+
rescue FFI::NotFoundError => error
|
524
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
end
|
530
|
+
|