sdl3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/LICENSE +21 -0
  4. data/README.md +188 -0
  5. data/Rakefile +12 -0
  6. data/examples/01_hello_window.rb +24 -0
  7. data/examples/02_basic_rendering.rb +45 -0
  8. data/examples/03_keyboard_input.rb +52 -0
  9. data/examples/04_mouse_input.rb +56 -0
  10. data/examples/05_simple_game.rb +107 -0
  11. data/lib/sdl3/high_level/audio_device.rb +202 -0
  12. data/lib/sdl3/high_level/camera.rb +118 -0
  13. data/lib/sdl3/high_level/clipboard.rb +59 -0
  14. data/lib/sdl3/high_level/event.rb +240 -0
  15. data/lib/sdl3/high_level/gamepad.rb +190 -0
  16. data/lib/sdl3/high_level/gpu.rb +194 -0
  17. data/lib/sdl3/high_level/haptic.rb +213 -0
  18. data/lib/sdl3/high_level/joystick.rb +165 -0
  19. data/lib/sdl3/high_level/renderer.rb +163 -0
  20. data/lib/sdl3/high_level/sensor.rb +105 -0
  21. data/lib/sdl3/high_level/surface.rb +143 -0
  22. data/lib/sdl3/high_level/texture.rb +111 -0
  23. data/lib/sdl3/high_level/timer.rb +88 -0
  24. data/lib/sdl3/high_level/window.rb +151 -0
  25. data/lib/sdl3/library_loader.rb +63 -0
  26. data/lib/sdl3/raw/assert.rb +32 -0
  27. data/lib/sdl3/raw/asyncio.rb +36 -0
  28. data/lib/sdl3/raw/atomic.rb +40 -0
  29. data/lib/sdl3/raw/audio.rb +95 -0
  30. data/lib/sdl3/raw/base.rb +12 -0
  31. data/lib/sdl3/raw/bits.rb +17 -0
  32. data/lib/sdl3/raw/blendmode.rb +36 -0
  33. data/lib/sdl3/raw/camera.rb +38 -0
  34. data/lib/sdl3/raw/clipboard.rb +20 -0
  35. data/lib/sdl3/raw/cpuinfo.rb +29 -0
  36. data/lib/sdl3/raw/dialog.rb +33 -0
  37. data/lib/sdl3/raw/endian.rb +8 -0
  38. data/lib/sdl3/raw/error.rb +15 -0
  39. data/lib/sdl3/raw/events.rb +563 -0
  40. data/lib/sdl3/raw/filesystem.rb +47 -0
  41. data/lib/sdl3/raw/gamepad.rb +135 -0
  42. data/lib/sdl3/raw/gpu.rb +734 -0
  43. data/lib/sdl3/raw/guid.rb +12 -0
  44. data/lib/sdl3/raw/haptic.rb +167 -0
  45. data/lib/sdl3/raw/hidapi.rb +57 -0
  46. data/lib/sdl3/raw/hints.rb +20 -0
  47. data/lib/sdl3/raw/init.rb +27 -0
  48. data/lib/sdl3/raw/iostream.rb +88 -0
  49. data/lib/sdl3/raw/joystick.rb +101 -0
  50. data/lib/sdl3/raw/keyboard.rb +30 -0
  51. data/lib/sdl3/raw/keycode.rb +132 -0
  52. data/lib/sdl3/raw/loadso.rb +9 -0
  53. data/lib/sdl3/raw/locale.rb +12 -0
  54. data/lib/sdl3/raw/log.rb +61 -0
  55. data/lib/sdl3/raw/main.rb +23 -0
  56. data/lib/sdl3/raw/messagebox.rb +50 -0
  57. data/lib/sdl3/raw/metal.rb +9 -0
  58. data/lib/sdl3/raw/misc.rb +7 -0
  59. data/lib/sdl3/raw/mouse.rb +82 -0
  60. data/lib/sdl3/raw/mutex.rb +48 -0
  61. data/lib/sdl3/raw/openxr.rb +21 -0
  62. data/lib/sdl3/raw/pen.rb +38 -0
  63. data/lib/sdl3/raw/pixels.rb +180 -0
  64. data/lib/sdl3/raw/platform.rb +7 -0
  65. data/lib/sdl3/raw/power.rb +14 -0
  66. data/lib/sdl3/raw/process.rb +15 -0
  67. data/lib/sdl3/raw/properties.rb +39 -0
  68. data/lib/sdl3/raw/rect.rb +41 -0
  69. data/lib/sdl3/raw/render.rb +153 -0
  70. data/lib/sdl3/raw/scancode.rb +112 -0
  71. data/lib/sdl3/raw/sensor.rb +31 -0
  72. data/lib/sdl3/raw/stdinc.rb +209 -0
  73. data/lib/sdl3/raw/storage.rb +50 -0
  74. data/lib/sdl3/raw/surface.rb +106 -0
  75. data/lib/sdl3/raw/system.rb +77 -0
  76. data/lib/sdl3/raw/thread.rb +40 -0
  77. data/lib/sdl3/raw/time.rb +36 -0
  78. data/lib/sdl3/raw/timer.rb +19 -0
  79. data/lib/sdl3/raw/touch.rb +22 -0
  80. data/lib/sdl3/raw/tray.rb +42 -0
  81. data/lib/sdl3/raw/types.rb +21 -0
  82. data/lib/sdl3/raw/version.rb +8 -0
  83. data/lib/sdl3/raw/video.rb +208 -0
  84. data/lib/sdl3/raw/vulkan.rb +13 -0
  85. data/lib/sdl3/version.rb +5 -0
  86. data/lib/sdl3.rb +128 -0
  87. data/sdl3.gemspec +30 -0
  88. metadata +143 -0
@@ -0,0 +1,190 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ class Gamepad
5
+ attr_reader :ptr
6
+
7
+ def initialize(instance_id)
8
+ @ptr = Raw.SDL_OpenGamepad(instance_id)
9
+ raise Error, Raw.SDL_GetError if @ptr.null?
10
+
11
+ ObjectSpace.define_finalizer(self, self.class.releasing(@ptr))
12
+ end
13
+
14
+ def self.releasing(ptr)
15
+ prevented_ptr = ptr
16
+ proc { Raw.SDL_CloseGamepad(prevented_ptr) unless prevented_ptr.null? }
17
+ end
18
+
19
+ def self.open(instance_id)
20
+ gamepad = new(instance_id)
21
+ return gamepad unless block_given?
22
+
23
+ begin
24
+ yield gamepad
25
+ ensure
26
+ gamepad.close
27
+ end
28
+ end
29
+
30
+ def self.available?
31
+ Raw.SDL_HasGamepad
32
+ end
33
+
34
+ def self.list
35
+ count_ptr = FFI::MemoryPointer.new(:int)
36
+ gamepads_ptr = Raw.SDL_GetGamepads(count_ptr)
37
+ return [] if gamepads_ptr.null?
38
+
39
+ count = count_ptr.read_int
40
+ gamepads_ptr.read_array_of_uint32(count)
41
+ end
42
+
43
+ def self.name_for_id(instance_id)
44
+ Raw.SDL_GetGamepadNameForID(instance_id)
45
+ end
46
+
47
+ def self.type_for_id(instance_id)
48
+ Raw.SDL_GetGamepadTypeForID(instance_id)
49
+ end
50
+
51
+ def self.is_gamepad?(joystick_id)
52
+ Raw.SDL_IsGamepad(joystick_id)
53
+ end
54
+
55
+ def self.add_mapping(mapping)
56
+ Raw.SDL_AddGamepadMapping(mapping)
57
+ end
58
+
59
+ def self.add_mappings_from_file(file)
60
+ Raw.SDL_AddGamepadMappingsFromFile(file)
61
+ end
62
+
63
+ def close
64
+ return if @ptr.null?
65
+
66
+ ObjectSpace.undefine_finalizer(self)
67
+ Raw.SDL_CloseGamepad(@ptr)
68
+ @ptr = FFI::Pointer::NULL
69
+ end
70
+
71
+ def id
72
+ Raw.SDL_GetGamepadID(@ptr)
73
+ end
74
+
75
+ def name
76
+ Raw.SDL_GetGamepadName(@ptr)
77
+ end
78
+
79
+ def path
80
+ Raw.SDL_GetGamepadPath(@ptr)
81
+ end
82
+
83
+ def type
84
+ Raw.SDL_GetGamepadType(@ptr)
85
+ end
86
+
87
+ def real_type
88
+ Raw.SDL_GetRealGamepadType(@ptr)
89
+ end
90
+
91
+ def vendor
92
+ Raw.SDL_GetGamepadVendor(@ptr)
93
+ end
94
+
95
+ def product
96
+ Raw.SDL_GetGamepadProduct(@ptr)
97
+ end
98
+
99
+ def product_version
100
+ Raw.SDL_GetGamepadProductVersion(@ptr)
101
+ end
102
+
103
+ def firmware_version
104
+ Raw.SDL_GetGamepadFirmwareVersion(@ptr)
105
+ end
106
+
107
+ def serial
108
+ Raw.SDL_GetGamepadSerial(@ptr)
109
+ end
110
+
111
+ def connected?
112
+ Raw.SDL_GamepadConnected(@ptr)
113
+ end
114
+
115
+ def joystick
116
+ ptr = Raw.SDL_GetGamepadJoystick(@ptr)
117
+ return nil if ptr.null?
118
+
119
+ ptr
120
+ end
121
+
122
+ def axis(axis_id)
123
+ Raw.SDL_GetGamepadAxis(@ptr, axis_id)
124
+ end
125
+
126
+ def button(button_id)
127
+ Raw.SDL_GetGamepadButton(@ptr, button_id)
128
+ end
129
+
130
+ def button?(button_id)
131
+ Raw.SDL_GetGamepadButton(@ptr, button_id)
132
+ end
133
+
134
+ def has_axis?(axis_id)
135
+ Raw.SDL_GamepadHasAxis(@ptr, axis_id)
136
+ end
137
+
138
+ def has_button?(button_id)
139
+ Raw.SDL_GamepadHasButton(@ptr, button_id)
140
+ end
141
+
142
+ def rumble(low_frequency, high_frequency, duration_ms)
143
+ Raw.SDL_RumbleGamepad(@ptr, low_frequency, high_frequency, duration_ms)
144
+ end
145
+
146
+ def rumble_triggers(left, right, duration_ms)
147
+ Raw.SDL_RumbleGamepadTriggers(@ptr, left, right, duration_ms)
148
+ end
149
+
150
+ def set_led(red, green, blue)
151
+ Raw.SDL_SetGamepadLED(@ptr, red, green, blue)
152
+ end
153
+
154
+ def player_index
155
+ Raw.SDL_GetGamepadPlayerIndex(@ptr)
156
+ end
157
+
158
+ def player_index=(index)
159
+ Raw.SDL_SetGamepadPlayerIndex(@ptr, index)
160
+ end
161
+
162
+ def connection_state
163
+ Raw.SDL_GetGamepadConnectionState(@ptr)
164
+ end
165
+
166
+ def num_touchpads
167
+ Raw.SDL_GetNumGamepadTouchpads(@ptr)
168
+ end
169
+
170
+ def has_sensor?(sensor_type)
171
+ Raw.SDL_GamepadHasSensor(@ptr, sensor_type)
172
+ end
173
+
174
+ def set_sensor_enabled(sensor_type, enabled)
175
+ Raw.SDL_SetGamepadSensorEnabled(@ptr, sensor_type, enabled)
176
+ end
177
+
178
+ def sensor_enabled?(sensor_type)
179
+ Raw.SDL_GamepadSensorEnabled(@ptr, sensor_type)
180
+ end
181
+
182
+ def mapping
183
+ Raw.SDL_GetGamepadMapping(@ptr)
184
+ end
185
+
186
+ def to_ptr
187
+ @ptr
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,194 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ class GPUDevice
5
+ attr_reader :ptr
6
+
7
+ def initialize(shader_formats, debug_mode = false, name = nil)
8
+ @ptr = Raw.SDL_CreateGPUDevice(shader_formats, debug_mode, name)
9
+ raise Error, Raw.SDL_GetError if @ptr.null?
10
+
11
+ ObjectSpace.define_finalizer(self, self.class.releasing(@ptr))
12
+ end
13
+
14
+ def self.releasing(ptr)
15
+ prevented_ptr = ptr
16
+ proc { Raw.SDL_DestroyGPUDevice(prevented_ptr) unless prevented_ptr.null? }
17
+ end
18
+
19
+ def self.create(shader_formats, debug_mode: false, name: nil)
20
+ device = new(shader_formats, debug_mode, name)
21
+ return device unless block_given?
22
+
23
+ begin
24
+ yield device
25
+ ensure
26
+ device.destroy
27
+ end
28
+ end
29
+
30
+ def self.create_with_properties(properties_id)
31
+ ptr = Raw.SDL_CreateGPUDeviceWithProperties(properties_id)
32
+ raise Error, Raw.SDL_GetError if ptr.null?
33
+
34
+ device = allocate
35
+ device.instance_variable_set(:@ptr, ptr)
36
+ ObjectSpace.define_finalizer(device, releasing(ptr))
37
+ device
38
+ end
39
+
40
+ def self.num_drivers
41
+ Raw.SDL_GetNumGPUDrivers
42
+ end
43
+
44
+ def self.driver(index)
45
+ Raw.SDL_GetGPUDriver(index)
46
+ end
47
+
48
+ def self.supports_shader_formats?(formats, name = nil)
49
+ Raw.SDL_GPUSupportsShaderFormats(formats, name)
50
+ end
51
+
52
+ def self.supports_properties?(properties_id)
53
+ Raw.SDL_GPUSupportsProperties(properties_id)
54
+ end
55
+
56
+ def destroy
57
+ return if @ptr.null?
58
+
59
+ ObjectSpace.undefine_finalizer(self)
60
+ Raw.SDL_DestroyGPUDevice(@ptr)
61
+ @ptr = FFI::Pointer::NULL
62
+ end
63
+
64
+ def driver
65
+ Raw.SDL_GetGPUDeviceDriver(@ptr)
66
+ end
67
+
68
+ def shader_formats
69
+ Raw.SDL_GetGPUShaderFormats(@ptr)
70
+ end
71
+
72
+ def create_compute_pipeline(create_info)
73
+ Raw.SDL_CreateGPUComputePipeline(@ptr, create_info)
74
+ end
75
+
76
+ def create_graphics_pipeline(create_info)
77
+ Raw.SDL_CreateGPUGraphicsPipeline(@ptr, create_info)
78
+ end
79
+
80
+ def create_sampler(create_info)
81
+ Raw.SDL_CreateGPUSampler(@ptr, create_info)
82
+ end
83
+
84
+ def create_shader(create_info)
85
+ Raw.SDL_CreateGPUShader(@ptr, create_info)
86
+ end
87
+
88
+ def create_texture(create_info)
89
+ Raw.SDL_CreateGPUTexture(@ptr, create_info)
90
+ end
91
+
92
+ def create_buffer(create_info)
93
+ Raw.SDL_CreateGPUBuffer(@ptr, create_info)
94
+ end
95
+
96
+ def create_transfer_buffer(create_info)
97
+ Raw.SDL_CreateGPUTransferBuffer(@ptr, create_info)
98
+ end
99
+
100
+ def release_texture(texture)
101
+ Raw.SDL_ReleaseGPUTexture(@ptr, texture)
102
+ end
103
+
104
+ def release_sampler(sampler)
105
+ Raw.SDL_ReleaseGPUSampler(@ptr, sampler)
106
+ end
107
+
108
+ def release_buffer(buffer)
109
+ Raw.SDL_ReleaseGPUBuffer(@ptr, buffer)
110
+ end
111
+
112
+ def release_transfer_buffer(transfer_buffer)
113
+ Raw.SDL_ReleaseGPUTransferBuffer(@ptr, transfer_buffer)
114
+ end
115
+
116
+ def release_compute_pipeline(pipeline)
117
+ Raw.SDL_ReleaseGPUComputePipeline(@ptr, pipeline)
118
+ end
119
+
120
+ def release_shader(shader)
121
+ Raw.SDL_ReleaseGPUShader(@ptr, shader)
122
+ end
123
+
124
+ def release_graphics_pipeline(pipeline)
125
+ Raw.SDL_ReleaseGPUGraphicsPipeline(@ptr, pipeline)
126
+ end
127
+
128
+ def acquire_command_buffer
129
+ Raw.SDL_AcquireGPUCommandBuffer(@ptr)
130
+ end
131
+
132
+ def claim_window(window)
133
+ Raw.SDL_ClaimWindowForGPUDevice(@ptr, window.to_ptr)
134
+ end
135
+
136
+ def release_window(window)
137
+ Raw.SDL_ReleaseWindowFromGPUDevice(@ptr, window.to_ptr)
138
+ end
139
+
140
+ def set_swapchain_parameters(window, composition, present_mode)
141
+ Raw.SDL_SetGPUSwapchainParameters(@ptr, window.to_ptr, composition, present_mode)
142
+ end
143
+
144
+ def set_allowed_frames_in_flight(count)
145
+ Raw.SDL_SetGPUAllowedFramesInFlight(@ptr, count)
146
+ end
147
+
148
+ def swapchain_texture_format(window)
149
+ Raw.SDL_GetGPUSwapchainTextureFormat(@ptr, window.to_ptr)
150
+ end
151
+
152
+ def wait_for_idle
153
+ Raw.SDL_WaitForGPUIdle(@ptr)
154
+ end
155
+
156
+ def wait_for_fences(wait_all, fences)
157
+ fences_ptr = FFI::MemoryPointer.new(:pointer, fences.size)
158
+ fences.each_with_index { |f, i| fences_ptr.put_pointer(i * FFI::Pointer.size, f) }
159
+ Raw.SDL_WaitForGPUFences(@ptr, wait_all, fences_ptr, fences.size)
160
+ end
161
+
162
+ def query_fence(fence)
163
+ Raw.SDL_QueryGPUFence(@ptr, fence)
164
+ end
165
+
166
+ def release_fence(fence)
167
+ Raw.SDL_ReleaseGPUFence(@ptr, fence)
168
+ end
169
+
170
+ def texture_supports_format?(format, type, usage)
171
+ Raw.SDL_GPUTextureSupportsFormat(@ptr, format, type, usage)
172
+ end
173
+
174
+ def texture_supports_sample_count?(format, sample_count)
175
+ Raw.SDL_GPUTextureSupportsSampleCount(@ptr, format, sample_count)
176
+ end
177
+
178
+ def to_ptr
179
+ @ptr
180
+ end
181
+ end
182
+
183
+ module GPU
184
+ class << self
185
+ def texture_format_texel_block_size(format)
186
+ Raw.SDL_GPUTextureFormatTexelBlockSize(format)
187
+ end
188
+
189
+ def calculate_texture_format_size(format, width, height, depth)
190
+ Raw.SDL_CalculateGPUTextureFormatSize(format, width, height, depth)
191
+ end
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,213 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ class Haptic
5
+ attr_reader :ptr
6
+
7
+ CONSTANT = Raw::SDL_HAPTIC_CONSTANT
8
+ SINE = Raw::SDL_HAPTIC_SINE
9
+ SQUARE = Raw::SDL_HAPTIC_SQUARE
10
+ TRIANGLE = Raw::SDL_HAPTIC_TRIANGLE
11
+ SAWTOOTHUP = Raw::SDL_HAPTIC_SAWTOOTHUP
12
+ SAWTOOTHDOWN = Raw::SDL_HAPTIC_SAWTOOTHDOWN
13
+ RAMP = Raw::SDL_HAPTIC_RAMP
14
+ SPRING = Raw::SDL_HAPTIC_SPRING
15
+ DAMPER = Raw::SDL_HAPTIC_DAMPER
16
+ INERTIA = Raw::SDL_HAPTIC_INERTIA
17
+ FRICTION = Raw::SDL_HAPTIC_FRICTION
18
+ LEFTRIGHT = Raw::SDL_HAPTIC_LEFTRIGHT
19
+ CUSTOM = Raw::SDL_HAPTIC_CUSTOM
20
+ GAIN = Raw::SDL_HAPTIC_GAIN
21
+ AUTOCENTER = Raw::SDL_HAPTIC_AUTOCENTER
22
+ STATUS = Raw::SDL_HAPTIC_STATUS
23
+ PAUSE = Raw::SDL_HAPTIC_PAUSE
24
+
25
+ POLAR = Raw::SDL_HAPTIC_POLAR
26
+ CARTESIAN = Raw::SDL_HAPTIC_CARTESIAN
27
+ SPHERICAL = Raw::SDL_HAPTIC_SPHERICAL
28
+ STEERING_AXIS = Raw::SDL_HAPTIC_STEERING_AXIS
29
+
30
+ INFINITY = Raw::SDL_HAPTIC_INFINITY
31
+
32
+ def initialize(haptic_id)
33
+ @ptr = Raw.SDL_OpenHaptic(haptic_id)
34
+ raise Error, Raw.SDL_GetError if @ptr.null?
35
+
36
+ ObjectSpace.define_finalizer(self, self.class.releasing(@ptr))
37
+ end
38
+
39
+ def self.releasing(ptr)
40
+ prevented_ptr = ptr
41
+ proc { Raw.SDL_CloseHaptic(prevented_ptr) unless prevented_ptr.null? }
42
+ end
43
+
44
+ def self.open(haptic_id)
45
+ haptic = new(haptic_id)
46
+ return haptic unless block_given?
47
+
48
+ begin
49
+ yield haptic
50
+ ensure
51
+ haptic.close
52
+ end
53
+ end
54
+
55
+ def self.open_from_mouse
56
+ ptr = Raw.SDL_OpenHapticFromMouse
57
+ raise Error, Raw.SDL_GetError if ptr.null?
58
+
59
+ haptic = allocate
60
+ haptic.instance_variable_set(:@ptr, ptr)
61
+ ObjectSpace.define_finalizer(haptic, releasing(ptr))
62
+
63
+ return haptic unless block_given?
64
+
65
+ begin
66
+ yield haptic
67
+ ensure
68
+ haptic.close
69
+ end
70
+ end
71
+
72
+ def self.open_from_joystick(joystick)
73
+ ptr = Raw.SDL_OpenHapticFromJoystick(joystick.to_ptr)
74
+ raise Error, Raw.SDL_GetError if ptr.null?
75
+
76
+ haptic = allocate
77
+ haptic.instance_variable_set(:@ptr, ptr)
78
+ ObjectSpace.define_finalizer(haptic, releasing(ptr))
79
+
80
+ return haptic unless block_given?
81
+
82
+ begin
83
+ yield haptic
84
+ ensure
85
+ haptic.close
86
+ end
87
+ end
88
+
89
+ def self.list
90
+ count_ptr = FFI::MemoryPointer.new(:int)
91
+ haptics_ptr = Raw.SDL_GetHaptics(count_ptr)
92
+ return [] if haptics_ptr.null?
93
+
94
+ count = count_ptr.read_int
95
+ haptics_ptr.read_array_of_uint32(count)
96
+ end
97
+
98
+ def self.name_for_id(haptic_id)
99
+ Raw.SDL_GetHapticNameForID(haptic_id)
100
+ end
101
+
102
+ def self.mouse_haptic?
103
+ Raw.SDL_IsMouseHaptic
104
+ end
105
+
106
+ def self.joystick_haptic?(joystick)
107
+ Raw.SDL_IsJoystickHaptic(joystick.to_ptr)
108
+ end
109
+
110
+ def close
111
+ return if @ptr.null?
112
+
113
+ ObjectSpace.undefine_finalizer(self)
114
+ Raw.SDL_CloseHaptic(@ptr)
115
+ @ptr = FFI::Pointer::NULL
116
+ end
117
+
118
+ def id
119
+ Raw.SDL_GetHapticID(@ptr)
120
+ end
121
+
122
+ def name
123
+ Raw.SDL_GetHapticName(@ptr)
124
+ end
125
+
126
+ def max_effects
127
+ Raw.SDL_GetMaxHapticEffects(@ptr)
128
+ end
129
+
130
+ def max_effects_playing
131
+ Raw.SDL_GetMaxHapticEffectsPlaying(@ptr)
132
+ end
133
+
134
+ def features
135
+ Raw.SDL_GetHapticFeatures(@ptr)
136
+ end
137
+
138
+ def num_axes
139
+ Raw.SDL_GetNumHapticAxes(@ptr)
140
+ end
141
+
142
+ def effect_supported?(effect)
143
+ Raw.SDL_HapticEffectSupported(@ptr, effect)
144
+ end
145
+
146
+ def create_effect(effect)
147
+ result = Raw.SDL_CreateHapticEffect(@ptr, effect)
148
+ raise Error, Raw.SDL_GetError if result < 0
149
+
150
+ result
151
+ end
152
+
153
+ def update_effect(effect_id, effect)
154
+ Raw.SDL_UpdateHapticEffect(@ptr, effect_id, effect)
155
+ end
156
+
157
+ def run_effect(effect_id, iterations = 1)
158
+ Raw.SDL_RunHapticEffect(@ptr, effect_id, iterations)
159
+ end
160
+
161
+ def stop_effect(effect_id)
162
+ Raw.SDL_StopHapticEffect(@ptr, effect_id)
163
+ end
164
+
165
+ def destroy_effect(effect_id)
166
+ Raw.SDL_DestroyHapticEffect(@ptr, effect_id)
167
+ end
168
+
169
+ def effect_status(effect_id)
170
+ Raw.SDL_GetHapticEffectStatus(@ptr, effect_id)
171
+ end
172
+
173
+ def gain=(value)
174
+ Raw.SDL_SetHapticGain(@ptr, value)
175
+ end
176
+
177
+ def autocenter=(value)
178
+ Raw.SDL_SetHapticAutocenter(@ptr, value)
179
+ end
180
+
181
+ def pause
182
+ Raw.SDL_PauseHaptic(@ptr)
183
+ end
184
+
185
+ def resume
186
+ Raw.SDL_ResumeHaptic(@ptr)
187
+ end
188
+
189
+ def stop_all
190
+ Raw.SDL_StopHapticEffects(@ptr)
191
+ end
192
+
193
+ def rumble_supported?
194
+ Raw.SDL_HapticRumbleSupported(@ptr)
195
+ end
196
+
197
+ def init_rumble
198
+ Raw.SDL_InitHapticRumble(@ptr)
199
+ end
200
+
201
+ def play_rumble(strength, duration_ms)
202
+ Raw.SDL_PlayHapticRumble(@ptr, strength, duration_ms)
203
+ end
204
+
205
+ def stop_rumble
206
+ Raw.SDL_StopHapticRumble(@ptr)
207
+ end
208
+
209
+ def to_ptr
210
+ @ptr
211
+ end
212
+ end
213
+ end