sdl2-bindings 0.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +55 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/lib/sdl2.rb +166 -0
- data/lib/sdl2_audio.rb +201 -0
- data/lib/sdl2_blendmode.rb +68 -0
- data/lib/sdl2_clipboard.rb +51 -0
- data/lib/sdl2_cpuinfo.rb +100 -0
- data/lib/sdl2_error.rb +61 -0
- data/lib/sdl2_events.rb +499 -0
- data/lib/sdl2_filesystem.rb +48 -0
- data/lib/sdl2_framerate.rb +67 -0
- data/lib/sdl2_gamecontroller.rb +188 -0
- data/lib/sdl2_gesture.rb +55 -0
- data/lib/sdl2_gfxPrimitives.rb +222 -0
- data/lib/sdl2_haptic.rb +268 -0
- data/lib/sdl2_hints.rb +68 -0
- data/lib/sdl2_image.rb +185 -0
- data/lib/sdl2_imageFilter.rb +132 -0
- data/lib/sdl2_joystick.rb +193 -0
- data/lib/sdl2_keyboard.rb +99 -0
- data/lib/sdl2_keycode.rb +297 -0
- data/lib/sdl2_log.rb +114 -0
- data/lib/sdl2_main.rb +67 -0
- data/lib/sdl2_messagebox.rb +96 -0
- data/lib/sdl2_mixer.rb +304 -0
- data/lib/sdl2_mouse.rb +115 -0
- data/lib/sdl2_pixels.rb +212 -0
- data/lib/sdl2_platform.rb +45 -0
- data/lib/sdl2_power.rb +51 -0
- data/lib/sdl2_rect.rb +102 -0
- data/lib/sdl2_render.rb +277 -0
- data/lib/sdl2_rotozoom.rb +66 -0
- data/lib/sdl2_rwops.rb +208 -0
- data/lib/sdl2_scancode.rb +287 -0
- data/lib/sdl2_shape.rb +77 -0
- data/lib/sdl2_surface.rb +179 -0
- data/lib/sdl2_timer.rb +62 -0
- data/lib/sdl2_touch.rb +73 -0
- data/lib/sdl2_ttf.rb +190 -0
- data/lib/sdl2_version.rb +62 -0
- data/lib/sdl2_video.rb +408 -0
- data/lib/sdl2_vulkan.rb +64 -0
- metadata +88 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] This is an automatically generated file.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module SDL2
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
|
14
|
+
# Enum
|
15
|
+
|
16
|
+
|
17
|
+
# Typedef
|
18
|
+
|
19
|
+
|
20
|
+
# Struct
|
21
|
+
|
22
|
+
|
23
|
+
# Function
|
24
|
+
|
25
|
+
def self.setup_gfx_imagefilter_symbols()
|
26
|
+
symbols = [
|
27
|
+
:SDL_imageFilterMMXdetect,
|
28
|
+
:SDL_imageFilterMMXoff,
|
29
|
+
:SDL_imageFilterMMXon,
|
30
|
+
:SDL_imageFilterAdd,
|
31
|
+
:SDL_imageFilterMean,
|
32
|
+
:SDL_imageFilterSub,
|
33
|
+
:SDL_imageFilterAbsDiff,
|
34
|
+
:SDL_imageFilterMult,
|
35
|
+
:SDL_imageFilterMultNor,
|
36
|
+
:SDL_imageFilterMultDivby2,
|
37
|
+
:SDL_imageFilterMultDivby4,
|
38
|
+
:SDL_imageFilterBitAnd,
|
39
|
+
:SDL_imageFilterBitOr,
|
40
|
+
:SDL_imageFilterDiv,
|
41
|
+
:SDL_imageFilterBitNegation,
|
42
|
+
:SDL_imageFilterAddByte,
|
43
|
+
:SDL_imageFilterAddUint,
|
44
|
+
:SDL_imageFilterAddByteToHalf,
|
45
|
+
:SDL_imageFilterSubByte,
|
46
|
+
:SDL_imageFilterSubUint,
|
47
|
+
:SDL_imageFilterShiftRight,
|
48
|
+
:SDL_imageFilterShiftRightUint,
|
49
|
+
:SDL_imageFilterMultByByte,
|
50
|
+
:SDL_imageFilterShiftRightAndMultByByte,
|
51
|
+
:SDL_imageFilterShiftLeftByte,
|
52
|
+
:SDL_imageFilterShiftLeftUint,
|
53
|
+
:SDL_imageFilterShiftLeft,
|
54
|
+
:SDL_imageFilterBinarizeUsingThreshold,
|
55
|
+
:SDL_imageFilterClipToRange,
|
56
|
+
:SDL_imageFilterNormalizeLinear,
|
57
|
+
]
|
58
|
+
args = {
|
59
|
+
:SDL_imageFilterMMXdetect => [],
|
60
|
+
:SDL_imageFilterMMXoff => [],
|
61
|
+
:SDL_imageFilterMMXon => [],
|
62
|
+
:SDL_imageFilterAdd => [:pointer, :pointer, :pointer, :uint],
|
63
|
+
:SDL_imageFilterMean => [:pointer, :pointer, :pointer, :uint],
|
64
|
+
:SDL_imageFilterSub => [:pointer, :pointer, :pointer, :uint],
|
65
|
+
:SDL_imageFilterAbsDiff => [:pointer, :pointer, :pointer, :uint],
|
66
|
+
:SDL_imageFilterMult => [:pointer, :pointer, :pointer, :uint],
|
67
|
+
:SDL_imageFilterMultNor => [:pointer, :pointer, :pointer, :uint],
|
68
|
+
:SDL_imageFilterMultDivby2 => [:pointer, :pointer, :pointer, :uint],
|
69
|
+
:SDL_imageFilterMultDivby4 => [:pointer, :pointer, :pointer, :uint],
|
70
|
+
:SDL_imageFilterBitAnd => [:pointer, :pointer, :pointer, :uint],
|
71
|
+
:SDL_imageFilterBitOr => [:pointer, :pointer, :pointer, :uint],
|
72
|
+
:SDL_imageFilterDiv => [:pointer, :pointer, :pointer, :uint],
|
73
|
+
:SDL_imageFilterBitNegation => [:pointer, :pointer, :uint],
|
74
|
+
:SDL_imageFilterAddByte => [:pointer, :pointer, :uint, :uchar],
|
75
|
+
:SDL_imageFilterAddUint => [:pointer, :pointer, :uint, :uint],
|
76
|
+
:SDL_imageFilterAddByteToHalf => [:pointer, :pointer, :uint, :uchar],
|
77
|
+
:SDL_imageFilterSubByte => [:pointer, :pointer, :uint, :uchar],
|
78
|
+
:SDL_imageFilterSubUint => [:pointer, :pointer, :uint, :uint],
|
79
|
+
:SDL_imageFilterShiftRight => [:pointer, :pointer, :uint, :uchar],
|
80
|
+
:SDL_imageFilterShiftRightUint => [:pointer, :pointer, :uint, :uchar],
|
81
|
+
:SDL_imageFilterMultByByte => [:pointer, :pointer, :uint, :uchar],
|
82
|
+
:SDL_imageFilterShiftRightAndMultByByte => [:pointer, :pointer, :uint, :uchar, :uchar],
|
83
|
+
:SDL_imageFilterShiftLeftByte => [:pointer, :pointer, :uint, :uchar],
|
84
|
+
:SDL_imageFilterShiftLeftUint => [:pointer, :pointer, :uint, :uchar],
|
85
|
+
:SDL_imageFilterShiftLeft => [:pointer, :pointer, :uint, :uchar],
|
86
|
+
:SDL_imageFilterBinarizeUsingThreshold => [:pointer, :pointer, :uint, :uchar],
|
87
|
+
:SDL_imageFilterClipToRange => [:pointer, :pointer, :uint, :uchar, :uchar],
|
88
|
+
:SDL_imageFilterNormalizeLinear => [:pointer, :pointer, :uint, :int, :int, :int, :int],
|
89
|
+
}
|
90
|
+
retvals = {
|
91
|
+
:SDL_imageFilterMMXdetect => :int,
|
92
|
+
:SDL_imageFilterMMXoff => :void,
|
93
|
+
:SDL_imageFilterMMXon => :void,
|
94
|
+
:SDL_imageFilterAdd => :int,
|
95
|
+
:SDL_imageFilterMean => :int,
|
96
|
+
:SDL_imageFilterSub => :int,
|
97
|
+
:SDL_imageFilterAbsDiff => :int,
|
98
|
+
:SDL_imageFilterMult => :int,
|
99
|
+
:SDL_imageFilterMultNor => :int,
|
100
|
+
:SDL_imageFilterMultDivby2 => :int,
|
101
|
+
:SDL_imageFilterMultDivby4 => :int,
|
102
|
+
:SDL_imageFilterBitAnd => :int,
|
103
|
+
:SDL_imageFilterBitOr => :int,
|
104
|
+
:SDL_imageFilterDiv => :int,
|
105
|
+
:SDL_imageFilterBitNegation => :int,
|
106
|
+
:SDL_imageFilterAddByte => :int,
|
107
|
+
:SDL_imageFilterAddUint => :int,
|
108
|
+
:SDL_imageFilterAddByteToHalf => :int,
|
109
|
+
:SDL_imageFilterSubByte => :int,
|
110
|
+
:SDL_imageFilterSubUint => :int,
|
111
|
+
:SDL_imageFilterShiftRight => :int,
|
112
|
+
:SDL_imageFilterShiftRightUint => :int,
|
113
|
+
:SDL_imageFilterMultByByte => :int,
|
114
|
+
:SDL_imageFilterShiftRightAndMultByByte => :int,
|
115
|
+
:SDL_imageFilterShiftLeftByte => :int,
|
116
|
+
:SDL_imageFilterShiftLeftUint => :int,
|
117
|
+
:SDL_imageFilterShiftLeft => :int,
|
118
|
+
:SDL_imageFilterBinarizeUsingThreshold => :int,
|
119
|
+
:SDL_imageFilterClipToRange => :int,
|
120
|
+
:SDL_imageFilterNormalizeLinear => :int,
|
121
|
+
}
|
122
|
+
symbols.each do |sym|
|
123
|
+
begin
|
124
|
+
attach_function sym, args[sym], retvals[sym]
|
125
|
+
rescue FFI::NotFoundError => error
|
126
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
@@ -0,0 +1,193 @@
|
|
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_JOYSTICK_AXIS_MAX = 32767
|
14
|
+
SDL_JOYSTICK_AXIS_MIN = -32768
|
15
|
+
SDL_HAT_CENTERED = 0x00
|
16
|
+
SDL_HAT_UP = 0x01
|
17
|
+
SDL_HAT_RIGHT = 0x02
|
18
|
+
SDL_HAT_DOWN = 0x04
|
19
|
+
SDL_HAT_LEFT = 0x08
|
20
|
+
SDL_HAT_RIGHTUP = ( SDL_HAT_RIGHT | SDL_HAT_UP )
|
21
|
+
SDL_HAT_RIGHTDOWN = ( SDL_HAT_RIGHT | SDL_HAT_DOWN )
|
22
|
+
SDL_HAT_LEFTUP = ( SDL_HAT_LEFT | SDL_HAT_UP )
|
23
|
+
SDL_HAT_LEFTDOWN = ( SDL_HAT_LEFT | SDL_HAT_DOWN )
|
24
|
+
|
25
|
+
# Enum
|
26
|
+
|
27
|
+
SDL_JOYSTICK_TYPE_UNKNOWN = 0
|
28
|
+
SDL_JOYSTICK_TYPE_GAMECONTROLLER = 1
|
29
|
+
SDL_JOYSTICK_TYPE_WHEEL = 2
|
30
|
+
SDL_JOYSTICK_TYPE_ARCADE_STICK = 3
|
31
|
+
SDL_JOYSTICK_TYPE_FLIGHT_STICK = 4
|
32
|
+
SDL_JOYSTICK_TYPE_DANCE_PAD = 5
|
33
|
+
SDL_JOYSTICK_TYPE_GUITAR = 6
|
34
|
+
SDL_JOYSTICK_TYPE_DRUM_KIT = 7
|
35
|
+
SDL_JOYSTICK_TYPE_ARCADE_PAD = 8
|
36
|
+
SDL_JOYSTICK_TYPE_THROTTLE = 9
|
37
|
+
SDL_JOYSTICK_POWER_UNKNOWN = -1
|
38
|
+
SDL_JOYSTICK_POWER_EMPTY = 0
|
39
|
+
SDL_JOYSTICK_POWER_LOW = 1
|
40
|
+
SDL_JOYSTICK_POWER_MEDIUM = 2
|
41
|
+
SDL_JOYSTICK_POWER_FULL = 3
|
42
|
+
SDL_JOYSTICK_POWER_WIRED = 4
|
43
|
+
SDL_JOYSTICK_POWER_MAX = 5
|
44
|
+
|
45
|
+
# Typedef
|
46
|
+
|
47
|
+
typedef :int, :SDL_JoystickID
|
48
|
+
typedef :int, :SDL_JoystickType
|
49
|
+
typedef :int, :SDL_JoystickPowerLevel
|
50
|
+
|
51
|
+
# Struct
|
52
|
+
|
53
|
+
class SDL_JoystickGUID < FFI::Struct
|
54
|
+
layout(
|
55
|
+
:data, [:uchar, 16],
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# Function
|
61
|
+
|
62
|
+
def self.setup_joystick_symbols()
|
63
|
+
symbols = [
|
64
|
+
:SDL_LockJoysticks,
|
65
|
+
:SDL_UnlockJoysticks,
|
66
|
+
:SDL_NumJoysticks,
|
67
|
+
:SDL_JoystickNameForIndex,
|
68
|
+
:SDL_JoystickGetDevicePlayerIndex,
|
69
|
+
:SDL_JoystickGetDeviceGUID,
|
70
|
+
:SDL_JoystickGetDeviceVendor,
|
71
|
+
:SDL_JoystickGetDeviceProduct,
|
72
|
+
:SDL_JoystickGetDeviceProductVersion,
|
73
|
+
:SDL_JoystickGetDeviceType,
|
74
|
+
:SDL_JoystickGetDeviceInstanceID,
|
75
|
+
:SDL_JoystickOpen,
|
76
|
+
:SDL_JoystickFromInstanceID,
|
77
|
+
:SDL_JoystickName,
|
78
|
+
:SDL_JoystickGetPlayerIndex,
|
79
|
+
:SDL_JoystickGetGUID,
|
80
|
+
:SDL_JoystickGetVendor,
|
81
|
+
:SDL_JoystickGetProduct,
|
82
|
+
:SDL_JoystickGetProductVersion,
|
83
|
+
:SDL_JoystickGetType,
|
84
|
+
:SDL_JoystickGetGUIDString,
|
85
|
+
:SDL_JoystickGetGUIDFromString,
|
86
|
+
:SDL_JoystickGetAttached,
|
87
|
+
:SDL_JoystickInstanceID,
|
88
|
+
:SDL_JoystickNumAxes,
|
89
|
+
:SDL_JoystickNumBalls,
|
90
|
+
:SDL_JoystickNumHats,
|
91
|
+
:SDL_JoystickNumButtons,
|
92
|
+
:SDL_JoystickUpdate,
|
93
|
+
:SDL_JoystickEventState,
|
94
|
+
:SDL_JoystickGetAxis,
|
95
|
+
:SDL_JoystickGetAxisInitialState,
|
96
|
+
:SDL_JoystickGetHat,
|
97
|
+
:SDL_JoystickGetBall,
|
98
|
+
:SDL_JoystickGetButton,
|
99
|
+
:SDL_JoystickRumble,
|
100
|
+
:SDL_JoystickClose,
|
101
|
+
:SDL_JoystickCurrentPowerLevel,
|
102
|
+
]
|
103
|
+
args = {
|
104
|
+
:SDL_LockJoysticks => [],
|
105
|
+
:SDL_UnlockJoysticks => [],
|
106
|
+
:SDL_NumJoysticks => [],
|
107
|
+
:SDL_JoystickNameForIndex => [:int],
|
108
|
+
:SDL_JoystickGetDevicePlayerIndex => [:int],
|
109
|
+
:SDL_JoystickGetDeviceGUID => [:int],
|
110
|
+
:SDL_JoystickGetDeviceVendor => [:int],
|
111
|
+
:SDL_JoystickGetDeviceProduct => [:int],
|
112
|
+
:SDL_JoystickGetDeviceProductVersion => [:int],
|
113
|
+
:SDL_JoystickGetDeviceType => [:int],
|
114
|
+
:SDL_JoystickGetDeviceInstanceID => [:int],
|
115
|
+
:SDL_JoystickOpen => [:int],
|
116
|
+
:SDL_JoystickFromInstanceID => [:int],
|
117
|
+
:SDL_JoystickName => [:pointer],
|
118
|
+
:SDL_JoystickGetPlayerIndex => [:pointer],
|
119
|
+
:SDL_JoystickGetGUID => [:pointer],
|
120
|
+
:SDL_JoystickGetVendor => [:pointer],
|
121
|
+
:SDL_JoystickGetProduct => [:pointer],
|
122
|
+
:SDL_JoystickGetProductVersion => [:pointer],
|
123
|
+
:SDL_JoystickGetType => [:pointer],
|
124
|
+
:SDL_JoystickGetGUIDString => [SDL_JoystickGUID, :pointer, :int],
|
125
|
+
:SDL_JoystickGetGUIDFromString => [:pointer],
|
126
|
+
:SDL_JoystickGetAttached => [:pointer],
|
127
|
+
:SDL_JoystickInstanceID => [:pointer],
|
128
|
+
:SDL_JoystickNumAxes => [:pointer],
|
129
|
+
:SDL_JoystickNumBalls => [:pointer],
|
130
|
+
:SDL_JoystickNumHats => [:pointer],
|
131
|
+
:SDL_JoystickNumButtons => [:pointer],
|
132
|
+
:SDL_JoystickUpdate => [],
|
133
|
+
:SDL_JoystickEventState => [:int],
|
134
|
+
:SDL_JoystickGetAxis => [:pointer, :int],
|
135
|
+
:SDL_JoystickGetAxisInitialState => [:pointer, :int, :pointer],
|
136
|
+
:SDL_JoystickGetHat => [:pointer, :int],
|
137
|
+
:SDL_JoystickGetBall => [:pointer, :int, :pointer, :pointer],
|
138
|
+
:SDL_JoystickGetButton => [:pointer, :int],
|
139
|
+
:SDL_JoystickRumble => [:pointer, :ushort, :ushort, :uint],
|
140
|
+
:SDL_JoystickClose => [:pointer],
|
141
|
+
:SDL_JoystickCurrentPowerLevel => [:pointer],
|
142
|
+
}
|
143
|
+
retvals = {
|
144
|
+
:SDL_LockJoysticks => :void,
|
145
|
+
:SDL_UnlockJoysticks => :void,
|
146
|
+
:SDL_NumJoysticks => :int,
|
147
|
+
:SDL_JoystickNameForIndex => :pointer,
|
148
|
+
:SDL_JoystickGetDevicePlayerIndex => :int,
|
149
|
+
:SDL_JoystickGetDeviceGUID => SDL_JoystickGUID,
|
150
|
+
:SDL_JoystickGetDeviceVendor => :ushort,
|
151
|
+
:SDL_JoystickGetDeviceProduct => :ushort,
|
152
|
+
:SDL_JoystickGetDeviceProductVersion => :ushort,
|
153
|
+
:SDL_JoystickGetDeviceType => :int,
|
154
|
+
:SDL_JoystickGetDeviceInstanceID => :int,
|
155
|
+
:SDL_JoystickOpen => :pointer,
|
156
|
+
:SDL_JoystickFromInstanceID => :pointer,
|
157
|
+
:SDL_JoystickName => :pointer,
|
158
|
+
:SDL_JoystickGetPlayerIndex => :int,
|
159
|
+
:SDL_JoystickGetGUID => SDL_JoystickGUID,
|
160
|
+
:SDL_JoystickGetVendor => :ushort,
|
161
|
+
:SDL_JoystickGetProduct => :ushort,
|
162
|
+
:SDL_JoystickGetProductVersion => :ushort,
|
163
|
+
:SDL_JoystickGetType => :int,
|
164
|
+
:SDL_JoystickGetGUIDString => :void,
|
165
|
+
:SDL_JoystickGetGUIDFromString => SDL_JoystickGUID,
|
166
|
+
:SDL_JoystickGetAttached => :int,
|
167
|
+
:SDL_JoystickInstanceID => :int,
|
168
|
+
:SDL_JoystickNumAxes => :int,
|
169
|
+
:SDL_JoystickNumBalls => :int,
|
170
|
+
:SDL_JoystickNumHats => :int,
|
171
|
+
:SDL_JoystickNumButtons => :int,
|
172
|
+
:SDL_JoystickUpdate => :void,
|
173
|
+
:SDL_JoystickEventState => :int,
|
174
|
+
:SDL_JoystickGetAxis => :short,
|
175
|
+
:SDL_JoystickGetAxisInitialState => :int,
|
176
|
+
:SDL_JoystickGetHat => :uchar,
|
177
|
+
:SDL_JoystickGetBall => :int,
|
178
|
+
:SDL_JoystickGetButton => :uchar,
|
179
|
+
:SDL_JoystickRumble => :int,
|
180
|
+
:SDL_JoystickClose => :void,
|
181
|
+
:SDL_JoystickCurrentPowerLevel => :int,
|
182
|
+
}
|
183
|
+
symbols.each do |sym|
|
184
|
+
begin
|
185
|
+
attach_function sym, args[sym], retvals[sym]
|
186
|
+
rescue FFI::NotFoundError => error
|
187
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
@@ -0,0 +1,99 @@
|
|
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
|
+
class SDL_Keysym < FFI::Struct
|
23
|
+
layout(
|
24
|
+
:scancode, :int,
|
25
|
+
:sym, :int,
|
26
|
+
:mod, :ushort,
|
27
|
+
:unused, :uint,
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Function
|
33
|
+
|
34
|
+
def self.setup_keyboard_symbols()
|
35
|
+
symbols = [
|
36
|
+
:SDL_GetKeyboardFocus,
|
37
|
+
:SDL_GetKeyboardState,
|
38
|
+
:SDL_GetModState,
|
39
|
+
:SDL_SetModState,
|
40
|
+
:SDL_GetKeyFromScancode,
|
41
|
+
:SDL_GetScancodeFromKey,
|
42
|
+
:SDL_GetScancodeName,
|
43
|
+
:SDL_GetScancodeFromName,
|
44
|
+
:SDL_GetKeyName,
|
45
|
+
:SDL_GetKeyFromName,
|
46
|
+
:SDL_StartTextInput,
|
47
|
+
:SDL_IsTextInputActive,
|
48
|
+
:SDL_StopTextInput,
|
49
|
+
:SDL_SetTextInputRect,
|
50
|
+
:SDL_HasScreenKeyboardSupport,
|
51
|
+
:SDL_IsScreenKeyboardShown,
|
52
|
+
]
|
53
|
+
args = {
|
54
|
+
:SDL_GetKeyboardFocus => [],
|
55
|
+
:SDL_GetKeyboardState => [:pointer],
|
56
|
+
:SDL_GetModState => [],
|
57
|
+
:SDL_SetModState => [:int],
|
58
|
+
:SDL_GetKeyFromScancode => [:int],
|
59
|
+
:SDL_GetScancodeFromKey => [:int],
|
60
|
+
:SDL_GetScancodeName => [:int],
|
61
|
+
:SDL_GetScancodeFromName => [:pointer],
|
62
|
+
:SDL_GetKeyName => [:int],
|
63
|
+
:SDL_GetKeyFromName => [:pointer],
|
64
|
+
:SDL_StartTextInput => [],
|
65
|
+
:SDL_IsTextInputActive => [],
|
66
|
+
:SDL_StopTextInput => [],
|
67
|
+
:SDL_SetTextInputRect => [:pointer],
|
68
|
+
:SDL_HasScreenKeyboardSupport => [],
|
69
|
+
:SDL_IsScreenKeyboardShown => [:pointer],
|
70
|
+
}
|
71
|
+
retvals = {
|
72
|
+
:SDL_GetKeyboardFocus => :pointer,
|
73
|
+
:SDL_GetKeyboardState => :pointer,
|
74
|
+
:SDL_GetModState => :int,
|
75
|
+
:SDL_SetModState => :void,
|
76
|
+
:SDL_GetKeyFromScancode => :int,
|
77
|
+
:SDL_GetScancodeFromKey => :int,
|
78
|
+
:SDL_GetScancodeName => :pointer,
|
79
|
+
:SDL_GetScancodeFromName => :int,
|
80
|
+
:SDL_GetKeyName => :pointer,
|
81
|
+
:SDL_GetKeyFromName => :int,
|
82
|
+
:SDL_StartTextInput => :void,
|
83
|
+
:SDL_IsTextInputActive => :int,
|
84
|
+
:SDL_StopTextInput => :void,
|
85
|
+
:SDL_SetTextInputRect => :void,
|
86
|
+
:SDL_HasScreenKeyboardSupport => :int,
|
87
|
+
:SDL_IsScreenKeyboardShown => :int,
|
88
|
+
}
|
89
|
+
symbols.each do |sym|
|
90
|
+
begin
|
91
|
+
attach_function sym, args[sym], retvals[sym]
|
92
|
+
rescue FFI::NotFoundError => error
|
93
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
data/lib/sdl2_keycode.rb
ADDED
@@ -0,0 +1,297 @@
|
|
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
|
+
SDLK_UNKNOWN = 0
|
17
|
+
SDLK_RETURN = 13
|
18
|
+
SDLK_ESCAPE = 27
|
19
|
+
SDLK_BACKSPACE = 8
|
20
|
+
SDLK_TAB = 9
|
21
|
+
SDLK_SPACE = 32
|
22
|
+
SDLK_EXCLAIM = 33
|
23
|
+
SDLK_QUOTEDBL = 34
|
24
|
+
SDLK_HASH = 35
|
25
|
+
SDLK_PERCENT = 37
|
26
|
+
SDLK_DOLLAR = 36
|
27
|
+
SDLK_AMPERSAND = 38
|
28
|
+
SDLK_QUOTE = 39
|
29
|
+
SDLK_LEFTPAREN = 40
|
30
|
+
SDLK_RIGHTPAREN = 41
|
31
|
+
SDLK_ASTERISK = 42
|
32
|
+
SDLK_PLUS = 43
|
33
|
+
SDLK_COMMA = 44
|
34
|
+
SDLK_MINUS = 45
|
35
|
+
SDLK_PERIOD = 46
|
36
|
+
SDLK_SLASH = 47
|
37
|
+
SDLK_0 = 48
|
38
|
+
SDLK_1 = 49
|
39
|
+
SDLK_2 = 50
|
40
|
+
SDLK_3 = 51
|
41
|
+
SDLK_4 = 52
|
42
|
+
SDLK_5 = 53
|
43
|
+
SDLK_6 = 54
|
44
|
+
SDLK_7 = 55
|
45
|
+
SDLK_8 = 56
|
46
|
+
SDLK_9 = 57
|
47
|
+
SDLK_COLON = 58
|
48
|
+
SDLK_SEMICOLON = 59
|
49
|
+
SDLK_LESS = 60
|
50
|
+
SDLK_EQUALS = 61
|
51
|
+
SDLK_GREATER = 62
|
52
|
+
SDLK_QUESTION = 63
|
53
|
+
SDLK_AT = 64
|
54
|
+
SDLK_LEFTBRACKET = 91
|
55
|
+
SDLK_BACKSLASH = 92
|
56
|
+
SDLK_RIGHTBRACKET = 93
|
57
|
+
SDLK_CARET = 94
|
58
|
+
SDLK_UNDERSCORE = 95
|
59
|
+
SDLK_BACKQUOTE = 96
|
60
|
+
SDLK_a = 97
|
61
|
+
SDLK_b = 98
|
62
|
+
SDLK_c = 99
|
63
|
+
SDLK_d = 100
|
64
|
+
SDLK_e = 101
|
65
|
+
SDLK_f = 102
|
66
|
+
SDLK_g = 103
|
67
|
+
SDLK_h = 104
|
68
|
+
SDLK_i = 105
|
69
|
+
SDLK_j = 106
|
70
|
+
SDLK_k = 107
|
71
|
+
SDLK_l = 108
|
72
|
+
SDLK_m = 109
|
73
|
+
SDLK_n = 110
|
74
|
+
SDLK_o = 111
|
75
|
+
SDLK_p = 112
|
76
|
+
SDLK_q = 113
|
77
|
+
SDLK_r = 114
|
78
|
+
SDLK_s = 115
|
79
|
+
SDLK_t = 116
|
80
|
+
SDLK_u = 117
|
81
|
+
SDLK_v = 118
|
82
|
+
SDLK_w = 119
|
83
|
+
SDLK_x = 120
|
84
|
+
SDLK_y = 121
|
85
|
+
SDLK_z = 122
|
86
|
+
SDLK_CAPSLOCK = 1073741881
|
87
|
+
SDLK_F1 = 1073741882
|
88
|
+
SDLK_F2 = 1073741883
|
89
|
+
SDLK_F3 = 1073741884
|
90
|
+
SDLK_F4 = 1073741885
|
91
|
+
SDLK_F5 = 1073741886
|
92
|
+
SDLK_F6 = 1073741887
|
93
|
+
SDLK_F7 = 1073741888
|
94
|
+
SDLK_F8 = 1073741889
|
95
|
+
SDLK_F9 = 1073741890
|
96
|
+
SDLK_F10 = 1073741891
|
97
|
+
SDLK_F11 = 1073741892
|
98
|
+
SDLK_F12 = 1073741893
|
99
|
+
SDLK_PRINTSCREEN = 1073741894
|
100
|
+
SDLK_SCROLLLOCK = 1073741895
|
101
|
+
SDLK_PAUSE = 1073741896
|
102
|
+
SDLK_INSERT = 1073741897
|
103
|
+
SDLK_HOME = 1073741898
|
104
|
+
SDLK_PAGEUP = 1073741899
|
105
|
+
SDLK_DELETE = 127
|
106
|
+
SDLK_END = 1073741901
|
107
|
+
SDLK_PAGEDOWN = 1073741902
|
108
|
+
SDLK_RIGHT = 1073741903
|
109
|
+
SDLK_LEFT = 1073741904
|
110
|
+
SDLK_DOWN = 1073741905
|
111
|
+
SDLK_UP = 1073741906
|
112
|
+
SDLK_NUMLOCKCLEAR = 1073741907
|
113
|
+
SDLK_KP_DIVIDE = 1073741908
|
114
|
+
SDLK_KP_MULTIPLY = 1073741909
|
115
|
+
SDLK_KP_MINUS = 1073741910
|
116
|
+
SDLK_KP_PLUS = 1073741911
|
117
|
+
SDLK_KP_ENTER = 1073741912
|
118
|
+
SDLK_KP_1 = 1073741913
|
119
|
+
SDLK_KP_2 = 1073741914
|
120
|
+
SDLK_KP_3 = 1073741915
|
121
|
+
SDLK_KP_4 = 1073741916
|
122
|
+
SDLK_KP_5 = 1073741917
|
123
|
+
SDLK_KP_6 = 1073741918
|
124
|
+
SDLK_KP_7 = 1073741919
|
125
|
+
SDLK_KP_8 = 1073741920
|
126
|
+
SDLK_KP_9 = 1073741921
|
127
|
+
SDLK_KP_0 = 1073741922
|
128
|
+
SDLK_KP_PERIOD = 1073741923
|
129
|
+
SDLK_APPLICATION = 1073741925
|
130
|
+
SDLK_POWER = 1073741926
|
131
|
+
SDLK_KP_EQUALS = 1073741927
|
132
|
+
SDLK_F13 = 1073741928
|
133
|
+
SDLK_F14 = 1073741929
|
134
|
+
SDLK_F15 = 1073741930
|
135
|
+
SDLK_F16 = 1073741931
|
136
|
+
SDLK_F17 = 1073741932
|
137
|
+
SDLK_F18 = 1073741933
|
138
|
+
SDLK_F19 = 1073741934
|
139
|
+
SDLK_F20 = 1073741935
|
140
|
+
SDLK_F21 = 1073741936
|
141
|
+
SDLK_F22 = 1073741937
|
142
|
+
SDLK_F23 = 1073741938
|
143
|
+
SDLK_F24 = 1073741939
|
144
|
+
SDLK_EXECUTE = 1073741940
|
145
|
+
SDLK_HELP = 1073741941
|
146
|
+
SDLK_MENU = 1073741942
|
147
|
+
SDLK_SELECT = 1073741943
|
148
|
+
SDLK_STOP = 1073741944
|
149
|
+
SDLK_AGAIN = 1073741945
|
150
|
+
SDLK_UNDO = 1073741946
|
151
|
+
SDLK_CUT = 1073741947
|
152
|
+
SDLK_COPY = 1073741948
|
153
|
+
SDLK_PASTE = 1073741949
|
154
|
+
SDLK_FIND = 1073741950
|
155
|
+
SDLK_MUTE = 1073741951
|
156
|
+
SDLK_VOLUMEUP = 1073741952
|
157
|
+
SDLK_VOLUMEDOWN = 1073741953
|
158
|
+
SDLK_KP_COMMA = 1073741957
|
159
|
+
SDLK_KP_EQUALSAS400 = 1073741958
|
160
|
+
SDLK_ALTERASE = 1073741977
|
161
|
+
SDLK_SYSREQ = 1073741978
|
162
|
+
SDLK_CANCEL = 1073741979
|
163
|
+
SDLK_CLEAR = 1073741980
|
164
|
+
SDLK_PRIOR = 1073741981
|
165
|
+
SDLK_RETURN2 = 1073741982
|
166
|
+
SDLK_SEPARATOR = 1073741983
|
167
|
+
SDLK_OUT = 1073741984
|
168
|
+
SDLK_OPER = 1073741985
|
169
|
+
SDLK_CLEARAGAIN = 1073741986
|
170
|
+
SDLK_CRSEL = 1073741987
|
171
|
+
SDLK_EXSEL = 1073741988
|
172
|
+
SDLK_KP_00 = 1073742000
|
173
|
+
SDLK_KP_000 = 1073742001
|
174
|
+
SDLK_THOUSANDSSEPARATOR = 1073742002
|
175
|
+
SDLK_DECIMALSEPARATOR = 1073742003
|
176
|
+
SDLK_CURRENCYUNIT = 1073742004
|
177
|
+
SDLK_CURRENCYSUBUNIT = 1073742005
|
178
|
+
SDLK_KP_LEFTPAREN = 1073742006
|
179
|
+
SDLK_KP_RIGHTPAREN = 1073742007
|
180
|
+
SDLK_KP_LEFTBRACE = 1073742008
|
181
|
+
SDLK_KP_RIGHTBRACE = 1073742009
|
182
|
+
SDLK_KP_TAB = 1073742010
|
183
|
+
SDLK_KP_BACKSPACE = 1073742011
|
184
|
+
SDLK_KP_A = 1073742012
|
185
|
+
SDLK_KP_B = 1073742013
|
186
|
+
SDLK_KP_C = 1073742014
|
187
|
+
SDLK_KP_D = 1073742015
|
188
|
+
SDLK_KP_E = 1073742016
|
189
|
+
SDLK_KP_F = 1073742017
|
190
|
+
SDLK_KP_XOR = 1073742018
|
191
|
+
SDLK_KP_POWER = 1073742019
|
192
|
+
SDLK_KP_PERCENT = 1073742020
|
193
|
+
SDLK_KP_LESS = 1073742021
|
194
|
+
SDLK_KP_GREATER = 1073742022
|
195
|
+
SDLK_KP_AMPERSAND = 1073742023
|
196
|
+
SDLK_KP_DBLAMPERSAND = 1073742024
|
197
|
+
SDLK_KP_VERTICALBAR = 1073742025
|
198
|
+
SDLK_KP_DBLVERTICALBAR = 1073742026
|
199
|
+
SDLK_KP_COLON = 1073742027
|
200
|
+
SDLK_KP_HASH = 1073742028
|
201
|
+
SDLK_KP_SPACE = 1073742029
|
202
|
+
SDLK_KP_AT = 1073742030
|
203
|
+
SDLK_KP_EXCLAM = 1073742031
|
204
|
+
SDLK_KP_MEMSTORE = 1073742032
|
205
|
+
SDLK_KP_MEMRECALL = 1073742033
|
206
|
+
SDLK_KP_MEMCLEAR = 1073742034
|
207
|
+
SDLK_KP_MEMADD = 1073742035
|
208
|
+
SDLK_KP_MEMSUBTRACT = 1073742036
|
209
|
+
SDLK_KP_MEMMULTIPLY = 1073742037
|
210
|
+
SDLK_KP_MEMDIVIDE = 1073742038
|
211
|
+
SDLK_KP_PLUSMINUS = 1073742039
|
212
|
+
SDLK_KP_CLEAR = 1073742040
|
213
|
+
SDLK_KP_CLEARENTRY = 1073742041
|
214
|
+
SDLK_KP_BINARY = 1073742042
|
215
|
+
SDLK_KP_OCTAL = 1073742043
|
216
|
+
SDLK_KP_DECIMAL = 1073742044
|
217
|
+
SDLK_KP_HEXADECIMAL = 1073742045
|
218
|
+
SDLK_LCTRL = 1073742048
|
219
|
+
SDLK_LSHIFT = 1073742049
|
220
|
+
SDLK_LALT = 1073742050
|
221
|
+
SDLK_LGUI = 1073742051
|
222
|
+
SDLK_RCTRL = 1073742052
|
223
|
+
SDLK_RSHIFT = 1073742053
|
224
|
+
SDLK_RALT = 1073742054
|
225
|
+
SDLK_RGUI = 1073742055
|
226
|
+
SDLK_MODE = 1073742081
|
227
|
+
SDLK_AUDIONEXT = 1073742082
|
228
|
+
SDLK_AUDIOPREV = 1073742083
|
229
|
+
SDLK_AUDIOSTOP = 1073742084
|
230
|
+
SDLK_AUDIOPLAY = 1073742085
|
231
|
+
SDLK_AUDIOMUTE = 1073742086
|
232
|
+
SDLK_MEDIASELECT = 1073742087
|
233
|
+
SDLK_WWW = 1073742088
|
234
|
+
SDLK_MAIL = 1073742089
|
235
|
+
SDLK_CALCULATOR = 1073742090
|
236
|
+
SDLK_COMPUTER = 1073742091
|
237
|
+
SDLK_AC_SEARCH = 1073742092
|
238
|
+
SDLK_AC_HOME = 1073742093
|
239
|
+
SDLK_AC_BACK = 1073742094
|
240
|
+
SDLK_AC_FORWARD = 1073742095
|
241
|
+
SDLK_AC_STOP = 1073742096
|
242
|
+
SDLK_AC_REFRESH = 1073742097
|
243
|
+
SDLK_AC_BOOKMARKS = 1073742098
|
244
|
+
SDLK_BRIGHTNESSDOWN = 1073742099
|
245
|
+
SDLK_BRIGHTNESSUP = 1073742100
|
246
|
+
SDLK_DISPLAYSWITCH = 1073742101
|
247
|
+
SDLK_KBDILLUMTOGGLE = 1073742102
|
248
|
+
SDLK_KBDILLUMDOWN = 1073742103
|
249
|
+
SDLK_KBDILLUMUP = 1073742104
|
250
|
+
SDLK_EJECT = 1073742105
|
251
|
+
SDLK_SLEEP = 1073742106
|
252
|
+
SDLK_APP1 = 1073742107
|
253
|
+
SDLK_APP2 = 1073742108
|
254
|
+
SDLK_AUDIOREWIND = 1073742109
|
255
|
+
SDLK_AUDIOFASTFORWARD = 1073742110
|
256
|
+
KMOD_NONE = 0
|
257
|
+
KMOD_LSHIFT = 1
|
258
|
+
KMOD_RSHIFT = 2
|
259
|
+
KMOD_LCTRL = 64
|
260
|
+
KMOD_RCTRL = 128
|
261
|
+
KMOD_LALT = 256
|
262
|
+
KMOD_RALT = 512
|
263
|
+
KMOD_LGUI = 1024
|
264
|
+
KMOD_RGUI = 2048
|
265
|
+
KMOD_NUM = 4096
|
266
|
+
KMOD_CAPS = 8192
|
267
|
+
KMOD_MODE = 16384
|
268
|
+
KMOD_RESERVED = 32768
|
269
|
+
|
270
|
+
# Typedef
|
271
|
+
|
272
|
+
typedef :int, :SDL_Keycode
|
273
|
+
typedef :int, :SDL_Keymod
|
274
|
+
|
275
|
+
# Struct
|
276
|
+
|
277
|
+
|
278
|
+
# Function
|
279
|
+
|
280
|
+
def self.setup_keycode_symbols()
|
281
|
+
symbols = [
|
282
|
+
]
|
283
|
+
args = {
|
284
|
+
}
|
285
|
+
retvals = {
|
286
|
+
}
|
287
|
+
symbols.each do |sym|
|
288
|
+
begin
|
289
|
+
attach_function sym, args[sym], retvals[sym]
|
290
|
+
rescue FFI::NotFoundError => error
|
291
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
|