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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ class SDL_GUID < FFI::Struct
6
+ layout :data, [:uint8, 16]
7
+ end
8
+
9
+ attach_function :SDL_GUIDToString, [SDL_GUID, :pointer, :int], :void
10
+ attach_function :SDL_StringToGUID, [:string], SDL_GUID.by_value
11
+ end
12
+ end
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ typedef :uint32, :SDL_HapticID
6
+
7
+ SDL_HAPTIC_CONSTANT = 1 << 0
8
+ SDL_HAPTIC_SINE = 1 << 1
9
+ SDL_HAPTIC_SQUARE = 1 << 2
10
+ SDL_HAPTIC_TRIANGLE = 1 << 3
11
+ SDL_HAPTIC_SAWTOOTHUP = 1 << 4
12
+ SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5
13
+ SDL_HAPTIC_RAMP = 1 << 6
14
+ SDL_HAPTIC_SPRING = 1 << 7
15
+ SDL_HAPTIC_DAMPER = 1 << 8
16
+ SDL_HAPTIC_INERTIA = 1 << 9
17
+ SDL_HAPTIC_FRICTION = 1 << 10
18
+ SDL_HAPTIC_LEFTRIGHT = 1 << 11
19
+ SDL_HAPTIC_RESERVED1 = 1 << 12
20
+ SDL_HAPTIC_RESERVED2 = 1 << 13
21
+ SDL_HAPTIC_RESERVED3 = 1 << 14
22
+ SDL_HAPTIC_CUSTOM = 1 << 15
23
+ SDL_HAPTIC_GAIN = 1 << 16
24
+ SDL_HAPTIC_AUTOCENTER = 1 << 17
25
+ SDL_HAPTIC_STATUS = 1 << 18
26
+ SDL_HAPTIC_PAUSE = 1 << 19
27
+
28
+ SDL_HAPTIC_POLAR = 0
29
+ SDL_HAPTIC_CARTESIAN = 1
30
+ SDL_HAPTIC_SPHERICAL = 2
31
+ SDL_HAPTIC_STEERING_AXIS = 3
32
+
33
+ SDL_HAPTIC_INFINITY = 4294967295
34
+
35
+ class SDL_HapticDirection < FFI::Struct
36
+ layout :type, :uint8,
37
+ :dir, [:int32, 3]
38
+ end
39
+
40
+ class SDL_HapticConstant < FFI::Struct
41
+ layout :type, :uint16,
42
+ :direction, SDL_HapticDirection,
43
+ :length, :uint32,
44
+ :delay, :uint16,
45
+ :button, :uint16,
46
+ :interval, :uint16,
47
+ :level, :int16,
48
+ :attack_length, :uint16,
49
+ :attack_level, :uint16,
50
+ :fade_length, :uint16,
51
+ :fade_level, :uint16
52
+ end
53
+
54
+ class SDL_HapticPeriodic < FFI::Struct
55
+ layout :type, :uint16,
56
+ :direction, SDL_HapticDirection,
57
+ :length, :uint32,
58
+ :delay, :uint16,
59
+ :button, :uint16,
60
+ :interval, :uint16,
61
+ :period, :uint16,
62
+ :magnitude, :int16,
63
+ :offset, :int16,
64
+ :phase, :uint16,
65
+ :attack_length, :uint16,
66
+ :attack_level, :uint16,
67
+ :fade_length, :uint16,
68
+ :fade_level, :uint16
69
+ end
70
+
71
+ class SDL_HapticCondition < FFI::Struct
72
+ layout :type, :uint16,
73
+ :direction, SDL_HapticDirection,
74
+ :length, :uint32,
75
+ :delay, :uint16,
76
+ :button, :uint16,
77
+ :interval, :uint16,
78
+ :right_sat, [:uint16, 3],
79
+ :left_sat, [:uint16, 3],
80
+ :right_coeff, [:int16, 3],
81
+ :left_coeff, [:int16, 3],
82
+ :deadband, [:uint16, 3],
83
+ :center, [:int16, 3]
84
+ end
85
+
86
+ class SDL_HapticRamp < FFI::Struct
87
+ layout :type, :uint16,
88
+ :direction, SDL_HapticDirection,
89
+ :length, :uint32,
90
+ :delay, :uint16,
91
+ :button, :uint16,
92
+ :interval, :uint16,
93
+ :start, :int16,
94
+ :end, :int16,
95
+ :attack_length, :uint16,
96
+ :attack_level, :uint16,
97
+ :fade_length, :uint16,
98
+ :fade_level, :uint16
99
+ end
100
+
101
+ class SDL_HapticLeftRight < FFI::Struct
102
+ layout :type, :uint16,
103
+ :length, :uint32,
104
+ :large_magnitude, :uint16,
105
+ :small_magnitude, :uint16
106
+ end
107
+
108
+ class SDL_HapticCustom < FFI::Struct
109
+ layout :type, :uint16,
110
+ :direction, SDL_HapticDirection,
111
+ :length, :uint32,
112
+ :delay, :uint16,
113
+ :button, :uint16,
114
+ :interval, :uint16,
115
+ :channels, :uint8,
116
+ :period, :uint16,
117
+ :samples, :uint16,
118
+ :data, :pointer,
119
+ :attack_length, :uint16,
120
+ :attack_level, :uint16,
121
+ :fade_length, :uint16,
122
+ :fade_level, :uint16
123
+ end
124
+
125
+ class SDL_HapticEffect < FFI::Union
126
+ layout :type, :uint16,
127
+ :constant, SDL_HapticConstant,
128
+ :periodic, SDL_HapticPeriodic,
129
+ :condition, SDL_HapticCondition,
130
+ :ramp, SDL_HapticRamp,
131
+ :leftright, SDL_HapticLeftRight,
132
+ :custom, SDL_HapticCustom
133
+ end
134
+
135
+ attach_function :SDL_GetHaptics, [:pointer], :pointer
136
+ attach_function :SDL_GetHapticNameForID, [:SDL_HapticID], :string
137
+ attach_function :SDL_OpenHaptic, [:SDL_HapticID], :pointer
138
+ attach_function :SDL_GetHapticFromID, [:SDL_HapticID], :pointer
139
+ attach_function :SDL_GetHapticID, [:pointer], :SDL_HapticID
140
+ attach_function :SDL_GetHapticName, [:pointer], :string
141
+ attach_function :SDL_IsMouseHaptic, [], :bool
142
+ attach_function :SDL_OpenHapticFromMouse, [], :pointer
143
+ attach_function :SDL_IsJoystickHaptic, [:pointer], :bool
144
+ attach_function :SDL_OpenHapticFromJoystick, [:pointer], :pointer
145
+ attach_function :SDL_CloseHaptic, [:pointer], :void
146
+ attach_function :SDL_GetMaxHapticEffects, [:pointer], :int
147
+ attach_function :SDL_GetMaxHapticEffectsPlaying, [:pointer], :int
148
+ attach_function :SDL_GetHapticFeatures, [:pointer], :uint32
149
+ attach_function :SDL_GetNumHapticAxes, [:pointer], :int
150
+ attach_function :SDL_HapticEffectSupported, [:pointer, SDL_HapticEffect.ptr], :bool
151
+ attach_function :SDL_CreateHapticEffect, [:pointer, SDL_HapticEffect.ptr], :int
152
+ attach_function :SDL_UpdateHapticEffect, [:pointer, :int, SDL_HapticEffect.ptr], :bool
153
+ attach_function :SDL_RunHapticEffect, %i[pointer int uint32], :bool
154
+ attach_function :SDL_StopHapticEffect, %i[pointer int], :bool
155
+ attach_function :SDL_DestroyHapticEffect, %i[pointer int], :void
156
+ attach_function :SDL_GetHapticEffectStatus, %i[pointer int], :bool
157
+ attach_function :SDL_SetHapticGain, %i[pointer int], :bool
158
+ attach_function :SDL_SetHapticAutocenter, %i[pointer int], :bool
159
+ attach_function :SDL_PauseHaptic, [:pointer], :bool
160
+ attach_function :SDL_ResumeHaptic, [:pointer], :bool
161
+ attach_function :SDL_StopHapticEffects, [:pointer], :bool
162
+ attach_function :SDL_HapticRumbleSupported, [:pointer], :bool
163
+ attach_function :SDL_InitHapticRumble, [:pointer], :bool
164
+ attach_function :SDL_PlayHapticRumble, %i[pointer float uint32], :bool
165
+ attach_function :SDL_StopHapticRumble, [:pointer], :bool
166
+ end
167
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDL_hid_bus_type = enum :SDL_HID_API_BUS_UNKNOWN, 0x00,
6
+ :SDL_HID_API_BUS_USB, 0x01,
7
+ :SDL_HID_API_BUS_BLUETOOTH, 0x02,
8
+ :SDL_HID_API_BUS_I2C, 0x03,
9
+ :SDL_HID_API_BUS_SPI, 0x04
10
+
11
+ class SDL_hid_device_info < FFI::Struct
12
+ layout :path, :string,
13
+ :vendor_id, :ushort,
14
+ :product_id, :ushort,
15
+ :serial_number, :pointer,
16
+ :release_number, :ushort,
17
+ :manufacturer_string, :pointer,
18
+ :product_string, :pointer,
19
+ :usage_page, :ushort,
20
+ :usage, :ushort,
21
+ :interface_number, :int,
22
+ :interface_class, :int,
23
+ :interface_subclass, :int,
24
+ :interface_protocol, :int,
25
+ :bus_type, SDL_hid_bus_type,
26
+ :next, :pointer
27
+ end
28
+
29
+ begin
30
+ attach_function :SDL_hid_init, [], :int
31
+ attach_function :SDL_hid_exit, [], :int
32
+ attach_function :SDL_hid_device_change_count, [], :uint32
33
+ attach_function :SDL_hid_enumerate, %i[ushort ushort], SDL_hid_device_info.ptr
34
+ attach_function :SDL_hid_free_enumeration, [SDL_hid_device_info.ptr], :void
35
+ attach_function :SDL_hid_open, %i[ushort ushort pointer], :pointer
36
+ attach_function :SDL_hid_open_path, [:string], :pointer
37
+ attach_function :SDL_hid_get_properties, [:pointer], :SDL_PropertiesID
38
+ attach_function :SDL_hid_write, %i[pointer pointer size_t], :int
39
+ attach_function :SDL_hid_read_timeout, %i[pointer pointer size_t int], :int
40
+ attach_function :SDL_hid_read, %i[pointer pointer size_t], :int
41
+ attach_function :SDL_hid_set_nonblocking, %i[pointer int], :int
42
+ attach_function :SDL_hid_send_feature_report, %i[pointer pointer size_t], :int
43
+ attach_function :SDL_hid_get_feature_report, %i[pointer pointer size_t], :int
44
+ attach_function :SDL_hid_get_input_report, %i[pointer pointer size_t], :int
45
+ attach_function :SDL_hid_close, [:pointer], :int
46
+ attach_function :SDL_hid_get_manufacturer_string, %i[pointer pointer size_t], :int
47
+ attach_function :SDL_hid_get_product_string, %i[pointer pointer size_t], :int
48
+ attach_function :SDL_hid_get_serial_number_string, %i[pointer pointer size_t], :int
49
+ attach_function :SDL_hid_get_indexed_string, %i[pointer int pointer size_t], :int
50
+ attach_function :SDL_hid_get_device_info, [:pointer], SDL_hid_device_info.ptr
51
+ attach_function :SDL_hid_get_report_descriptor, %i[pointer pointer size_t], :int
52
+ attach_function :SDL_hid_ble_scan, [:bool], :void
53
+ rescue FFI::NotFoundError
54
+ # HIDAPI may not be available in all SDL3 builds
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDL_HintPriority = enum :SDL_HINT_DEFAULT, 0,
6
+ :SDL_HINT_NORMAL, 1,
7
+ :SDL_HINT_OVERRIDE, 2
8
+
9
+ callback :SDL_HintCallback, %i[pointer string string string], :void
10
+
11
+ attach_function :SDL_SetHintWithPriority, [:string, :string, SDL_HintPriority], :bool
12
+ attach_function :SDL_SetHint, %i[string string], :bool
13
+ attach_function :SDL_ResetHint, [:string], :bool
14
+ attach_function :SDL_ResetHints, [], :void
15
+ attach_function :SDL_GetHint, [:string], :string
16
+ attach_function :SDL_GetHintBoolean, [:string, :bool], :bool
17
+ attach_function :SDL_AddHintCallback, [:string, :SDL_HintCallback, :pointer], :bool
18
+ attach_function :SDL_RemoveHintCallback, [:string, :SDL_HintCallback, :pointer], :void
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDL_INIT_AUDIO = 0x00000010
6
+ SDL_INIT_VIDEO = 0x00000020
7
+ SDL_INIT_JOYSTICK = 0x00000200
8
+ SDL_INIT_HAPTIC = 0x00001000
9
+ SDL_INIT_GAMEPAD = 0x00002000
10
+ SDL_INIT_EVENTS = 0x00004000
11
+ SDL_INIT_SENSOR = 0x00008000
12
+ SDL_INIT_CAMERA = 0x00010000
13
+
14
+ callback :SDL_MainThreadCallback, %i[pointer], :void
15
+
16
+ attach_function :SDL_Init, [:uint32], :bool
17
+ attach_function :SDL_InitSubSystem, [:uint32], :bool
18
+ attach_function :SDL_QuitSubSystem, [:uint32], :void
19
+ attach_function :SDL_WasInit, [:uint32], :uint32
20
+ attach_function :SDL_Quit, [], :void
21
+ attach_function :SDL_IsMainThread, [], :bool
22
+ attach_function :SDL_RunOnMainThread, [:SDL_MainThreadCallback, :pointer, :bool], :bool
23
+ attach_function :SDL_SetAppMetadata, %i[string string string], :bool
24
+ attach_function :SDL_SetAppMetadataProperty, %i[string string], :bool
25
+ attach_function :SDL_GetAppMetadataProperty, [:string], :string
26
+ end
27
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDL_IOStatus = enum :SDL_IO_STATUS_READY, 0,
6
+ :SDL_IO_STATUS_ERROR, 1,
7
+ :SDL_IO_STATUS_EOF, 2,
8
+ :SDL_IO_STATUS_NOT_READY, 3,
9
+ :SDL_IO_STATUS_READONLY, 4,
10
+ :SDL_IO_STATUS_WRITEONLY, 5
11
+
12
+ SDL_IOWhence = enum :SDL_IO_SEEK_SET, 0,
13
+ :SDL_IO_SEEK_CUR, 1,
14
+ :SDL_IO_SEEK_END, 2
15
+
16
+ callback :SDL_IOStreamInterfaceSizeCallback, [:pointer], :int64
17
+ callback :SDL_IOStreamInterfaceSeekCallback, %i[pointer int64 int], :int64
18
+ callback :SDL_IOStreamInterfaceReadCallback, %i[pointer pointer size_t pointer], :size_t
19
+ callback :SDL_IOStreamInterfaceWriteCallback, %i[pointer pointer size_t pointer], :size_t
20
+ callback :SDL_IOStreamInterfaceFlushCallback, %i[pointer pointer], :bool
21
+ callback :SDL_IOStreamInterfaceCloseCallback, [:pointer], :bool
22
+
23
+ class SDL_IOStreamInterface < FFI::Struct
24
+ layout :version, :uint32,
25
+ :size, :SDL_IOStreamInterfaceSizeCallback,
26
+ :seek, :SDL_IOStreamInterfaceSeekCallback,
27
+ :read, :SDL_IOStreamInterfaceReadCallback,
28
+ :write, :SDL_IOStreamInterfaceWriteCallback,
29
+ :flush, :SDL_IOStreamInterfaceFlushCallback,
30
+ :close, :SDL_IOStreamInterfaceCloseCallback
31
+ end
32
+
33
+ attach_function :SDL_IOFromFile, %i[string string], :pointer
34
+ attach_function :SDL_IOFromMem, %i[pointer size_t], :pointer
35
+ attach_function :SDL_IOFromConstMem, %i[pointer size_t], :pointer
36
+ attach_function :SDL_IOFromDynamicMem, [], :pointer
37
+ attach_function :SDL_OpenIO, [SDL_IOStreamInterface.ptr, :pointer], :pointer
38
+ attach_function :SDL_CloseIO, [:pointer], :bool
39
+ attach_function :SDL_GetIOProperties, [:pointer], :SDL_PropertiesID
40
+ attach_function :SDL_GetIOStatus, [:pointer], SDL_IOStatus
41
+ attach_function :SDL_GetIOSize, [:pointer], :int64
42
+ attach_function :SDL_SeekIO, [:pointer, :int64, SDL_IOWhence], :int64
43
+ attach_function :SDL_TellIO, [:pointer], :int64
44
+ attach_function :SDL_ReadIO, %i[pointer pointer size_t], :size_t
45
+ attach_function :SDL_WriteIO, %i[pointer pointer size_t], :size_t
46
+ attach_function :SDL_IOprintf, [:pointer, :string, :varargs], :size_t
47
+ begin
48
+ attach_function :SDL_IOvprintf, %i[pointer string pointer], :size_t
49
+ rescue FFI::NotFoundError
50
+ # Added in newer SDL3 versions.
51
+ end
52
+ attach_function :SDL_FlushIO, [:pointer], :bool
53
+ attach_function :SDL_LoadFile_IO, %i[pointer pointer bool], :pointer
54
+ attach_function :SDL_LoadFile, %i[string pointer], :pointer
55
+ attach_function :SDL_SaveFile_IO, %i[pointer pointer size_t bool], :bool
56
+ attach_function :SDL_SaveFile, %i[string pointer size_t], :bool
57
+
58
+ attach_function :SDL_ReadU8, %i[pointer pointer], :bool
59
+ attach_function :SDL_ReadS8, %i[pointer pointer], :bool
60
+ attach_function :SDL_ReadU16LE, %i[pointer pointer], :bool
61
+ attach_function :SDL_ReadS16LE, %i[pointer pointer], :bool
62
+ attach_function :SDL_ReadU16BE, %i[pointer pointer], :bool
63
+ attach_function :SDL_ReadS16BE, %i[pointer pointer], :bool
64
+ attach_function :SDL_ReadU32LE, %i[pointer pointer], :bool
65
+ attach_function :SDL_ReadS32LE, %i[pointer pointer], :bool
66
+ attach_function :SDL_ReadU32BE, %i[pointer pointer], :bool
67
+ attach_function :SDL_ReadS32BE, %i[pointer pointer], :bool
68
+ attach_function :SDL_ReadU64LE, %i[pointer pointer], :bool
69
+ attach_function :SDL_ReadS64LE, %i[pointer pointer], :bool
70
+ attach_function :SDL_ReadU64BE, %i[pointer pointer], :bool
71
+ attach_function :SDL_ReadS64BE, %i[pointer pointer], :bool
72
+
73
+ attach_function :SDL_WriteU8, %i[pointer uint8], :bool
74
+ attach_function :SDL_WriteS8, %i[pointer int8], :bool
75
+ attach_function :SDL_WriteU16LE, %i[pointer uint16], :bool
76
+ attach_function :SDL_WriteS16LE, %i[pointer int16], :bool
77
+ attach_function :SDL_WriteU16BE, %i[pointer uint16], :bool
78
+ attach_function :SDL_WriteS16BE, %i[pointer int16], :bool
79
+ attach_function :SDL_WriteU32LE, %i[pointer uint32], :bool
80
+ attach_function :SDL_WriteS32LE, %i[pointer int32], :bool
81
+ attach_function :SDL_WriteU32BE, %i[pointer uint32], :bool
82
+ attach_function :SDL_WriteS32BE, %i[pointer int32], :bool
83
+ attach_function :SDL_WriteU64LE, %i[pointer uint64], :bool
84
+ attach_function :SDL_WriteS64LE, %i[pointer int64], :bool
85
+ attach_function :SDL_WriteU64BE, %i[pointer uint64], :bool
86
+ attach_function :SDL_WriteS64BE, %i[pointer int64], :bool
87
+ end
88
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDL_JoystickType = enum :SDL_JOYSTICK_TYPE_UNKNOWN, 0,
6
+ :SDL_JOYSTICK_TYPE_GAMEPAD, 1,
7
+ :SDL_JOYSTICK_TYPE_WHEEL, 2,
8
+ :SDL_JOYSTICK_TYPE_ARCADE_STICK, 3,
9
+ :SDL_JOYSTICK_TYPE_FLIGHT_STICK, 4,
10
+ :SDL_JOYSTICK_TYPE_DANCE_PAD, 5,
11
+ :SDL_JOYSTICK_TYPE_GUITAR, 6,
12
+ :SDL_JOYSTICK_TYPE_DRUM_KIT, 7,
13
+ :SDL_JOYSTICK_TYPE_ARCADE_PAD, 8,
14
+ :SDL_JOYSTICK_TYPE_THROTTLE, 9,
15
+ :SDL_JOYSTICK_TYPE_COUNT, 10
16
+
17
+ SDL_JoystickConnectionState = enum :SDL_JOYSTICK_CONNECTION_INVALID, -1,
18
+ :SDL_JOYSTICK_CONNECTION_UNKNOWN, 0,
19
+ :SDL_JOYSTICK_CONNECTION_WIRED, 1,
20
+ :SDL_JOYSTICK_CONNECTION_WIRELESS, 2
21
+
22
+ SDL_HAT_CENTERED = 0x00
23
+ SDL_HAT_UP = 0x01
24
+ SDL_HAT_RIGHT = 0x02
25
+ SDL_HAT_DOWN = 0x04
26
+ SDL_HAT_LEFT = 0x08
27
+ SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP
28
+ SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN
29
+ SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP
30
+ SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN
31
+
32
+ attach_function :SDL_LockJoysticks, [], :void
33
+ begin
34
+ attach_function :SDL_TryLockJoysticks, [], :bool
35
+ rescue FFI::NotFoundError
36
+ # Added in newer SDL3 versions.
37
+ end
38
+ attach_function :SDL_UnlockJoysticks, [], :void
39
+ attach_function :SDL_HasJoystick, [], :bool
40
+ attach_function :SDL_GetJoysticks, [:pointer], :pointer
41
+ attach_function :SDL_GetJoystickNameForID, [:SDL_JoystickID], :string
42
+ attach_function :SDL_GetJoystickPathForID, [:SDL_JoystickID], :string
43
+ attach_function :SDL_GetJoystickPlayerIndexForID, [:SDL_JoystickID], :int
44
+ attach_function :SDL_GetJoystickGUIDForID, [:SDL_JoystickID], SDL_GUID.by_value
45
+ attach_function :SDL_GetJoystickVendorForID, [:SDL_JoystickID], :uint16
46
+ attach_function :SDL_GetJoystickProductForID, [:SDL_JoystickID], :uint16
47
+ attach_function :SDL_GetJoystickProductVersionForID, [:SDL_JoystickID], :uint16
48
+ attach_function :SDL_GetJoystickTypeForID, [:SDL_JoystickID], SDL_JoystickType
49
+ attach_function :SDL_OpenJoystick, [:SDL_JoystickID], :pointer
50
+ attach_function :SDL_GetJoystickFromID, [:SDL_JoystickID], :pointer
51
+ attach_function :SDL_GetJoystickFromPlayerIndex, [:int], :pointer
52
+ attach_function :SDL_GetJoystickProperties, [:pointer], :SDL_PropertiesID
53
+ attach_function :SDL_GetJoystickName, [:pointer], :string
54
+ attach_function :SDL_GetJoystickPath, [:pointer], :string
55
+ attach_function :SDL_GetJoystickPlayerIndex, [:pointer], :int
56
+ attach_function :SDL_SetJoystickPlayerIndex, %i[pointer int], :bool
57
+ attach_function :SDL_GetJoystickGUID, [:pointer], SDL_GUID.by_value
58
+ attach_function :SDL_GetJoystickVendor, [:pointer], :uint16
59
+ attach_function :SDL_GetJoystickProduct, [:pointer], :uint16
60
+ attach_function :SDL_GetJoystickProductVersion, [:pointer], :uint16
61
+ attach_function :SDL_GetJoystickFirmwareVersion, [:pointer], :uint16
62
+ attach_function :SDL_GetJoystickSerial, [:pointer], :string
63
+ attach_function :SDL_GetJoystickType, [:pointer], SDL_JoystickType
64
+ attach_function :SDL_GetJoystickID, [:pointer], :SDL_JoystickID
65
+ attach_function :SDL_JoystickConnected, [:pointer], :bool
66
+ attach_function :SDL_GetNumJoystickAxes, [:pointer], :int
67
+ attach_function :SDL_GetNumJoystickBalls, [:pointer], :int
68
+ attach_function :SDL_GetNumJoystickHats, [:pointer], :int
69
+ attach_function :SDL_GetNumJoystickButtons, [:pointer], :int
70
+ attach_function :SDL_SetJoystickEventsEnabled, [:bool], :void
71
+ attach_function :SDL_JoystickEventsEnabled, [], :bool
72
+ attach_function :SDL_UpdateJoysticks, [], :void
73
+ attach_function :SDL_GetJoystickAxis, %i[pointer int], :int16
74
+ attach_function :SDL_GetJoystickAxisInitialState, %i[pointer int pointer], :bool
75
+ attach_function :SDL_GetJoystickBall, %i[pointer int pointer pointer], :bool
76
+ attach_function :SDL_GetJoystickHat, %i[pointer int], :uint8
77
+ attach_function :SDL_GetJoystickButton, %i[pointer int], :bool
78
+ attach_function :SDL_RumbleJoystick, %i[pointer uint16 uint16 uint32], :bool
79
+ attach_function :SDL_RumbleJoystickTriggers, %i[pointer uint16 uint16 uint32], :bool
80
+ attach_function :SDL_SetJoystickLED, %i[pointer uint8 uint8 uint8], :bool
81
+ attach_function :SDL_SendJoystickEffect, %i[pointer pointer int], :bool
82
+ attach_function :SDL_CloseJoystick, [:pointer], :void
83
+ attach_function :SDL_GetJoystickConnectionState, [:pointer], SDL_JoystickConnectionState
84
+ attach_function :SDL_GetJoystickPowerInfo, %i[pointer pointer], :int32
85
+
86
+ begin
87
+ attach_function :SDL_AttachVirtualJoystick, [:pointer], :SDL_JoystickID
88
+ attach_function :SDL_DetachVirtualJoystick, [:SDL_JoystickID], :bool
89
+ attach_function :SDL_IsJoystickVirtual, [:SDL_JoystickID], :bool
90
+ attach_function :SDL_SetJoystickVirtualAxis, %i[pointer int int16], :bool
91
+ attach_function :SDL_SetJoystickVirtualBall, %i[pointer int int16 int16], :bool
92
+ attach_function :SDL_SetJoystickVirtualButton, %i[pointer int bool], :bool
93
+ attach_function :SDL_SetJoystickVirtualHat, %i[pointer int uint8], :bool
94
+ attach_function :SDL_SetJoystickVirtualTouchpad, %i[pointer int int bool float float float], :bool
95
+ attach_function :SDL_SendJoystickVirtualSensorData, %i[pointer int uint64 pointer int], :bool
96
+ attach_function :SDL_GetJoystickGUIDInfo, [SDL_GUID.by_value, :pointer, :pointer, :pointer, :pointer], :void
97
+ rescue FFI::NotFoundError
98
+ # Added in newer SDL3 versions.
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ attach_function :SDL_HasKeyboard, [], :bool
6
+ attach_function :SDL_GetKeyboards, [:pointer], :pointer
7
+ attach_function :SDL_GetKeyboardNameForID, [:SDL_KeyboardID], :string
8
+ attach_function :SDL_GetKeyboardFocus, [], :pointer
9
+ attach_function :SDL_GetKeyboardState, [:pointer], :pointer
10
+ attach_function :SDL_ResetKeyboard, [], :void
11
+ attach_function :SDL_GetModState, [], :uint16
12
+ attach_function :SDL_SetModState, [:uint16], :void
13
+ attach_function :SDL_GetKeyFromScancode, [:SDL_Scancode, :uint16, :bool], :SDL_Keycode
14
+ attach_function :SDL_GetScancodeFromKey, [:SDL_Keycode, :pointer], :SDL_Scancode
15
+ attach_function :SDL_SetScancodeName, [:SDL_Scancode, :string], :bool
16
+ attach_function :SDL_GetScancodeName, [:SDL_Scancode], :string
17
+ attach_function :SDL_GetScancodeFromName, [:string], :SDL_Scancode
18
+ attach_function :SDL_GetKeyName, [:SDL_Keycode], :string
19
+ attach_function :SDL_GetKeyFromName, [:string], :SDL_Keycode
20
+ attach_function :SDL_StartTextInput, [:pointer], :bool
21
+ attach_function :SDL_StartTextInputWithProperties, [:pointer, :SDL_PropertiesID], :bool
22
+ attach_function :SDL_TextInputActive, [:pointer], :bool
23
+ attach_function :SDL_StopTextInput, [:pointer], :bool
24
+ attach_function :SDL_ClearComposition, [:pointer], :bool
25
+ attach_function :SDL_SetTextInputArea, [:pointer, SDL_Rect.ptr, :int], :bool
26
+ attach_function :SDL_GetTextInputArea, [:pointer, SDL_Rect.ptr, :pointer], :bool
27
+ attach_function :SDL_HasScreenKeyboardSupport, [], :bool
28
+ attach_function :SDL_ScreenKeyboardShown, [:pointer], :bool
29
+ end
30
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ SDLK_SCANCODE_MASK = 0x40000000
6
+
7
+ SDLK_UNKNOWN = 0x00000000
8
+ SDLK_RETURN = 0x0000000D
9
+ SDLK_ESCAPE = 0x0000001B
10
+ SDLK_BACKSPACE = 0x00000008
11
+ SDLK_TAB = 0x00000009
12
+ SDLK_SPACE = 0x00000020
13
+ SDLK_EXCLAIM = 0x00000021
14
+ SDLK_DBLAPOSTROPHE = 0x00000022
15
+ SDLK_HASH = 0x00000023
16
+ SDLK_DOLLAR = 0x00000024
17
+ SDLK_PERCENT = 0x00000025
18
+ SDLK_AMPERSAND = 0x00000026
19
+ SDLK_APOSTROPHE = 0x00000027
20
+ SDLK_LEFTPAREN = 0x00000028
21
+ SDLK_RIGHTPAREN = 0x00000029
22
+ SDLK_ASTERISK = 0x0000002A
23
+ SDLK_PLUS = 0x0000002B
24
+ SDLK_COMMA = 0x0000002C
25
+ SDLK_MINUS = 0x0000002D
26
+ SDLK_PERIOD = 0x0000002E
27
+ SDLK_SLASH = 0x0000002F
28
+ SDLK_0 = 0x00000030
29
+ SDLK_1 = 0x00000031
30
+ SDLK_2 = 0x00000032
31
+ SDLK_3 = 0x00000033
32
+ SDLK_4 = 0x00000034
33
+ SDLK_5 = 0x00000035
34
+ SDLK_6 = 0x00000036
35
+ SDLK_7 = 0x00000037
36
+ SDLK_8 = 0x00000038
37
+ SDLK_9 = 0x00000039
38
+ SDLK_COLON = 0x0000003A
39
+ SDLK_SEMICOLON = 0x0000003B
40
+ SDLK_LESS = 0x0000003C
41
+ SDLK_EQUALS = 0x0000003D
42
+ SDLK_GREATER = 0x0000003E
43
+ SDLK_QUESTION = 0x0000003F
44
+ SDLK_AT = 0x00000040
45
+ SDLK_LEFTBRACKET = 0x0000005B
46
+ SDLK_BACKSLASH = 0x0000005C
47
+ SDLK_RIGHTBRACKET = 0x0000005D
48
+ SDLK_CARET = 0x0000005E
49
+ SDLK_UNDERSCORE = 0x0000005F
50
+ SDLK_GRAVE = 0x00000060
51
+ SDLK_A = 0x00000061
52
+ SDLK_B = 0x00000062
53
+ SDLK_C = 0x00000063
54
+ SDLK_D = 0x00000064
55
+ SDLK_E = 0x00000065
56
+ SDLK_F = 0x00000066
57
+ SDLK_G = 0x00000067
58
+ SDLK_H = 0x00000068
59
+ SDLK_I = 0x00000069
60
+ SDLK_J = 0x0000006A
61
+ SDLK_K = 0x0000006B
62
+ SDLK_L = 0x0000006C
63
+ SDLK_M = 0x0000006D
64
+ SDLK_N = 0x0000006E
65
+ SDLK_O = 0x0000006F
66
+ SDLK_P = 0x00000070
67
+ SDLK_Q = 0x00000071
68
+ SDLK_R = 0x00000072
69
+ SDLK_S = 0x00000073
70
+ SDLK_T = 0x00000074
71
+ SDLK_U = 0x00000075
72
+ SDLK_V = 0x00000076
73
+ SDLK_W = 0x00000077
74
+ SDLK_X = 0x00000078
75
+ SDLK_Y = 0x00000079
76
+ SDLK_Z = 0x0000007A
77
+ SDLK_DELETE = 0x0000007F
78
+
79
+ SDLK_CAPSLOCK = 0x40000039
80
+ SDLK_F1 = 0x4000003A
81
+ SDLK_F2 = 0x4000003B
82
+ SDLK_F3 = 0x4000003C
83
+ SDLK_F4 = 0x4000003D
84
+ SDLK_F5 = 0x4000003E
85
+ SDLK_F6 = 0x4000003F
86
+ SDLK_F7 = 0x40000040
87
+ SDLK_F8 = 0x40000041
88
+ SDLK_F9 = 0x40000042
89
+ SDLK_F10 = 0x40000043
90
+ SDLK_F11 = 0x40000044
91
+ SDLK_F12 = 0x40000045
92
+ SDLK_PRINTSCREEN = 0x40000046
93
+ SDLK_SCROLLLOCK = 0x40000047
94
+ SDLK_PAUSE = 0x40000048
95
+ SDLK_INSERT = 0x40000049
96
+ SDLK_HOME = 0x4000004A
97
+ SDLK_PAGEUP = 0x4000004B
98
+ SDLK_END = 0x4000004D
99
+ SDLK_PAGEDOWN = 0x4000004E
100
+ SDLK_RIGHT = 0x4000004F
101
+ SDLK_LEFT = 0x40000050
102
+ SDLK_DOWN = 0x40000051
103
+ SDLK_UP = 0x40000052
104
+
105
+ SDLK_LCTRL = 0x400000E0
106
+ SDLK_LSHIFT = 0x400000E1
107
+ SDLK_LALT = 0x400000E2
108
+ SDLK_LGUI = 0x400000E3
109
+ SDLK_RCTRL = 0x400000E4
110
+ SDLK_RSHIFT = 0x400000E5
111
+ SDLK_RALT = 0x400000E6
112
+ SDLK_RGUI = 0x400000E7
113
+
114
+ SDL_KMOD_NONE = 0x0000
115
+ SDL_KMOD_LSHIFT = 0x0001
116
+ SDL_KMOD_RSHIFT = 0x0002
117
+ SDL_KMOD_LCTRL = 0x0040
118
+ SDL_KMOD_RCTRL = 0x0080
119
+ SDL_KMOD_LALT = 0x0100
120
+ SDL_KMOD_RALT = 0x0200
121
+ SDL_KMOD_LGUI = 0x0400
122
+ SDL_KMOD_RGUI = 0x0800
123
+ SDL_KMOD_NUM = 0x1000
124
+ SDL_KMOD_CAPS = 0x2000
125
+ SDL_KMOD_MODE = 0x4000
126
+ SDL_KMOD_SCROLL = 0x8000
127
+ SDL_KMOD_CTRL = SDL_KMOD_LCTRL | SDL_KMOD_RCTRL
128
+ SDL_KMOD_SHIFT = SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT
129
+ SDL_KMOD_ALT = SDL_KMOD_LALT | SDL_KMOD_RALT
130
+ SDL_KMOD_GUI = SDL_KMOD_LGUI | SDL_KMOD_RGUI
131
+ end
132
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ attach_function :SDL_LoadObject, [:string], :pointer
6
+ attach_function :SDL_LoadFunction, %i[pointer string], :pointer
7
+ attach_function :SDL_UnloadObject, [:pointer], :void
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SDL3
4
+ module Raw
5
+ class SDL_Locale < FFI::Struct
6
+ layout :language, :string,
7
+ :country, :string
8
+ end
9
+
10
+ attach_function :SDL_GetPreferredLocales, [:pointer], :pointer
11
+ end
12
+ end