Compare commits
2 Commits
45ee35163c
...
d82587e040
| Author | SHA1 | Date |
|---|---|---|
|
|
d82587e040 | |
|
|
264ffc99c4 |
|
|
@ -4,3 +4,4 @@ sdl3/
|
||||||
archive/
|
archive/
|
||||||
tmp/
|
tmp/
|
||||||
debug/
|
debug/
|
||||||
|
all-releases/
|
||||||
|
|
|
||||||
78
AGENTS.md
78
AGENTS.md
|
|
@ -8,7 +8,7 @@ This is an SDL3 header parser that converts C header files into Zig interfaces,
|
||||||
- Not a real C parser - best-effort text transformation specifically for SDL3 headers
|
- Not a real C parser - best-effort text transformation specifically for SDL3 headers
|
||||||
- Does not do proper AST elaboration or tokenization
|
- Does not do proper AST elaboration or tokenization
|
||||||
- Simple to modify but brittle
|
- Simple to modify but brittle
|
||||||
- Requires Zig 0.15.2 and git
|
- Requires Zig 0.17.0 and git
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|
@ -54,6 +54,8 @@ The parser converts C headers to Zig files:
|
||||||
- `--generate-json=<path>` - Generate JSON representation
|
- `--generate-json=<path>` - Generate JSON representation
|
||||||
- `--timestamp=<timestamp>` - Set custom timestamp
|
- `--timestamp=<timestamp>` - Set custom timestamp
|
||||||
- `--basedir=<directory>` - Set base directory for dependency resolution
|
- `--basedir=<directory>` - Set base directory for dependency resolution
|
||||||
|
- `--c-import=<path>` - Path the generated file imports `c` from (default `c.zig`)
|
||||||
|
- `--skip-missing` - Exit successfully when the header does not exist (older SDL releases lack some headers); `zig build generate` passes this
|
||||||
|
|
||||||
### Output Directories
|
### Output Directories
|
||||||
|
|
||||||
|
|
@ -66,37 +68,18 @@ The parser converts C headers to Zig files:
|
||||||
|
|
||||||
### Build System Patterns
|
### Build System Patterns
|
||||||
|
|
||||||
**Custom Build Steps:**
|
**Build Helper Executable:**
|
||||||
The project uses custom Zig build steps for operations that need to happen during the build process:
|
Zig 0.17 no longer supports custom build steps with a `makeFn` (the configure and make phases run in separate processes). Filesystem work that has to happen at make time is done by a small helper executable, `src/build_helper.zig`, which build.zig runs through `addHelperStep`:
|
||||||
|
|
||||||
```zig
|
```zig
|
||||||
const MakeDirStep = struct {
|
// build-helper archive [base_dir] | mkdir <dir> | write <path> <contents> | rmtree <dir>
|
||||||
step: std.Build.Step,
|
const mkdir_step = addHelperStep(b, helper_exe, b.fmt("mkdir {s}", .{dir}), &.{ "mkdir", dir });
|
||||||
dir_path: []const u8,
|
mkdir_step.dependOn(previous_step);
|
||||||
|
|
||||||
pub fn create(b: *std.Build, dir_path: []const u8) *std.Build.Step {
|
|
||||||
const self = b.allocator.create(MakeDirStep) catch @panic("OOM");
|
|
||||||
self.* = .{
|
|
||||||
.step = std.Build.Step.init(.{
|
|
||||||
.id = .custom,
|
|
||||||
.name = b.fmt("mkdir {s}", .{dir_path}),
|
|
||||||
.owner = b,
|
|
||||||
.makeFn = make,
|
|
||||||
}),
|
|
||||||
.dir_path = dir_path,
|
|
||||||
};
|
|
||||||
return &self.step;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
|
|
||||||
_ = options;
|
|
||||||
const self: *MakeDirStep = @fieldParentPtr("step", step);
|
|
||||||
try std.fs.cwd().makePath(self.dir_path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This pattern allows cross-platform directory creation and other filesystem operations during build without relying on shell commands.
|
This allows cross-platform directory creation and other filesystem operations during build without relying on shell commands.
|
||||||
|
|
||||||
|
build.zig also checks whether `sdl3/` exists and takes a timestamp at configure time, so it calls `b.graph.poisonCache()` to keep the configuration from being cached.
|
||||||
|
|
||||||
### Error Handling
|
### Error Handling
|
||||||
**CRITICAL:** Whenever actual errors are encountered (parsing failures, invalid declarations, missing types, etc.), you MUST call `io.emitError` to report them properly. Do NOT use `std.debug.print` for actual errors.
|
**CRITICAL:** Whenever actual errors are encountered (parsing failures, invalid declarations, missing types, etc.), you MUST call `io.emitError` to report them properly. Do NOT use `std.debug.print` for actual errors.
|
||||||
|
|
@ -113,16 +96,24 @@ std.debug.print("Error: Failed to parse...\n", .{});
|
||||||
|
|
||||||
The code generator automatically adds appropriate casts when calling C functions:
|
The code generator automatically adds appropriate casts when calling C functions:
|
||||||
|
|
||||||
**Parameters:**
|
Casts are chosen from how the C type is declared (see `castForCType` in `src/codegen.zig`), not from its name. The same rules apply to parameters and return values:
|
||||||
- Opaque pointers (`*Window`, `?*GPUDevice`) → `@ptrCast`
|
|
||||||
- Enums → `@intFromEnum`
|
|
||||||
- Flags (packed structs) → `@bitCast`
|
|
||||||
- Booleans → `@bitCast`
|
|
||||||
|
|
||||||
**Return values:**
|
| C type | Parameter | Return value |
|
||||||
- Opaque pointers (`?*Window`) → `@ptrCast`
|
|---|---|---|
|
||||||
- Booleans → `@bitCast`
|
| Pointer to an SDL opaque type, struct, union, enum or flags type (any pointer depth) | `@ptrCast(@alignCast(x))` | `@ptrCast(@alignCast(...))` |
|
||||||
- Flags (packed structs) → `@bitCast`
|
| Pointer to a primitive (`int *`, `const char *`, `void *`) | no cast | no cast |
|
||||||
|
| Enum (`enum(c_int)` in Zig; `c_uint` or `c_int` in C depending on the target) | `@intCast(@backingInt(x))` | `@fromBackingInt(@intCast(...))` |
|
||||||
|
| Flags (packed struct), `bool` | `@bitCast(x)` | `@bitCast(...)` |
|
||||||
|
| Struct/union passed by value | `@as(*const c.SDL_Foo, @ptrCast(@alignCast(&x))).*` | `@as(*const Foo, @ptrCast(@alignCast(&...))).*` |
|
||||||
|
| Function pointer typedef re-declared in Zig | `@ptrCast(@alignCast(x))` | `@ptrCast(@alignCast(...))` |
|
||||||
|
| Typedef | follows the underlying type | follows the underlying type |
|
||||||
|
|
||||||
|
**Enums:**
|
||||||
|
- Enumerators are numbered the way C numbers them. An enumerator whose value repeats an earlier one becomes an alias (`pub const eventDisplayFirst = .eventDisplayOrientation;`) because Zig enums cannot have duplicate values.
|
||||||
|
- Inside `#if SDL_BYTEORDER == ...` blocks the little endian branch is used.
|
||||||
|
|
||||||
|
**Flags:**
|
||||||
|
- Packed struct fields are emitted in bit order with `padN` fields for unused bits, so each flag sits on the bit the header assigns to it.
|
||||||
|
|
||||||
**Pointer Optionality:**
|
**Pointer Optionality:**
|
||||||
- All pointer parameters in standalone functions are optional (`?*const Type`) to allow null values
|
- All pointer parameters in standalone functions are optional (`?*const Type`) to allow null values
|
||||||
|
|
@ -182,17 +173,22 @@ Use `zig build generate` to regenerate all SDL3 headers and verify no regression
|
||||||
- `freeDeclDeep()` - frees a single declaration
|
- `freeDeclDeep()` - frees a single declaration
|
||||||
- Both free all nested allocations (names, types, doc comments, params/fields/values/flags)
|
- Both free all nested allocations (names, types, doc comments, params/fields/values/flags)
|
||||||
|
|
||||||
### Zig 0.15 Specifics
|
### Zig 0.17 Specifics
|
||||||
**IMPORTANT:** In Zig 0.15, `std.ArrayList` is an alias to `std.ArrayListUnmanaged`. This means:
|
**IMPORTANT:** `std.ArrayList` is unmanaged. This means:
|
||||||
- ArrayList methods require an explicit allocator parameter
|
- ArrayList methods require an explicit allocator parameter
|
||||||
- Use `list.append(allocator, item)` instead of `list.append(item)`
|
- Use `list.append(allocator, item)` instead of `list.append(item)`
|
||||||
- Use `list.toOwnedSlice(allocator)` instead of `list.toOwnedSlice()`
|
- Use `list.toOwnedSlice(allocator)` instead of `list.toOwnedSlice()`
|
||||||
- Use `list.deinit(allocator)` instead of `list.deinit()`
|
- Use `list.deinit(allocator)` instead of `list.deinit()`
|
||||||
- Initialize with `std.ArrayList(T){}` (empty init)
|
- Initialize with `.empty`
|
||||||
|
- There is no `list.writer()`; use `list.print(allocator, fmt, args)` or wrap the list in a `std.Io.Writer.Allocating` (`.fromArrayList` / `.toArrayList`)
|
||||||
|
|
||||||
|
File system, process and clock APIs take an `std.Io` instance. `main` receives it via `std.process.Init` and stores it in `src/io.zig`; use `io.get()` and `io.cwd()` (e.g. `io.cwd().readFileAlloc(io.get(), path, allocator, .limited(max))`).
|
||||||
|
|
||||||
|
Generated code uses the 0.17 builtin names `@backingInt` / `@fromBackingInt` (formerly `@intFromEnum` / `@enumFromInt`) and `callconv(.c)`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```zig
|
```zig
|
||||||
var list = std.ArrayList(MyType){};
|
var list: std.ArrayList(MyType) = .empty;
|
||||||
errdefer list.deinit(allocator);
|
errdefer list.deinit(allocator);
|
||||||
try list.append(allocator, item);
|
try list.append(allocator, item);
|
||||||
const slice = try list.toOwnedSlice(allocator);
|
const slice = try list.toOwnedSlice(allocator);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ The zig code has gone through some manual fixups but only where there was actual
|
||||||
|
|
||||||
works on any header in the sdl3 library. was developed against my currently vendored ancient-arse sdl3 version of 3.2.10
|
works on any header in the sdl3 library. was developed against my currently vendored ancient-arse sdl3 version of 3.2.10
|
||||||
|
|
||||||
requires zig 0.15.2 and git to be installed
|
requires zig 0.17.0 and git to be installed
|
||||||
|
|
||||||
## Automated usage
|
## Automated usage
|
||||||
|
|
||||||
|
|
|
||||||
116
api/audio.zig
116
api/audio.zig
|
|
@ -16,6 +16,10 @@ pub const AudioFormat = enum(c_int) {
|
||||||
audioS32be = 0x9020, //As above, but big-endian byte order
|
audioS32be = 0x9020, //As above, but big-endian byte order
|
||||||
audioF32le = 0x8120, //32-bit floating point samples
|
audioF32le = 0x8120, //32-bit floating point samples
|
||||||
audioF32be = 0x9120, //As above, but big-endian byte order
|
audioF32be = 0x9120, //As above, but big-endian byte order
|
||||||
|
|
||||||
|
pub const audioS16 = .audioS16le;
|
||||||
|
pub const audioS32 = .audioS32le;
|
||||||
|
pub const audioF32 = .audioF32le;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const AudioDeviceID = u32;
|
pub const AudioDeviceID = u32;
|
||||||
|
|
@ -28,119 +32,119 @@ pub const AudioSpec = extern struct {
|
||||||
|
|
||||||
pub const AudioStream = opaque {
|
pub const AudioStream = opaque {
|
||||||
pub inline fn unbindAudioStream(audiostream: *AudioStream) void {
|
pub inline fn unbindAudioStream(audiostream: *AudioStream) void {
|
||||||
return c.SDL_UnbindAudioStream(@ptrCast(audiostream));
|
return c.SDL_UnbindAudioStream(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamDevice(audiostream: *AudioStream) AudioDeviceID {
|
pub inline fn getAudioStreamDevice(audiostream: *AudioStream) AudioDeviceID {
|
||||||
return c.SDL_GetAudioStreamDevice(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamDevice(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamProperties(audiostream: *AudioStream) PropertiesID {
|
pub inline fn getAudioStreamProperties(audiostream: *AudioStream) PropertiesID {
|
||||||
return c.SDL_GetAudioStreamProperties(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamProperties(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*AudioSpec, dst_spec: ?*AudioSpec) bool {
|
pub inline fn getAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*AudioSpec, dst_spec: ?*AudioSpec) bool {
|
||||||
return @bitCast(c.SDL_GetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @bitCast(c.SDL_GetAudioStreamFormat(@ptrCast(@alignCast(audiostream)), @ptrCast(@alignCast(src_spec)), @ptrCast(@alignCast(dst_spec))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) bool {
|
pub inline fn setAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @bitCast(c.SDL_SetAudioStreamFormat(@ptrCast(@alignCast(audiostream)), @ptrCast(@alignCast(src_spec)), @ptrCast(@alignCast(dst_spec))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamFrequencyRatio(audiostream: *AudioStream) f32 {
|
pub inline fn getAudioStreamFrequencyRatio(audiostream: *AudioStream) f32 {
|
||||||
return c.SDL_GetAudioStreamFrequencyRatio(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamFrequencyRatio(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamFrequencyRatio(audiostream: *AudioStream, ratio: f32) bool {
|
pub inline fn setAudioStreamFrequencyRatio(audiostream: *AudioStream, ratio: f32) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamFrequencyRatio(@ptrCast(audiostream), ratio));
|
return @bitCast(c.SDL_SetAudioStreamFrequencyRatio(@ptrCast(@alignCast(audiostream)), ratio));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamGain(audiostream: *AudioStream) f32 {
|
pub inline fn getAudioStreamGain(audiostream: *AudioStream) f32 {
|
||||||
return c.SDL_GetAudioStreamGain(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamGain(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamGain(audiostream: *AudioStream, gain: f32) bool {
|
pub inline fn setAudioStreamGain(audiostream: *AudioStream, gain: f32) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamGain(@ptrCast(audiostream), gain));
|
return @bitCast(c.SDL_SetAudioStreamGain(@ptrCast(@alignCast(audiostream)), gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamInputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
pub inline fn getAudioStreamInputChannelMap(audiostream: *AudioStream, count: ?*c_int) *c_int {
|
||||||
return @ptrCast(c.SDL_GetAudioStreamInputChannelMap(@ptrCast(audiostream), @ptrCast(count)));
|
return c.SDL_GetAudioStreamInputChannelMap(@ptrCast(@alignCast(audiostream)), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamOutputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
pub inline fn getAudioStreamOutputChannelMap(audiostream: *AudioStream, count: ?*c_int) *c_int {
|
||||||
return @ptrCast(c.SDL_GetAudioStreamOutputChannelMap(@ptrCast(audiostream), @ptrCast(count)));
|
return c.SDL_GetAudioStreamOutputChannelMap(@ptrCast(@alignCast(audiostream)), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamInputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
pub inline fn setAudioStreamInputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamInputChannelMap(@ptrCast(audiostream), chmap, count));
|
return @bitCast(c.SDL_SetAudioStreamInputChannelMap(@ptrCast(@alignCast(audiostream)), chmap, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamOutputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
pub inline fn setAudioStreamOutputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamOutputChannelMap(@ptrCast(audiostream), chmap, count));
|
return @bitCast(c.SDL_SetAudioStreamOutputChannelMap(@ptrCast(@alignCast(audiostream)), chmap, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn putAudioStreamData(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int) bool {
|
pub inline fn putAudioStreamData(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int) bool {
|
||||||
return @bitCast(c.SDL_PutAudioStreamData(@ptrCast(audiostream), buf, len));
|
return @bitCast(c.SDL_PutAudioStreamData(@ptrCast(@alignCast(audiostream)), buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn putAudioStreamDataNoCopy(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int, callback: AudioStreamDataCompleteCallback, userdata: ?*anyopaque) bool {
|
pub inline fn putAudioStreamDataNoCopy(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int, callback: AudioStreamDataCompleteCallback, userdata: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_PutAudioStreamDataNoCopy(@ptrCast(audiostream), buf, len, callback, userdata));
|
return @bitCast(c.SDL_PutAudioStreamDataNoCopy(@ptrCast(@alignCast(audiostream)), buf, len, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn putAudioStreamPlanarData(audiostream: *AudioStream, channel_buffers: [*c]const *anyopaque, num_channels: c_int, num_samples: c_int) bool {
|
pub inline fn putAudioStreamPlanarData(audiostream: *AudioStream, channel_buffers: [*c]const *anyopaque, num_channels: c_int, num_samples: c_int) bool {
|
||||||
return @bitCast(c.SDL_PutAudioStreamPlanarData(@ptrCast(audiostream), channel_buffers, num_channels, num_samples));
|
return @bitCast(c.SDL_PutAudioStreamPlanarData(@ptrCast(@alignCast(audiostream)), channel_buffers, num_channels, num_samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamData(audiostream: *AudioStream, buf: ?*anyopaque, len: c_int) c_int {
|
pub inline fn getAudioStreamData(audiostream: *AudioStream, buf: ?*anyopaque, len: c_int) c_int {
|
||||||
return c.SDL_GetAudioStreamData(@ptrCast(audiostream), buf, len);
|
return c.SDL_GetAudioStreamData(@ptrCast(@alignCast(audiostream)), buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamAvailable(audiostream: *AudioStream) c_int {
|
pub inline fn getAudioStreamAvailable(audiostream: *AudioStream) c_int {
|
||||||
return c.SDL_GetAudioStreamAvailable(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamAvailable(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamQueued(audiostream: *AudioStream) c_int {
|
pub inline fn getAudioStreamQueued(audiostream: *AudioStream) c_int {
|
||||||
return c.SDL_GetAudioStreamQueued(@ptrCast(audiostream));
|
return c.SDL_GetAudioStreamQueued(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flushAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn flushAudioStream(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_FlushAudioStream(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_FlushAudioStream(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn clearAudioStream(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_ClearAudioStream(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_ClearAudioStream(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pauseAudioStreamDevice(audiostream: *AudioStream) bool {
|
pub inline fn pauseAudioStreamDevice(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_PauseAudioStreamDevice(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_PauseAudioStreamDevice(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resumeAudioStreamDevice(audiostream: *AudioStream) bool {
|
pub inline fn resumeAudioStreamDevice(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_ResumeAudioStreamDevice(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_ResumeAudioStreamDevice(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn audioStreamDevicePaused(audiostream: *AudioStream) bool {
|
pub inline fn audioStreamDevicePaused(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_AudioStreamDevicePaused(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_AudioStreamDevicePaused(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn lockAudioStream(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_LockAudioStream(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_LockAudioStream(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn unlockAudioStream(audiostream: *AudioStream) bool {
|
||||||
return @bitCast(c.SDL_UnlockAudioStream(@ptrCast(audiostream)));
|
return @bitCast(c.SDL_UnlockAudioStream(@ptrCast(@alignCast(audiostream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamGetCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
pub inline fn setAudioStreamGetCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamGetCallback(@ptrCast(audiostream), callback, userdata));
|
return @bitCast(c.SDL_SetAudioStreamGetCallback(@ptrCast(@alignCast(audiostream)), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamPutCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
pub inline fn setAudioStreamPutCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamPutCallback(@ptrCast(audiostream), callback, userdata));
|
return @bitCast(c.SDL_SetAudioStreamPutCallback(@ptrCast(@alignCast(audiostream)), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyAudioStream(audiostream: *AudioStream) void {
|
pub inline fn destroyAudioStream(audiostream: *AudioStream) void {
|
||||||
return c.SDL_DestroyAudioStream(@ptrCast(audiostream));
|
return c.SDL_DestroyAudioStream(@ptrCast(@alignCast(audiostream)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -156,28 +160,28 @@ pub inline fn getCurrentAudioDriver() [*c]const u8 {
|
||||||
return c.SDL_GetCurrentAudioDriver();
|
return c.SDL_GetCurrentAudioDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioPlaybackDevices(count: *c_int) ?*AudioDeviceID {
|
pub inline fn getAudioPlaybackDevices(count: ?*c_int) ?*AudioDeviceID {
|
||||||
return @ptrCast(c.SDL_GetAudioPlaybackDevices(@ptrCast(count)));
|
return c.SDL_GetAudioPlaybackDevices(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioRecordingDevices(count: *c_int) ?*AudioDeviceID {
|
pub inline fn getAudioRecordingDevices(count: ?*c_int) ?*AudioDeviceID {
|
||||||
return @ptrCast(c.SDL_GetAudioRecordingDevices(@ptrCast(count)));
|
return c.SDL_GetAudioRecordingDevices(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceName(devid: AudioDeviceID) [*c]const u8 {
|
pub inline fn getAudioDeviceName(devid: AudioDeviceID) [*c]const u8 {
|
||||||
return c.SDL_GetAudioDeviceName(devid);
|
return c.SDL_GetAudioDeviceName(devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceFormat(devid: AudioDeviceID, spec: ?*AudioSpec, sample_frames: *c_int) bool {
|
pub inline fn getAudioDeviceFormat(devid: AudioDeviceID, spec: ?*AudioSpec, sample_frames: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetAudioDeviceFormat(devid, @ptrCast(spec), @ptrCast(sample_frames)));
|
return @bitCast(c.SDL_GetAudioDeviceFormat(devid, @ptrCast(@alignCast(spec)), sample_frames));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceChannelMap(devid: AudioDeviceID, count: *c_int) *c_int {
|
pub inline fn getAudioDeviceChannelMap(devid: AudioDeviceID, count: ?*c_int) *c_int {
|
||||||
return @ptrCast(c.SDL_GetAudioDeviceChannelMap(devid, @ptrCast(count)));
|
return c.SDL_GetAudioDeviceChannelMap(devid, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openAudioDevice(devid: AudioDeviceID, spec: ?*const AudioSpec) AudioDeviceID {
|
pub inline fn openAudioDevice(devid: AudioDeviceID, spec: ?*const AudioSpec) AudioDeviceID {
|
||||||
return c.SDL_OpenAudioDevice(devid, @ptrCast(spec));
|
return c.SDL_OpenAudioDevice(devid, @ptrCast(@alignCast(spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isAudioDevicePhysical(devid: AudioDeviceID) bool {
|
pub inline fn isAudioDevicePhysical(devid: AudioDeviceID) bool {
|
||||||
|
|
@ -212,20 +216,20 @@ pub inline fn closeAudioDevice(devid: AudioDeviceID) void {
|
||||||
return c.SDL_CloseAudioDevice(devid);
|
return c.SDL_CloseAudioDevice(devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindAudioStreams(devid: AudioDeviceID, streams: [*c]?*const AudioStream, num_streams: c_int) bool {
|
pub inline fn bindAudioStreams(devid: AudioDeviceID, streams: [*c]const ?*AudioStream, num_streams: c_int) bool {
|
||||||
return @bitCast(c.SDL_BindAudioStreams(devid, streams, num_streams));
|
return @bitCast(c.SDL_BindAudioStreams(devid, @ptrCast(@alignCast(streams)), num_streams));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindAudioStream(devid: AudioDeviceID, stream: ?*AudioStream) bool {
|
pub inline fn bindAudioStream(devid: AudioDeviceID, stream: ?*AudioStream) bool {
|
||||||
return @bitCast(c.SDL_BindAudioStream(devid, @ptrCast(stream)));
|
return @bitCast(c.SDL_BindAudioStream(devid, @ptrCast(@alignCast(stream))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unbindAudioStreams(streams: [*c]?*const AudioStream, num_streams: c_int) void {
|
pub inline fn unbindAudioStreams(streams: [*c]const ?*AudioStream, num_streams: c_int) void {
|
||||||
return c.SDL_UnbindAudioStreams(streams, num_streams);
|
return c.SDL_UnbindAudioStreams(@ptrCast(@alignCast(streams)), num_streams);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createAudioStream(src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) ?*AudioStream {
|
pub inline fn createAudioStream(src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) ?*AudioStream {
|
||||||
return @ptrCast(c.SDL_CreateAudioStream(@ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @ptrCast(@alignCast(c.SDL_CreateAudioStream(@ptrCast(@alignCast(src_spec)), @ptrCast(@alignCast(dst_spec)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const AudioStreamDataCompleteCallback = c.SDL_AudioStreamDataCompleteCallback;
|
pub const AudioStreamDataCompleteCallback = c.SDL_AudioStreamDataCompleteCallback;
|
||||||
|
|
@ -233,7 +237,7 @@ pub const AudioStreamDataCompleteCallback = c.SDL_AudioStreamDataCompleteCallbac
|
||||||
pub const AudioStreamCallback = c.SDL_AudioStreamCallback;
|
pub const AudioStreamCallback = c.SDL_AudioStreamCallback;
|
||||||
|
|
||||||
pub inline fn openAudioDeviceStream(devid: AudioDeviceID, spec: ?*const AudioSpec, callback: AudioStreamCallback, userdata: ?*anyopaque) ?*AudioStream {
|
pub inline fn openAudioDeviceStream(devid: AudioDeviceID, spec: ?*const AudioSpec, callback: AudioStreamCallback, userdata: ?*anyopaque) ?*AudioStream {
|
||||||
return @ptrCast(c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata));
|
return @ptrCast(@alignCast(c.SDL_OpenAudioDeviceStream(devid, @ptrCast(@alignCast(spec)), callback, userdata)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const AudioPostmixCallback = c.SDL_AudioPostmixCallback;
|
pub const AudioPostmixCallback = c.SDL_AudioPostmixCallback;
|
||||||
|
|
@ -242,26 +246,26 @@ pub inline fn setAudioPostmixCallback(devid: AudioDeviceID, callback: AudioPostm
|
||||||
return @bitCast(c.SDL_SetAudioPostmixCallback(devid, callback, userdata));
|
return @bitCast(c.SDL_SetAudioPostmixCallback(devid, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadWAV_IO(src: ?*IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
pub inline fn loadWAV_IO(src: ?*IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_LoadWAV_IO(@ptrCast(src), @bitCast(closeio), @ptrCast(spec), audio_buf, @ptrCast(audio_len)));
|
return @bitCast(c.SDL_LoadWAV_IO(@ptrCast(@alignCast(src)), @bitCast(closeio), @ptrCast(@alignCast(spec)), audio_buf, audio_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_LoadWAV(path, @ptrCast(spec), audio_buf, @ptrCast(audio_len)));
|
return @bitCast(c.SDL_LoadWAV(path, @ptrCast(@alignCast(spec)), audio_buf, audio_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mixAudio(dst: [*c]u8, src: [*c]const u8, format: AudioFormat, len: u32, volume: f32) bool {
|
pub inline fn mixAudio(dst: [*c]u8, src: [*c]const u8, format: AudioFormat, len: u32, volume: f32) bool {
|
||||||
return @bitCast(c.SDL_MixAudio(dst, src, @bitCast(format), len, volume));
|
return @bitCast(c.SDL_MixAudio(dst, src, @intCast(@backingInt(format)), len, volume));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertAudioSamples(src_spec: ?*const AudioSpec, src_data: [*c]const u8, src_len: c_int, dst_spec: ?*const AudioSpec, dst_data: [*c][*c]u8, dst_len: *c_int) bool {
|
pub inline fn convertAudioSamples(src_spec: ?*const AudioSpec, src_data: [*c]const u8, src_len: c_int, dst_spec: ?*const AudioSpec, dst_data: [*c][*c]u8, dst_len: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_ConvertAudioSamples(@ptrCast(src_spec), src_data, src_len, @ptrCast(dst_spec), dst_data, @ptrCast(dst_len)));
|
return @bitCast(c.SDL_ConvertAudioSamples(@ptrCast(@alignCast(src_spec)), src_data, src_len, @ptrCast(@alignCast(dst_spec)), dst_data, dst_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioFormatName(format: AudioFormat) [*c]const u8 {
|
pub inline fn getAudioFormatName(format: AudioFormat) [*c]const u8 {
|
||||||
return c.SDL_GetAudioFormatName(@bitCast(format));
|
return c.SDL_GetAudioFormatName(@intCast(@backingInt(format)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSilenceValueForFormat(format: AudioFormat) c_int {
|
pub inline fn getSilenceValueForFormat(format: AudioFormat) c_int {
|
||||||
return c.SDL_GetSilenceValueForFormat(@bitCast(format));
|
return c.SDL_GetSilenceValueForFormat(@intCast(@backingInt(format)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub const BlendOperation = enum(c_int) {
|
||||||
blendoperationSubtract = 0x2, //src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationSubtract = 0x2, //src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationRevSubtract = 0x3, //dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationRevSubtract = 0x3, //dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationMinimum = 0x4, //min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationMinimum = 0x4, //min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationMaximum = 0x5,
|
blendoperationMaximum = 0x5, //max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BlendFactor = enum(c_int) {
|
pub const BlendFactor = enum(c_int) {
|
||||||
|
|
@ -20,9 +20,9 @@ pub const BlendFactor = enum(c_int) {
|
||||||
blendfactorDstColor = 0x7, //dstR, dstG, dstB, dstA
|
blendfactorDstColor = 0x7, //dstR, dstG, dstB, dstA
|
||||||
blendfactorOneMinusDstColor = 0x8, //1-dstR, 1-dstG, 1-dstB, 1-dstA
|
blendfactorOneMinusDstColor = 0x8, //1-dstR, 1-dstG, 1-dstB, 1-dstA
|
||||||
blendfactorDstAlpha = 0x9, //dstA, dstA, dstA, dstA
|
blendfactorDstAlpha = 0x9, //dstA, dstA, dstA, dstA
|
||||||
blendfactorOneMinusDstAlpha = 0xA,
|
blendfactorOneMinusDstAlpha = 0xA, //1-dstA, 1-dstA, 1-dstA, 1-dstA
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn composeCustomBlendMode(srcColorFactor: BlendFactor, dstColorFactor: BlendFactor, colorOperation: BlendOperation, srcAlphaFactor: BlendFactor, dstAlphaFactor: BlendFactor, alphaOperation: BlendOperation) BlendMode {
|
pub inline fn composeCustomBlendMode(srcColorFactor: BlendFactor, dstColorFactor: BlendFactor, colorOperation: BlendOperation, srcAlphaFactor: BlendFactor, dstAlphaFactor: BlendFactor, alphaOperation: BlendOperation) BlendMode {
|
||||||
return @intFromEnum(c.SDL_ComposeCustomBlendMode(srcColorFactor, dstColorFactor, @intFromEnum(colorOperation), srcAlphaFactor, dstAlphaFactor, @intFromEnum(alphaOperation)));
|
return c.SDL_ComposeCustomBlendMode(@intCast(@backingInt(srcColorFactor)), @intCast(@backingInt(dstColorFactor)), @intCast(@backingInt(colorOperation)), @intCast(@backingInt(srcAlphaFactor)), @intCast(@backingInt(dstAlphaFactor)), @intCast(@backingInt(alphaOperation)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,31 +13,31 @@ pub const CameraID = u32;
|
||||||
|
|
||||||
pub const Camera = opaque {
|
pub const Camera = opaque {
|
||||||
pub inline fn getCameraPermissionState(camera: *Camera) CameraPermissionState {
|
pub inline fn getCameraPermissionState(camera: *Camera) CameraPermissionState {
|
||||||
return c.SDL_GetCameraPermissionState(@ptrCast(camera));
|
return @fromBackingInt(@intCast(c.SDL_GetCameraPermissionState(@ptrCast(@alignCast(camera)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraID(camera: *Camera) CameraID {
|
pub inline fn getCameraID(camera: *Camera) CameraID {
|
||||||
return c.SDL_GetCameraID(@ptrCast(camera));
|
return c.SDL_GetCameraID(@ptrCast(@alignCast(camera)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
||||||
return c.SDL_GetCameraProperties(@ptrCast(camera));
|
return c.SDL_GetCameraProperties(@ptrCast(@alignCast(camera)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
||||||
return @bitCast(c.SDL_GetCameraFormat(@ptrCast(camera), @ptrCast(spec)));
|
return @bitCast(c.SDL_GetCameraFormat(@ptrCast(@alignCast(camera)), @ptrCast(@alignCast(spec))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: *u64) ?*Surface {
|
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: ?*u64) ?*Surface {
|
||||||
return @ptrCast(c.SDL_AcquireCameraFrame(@ptrCast(camera), @ptrCast(timestampNS)));
|
return @ptrCast(@alignCast(c.SDL_AcquireCameraFrame(@ptrCast(@alignCast(camera)), timestampNS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
||||||
return c.SDL_ReleaseCameraFrame(@ptrCast(camera), @ptrCast(frame));
|
return c.SDL_ReleaseCameraFrame(@ptrCast(@alignCast(camera)), @ptrCast(@alignCast(frame)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeCamera(camera: *Camera) void {
|
pub inline fn closeCamera(camera: *Camera) void {
|
||||||
return c.SDL_CloseCamera(@ptrCast(camera));
|
return c.SDL_CloseCamera(@ptrCast(@alignCast(camera)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -57,6 +57,7 @@ pub const CameraPosition = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CameraPermissionState = enum(c_int) {
|
pub const CameraPermissionState = enum(c_int) {
|
||||||
|
cameraPermissionStateDenied = -1,
|
||||||
cameraPermissionStatePending,
|
cameraPermissionStatePending,
|
||||||
cameraPermissionStateApproved,
|
cameraPermissionStateApproved,
|
||||||
};
|
};
|
||||||
|
|
@ -73,12 +74,12 @@ pub inline fn getCurrentCameraDriver() [*c]const u8 {
|
||||||
return c.SDL_GetCurrentCameraDriver();
|
return c.SDL_GetCurrentCameraDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameras(count: *c_int) ?*CameraID {
|
pub inline fn getCameras(count: ?*c_int) ?*CameraID {
|
||||||
return @ptrCast(c.SDL_GetCameras(@ptrCast(count)));
|
return c.SDL_GetCameras(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: *c_int) [*c]?*CameraSpec {
|
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: ?*c_int) [*c]?*CameraSpec {
|
||||||
return c.SDL_GetCameraSupportedFormats(instance_id, @ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetCameraSupportedFormats(instance_id, count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraName(instance_id: CameraID) [*c]const u8 {
|
pub inline fn getCameraName(instance_id: CameraID) [*c]const u8 {
|
||||||
|
|
@ -86,9 +87,9 @@ pub inline fn getCameraName(instance_id: CameraID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
||||||
return c.SDL_GetCameraPosition(instance_id);
|
return @fromBackingInt(@intCast(c.SDL_GetCameraPosition(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openCamera(instance_id: CameraID, spec: ?*const CameraSpec) ?*Camera {
|
pub inline fn openCamera(instance_id: CameraID, spec: ?*const CameraSpec) ?*Camera {
|
||||||
return @ptrCast(c.SDL_OpenCamera(instance_id, @ptrCast(spec)));
|
return @ptrCast(@alignCast(c.SDL_OpenCamera(instance_id, @ptrCast(@alignCast(spec)))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub const ClipboardDataCallback = c.SDL_ClipboardDataCallback;
|
||||||
|
|
||||||
pub const ClipboardCleanupCallback = c.SDL_ClipboardCleanupCallback;
|
pub const ClipboardCleanupCallback = c.SDL_ClipboardCleanupCallback;
|
||||||
|
|
||||||
pub inline fn setClipboardData(callback: ClipboardDataCallback, cleanup: ClipboardCleanupCallback, userdata: ?*anyopaque, mime_types: [*c][*c]const u8, num_mime_types: usize) bool {
|
pub inline fn setClipboardData(callback: ClipboardDataCallback, cleanup: ClipboardCleanupCallback, userdata: ?*anyopaque, mime_types: [*c]const [*c]const u8, num_mime_types: usize) bool {
|
||||||
return @bitCast(c.SDL_SetClipboardData(callback, cleanup, userdata, mime_types, num_mime_types));
|
return @bitCast(c.SDL_SetClipboardData(callback, cleanup, userdata, mime_types, num_mime_types));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,14 +36,14 @@ pub inline fn clearClipboardData() bool {
|
||||||
return @bitCast(c.SDL_ClearClipboardData());
|
return @bitCast(c.SDL_ClearClipboardData());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClipboardData(mime_type: [*c]const u8, size: *usize) ?*anyopaque {
|
pub inline fn getClipboardData(mime_type: [*c]const u8, size: ?*usize) ?*anyopaque {
|
||||||
return c.SDL_GetClipboardData(mime_type, @ptrCast(size));
|
return c.SDL_GetClipboardData(mime_type, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasClipboardData(mime_type: [*c]const u8) bool {
|
pub inline fn hasClipboardData(mime_type: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_HasClipboardData(mime_type));
|
return @bitCast(c.SDL_HasClipboardData(mime_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClipboardMimeTypes(num_mime_types: *usize) [*c][*c]u8 {
|
pub inline fn getClipboardMimeTypes(num_mime_types: ?*usize) [*c][*c]u8 {
|
||||||
return c.SDL_GetClipboardMimeTypes(@ptrCast(num_mime_types));
|
return c.SDL_GetClipboardMimeTypes(num_mime_types);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,15 @@ pub const DialogFileFilter = extern struct {
|
||||||
pub const DialogFileCallback = c.SDL_DialogFileCallback;
|
pub const DialogFileCallback = c.SDL_DialogFileCallback;
|
||||||
|
|
||||||
pub inline fn showOpenFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: ?*const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8, allow_many: bool) void {
|
pub inline fn showOpenFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: ?*const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8, allow_many: bool) void {
|
||||||
return c.SDL_ShowOpenFileDialog(callback, userdata, @ptrCast(window), @ptrCast(filters), nfilters, default_location, @bitCast(allow_many));
|
return c.SDL_ShowOpenFileDialog(callback, userdata, @ptrCast(@alignCast(window)), @ptrCast(@alignCast(filters)), nfilters, default_location, @bitCast(allow_many));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showSaveFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: ?*const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8) void {
|
pub inline fn showSaveFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: ?*const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8) void {
|
||||||
return c.SDL_ShowSaveFileDialog(callback, userdata, @ptrCast(window), @ptrCast(filters), nfilters, default_location);
|
return c.SDL_ShowSaveFileDialog(callback, userdata, @ptrCast(@alignCast(window)), @ptrCast(@alignCast(filters)), nfilters, default_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showOpenFolderDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, default_location: [*c]const u8, allow_many: bool) void {
|
pub inline fn showOpenFolderDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, default_location: [*c]const u8, allow_many: bool) void {
|
||||||
return c.SDL_ShowOpenFolderDialog(callback, userdata, @ptrCast(window), default_location, @bitCast(allow_many));
|
return c.SDL_ShowOpenFolderDialog(callback, userdata, @ptrCast(@alignCast(window)), default_location, @bitCast(allow_many));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const FileDialogType = enum(c_int) {
|
pub const FileDialogType = enum(c_int) {
|
||||||
|
|
@ -32,5 +32,5 @@ pub const FileDialogType = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn showFileDialogWithProperties(_type: FileDialogType, callback: DialogFileCallback, userdata: ?*anyopaque, props: PropertiesID) void {
|
pub inline fn showFileDialogWithProperties(_type: FileDialogType, callback: DialogFileCallback, userdata: ?*anyopaque, props: PropertiesID) void {
|
||||||
return c.SDL_ShowFileDialogWithProperties(@intFromEnum(_type), callback, userdata, props);
|
return c.SDL_ShowFileDialogWithProperties(@intCast(@backingInt(_type)), callback, userdata, props);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
pub const unsupported = struct {
|
||||||
|
pub const SDL_SetError = "varargs function is not representable in Zig";
|
||||||
|
pub const SDL_SetErrorV = "varargs function is not representable in Zig";
|
||||||
|
};
|
||||||
|
|
||||||
pub inline fn outOfMemory() bool {
|
pub inline fn outOfMemory() bool {
|
||||||
return @bitCast(c.SDL_OutOfMemory());
|
return @bitCast(c.SDL_OutOfMemory());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,11 @@ pub const MouseButtonFlags = mouse_api.MouseButtonFlags;
|
||||||
pub const Scancode = scancode_api.Scancode;
|
pub const Scancode = scancode_api.Scancode;
|
||||||
pub const TouchID = touch_api.TouchID;
|
pub const TouchID = touch_api.TouchID;
|
||||||
pub const KeyboardID = keyboard_api.KeyboardID;
|
pub const KeyboardID = keyboard_api.KeyboardID;
|
||||||
|
pub const PenDeviceType = pen_api.PenDeviceType;
|
||||||
pub const PenAxis = pen_api.PenAxis;
|
pub const PenAxis = pen_api.PenAxis;
|
||||||
pub const MouseID = mouse_api.MouseID;
|
pub const MouseID = mouse_api.MouseID;
|
||||||
pub const MouseWheelDirection = mouse_api.MouseWheelDirection;
|
|
||||||
pub const PowerState = power_api.PowerState;
|
pub const PowerState = power_api.PowerState;
|
||||||
|
pub const MouseWheelDirection = mouse_api.MouseWheelDirection;
|
||||||
pub const Window = video_api.Window;
|
pub const Window = video_api.Window;
|
||||||
pub const FingerID = touch_api.FingerID;
|
pub const FingerID = touch_api.FingerID;
|
||||||
pub const Keycode = keycode_api.Keycode;
|
pub const Keycode = keycode_api.Keycode;
|
||||||
|
|
@ -37,12 +38,12 @@ pub const Keymod = keycode_api.Keymod;
|
||||||
pub const EventType = enum(c_int) {
|
pub const EventType = enum(c_int) {
|
||||||
eventFirst = 0, //Unused (do not remove)
|
eventFirst = 0, //Unused (do not remove)
|
||||||
eventQuit = 0x100, //User-requested quit
|
eventQuit = 0x100, //User-requested quit
|
||||||
eventTerminating,
|
eventTerminating, //The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillTerminate() Called on Android in onDestroy()
|
||||||
eventLowMemory,
|
eventLowMemory, //The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onTrimMemory()
|
||||||
eventWillEnterBackground,
|
eventWillEnterBackground, //The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillResignActive() Called on Android in onPause()
|
||||||
eventDidEnterBackground,
|
eventDidEnterBackground, //The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidEnterBackground() Called on Android in onPause()
|
||||||
eventWillEnterForeground,
|
eventWillEnterForeground, //The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillEnterForeground() Called on Android in onResume()
|
||||||
eventDidEnterForeground,
|
eventDidEnterForeground, //The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidBecomeActive() Called on Android in onResume()
|
||||||
eventLocaleChanged, //The user's locale preferences have changed.
|
eventLocaleChanged, //The user's locale preferences have changed.
|
||||||
eventSystemThemeChanged, //The system theme changed
|
eventSystemThemeChanged, //The system theme changed
|
||||||
eventDisplayOrientation = 0x151, //Display orientation has changed to data1
|
eventDisplayOrientation = 0x151, //Display orientation has changed to data1
|
||||||
|
|
@ -55,7 +56,7 @@ pub const EventType = enum(c_int) {
|
||||||
eventDisplayUsableBoundsChanged, //Display has changed usable bounds
|
eventDisplayUsableBoundsChanged, //Display has changed usable bounds
|
||||||
eventWindowShown = 0x202, //Window has been shown
|
eventWindowShown = 0x202, //Window has been shown
|
||||||
eventWindowHidden, //Window has been hidden
|
eventWindowHidden, //Window has been hidden
|
||||||
eventWindowExposed,
|
eventWindowExposed, //Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event. data1 is 1 for live-resize expose events, 0 otherwise.
|
||||||
eventWindowMoved, //Window has been moved to data1, data2
|
eventWindowMoved, //Window has been moved to data1, data2
|
||||||
eventWindowResized, //Window has been resized to data1xdata2
|
eventWindowResized, //Window has been resized to data1xdata2
|
||||||
eventWindowPixelSizeChanged, //The pixel size of the window has changed to data1xdata2
|
eventWindowPixelSizeChanged, //The pixel size of the window has changed to data1xdata2
|
||||||
|
|
@ -76,13 +77,13 @@ pub const EventType = enum(c_int) {
|
||||||
eventWindowOccluded, //The window has been occluded
|
eventWindowOccluded, //The window has been occluded
|
||||||
eventWindowEnterFullscreen, //The window has entered fullscreen mode
|
eventWindowEnterFullscreen, //The window has entered fullscreen mode
|
||||||
eventWindowLeaveFullscreen, //The window has left fullscreen mode
|
eventWindowLeaveFullscreen, //The window has left fullscreen mode
|
||||||
eventWindowDestroyed,
|
eventWindowDestroyed, //The window with the associated ID is being or has been destroyed. If this message is being handled in an event watcher, the window handle is still valid and can still be used to retrieve any properties associated with the window. Otherwise, the handle has already been destroyed and all resources associated with it are invalid
|
||||||
eventWindowHdrStateChanged, //Window HDR properties have changed
|
eventWindowHdrStateChanged, //Window HDR properties have changed
|
||||||
eventKeyDown = 0x300, //Key pressed
|
eventKeyDown = 0x300, //Key pressed
|
||||||
eventKeyUp, //Key released
|
eventKeyUp, //Key released
|
||||||
eventTextEditing, //Keyboard text editing (composition)
|
eventTextEditing, //Keyboard text editing (composition)
|
||||||
eventTextInput, //Keyboard text input
|
eventTextInput, //Keyboard text input
|
||||||
eventKeymapChanged,
|
eventKeymapChanged, //Keymap changed due to a system event such as an input language or keyboard layout change.
|
||||||
eventKeyboardAdded, //A new keyboard has been inserted into the system
|
eventKeyboardAdded, //A new keyboard has been inserted into the system
|
||||||
eventKeyboardRemoved, //A keyboard has been removed
|
eventKeyboardRemoved, //A keyboard has been removed
|
||||||
eventTextEditingCandidates, //Keyboard text editing candidates
|
eventTextEditingCandidates, //Keyboard text editing candidates
|
||||||
|
|
@ -115,6 +116,7 @@ pub const EventType = enum(c_int) {
|
||||||
eventGamepadSensorUpdate, //Gamepad sensor was updated
|
eventGamepadSensorUpdate, //Gamepad sensor was updated
|
||||||
eventGamepadUpdateComplete, //Gamepad update is complete
|
eventGamepadUpdateComplete, //Gamepad update is complete
|
||||||
eventGamepadSteamHandleUpdated, //Gamepad Steam handle has changed
|
eventGamepadSteamHandleUpdated, //Gamepad Steam handle has changed
|
||||||
|
eventFingerDown = 0x700,
|
||||||
eventFingerUp,
|
eventFingerUp,
|
||||||
eventFingerMotion,
|
eventFingerMotion,
|
||||||
eventFingerCanceled,
|
eventFingerCanceled,
|
||||||
|
|
@ -146,10 +148,19 @@ pub const EventType = enum(c_int) {
|
||||||
eventRenderTargetsReset = 0x2000, //The render targets have been reset and their contents need to be updated
|
eventRenderTargetsReset = 0x2000, //The render targets have been reset and their contents need to be updated
|
||||||
eventRenderDeviceReset, //The device has been reset and all textures need to be recreated
|
eventRenderDeviceReset, //The device has been reset and all textures need to be recreated
|
||||||
eventRenderDeviceLost, //The device has been lost and can't be recovered.
|
eventRenderDeviceLost, //The device has been lost and can't be recovered.
|
||||||
|
eventPrivate0 = 0x4000,
|
||||||
eventPrivate1,
|
eventPrivate1,
|
||||||
eventPrivate2,
|
eventPrivate2,
|
||||||
eventPrivate3,
|
eventPrivate3,
|
||||||
eventPollSentinel = 0x7F00, //Signals the end of an event poll cycle
|
eventPollSentinel = 0x7F00, //Signals the end of an event poll cycle
|
||||||
|
eventUser = 0x8000,
|
||||||
|
eventLast = 0xFFFF,
|
||||||
|
eventEnumPadding = 0x7FFFFFFF,
|
||||||
|
|
||||||
|
pub const eventDisplayFirst = .eventDisplayOrientation;
|
||||||
|
pub const eventDisplayLast = .eventDisplayUsableBoundsChanged;
|
||||||
|
pub const eventWindowFirst = .eventWindowShown;
|
||||||
|
pub const eventWindowLast = .eventWindowHdrStateChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CommonEvent = extern struct {
|
pub const CommonEvent = extern struct {
|
||||||
|
|
@ -212,7 +223,7 @@ pub const TextEditingCandidatesEvent = extern struct {
|
||||||
reserved: u32,
|
reserved: u32,
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
windowID: WindowID, // The window with keyboard focus, if any
|
windowID: WindowID, // The window with keyboard focus, if any
|
||||||
candidates: [*c]const [*c]const u8, // The list of candidates, or NULL if there are no candidates available
|
candidates: [*c][*c]const u8, // The list of candidates, or NULL if there are no candidates available
|
||||||
num_candidates: i32, // The number of strings in `candidates`
|
num_candidates: i32, // The number of strings in `candidates`
|
||||||
selected_candidate: i32, // The index of the selected candidate, or -1 if no candidate is selected
|
selected_candidate: i32, // The index of the selected candidate, or -1 if no candidate is selected
|
||||||
horizontal: bool, // true if the list is horizontal, false if it's vertical
|
horizontal: bool, // true if the list is horizontal, false if it's vertical
|
||||||
|
|
@ -241,7 +252,7 @@ pub const MouseMotionEvent = extern struct {
|
||||||
reserved: u32,
|
reserved: u32,
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
windowID: WindowID, // The window with mouse focus, if any
|
windowID: WindowID, // The window with mouse focus, if any
|
||||||
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0
|
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, SDL_PEN_MOUSEID for pen events, or 0
|
||||||
state: MouseButtonFlags, // The current button state
|
state: MouseButtonFlags, // The current button state
|
||||||
x: f32, // X coordinate, relative to window
|
x: f32, // X coordinate, relative to window
|
||||||
y: f32, // Y coordinate, relative to window
|
y: f32, // Y coordinate, relative to window
|
||||||
|
|
@ -310,6 +321,7 @@ pub const JoyHatEvent = extern struct {
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
which: JoystickID, // The joystick instance id
|
which: JoystickID, // The joystick instance id
|
||||||
hat: u8, // The joystick hat index
|
hat: u8, // The joystick hat index
|
||||||
|
value: u8,
|
||||||
padding1: u8,
|
padding1: u8,
|
||||||
padding2: u8,
|
padding2: u8,
|
||||||
};
|
};
|
||||||
|
|
@ -447,6 +459,8 @@ pub const PenProximityEvent = extern struct {
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
windowID: WindowID, // The window with pen focus, if any
|
windowID: WindowID, // The window with pen focus, if any
|
||||||
which: PenID, // The pen instance id
|
which: PenID, // The pen instance id
|
||||||
|
pen_state: PenInputFlags, // Complete pen input state at time of event (added in 3.4.16).
|
||||||
|
device_type: PenDeviceType, // the device type of the pen, if known (added in 3.4.18).
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PenMotionEvent = extern struct {
|
pub const PenMotionEvent = extern struct {
|
||||||
|
|
@ -458,6 +472,7 @@ pub const PenMotionEvent = extern struct {
|
||||||
pen_state: PenInputFlags, // Complete pen input state at time of event
|
pen_state: PenInputFlags, // Complete pen input state at time of event
|
||||||
x: f32, // X coordinate, relative to window
|
x: f32, // X coordinate, relative to window
|
||||||
y: f32, // Y coordinate, relative to window
|
y: f32, // Y coordinate, relative to window
|
||||||
|
device_type: PenDeviceType, // the device type of the pen, if known (added in 3.4.18).
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PenTouchEvent = extern struct {
|
pub const PenTouchEvent = extern struct {
|
||||||
|
|
@ -471,6 +486,7 @@ pub const PenTouchEvent = extern struct {
|
||||||
y: f32, // Y coordinate, relative to window
|
y: f32, // Y coordinate, relative to window
|
||||||
eraser: bool, // true if eraser end is used (not all pens support this).
|
eraser: bool, // true if eraser end is used (not all pens support this).
|
||||||
down: bool, // true if the pen is touching or false if the pen is lifted off
|
down: bool, // true if the pen is touching or false if the pen is lifted off
|
||||||
|
device_type: PenDeviceType, // the device type of the pen, if known (added in 3.4.18).
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PenButtonEvent = extern struct {
|
pub const PenButtonEvent = extern struct {
|
||||||
|
|
@ -484,6 +500,7 @@ pub const PenButtonEvent = extern struct {
|
||||||
y: f32, // Y coordinate, relative to window
|
y: f32, // Y coordinate, relative to window
|
||||||
button: u8, // The pen button index (first button is 1).
|
button: u8, // The pen button index (first button is 1).
|
||||||
down: bool, // true if the button is pressed
|
down: bool, // true if the button is pressed
|
||||||
|
device_type: PenDeviceType, // the device type of the pen, if known (added in 3.4.18).
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PenAxisEvent = extern struct {
|
pub const PenAxisEvent = extern struct {
|
||||||
|
|
@ -497,6 +514,7 @@ pub const PenAxisEvent = extern struct {
|
||||||
y: f32, // Y coordinate, relative to window
|
y: f32, // Y coordinate, relative to window
|
||||||
axis: PenAxis, // Axis that has changed
|
axis: PenAxis, // Axis that has changed
|
||||||
value: f32, // New value of axis
|
value: f32, // New value of axis
|
||||||
|
device_type: PenDeviceType, // the device type of the pen, if known (added in 3.4.18).
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DropEvent = extern struct {
|
pub const DropEvent = extern struct {
|
||||||
|
|
@ -598,7 +616,7 @@ pub const EventAction = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32) c_int {
|
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32) c_int {
|
||||||
return c.SDL_PeepEvents(@ptrCast(events), numevents, action, minType, maxType);
|
return c.SDL_PeepEvents(@ptrCast(@alignCast(events)), numevents, @intCast(@backingInt(action)), minType, maxType);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasEvent(_type: u32) bool {
|
pub inline fn hasEvent(_type: u32) bool {
|
||||||
|
|
@ -618,19 +636,19 @@ pub inline fn flushEvents(minType: u32, maxType: u32) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pollEvent(event: ?*Event) bool {
|
pub inline fn pollEvent(event: ?*Event) bool {
|
||||||
return @bitCast(c.SDL_PollEvent(@ptrCast(event)));
|
return @bitCast(c.SDL_PollEvent(@ptrCast(@alignCast(event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitEvent(event: ?*Event) bool {
|
pub inline fn waitEvent(event: ?*Event) bool {
|
||||||
return @bitCast(c.SDL_WaitEvent(@ptrCast(event)));
|
return @bitCast(c.SDL_WaitEvent(@ptrCast(@alignCast(event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitEventTimeout(event: ?*Event, timeoutMS: i32) bool {
|
pub inline fn waitEventTimeout(event: ?*Event, timeoutMS: i32) bool {
|
||||||
return @bitCast(c.SDL_WaitEventTimeout(@ptrCast(event), timeoutMS));
|
return @bitCast(c.SDL_WaitEventTimeout(@ptrCast(@alignCast(event)), timeoutMS));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushEvent(event: ?*Event) bool {
|
pub inline fn pushEvent(event: ?*Event) bool {
|
||||||
return @bitCast(c.SDL_PushEvent(@ptrCast(event)));
|
return @bitCast(c.SDL_PushEvent(@ptrCast(@alignCast(event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const EventFilter = c.SDL_EventFilter;
|
pub const EventFilter = c.SDL_EventFilter;
|
||||||
|
|
@ -640,7 +658,7 @@ pub inline fn setEventFilter(filter: EventFilter, userdata: ?*anyopaque) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getEventFilter(filter: ?*EventFilter, userdata: [*c]?*anyopaque) bool {
|
pub inline fn getEventFilter(filter: ?*EventFilter, userdata: [*c]?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_GetEventFilter(@ptrCast(filter), userdata));
|
return @bitCast(c.SDL_GetEventFilter(filter, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addEventWatch(filter: EventFilter, userdata: ?*anyopaque) bool {
|
pub inline fn addEventWatch(filter: EventFilter, userdata: ?*anyopaque) bool {
|
||||||
|
|
@ -668,9 +686,9 @@ pub inline fn registerEvents(numevents: c_int) u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFromEvent(event: ?*const Event) ?*Window {
|
pub inline fn getWindowFromEvent(event: ?*const Event) ?*Window {
|
||||||
return @ptrCast(c.SDL_GetWindowFromEvent(@ptrCast(event)));
|
return @ptrCast(@alignCast(c.SDL_GetWindowFromEvent(@ptrCast(@alignCast(event)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getEventDescription(event: ?*const Event, buf: [*c]u8, buflen: c_int) c_int {
|
pub inline fn getEventDescription(event: ?*const Event, buf: [*c]u8, buflen: c_int) c_int {
|
||||||
return c.SDL_GetEventDescription(@ptrCast(event), buf, buflen);
|
return c.SDL_GetEventDescription(@ptrCast(@alignCast(event)), buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,18 @@ pub const Folder = enum(c_int) {
|
||||||
folderScreenshots, //Application screenshots.
|
folderScreenshots, //Application screenshots.
|
||||||
folderTemplates, //Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file.
|
folderTemplates, //Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file.
|
||||||
folderVideos, //Video files that can be played using a standard video player (mp4, webm...).
|
folderVideos, //Video files that can be played using a standard video player (mp4, webm...).
|
||||||
folderCount,
|
folderCount, //Total number of types in this enum, not a folder type by itself.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getUserFolder(folder: Folder) [*c]const u8 {
|
pub inline fn getUserFolder(folder: Folder) [*c]const u8 {
|
||||||
return c.SDL_GetUserFolder(folder);
|
return c.SDL_GetUserFolder(@intCast(@backingInt(folder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const PathType = enum(c_int) {
|
pub const PathType = enum(c_int) {
|
||||||
pathtypeNone, //path does not exist
|
pathtypeNone, //path does not exist
|
||||||
pathtypeFile, //a normal file
|
pathtypeFile, //a normal file
|
||||||
pathtypeDirectory, //a directory
|
pathtypeDirectory, //a directory
|
||||||
pathtypeOther,
|
pathtypeOther, //something completely different like a device node (not a symlink, those are always followed)
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PathInfo = extern struct {
|
pub const PathInfo = extern struct {
|
||||||
|
|
@ -61,7 +61,7 @@ pub inline fn createDirectory(path: [*c]const u8) bool {
|
||||||
pub const EnumerationResult = enum(c_int) {
|
pub const EnumerationResult = enum(c_int) {
|
||||||
enumContinue, //Value that requests that enumeration continue.
|
enumContinue, //Value that requests that enumeration continue.
|
||||||
enumSuccess, //Value that requests that enumeration stop, successfully.
|
enumSuccess, //Value that requests that enumeration stop, successfully.
|
||||||
enumFailure,
|
enumFailure, //Value that requests that enumeration stop, as a failure.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
||||||
|
|
@ -83,11 +83,11 @@ pub inline fn copyFile(oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool {
|
pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool {
|
||||||
return @bitCast(c.SDL_GetPathInfo(path, @ptrCast(info)));
|
return @bitCast(c.SDL_GetPathInfo(path, @ptrCast(@alignCast(info))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn globDirectory(path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: *c_int) [*c][*c]u8 {
|
pub inline fn globDirectory(path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: ?*c_int) [*c][*c]u8 {
|
||||||
return c.SDL_GlobDirectory(path, pattern, @bitCast(flags), @ptrCast(count));
|
return c.SDL_GlobDirectory(path, pattern, @bitCast(flags), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentDirectory() [*c]u8 {
|
pub inline fn getCurrentDirectory() [*c]u8 {
|
||||||
|
|
|
||||||
141
api/gamepad.zig
141
api/gamepad.zig
|
|
@ -18,167 +18,168 @@ pub const Joystick = joystick_api.Joystick;
|
||||||
|
|
||||||
pub const Gamepad = opaque {
|
pub const Gamepad = opaque {
|
||||||
pub inline fn getGamepadMapping(gamepad: *Gamepad) [*c]u8 {
|
pub inline fn getGamepadMapping(gamepad: *Gamepad) [*c]u8 {
|
||||||
return c.SDL_GetGamepadMapping(@ptrCast(gamepad));
|
return c.SDL_GetGamepadMapping(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProperties(gamepad: *Gamepad) PropertiesID {
|
pub inline fn getGamepadProperties(gamepad: *Gamepad) PropertiesID {
|
||||||
return c.SDL_GetGamepadProperties(@ptrCast(gamepad));
|
return c.SDL_GetGamepadProperties(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadID(gamepad: *Gamepad) JoystickID {
|
pub inline fn getGamepadID(gamepad: *Gamepad) JoystickID {
|
||||||
return c.SDL_GetGamepadID(@ptrCast(gamepad));
|
return c.SDL_GetGamepadID(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadName(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadName(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadName(@ptrCast(gamepad));
|
return c.SDL_GetGamepadName(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPath(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadPath(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadPath(@ptrCast(gamepad));
|
return c.SDL_GetGamepadPath(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadType(gamepad: *Gamepad) GamepadType {
|
pub inline fn getGamepadType(gamepad: *Gamepad) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetGamepadType(@ptrCast(gamepad)));
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadType(@ptrCast(@alignCast(gamepad)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRealGamepadType(gamepad: *Gamepad) GamepadType {
|
pub inline fn getRealGamepadType(gamepad: *Gamepad) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetRealGamepadType(@ptrCast(gamepad)));
|
return @fromBackingInt(@intCast(c.SDL_GetRealGamepadType(@ptrCast(@alignCast(gamepad)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPlayerIndex(gamepad: *Gamepad) c_int {
|
pub inline fn getGamepadPlayerIndex(gamepad: *Gamepad) c_int {
|
||||||
return c.SDL_GetGamepadPlayerIndex(@ptrCast(gamepad));
|
return c.SDL_GetGamepadPlayerIndex(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadPlayerIndex(gamepad: *Gamepad, player_index: c_int) bool {
|
pub inline fn setGamepadPlayerIndex(gamepad: *Gamepad, player_index: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetGamepadPlayerIndex(@ptrCast(gamepad), player_index));
|
return @bitCast(c.SDL_SetGamepadPlayerIndex(@ptrCast(@alignCast(gamepad)), player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadVendor(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadVendor(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadVendor(@ptrCast(gamepad));
|
return c.SDL_GetGamepadVendor(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProduct(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadProduct(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadProduct(@ptrCast(gamepad));
|
return c.SDL_GetGamepadProduct(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProductVersion(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadProductVersion(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadProductVersion(@ptrCast(gamepad));
|
return c.SDL_GetGamepadProductVersion(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFirmwareVersion(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadFirmwareVersion(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadFirmwareVersion(@ptrCast(gamepad));
|
return c.SDL_GetGamepadFirmwareVersion(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSerial(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadSerial(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadSerial(@ptrCast(gamepad));
|
return c.SDL_GetGamepadSerial(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSteamHandle(gamepad: *Gamepad) u64 {
|
pub inline fn getGamepadSteamHandle(gamepad: *Gamepad) u64 {
|
||||||
return c.SDL_GetGamepadSteamHandle(@ptrCast(gamepad));
|
return c.SDL_GetGamepadSteamHandle(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadConnectionState(gamepad: *Gamepad) JoystickConnectionState {
|
pub inline fn getGamepadConnectionState(gamepad: *Gamepad) JoystickConnectionState {
|
||||||
return c.SDL_GetGamepadConnectionState(@ptrCast(gamepad));
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadConnectionState(@ptrCast(@alignCast(gamepad)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPowerInfo(gamepad: *Gamepad, percent: *c_int) PowerState {
|
pub inline fn getGamepadPowerInfo(gamepad: *Gamepad, percent: ?*c_int) PowerState {
|
||||||
return c.SDL_GetGamepadPowerInfo(@ptrCast(gamepad), @ptrCast(percent));
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadPowerInfo(@ptrCast(@alignCast(gamepad)), percent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadConnected(gamepad: *Gamepad) bool {
|
pub inline fn gamepadConnected(gamepad: *Gamepad) bool {
|
||||||
return @bitCast(c.SDL_GamepadConnected(@ptrCast(gamepad)));
|
return @bitCast(c.SDL_GamepadConnected(@ptrCast(@alignCast(gamepad))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadJoystick(gamepad: *Gamepad) ?*Joystick {
|
pub inline fn getGamepadJoystick(gamepad: *Gamepad) ?*Joystick {
|
||||||
return @ptrCast(c.SDL_GetGamepadJoystick(@ptrCast(gamepad)));
|
return @ptrCast(@alignCast(c.SDL_GetGamepadJoystick(@ptrCast(@alignCast(gamepad)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadBindings(gamepad: *Gamepad, count: *c_int) [*c]?*GamepadBinding {
|
pub inline fn getGamepadBindings(gamepad: *Gamepad, count: ?*c_int) [*c]?*GamepadBinding {
|
||||||
return c.SDL_GetGamepadBindings(@ptrCast(gamepad), @ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetGamepadBindings(@ptrCast(@alignCast(gamepad)), count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasAxis(gamepad: *Gamepad, axis: GamepadAxis) bool {
|
pub inline fn gamepadHasAxis(gamepad: *Gamepad, axis: GamepadAxis) bool {
|
||||||
return @bitCast(c.SDL_GamepadHasAxis(@ptrCast(gamepad), axis));
|
return @bitCast(c.SDL_GamepadHasAxis(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(axis))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAxis(gamepad: *Gamepad, axis: GamepadAxis) i16 {
|
pub inline fn getGamepadAxis(gamepad: *Gamepad, axis: GamepadAxis) i16 {
|
||||||
return c.SDL_GetGamepadAxis(@ptrCast(gamepad), axis);
|
return c.SDL_GetGamepadAxis(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(axis)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
pub inline fn gamepadHasButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
||||||
return @bitCast(c.SDL_GamepadHasButton(@ptrCast(gamepad), button));
|
return @bitCast(c.SDL_GamepadHasButton(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(button))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
pub inline fn getGamepadButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
||||||
return @bitCast(c.SDL_GetGamepadButton(@ptrCast(gamepad), button));
|
return @bitCast(c.SDL_GetGamepadButton(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(button))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButtonLabel(gamepad: *Gamepad, button: GamepadButton) GamepadButtonLabel {
|
pub inline fn getGamepadButtonLabel(gamepad: *Gamepad, button: GamepadButton) GamepadButtonLabel {
|
||||||
return c.SDL_GetGamepadButtonLabel(@ptrCast(gamepad), button);
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadButtonLabel(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(button)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumGamepadTouchpads(gamepad: *Gamepad) c_int {
|
pub inline fn getNumGamepadTouchpads(gamepad: *Gamepad) c_int {
|
||||||
return c.SDL_GetNumGamepadTouchpads(@ptrCast(gamepad));
|
return c.SDL_GetNumGamepadTouchpads(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumGamepadTouchpadFingers(gamepad: *Gamepad, touchpad: c_int) c_int {
|
pub inline fn getNumGamepadTouchpadFingers(gamepad: *Gamepad, touchpad: c_int) c_int {
|
||||||
return c.SDL_GetNumGamepadTouchpadFingers(@ptrCast(gamepad), touchpad);
|
return c.SDL_GetNumGamepadTouchpadFingers(@ptrCast(@alignCast(gamepad)), touchpad);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadTouchpadFinger(gamepad: *Gamepad, touchpad: c_int, finger: c_int, down: *bool, x: *f32, y: *f32, pressure: *f32) bool {
|
pub inline fn getGamepadTouchpadFinger(gamepad: *Gamepad, touchpad: c_int, finger: c_int, down: ?*bool, x: ?*f32, y: ?*f32, pressure: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetGamepadTouchpadFinger(@ptrCast(gamepad), touchpad, finger, @ptrCast(down), @ptrCast(x), @ptrCast(y), @ptrCast(pressure)));
|
return @bitCast(c.SDL_GetGamepadTouchpadFinger(@ptrCast(@alignCast(gamepad)), touchpad, finger, @ptrCast(@alignCast(down)), x, y, pressure));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasSensor(gamepad: *Gamepad, _type: SensorType) bool {
|
pub inline fn gamepadHasSensor(gamepad: *Gamepad, _type: SensorType) bool {
|
||||||
return @bitCast(c.SDL_GamepadHasSensor(@ptrCast(gamepad), @intFromEnum(_type)));
|
return @bitCast(c.SDL_GamepadHasSensor(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(_type))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType, enabled: bool) bool {
|
pub inline fn setGamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType, enabled: bool) bool {
|
||||||
return @bitCast(c.SDL_SetGamepadSensorEnabled(@ptrCast(gamepad), @intFromEnum(_type), @bitCast(enabled)));
|
return @bitCast(c.SDL_SetGamepadSensorEnabled(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(_type)), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType) bool {
|
pub inline fn gamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType) bool {
|
||||||
return @bitCast(c.SDL_GamepadSensorEnabled(@ptrCast(gamepad), @intFromEnum(_type)));
|
return @bitCast(c.SDL_GamepadSensorEnabled(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(_type))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSensorDataRate(gamepad: *Gamepad, _type: SensorType) f32 {
|
pub inline fn getGamepadSensorDataRate(gamepad: *Gamepad, _type: SensorType) f32 {
|
||||||
return c.SDL_GetGamepadSensorDataRate(@ptrCast(gamepad), @intFromEnum(_type));
|
return c.SDL_GetGamepadSensorDataRate(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSensorData(gamepad: *Gamepad, _type: SensorType, data: *f32, num_values: c_int) bool {
|
pub inline fn getGamepadSensorData(gamepad: *Gamepad, _type: SensorType, data: ?*f32, num_values: c_int) bool {
|
||||||
return @bitCast(c.SDL_GetGamepadSensorData(@ptrCast(gamepad), @intFromEnum(_type), @ptrCast(data), num_values));
|
return @bitCast(c.SDL_GetGamepadSensorData(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(_type)), data, num_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rumbleGamepad(gamepad: *Gamepad, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
|
pub inline fn rumbleGamepad(gamepad: *Gamepad, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
|
||||||
return @bitCast(c.SDL_RumbleGamepad(@ptrCast(gamepad), low_frequency_rumble, high_frequency_rumble, duration_ms));
|
return @bitCast(c.SDL_RumbleGamepad(@ptrCast(@alignCast(gamepad)), low_frequency_rumble, high_frequency_rumble, duration_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rumbleGamepadTriggers(gamepad: *Gamepad, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
|
pub inline fn rumbleGamepadTriggers(gamepad: *Gamepad, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
|
||||||
return @bitCast(c.SDL_RumbleGamepadTriggers(@ptrCast(gamepad), left_rumble, right_rumble, duration_ms));
|
return @bitCast(c.SDL_RumbleGamepadTriggers(@ptrCast(@alignCast(gamepad)), left_rumble, right_rumble, duration_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadLED(gamepad: *Gamepad, red: u8, green: u8, blue: u8) bool {
|
pub inline fn setGamepadLED(gamepad: *Gamepad, red: u8, green: u8, blue: u8) bool {
|
||||||
return @bitCast(c.SDL_SetGamepadLED(@ptrCast(gamepad), red, green, blue));
|
return @bitCast(c.SDL_SetGamepadLED(@ptrCast(@alignCast(gamepad)), red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendGamepadEffect(gamepad: *Gamepad, data: ?*const anyopaque, size: c_int) bool {
|
pub inline fn sendGamepadEffect(gamepad: *Gamepad, data: ?*const anyopaque, size: c_int) bool {
|
||||||
return @bitCast(c.SDL_SendGamepadEffect(@ptrCast(gamepad), data, size));
|
return @bitCast(c.SDL_SendGamepadEffect(@ptrCast(@alignCast(gamepad)), data, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeGamepad(gamepad: *Gamepad) void {
|
pub inline fn closeGamepad(gamepad: *Gamepad) void {
|
||||||
return c.SDL_CloseGamepad(@ptrCast(gamepad));
|
return c.SDL_CloseGamepad(@ptrCast(@alignCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAppleSFSymbolsNameForButton(gamepad: *Gamepad, button: GamepadButton) [*c]const u8 {
|
pub inline fn getGamepadAppleSFSymbolsNameForButton(gamepad: *Gamepad, button: GamepadButton) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadAppleSFSymbolsNameForButton(@ptrCast(gamepad), button);
|
return c.SDL_GetGamepadAppleSFSymbolsNameForButton(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(button)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAppleSFSymbolsNameForAxis(gamepad: *Gamepad, axis: GamepadAxis) [*c]const u8 {
|
pub inline fn getGamepadAppleSFSymbolsNameForAxis(gamepad: *Gamepad, axis: GamepadAxis) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadAppleSFSymbolsNameForAxis(@ptrCast(gamepad), axis);
|
return c.SDL_GetGamepadAppleSFSymbolsNameForAxis(@ptrCast(@alignCast(gamepad)), @intCast(@backingInt(axis)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GamepadType = enum(c_int) {
|
pub const GamepadType = enum(c_int) {
|
||||||
|
gamepadTypeUnknown = 0,
|
||||||
gamepadTypeStandard,
|
gamepadTypeStandard,
|
||||||
gamepadTypeXbox360,
|
gamepadTypeXbox360,
|
||||||
gamepadTypeXboxone,
|
gamepadTypeXboxone,
|
||||||
|
|
@ -190,10 +191,12 @@ pub const GamepadType = enum(c_int) {
|
||||||
gamepadTypeNintendoSwitchJoyconRight,
|
gamepadTypeNintendoSwitchJoyconRight,
|
||||||
gamepadTypeNintendoSwitchJoyconPair,
|
gamepadTypeNintendoSwitchJoyconPair,
|
||||||
gamepadTypeGamecube,
|
gamepadTypeGamecube,
|
||||||
|
gamepadTypeSteam,
|
||||||
gamepadTypeCount,
|
gamepadTypeCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GamepadButton = enum(c_int) {
|
pub const GamepadButton = enum(c_int) {
|
||||||
|
gamepadButtonInvalid = -1,
|
||||||
gamepadButtonSouth, //Bottom face button (e.g. Xbox A button)
|
gamepadButtonSouth, //Bottom face button (e.g. Xbox A button)
|
||||||
gamepadButtonEast, //Right face button (e.g. Xbox B button)
|
gamepadButtonEast, //Right face button (e.g. Xbox B button)
|
||||||
gamepadButtonWest, //Left face button (e.g. Xbox X button)
|
gamepadButtonWest, //Left face button (e.g. Xbox X button)
|
||||||
|
|
@ -209,11 +212,11 @@ pub const GamepadButton = enum(c_int) {
|
||||||
gamepadButtonDpadDown,
|
gamepadButtonDpadDown,
|
||||||
gamepadButtonDpadLeft,
|
gamepadButtonDpadLeft,
|
||||||
gamepadButtonDpadRight,
|
gamepadButtonDpadRight,
|
||||||
gamepadButtonMisc1, //Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)
|
gamepadButtonMisc1, //Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Steam Controller QAM button, Amazon Luna microphone button, Google Stadia capture button)
|
||||||
gamepadButtonRightPaddle1, //Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)
|
gamepadButtonRightPaddle1, //Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button, Steam Controller R4 button)
|
||||||
gamepadButtonLeftPaddle1, //Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)
|
gamepadButtonLeftPaddle1, //Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button, Steam Controller L4 button)
|
||||||
gamepadButtonRightPaddle2, //Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)
|
gamepadButtonRightPaddle2, //Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button, Steam Controller R5 button)
|
||||||
gamepadButtonLeftPaddle2, //Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)
|
gamepadButtonLeftPaddle2, //Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button, Steam Controller L5 button)
|
||||||
gamepadButtonTouchpad, //PS4/PS5 touchpad button
|
gamepadButtonTouchpad, //PS4/PS5 touchpad button
|
||||||
gamepadButtonMisc2, //Additional button
|
gamepadButtonMisc2, //Additional button
|
||||||
gamepadButtonMisc3, //Additional button (e.g. Nintendo GameCube left trigger click)
|
gamepadButtonMisc3, //Additional button (e.g. Nintendo GameCube left trigger click)
|
||||||
|
|
@ -236,6 +239,7 @@ pub const GamepadButtonLabel = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GamepadAxis = enum(c_int) {
|
pub const GamepadAxis = enum(c_int) {
|
||||||
|
gamepadAxisInvalid = -1,
|
||||||
gamepadAxisLeftx,
|
gamepadAxisLeftx,
|
||||||
gamepadAxisLefty,
|
gamepadAxisLefty,
|
||||||
gamepadAxisRightx,
|
gamepadAxisRightx,
|
||||||
|
|
@ -246,6 +250,7 @@ pub const GamepadAxis = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GamepadBindingType = enum(c_int) {
|
pub const GamepadBindingType = enum(c_int) {
|
||||||
|
gamepadBindtypeNone = 0,
|
||||||
gamepadBindtypeButton,
|
gamepadBindtypeButton,
|
||||||
gamepadBindtypeAxis,
|
gamepadBindtypeAxis,
|
||||||
gamepadBindtypeHat,
|
gamepadBindtypeHat,
|
||||||
|
|
@ -258,7 +263,7 @@ pub inline fn addGamepadMapping(mapping: [*c]const u8) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addGamepadMappingsFromIO(src: ?*IOStream, closeio: bool) c_int {
|
pub inline fn addGamepadMappingsFromIO(src: ?*IOStream, closeio: bool) c_int {
|
||||||
return c.SDL_AddGamepadMappingsFromIO(@ptrCast(src), @bitCast(closeio));
|
return c.SDL_AddGamepadMappingsFromIO(@ptrCast(@alignCast(src)), @bitCast(closeio));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addGamepadMappingsFromFile(file: [*c]const u8) c_int {
|
pub inline fn addGamepadMappingsFromFile(file: [*c]const u8) c_int {
|
||||||
|
|
@ -269,12 +274,12 @@ pub inline fn reloadGamepadMappings() bool {
|
||||||
return @bitCast(c.SDL_ReloadGamepadMappings());
|
return @bitCast(c.SDL_ReloadGamepadMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadMappings(count: *c_int) [*c][*c]u8 {
|
pub inline fn getGamepadMappings(count: ?*c_int) [*c][*c]u8 {
|
||||||
return c.SDL_GetGamepadMappings(@ptrCast(count));
|
return c.SDL_GetGamepadMappings(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadMappingForGUID(guid: GUID) [*c]u8 {
|
pub inline fn getGamepadMappingForGUID(guid: GUID) [*c]u8 {
|
||||||
return c.SDL_GetGamepadMappingForGUID(guid);
|
return c.SDL_GetGamepadMappingForGUID(@as(*const c.SDL_GUID, @ptrCast(@alignCast(&guid))).*);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadMapping(instance_id: JoystickID, mapping: [*c]const u8) bool {
|
pub inline fn setGamepadMapping(instance_id: JoystickID, mapping: [*c]const u8) bool {
|
||||||
|
|
@ -285,8 +290,8 @@ pub inline fn hasGamepad() bool {
|
||||||
return @bitCast(c.SDL_HasGamepad());
|
return @bitCast(c.SDL_HasGamepad());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepads(count: *c_int) ?*JoystickID {
|
pub inline fn getGamepads(count: ?*c_int) ?*JoystickID {
|
||||||
return @ptrCast(c.SDL_GetGamepads(@ptrCast(count)));
|
return c.SDL_GetGamepads(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isGamepad(instance_id: JoystickID) bool {
|
pub inline fn isGamepad(instance_id: JoystickID) bool {
|
||||||
|
|
@ -306,7 +311,7 @@ pub inline fn getGamepadPlayerIndexForID(instance_id: JoystickID) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadGUIDForID(instance_id: JoystickID) GUID {
|
pub inline fn getGamepadGUIDForID(instance_id: JoystickID) GUID {
|
||||||
return c.SDL_GetGamepadGUIDForID(instance_id);
|
return @as(*const GUID, @ptrCast(@alignCast(&c.SDL_GetGamepadGUIDForID(instance_id)))).*;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadVendorForID(instance_id: JoystickID) u16 {
|
pub inline fn getGamepadVendorForID(instance_id: JoystickID) u16 {
|
||||||
|
|
@ -322,11 +327,11 @@ pub inline fn getGamepadProductVersionForID(instance_id: JoystickID) u16 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadTypeForID(instance_id: JoystickID) GamepadType {
|
pub inline fn getGamepadTypeForID(instance_id: JoystickID) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetGamepadTypeForID(instance_id));
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadTypeForID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRealGamepadTypeForID(instance_id: JoystickID) GamepadType {
|
pub inline fn getRealGamepadTypeForID(instance_id: JoystickID) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetRealGamepadTypeForID(instance_id));
|
return @fromBackingInt(@intCast(c.SDL_GetRealGamepadTypeForID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadMappingForID(instance_id: JoystickID) [*c]u8 {
|
pub inline fn getGamepadMappingForID(instance_id: JoystickID) [*c]u8 {
|
||||||
|
|
@ -334,15 +339,15 @@ pub inline fn getGamepadMappingForID(instance_id: JoystickID) [*c]u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openGamepad(instance_id: JoystickID) ?*Gamepad {
|
pub inline fn openGamepad(instance_id: JoystickID) ?*Gamepad {
|
||||||
return @ptrCast(c.SDL_OpenGamepad(instance_id));
|
return @ptrCast(@alignCast(c.SDL_OpenGamepad(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFromID(instance_id: JoystickID) ?*Gamepad {
|
pub inline fn getGamepadFromID(instance_id: JoystickID) ?*Gamepad {
|
||||||
return @ptrCast(c.SDL_GetGamepadFromID(instance_id));
|
return @ptrCast(@alignCast(c.SDL_GetGamepadFromID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFromPlayerIndex(player_index: c_int) ?*Gamepad {
|
pub inline fn getGamepadFromPlayerIndex(player_index: c_int) ?*Gamepad {
|
||||||
return @ptrCast(c.SDL_GetGamepadFromPlayerIndex(player_index));
|
return @ptrCast(@alignCast(c.SDL_GetGamepadFromPlayerIndex(player_index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadEventsEnabled(enabled: bool) void {
|
pub inline fn setGamepadEventsEnabled(enabled: bool) void {
|
||||||
|
|
@ -358,29 +363,29 @@ pub inline fn updateGamepads() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadTypeFromString(str: [*c]const u8) GamepadType {
|
pub inline fn getGamepadTypeFromString(str: [*c]const u8) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetGamepadTypeFromString(str));
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadTypeFromString(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadStringForType(_type: GamepadType) [*c]const u8 {
|
pub inline fn getGamepadStringForType(_type: GamepadType) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadStringForType(@intFromEnum(_type));
|
return c.SDL_GetGamepadStringForType(@intCast(@backingInt(_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAxisFromString(str: [*c]const u8) GamepadAxis {
|
pub inline fn getGamepadAxisFromString(str: [*c]const u8) GamepadAxis {
|
||||||
return c.SDL_GetGamepadAxisFromString(str);
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadAxisFromString(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadStringForAxis(axis: GamepadAxis) [*c]const u8 {
|
pub inline fn getGamepadStringForAxis(axis: GamepadAxis) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadStringForAxis(axis);
|
return c.SDL_GetGamepadStringForAxis(@intCast(@backingInt(axis)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButtonFromString(str: [*c]const u8) GamepadButton {
|
pub inline fn getGamepadButtonFromString(str: [*c]const u8) GamepadButton {
|
||||||
return c.SDL_GetGamepadButtonFromString(str);
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadButtonFromString(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadStringForButton(button: GamepadButton) [*c]const u8 {
|
pub inline fn getGamepadStringForButton(button: GamepadButton) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadStringForButton(button);
|
return c.SDL_GetGamepadStringForButton(@intCast(@backingInt(button)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButtonLabelForType(_type: GamepadType, button: GamepadButton) GamepadButtonLabel {
|
pub inline fn getGamepadButtonLabelForType(_type: GamepadType, button: GamepadButton) GamepadButtonLabel {
|
||||||
return c.SDL_GetGamepadButtonLabelForType(@intFromEnum(_type), button);
|
return @fromBackingInt(@intCast(c.SDL_GetGamepadButtonLabelForType(@intCast(@backingInt(_type)), @intCast(@backingInt(button)))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
214
api/gpu.zig
214
api/gpu.zig
|
|
@ -15,159 +15,159 @@ pub const FlipMode = surface_api.FlipMode;
|
||||||
|
|
||||||
pub const GPUDevice = opaque {
|
pub const GPUDevice = opaque {
|
||||||
pub inline fn destroyGPUDevice(gpudevice: *GPUDevice) void {
|
pub inline fn destroyGPUDevice(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_DestroyGPUDevice(@ptrCast(gpudevice));
|
return c.SDL_DestroyGPUDevice(@ptrCast(@alignCast(gpudevice)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUDeviceDriver(gpudevice: *GPUDevice) [*c]const u8 {
|
pub inline fn getGPUDeviceDriver(gpudevice: *GPUDevice) [*c]const u8 {
|
||||||
return c.SDL_GetGPUDeviceDriver(@ptrCast(gpudevice));
|
return c.SDL_GetGPUDeviceDriver(@ptrCast(@alignCast(gpudevice)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUShaderFormats(gpudevice: *GPUDevice) GPUShaderFormat {
|
pub inline fn getGPUShaderFormats(gpudevice: *GPUDevice) GPUShaderFormat {
|
||||||
return @bitCast(c.SDL_GetGPUShaderFormats(@ptrCast(gpudevice)));
|
return @bitCast(c.SDL_GetGPUShaderFormats(@ptrCast(@alignCast(gpudevice))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUDeviceProperties(gpudevice: *GPUDevice) PropertiesID {
|
pub inline fn getGPUDeviceProperties(gpudevice: *GPUDevice) PropertiesID {
|
||||||
return c.SDL_GetGPUDeviceProperties(@ptrCast(gpudevice));
|
return c.SDL_GetGPUDeviceProperties(@ptrCast(@alignCast(gpudevice)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUComputePipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUComputePipelineCreateInfo) ?*GPUComputePipeline {
|
pub inline fn createGPUComputePipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUComputePipelineCreateInfo) ?*GPUComputePipeline {
|
||||||
return @ptrCast(c.SDL_CreateGPUComputePipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUComputePipeline(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUGraphicsPipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUGraphicsPipelineCreateInfo) ?*GPUGraphicsPipeline {
|
pub inline fn createGPUGraphicsPipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUGraphicsPipelineCreateInfo) ?*GPUGraphicsPipeline {
|
||||||
return @ptrCast(c.SDL_CreateGPUGraphicsPipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUGraphicsPipeline(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUSampler(gpudevice: *GPUDevice, createinfo: ?*const GPUSamplerCreateInfo) ?*GPUSampler {
|
pub inline fn createGPUSampler(gpudevice: *GPUDevice, createinfo: ?*const GPUSamplerCreateInfo) ?*GPUSampler {
|
||||||
return @ptrCast(c.SDL_CreateGPUSampler(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUSampler(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUShader(gpudevice: *GPUDevice, createinfo: ?*const GPUShaderCreateInfo) ?*GPUShader {
|
pub inline fn createGPUShader(gpudevice: *GPUDevice, createinfo: ?*const GPUShaderCreateInfo) ?*GPUShader {
|
||||||
return @ptrCast(c.SDL_CreateGPUShader(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUShader(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUTexture(gpudevice: *GPUDevice, createinfo: ?*const GPUTextureCreateInfo) ?*GPUTexture {
|
pub inline fn createGPUTexture(gpudevice: *GPUDevice, createinfo: ?*const GPUTextureCreateInfo) ?*GPUTexture {
|
||||||
return @ptrCast(c.SDL_CreateGPUTexture(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUTexture(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUBufferCreateInfo) ?*GPUBuffer {
|
pub inline fn createGPUBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUBufferCreateInfo) ?*GPUBuffer {
|
||||||
return @ptrCast(c.SDL_CreateGPUBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUTransferBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUTransferBufferCreateInfo) ?*GPUTransferBuffer {
|
pub inline fn createGPUTransferBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUTransferBufferCreateInfo) ?*GPUTransferBuffer {
|
||||||
return @ptrCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUBufferName(gpudevice: *GPUDevice, buffer: ?*GPUBuffer, text: [*c]const u8) void {
|
pub inline fn setGPUBufferName(gpudevice: *GPUDevice, buffer: ?*GPUBuffer, text: [*c]const u8) void {
|
||||||
return c.SDL_SetGPUBufferName(@ptrCast(gpudevice), @ptrCast(buffer), text);
|
return c.SDL_SetGPUBufferName(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(buffer)), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUTextureName(gpudevice: *GPUDevice, texture: ?*GPUTexture, text: [*c]const u8) void {
|
pub inline fn setGPUTextureName(gpudevice: *GPUDevice, texture: ?*GPUTexture, text: [*c]const u8) void {
|
||||||
return c.SDL_SetGPUTextureName(@ptrCast(gpudevice), @ptrCast(texture), text);
|
return c.SDL_SetGPUTextureName(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(texture)), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUTexture(gpudevice: *GPUDevice, texture: ?*GPUTexture) void {
|
pub inline fn releaseGPUTexture(gpudevice: *GPUDevice, texture: ?*GPUTexture) void {
|
||||||
return c.SDL_ReleaseGPUTexture(@ptrCast(gpudevice), @ptrCast(texture));
|
return c.SDL_ReleaseGPUTexture(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(texture)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUSampler(gpudevice: *GPUDevice, sampler: ?*GPUSampler) void {
|
pub inline fn releaseGPUSampler(gpudevice: *GPUDevice, sampler: ?*GPUSampler) void {
|
||||||
return c.SDL_ReleaseGPUSampler(@ptrCast(gpudevice), @ptrCast(sampler));
|
return c.SDL_ReleaseGPUSampler(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(sampler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUBuffer(gpudevice: *GPUDevice, buffer: ?*GPUBuffer) void {
|
pub inline fn releaseGPUBuffer(gpudevice: *GPUDevice, buffer: ?*GPUBuffer) void {
|
||||||
return c.SDL_ReleaseGPUBuffer(@ptrCast(gpudevice), @ptrCast(buffer));
|
return c.SDL_ReleaseGPUBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
pub inline fn releaseGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
||||||
return c.SDL_ReleaseGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer));
|
return c.SDL_ReleaseGPUTransferBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(transfer_buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUComputePipeline(gpudevice: *GPUDevice, compute_pipeline: ?*GPUComputePipeline) void {
|
pub inline fn releaseGPUComputePipeline(gpudevice: *GPUDevice, compute_pipeline: ?*GPUComputePipeline) void {
|
||||||
return c.SDL_ReleaseGPUComputePipeline(@ptrCast(gpudevice), @ptrCast(compute_pipeline));
|
return c.SDL_ReleaseGPUComputePipeline(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(compute_pipeline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUShader(gpudevice: *GPUDevice, shader: ?*GPUShader) void {
|
pub inline fn releaseGPUShader(gpudevice: *GPUDevice, shader: ?*GPUShader) void {
|
||||||
return c.SDL_ReleaseGPUShader(@ptrCast(gpudevice), @ptrCast(shader));
|
return c.SDL_ReleaseGPUShader(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(shader)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUGraphicsPipeline(gpudevice: *GPUDevice, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
pub inline fn releaseGPUGraphicsPipeline(gpudevice: *GPUDevice, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
||||||
return c.SDL_ReleaseGPUGraphicsPipeline(@ptrCast(gpudevice), @ptrCast(graphics_pipeline));
|
return c.SDL_ReleaseGPUGraphicsPipeline(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(graphics_pipeline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireGPUCommandBuffer(gpudevice: *GPUDevice) ?*GPUCommandBuffer {
|
pub inline fn acquireGPUCommandBuffer(gpudevice: *GPUDevice) ?*GPUCommandBuffer {
|
||||||
return @ptrCast(c.SDL_AcquireGPUCommandBuffer(@ptrCast(gpudevice)));
|
return @ptrCast(@alignCast(c.SDL_AcquireGPUCommandBuffer(@ptrCast(@alignCast(gpudevice)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer, cycle: bool) ?*anyopaque {
|
pub inline fn mapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer, cycle: bool) ?*anyopaque {
|
||||||
return c.SDL_MapGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer), @bitCast(cycle));
|
return c.SDL_MapGPUTransferBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(transfer_buffer)), @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unmapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
pub inline fn unmapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
||||||
return c.SDL_UnmapGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer));
|
return c.SDL_UnmapGPUTransferBuffer(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(transfer_buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowSupportsGPUSwapchainComposition(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition) bool {
|
pub inline fn windowSupportsGPUSwapchainComposition(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition) bool {
|
||||||
return @bitCast(c.SDL_WindowSupportsGPUSwapchainComposition(@ptrCast(gpudevice), @ptrCast(window), swapchain_composition));
|
return @bitCast(c.SDL_WindowSupportsGPUSwapchainComposition(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window)), @intCast(@backingInt(swapchain_composition))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowSupportsGPUPresentMode(gpudevice: *GPUDevice, window: ?*Window, present_mode: GPUPresentMode) bool {
|
pub inline fn windowSupportsGPUPresentMode(gpudevice: *GPUDevice, window: ?*Window, present_mode: GPUPresentMode) bool {
|
||||||
return @bitCast(c.SDL_WindowSupportsGPUPresentMode(@ptrCast(gpudevice), @ptrCast(window), @intFromEnum(present_mode)));
|
return @bitCast(c.SDL_WindowSupportsGPUPresentMode(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window)), @intCast(@backingInt(present_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn claimWindowForGPUDevice(gpudevice: *GPUDevice, window: ?*Window) bool {
|
pub inline fn claimWindowForGPUDevice(gpudevice: *GPUDevice, window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_ClaimWindowForGPUDevice(@ptrCast(gpudevice), @ptrCast(window)));
|
return @bitCast(c.SDL_ClaimWindowForGPUDevice(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseWindowFromGPUDevice(gpudevice: *GPUDevice, window: ?*Window) void {
|
pub inline fn releaseWindowFromGPUDevice(gpudevice: *GPUDevice, window: ?*Window) void {
|
||||||
return c.SDL_ReleaseWindowFromGPUDevice(@ptrCast(gpudevice), @ptrCast(window));
|
return c.SDL_ReleaseWindowFromGPUDevice(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUSwapchainParameters(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition, present_mode: GPUPresentMode) bool {
|
pub inline fn setGPUSwapchainParameters(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition, present_mode: GPUPresentMode) bool {
|
||||||
return @bitCast(c.SDL_SetGPUSwapchainParameters(@ptrCast(gpudevice), @ptrCast(window), swapchain_composition, @intFromEnum(present_mode)));
|
return @bitCast(c.SDL_SetGPUSwapchainParameters(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window)), @intCast(@backingInt(swapchain_composition)), @intCast(@backingInt(present_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUAllowedFramesInFlight(gpudevice: *GPUDevice, allowed_frames_in_flight: u32) bool {
|
pub inline fn setGPUAllowedFramesInFlight(gpudevice: *GPUDevice, allowed_frames_in_flight: u32) bool {
|
||||||
return @bitCast(c.SDL_SetGPUAllowedFramesInFlight(@ptrCast(gpudevice), allowed_frames_in_flight));
|
return @bitCast(c.SDL_SetGPUAllowedFramesInFlight(@ptrCast(@alignCast(gpudevice)), allowed_frames_in_flight));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUSwapchainTextureFormat(gpudevice: *GPUDevice, window: ?*Window) GPUTextureFormat {
|
pub inline fn getGPUSwapchainTextureFormat(gpudevice: *GPUDevice, window: ?*Window) GPUTextureFormat {
|
||||||
return @bitCast(c.SDL_GetGPUSwapchainTextureFormat(@ptrCast(gpudevice), @ptrCast(window)));
|
return @fromBackingInt(@intCast(c.SDL_GetGPUSwapchainTextureFormat(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitForGPUSwapchain(gpudevice: *GPUDevice, window: ?*Window) bool {
|
pub inline fn waitForGPUSwapchain(gpudevice: *GPUDevice, window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_WaitForGPUSwapchain(@ptrCast(gpudevice), @ptrCast(window)));
|
return @bitCast(c.SDL_WaitForGPUSwapchain(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitForGPUIdle(gpudevice: *GPUDevice) bool {
|
pub inline fn waitForGPUIdle(gpudevice: *GPUDevice) bool {
|
||||||
return @bitCast(c.SDL_WaitForGPUIdle(@ptrCast(gpudevice)));
|
return @bitCast(c.SDL_WaitForGPUIdle(@ptrCast(@alignCast(gpudevice))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitForGPUFences(gpudevice: *GPUDevice, wait_all: bool, fences: [*c]?*const GPUFence, num_fences: u32) bool {
|
pub inline fn waitForGPUFences(gpudevice: *GPUDevice, wait_all: bool, fences: [*c]const ?*GPUFence, num_fences: u32) bool {
|
||||||
return @bitCast(c.SDL_WaitForGPUFences(@ptrCast(gpudevice), @bitCast(wait_all), fences, num_fences));
|
return @bitCast(c.SDL_WaitForGPUFences(@ptrCast(@alignCast(gpudevice)), @bitCast(wait_all), @ptrCast(@alignCast(fences)), num_fences));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn queryGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) bool {
|
pub inline fn queryGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) bool {
|
||||||
return @bitCast(c.SDL_QueryGPUFence(@ptrCast(gpudevice), @ptrCast(fence)));
|
return @bitCast(c.SDL_QueryGPUFence(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(fence))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) void {
|
pub inline fn releaseGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) void {
|
||||||
return c.SDL_ReleaseGPUFence(@ptrCast(gpudevice), @ptrCast(fence));
|
return c.SDL_ReleaseGPUFence(@ptrCast(@alignCast(gpudevice)), @ptrCast(@alignCast(fence)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gpuTextureSupportsFormat(gpudevice: *GPUDevice, format: GPUTextureFormat, _type: GPUTextureType, usage: GPUTextureUsageFlags) bool {
|
pub inline fn gpuTextureSupportsFormat(gpudevice: *GPUDevice, format: GPUTextureFormat, _type: GPUTextureType, usage: GPUTextureUsageFlags) bool {
|
||||||
return @bitCast(c.SDL_GPUTextureSupportsFormat(@ptrCast(gpudevice), @bitCast(format), @intFromEnum(_type), @bitCast(usage)));
|
return @bitCast(c.SDL_GPUTextureSupportsFormat(@ptrCast(@alignCast(gpudevice)), @intCast(@backingInt(format)), @intCast(@backingInt(_type)), @bitCast(usage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gpuTextureSupportsSampleCount(gpudevice: *GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) bool {
|
pub inline fn gpuTextureSupportsSampleCount(gpudevice: *GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) bool {
|
||||||
return @bitCast(c.SDL_GPUTextureSupportsSampleCount(@ptrCast(gpudevice), @bitCast(format), sample_count));
|
return @bitCast(c.SDL_GPUTextureSupportsSampleCount(@ptrCast(@alignCast(gpudevice)), @intCast(@backingInt(format)), @intCast(@backingInt(sample_count))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gdkSuspendGPU(gpudevice: *GPUDevice) void {
|
pub inline fn gdkSuspendGPU(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_GDKSuspendGPU(@ptrCast(gpudevice));
|
return c.SDL_GDKSuspendGPU(@ptrCast(@alignCast(gpudevice)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gdkResumeGPU(gpudevice: *GPUDevice) void {
|
pub inline fn gdkResumeGPU(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_GDKResumeGPU(@ptrCast(gpudevice));
|
return c.SDL_GDKResumeGPU(@ptrCast(@alignCast(gpudevice)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -187,201 +187,201 @@ pub const GPUGraphicsPipeline = opaque {};
|
||||||
|
|
||||||
pub const GPUCommandBuffer = opaque {
|
pub const GPUCommandBuffer = opaque {
|
||||||
pub inline fn insertGPUDebugLabel(gpucommandbuffer: *GPUCommandBuffer, text: [*c]const u8) void {
|
pub inline fn insertGPUDebugLabel(gpucommandbuffer: *GPUCommandBuffer, text: [*c]const u8) void {
|
||||||
return c.SDL_InsertGPUDebugLabel(@ptrCast(gpucommandbuffer), text);
|
return c.SDL_InsertGPUDebugLabel(@ptrCast(@alignCast(gpucommandbuffer)), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer, name: [*c]const u8) void {
|
pub inline fn pushGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer, name: [*c]const u8) void {
|
||||||
return c.SDL_PushGPUDebugGroup(@ptrCast(gpucommandbuffer), name);
|
return c.SDL_PushGPUDebugGroup(@ptrCast(@alignCast(gpucommandbuffer)), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn popGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer) void {
|
pub inline fn popGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer) void {
|
||||||
return c.SDL_PopGPUDebugGroup(@ptrCast(gpucommandbuffer));
|
return c.SDL_PopGPUDebugGroup(@ptrCast(@alignCast(gpucommandbuffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushGPUVertexUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
pub inline fn pushGPUVertexUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
||||||
return c.SDL_PushGPUVertexUniformData(@ptrCast(gpucommandbuffer), slot_index, data, length);
|
return c.SDL_PushGPUVertexUniformData(@ptrCast(@alignCast(gpucommandbuffer)), slot_index, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushGPUFragmentUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
pub inline fn pushGPUFragmentUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
||||||
return c.SDL_PushGPUFragmentUniformData(@ptrCast(gpucommandbuffer), slot_index, data, length);
|
return c.SDL_PushGPUFragmentUniformData(@ptrCast(@alignCast(gpucommandbuffer)), slot_index, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushGPUComputeUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
pub inline fn pushGPUComputeUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
|
||||||
return c.SDL_PushGPUComputeUniformData(@ptrCast(gpucommandbuffer), slot_index, data, length);
|
return c.SDL_PushGPUComputeUniformData(@ptrCast(@alignCast(gpucommandbuffer)), slot_index, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn beginGPURenderPass(gpucommandbuffer: *GPUCommandBuffer, color_target_infos: ?*const GPUColorTargetInfo, num_color_targets: u32, depth_stencil_target_info: ?*const GPUDepthStencilTargetInfo) ?*GPURenderPass {
|
pub inline fn beginGPURenderPass(gpucommandbuffer: *GPUCommandBuffer, color_target_infos: ?*const GPUColorTargetInfo, num_color_targets: u32, depth_stencil_target_info: ?*const GPUDepthStencilTargetInfo) ?*GPURenderPass {
|
||||||
return @ptrCast(c.SDL_BeginGPURenderPass(@ptrCast(gpucommandbuffer), @ptrCast(color_target_infos), num_color_targets, @ptrCast(depth_stencil_target_info)));
|
return @ptrCast(@alignCast(c.SDL_BeginGPURenderPass(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(color_target_infos)), num_color_targets, @ptrCast(@alignCast(depth_stencil_target_info)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn beginGPUComputePass(gpucommandbuffer: *GPUCommandBuffer, storage_texture_bindings: ?*const GPUStorageTextureReadWriteBinding, num_storage_texture_bindings: u32, storage_buffer_bindings: ?*const GPUStorageBufferReadWriteBinding, num_storage_buffer_bindings: u32) ?*GPUComputePass {
|
pub inline fn beginGPUComputePass(gpucommandbuffer: *GPUCommandBuffer, storage_texture_bindings: ?*const GPUStorageTextureReadWriteBinding, num_storage_texture_bindings: u32, storage_buffer_bindings: ?*const GPUStorageBufferReadWriteBinding, num_storage_buffer_bindings: u32) ?*GPUComputePass {
|
||||||
return @ptrCast(c.SDL_BeginGPUComputePass(@ptrCast(gpucommandbuffer), @ptrCast(storage_texture_bindings), num_storage_texture_bindings, @ptrCast(storage_buffer_bindings), num_storage_buffer_bindings));
|
return @ptrCast(@alignCast(c.SDL_BeginGPUComputePass(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(storage_texture_bindings)), num_storage_texture_bindings, @ptrCast(@alignCast(storage_buffer_bindings)), num_storage_buffer_bindings)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn beginGPUCopyPass(gpucommandbuffer: *GPUCommandBuffer) ?*GPUCopyPass {
|
pub inline fn beginGPUCopyPass(gpucommandbuffer: *GPUCommandBuffer) ?*GPUCopyPass {
|
||||||
return @ptrCast(c.SDL_BeginGPUCopyPass(@ptrCast(gpucommandbuffer)));
|
return @ptrCast(@alignCast(c.SDL_BeginGPUCopyPass(@ptrCast(@alignCast(gpucommandbuffer)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn generateMipmapsForGPUTexture(gpucommandbuffer: *GPUCommandBuffer, texture: ?*GPUTexture) void {
|
pub inline fn generateMipmapsForGPUTexture(gpucommandbuffer: *GPUCommandBuffer, texture: ?*GPUTexture) void {
|
||||||
return c.SDL_GenerateMipmapsForGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(texture));
|
return c.SDL_GenerateMipmapsForGPUTexture(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(texture)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitGPUTexture(gpucommandbuffer: *GPUCommandBuffer, info: ?*const GPUBlitInfo) void {
|
pub inline fn blitGPUTexture(gpucommandbuffer: *GPUCommandBuffer, info: ?*const GPUBlitInfo) void {
|
||||||
return c.SDL_BlitGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(info));
|
return c.SDL_BlitGPUTexture(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
pub inline fn acquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: ?*u32, swapchain_texture_height: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_AcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
return @bitCast(c.SDL_AcquireGPUSwapchainTexture(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(window)), @ptrCast(@alignCast(swapchain_texture)), swapchain_texture_width, swapchain_texture_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitAndAcquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
pub inline fn waitAndAcquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: ?*u32, swapchain_texture_height: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
return @bitCast(c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(@alignCast(gpucommandbuffer)), @ptrCast(@alignCast(window)), @ptrCast(@alignCast(swapchain_texture)), swapchain_texture_width, swapchain_texture_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn submitGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
pub inline fn submitGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
||||||
return @bitCast(c.SDL_SubmitGPUCommandBuffer(@ptrCast(gpucommandbuffer)));
|
return @bitCast(c.SDL_SubmitGPUCommandBuffer(@ptrCast(@alignCast(gpucommandbuffer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn submitGPUCommandBufferAndAcquireFence(gpucommandbuffer: *GPUCommandBuffer) ?*GPUFence {
|
pub inline fn submitGPUCommandBufferAndAcquireFence(gpucommandbuffer: *GPUCommandBuffer) ?*GPUFence {
|
||||||
return @ptrCast(c.SDL_SubmitGPUCommandBufferAndAcquireFence(@ptrCast(gpucommandbuffer)));
|
return @ptrCast(@alignCast(c.SDL_SubmitGPUCommandBufferAndAcquireFence(@ptrCast(@alignCast(gpucommandbuffer)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn cancelGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
pub inline fn cancelGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
||||||
return @bitCast(c.SDL_CancelGPUCommandBuffer(@ptrCast(gpucommandbuffer)));
|
return @bitCast(c.SDL_CancelGPUCommandBuffer(@ptrCast(@alignCast(gpucommandbuffer))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPURenderPass = opaque {
|
pub const GPURenderPass = opaque {
|
||||||
pub inline fn bindGPUGraphicsPipeline(gpurenderpass: *GPURenderPass, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
pub inline fn bindGPUGraphicsPipeline(gpurenderpass: *GPURenderPass, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
||||||
return c.SDL_BindGPUGraphicsPipeline(@ptrCast(gpurenderpass), @ptrCast(graphics_pipeline));
|
return c.SDL_BindGPUGraphicsPipeline(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(graphics_pipeline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUViewport(gpurenderpass: *GPURenderPass, viewport: ?*const GPUViewport) void {
|
pub inline fn setGPUViewport(gpurenderpass: *GPURenderPass, viewport: ?*const GPUViewport) void {
|
||||||
return c.SDL_SetGPUViewport(@ptrCast(gpurenderpass), @ptrCast(viewport));
|
return c.SDL_SetGPUViewport(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(viewport)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUScissor(gpurenderpass: *GPURenderPass, scissor: ?*const Rect) void {
|
pub inline fn setGPUScissor(gpurenderpass: *GPURenderPass, scissor: ?*const Rect) void {
|
||||||
return c.SDL_SetGPUScissor(@ptrCast(gpurenderpass), @ptrCast(scissor));
|
return c.SDL_SetGPUScissor(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(scissor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUBlendConstants(gpurenderpass: *GPURenderPass, blend_constants: FColor) void {
|
pub inline fn setGPUBlendConstants(gpurenderpass: *GPURenderPass, blend_constants: FColor) void {
|
||||||
return c.SDL_SetGPUBlendConstants(@ptrCast(gpurenderpass), blend_constants);
|
return c.SDL_SetGPUBlendConstants(@ptrCast(@alignCast(gpurenderpass)), @as(*const c.SDL_FColor, @ptrCast(@alignCast(&blend_constants))).*);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUStencilReference(gpurenderpass: *GPURenderPass, reference: u8) void {
|
pub inline fn setGPUStencilReference(gpurenderpass: *GPURenderPass, reference: u8) void {
|
||||||
return c.SDL_SetGPUStencilReference(@ptrCast(gpurenderpass), reference);
|
return c.SDL_SetGPUStencilReference(@ptrCast(@alignCast(gpurenderpass)), reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUVertexBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, bindings: ?*const GPUBufferBinding, num_bindings: u32) void {
|
pub inline fn bindGPUVertexBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, bindings: ?*const GPUBufferBinding, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUVertexBuffers(@ptrCast(gpurenderpass), first_slot, @ptrCast(bindings), num_bindings);
|
return c.SDL_BindGPUVertexBuffers(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(bindings)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUIndexBuffer(gpurenderpass: *GPURenderPass, binding: ?*const GPUBufferBinding, index_element_size: GPUIndexElementSize) void {
|
pub inline fn bindGPUIndexBuffer(gpurenderpass: *GPURenderPass, binding: ?*const GPUBufferBinding, index_element_size: GPUIndexElementSize) void {
|
||||||
return c.SDL_BindGPUIndexBuffer(@ptrCast(gpurenderpass), @ptrCast(binding), index_element_size);
|
return c.SDL_BindGPUIndexBuffer(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(binding)), @intCast(@backingInt(index_element_size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUVertexSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
pub inline fn bindGPUVertexSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUVertexSamplers(@ptrCast(gpurenderpass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUVertexSamplers(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(texture_sampler_bindings)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUVertexStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]?*const GPUTexture, num_bindings: u32) void {
|
pub inline fn bindGPUVertexStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]const ?*GPUTexture, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUVertexStorageTextures(@ptrCast(gpurenderpass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUVertexStorageTextures(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(storage_textures)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUVertexStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]?*const GPUBuffer, num_bindings: u32) void {
|
pub inline fn bindGPUVertexStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]const ?*GPUBuffer, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUVertexStorageBuffers(@ptrCast(gpurenderpass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUVertexStorageBuffers(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(storage_buffers)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUFragmentSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
pub inline fn bindGPUFragmentSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUFragmentSamplers(@ptrCast(gpurenderpass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUFragmentSamplers(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(texture_sampler_bindings)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUFragmentStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]?*const GPUTexture, num_bindings: u32) void {
|
pub inline fn bindGPUFragmentStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]const ?*GPUTexture, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUFragmentStorageTextures(@ptrCast(gpurenderpass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUFragmentStorageTextures(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(storage_textures)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUFragmentStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]?*const GPUBuffer, num_bindings: u32) void {
|
pub inline fn bindGPUFragmentStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]const ?*GPUBuffer, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUFragmentStorageBuffers(@ptrCast(gpurenderpass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUFragmentStorageBuffers(@ptrCast(@alignCast(gpurenderpass)), first_slot, @ptrCast(@alignCast(storage_buffers)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn drawGPUIndexedPrimitives(gpurenderpass: *GPURenderPass, num_indices: u32, num_instances: u32, first_index: u32, vertex_offset: i32, first_instance: u32) void {
|
pub inline fn drawGPUIndexedPrimitives(gpurenderpass: *GPURenderPass, num_indices: u32, num_instances: u32, first_index: u32, vertex_offset: i32, first_instance: u32) void {
|
||||||
return c.SDL_DrawGPUIndexedPrimitives(@ptrCast(gpurenderpass), num_indices, num_instances, first_index, vertex_offset, first_instance);
|
return c.SDL_DrawGPUIndexedPrimitives(@ptrCast(@alignCast(gpurenderpass)), num_indices, num_instances, first_index, vertex_offset, first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn drawGPUPrimitives(gpurenderpass: *GPURenderPass, num_vertices: u32, num_instances: u32, first_vertex: u32, first_instance: u32) void {
|
pub inline fn drawGPUPrimitives(gpurenderpass: *GPURenderPass, num_vertices: u32, num_instances: u32, first_vertex: u32, first_instance: u32) void {
|
||||||
return c.SDL_DrawGPUPrimitives(@ptrCast(gpurenderpass), num_vertices, num_instances, first_vertex, first_instance);
|
return c.SDL_DrawGPUPrimitives(@ptrCast(@alignCast(gpurenderpass)), num_vertices, num_instances, first_vertex, first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn drawGPUPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
|
pub inline fn drawGPUPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
|
||||||
return c.SDL_DrawGPUPrimitivesIndirect(@ptrCast(gpurenderpass), @ptrCast(buffer), offset, draw_count);
|
return c.SDL_DrawGPUPrimitivesIndirect(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(buffer)), offset, draw_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn drawGPUIndexedPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
|
pub inline fn drawGPUIndexedPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
|
||||||
return c.SDL_DrawGPUIndexedPrimitivesIndirect(@ptrCast(gpurenderpass), @ptrCast(buffer), offset, draw_count);
|
return c.SDL_DrawGPUIndexedPrimitivesIndirect(@ptrCast(@alignCast(gpurenderpass)), @ptrCast(@alignCast(buffer)), offset, draw_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPURenderPass(gpurenderpass: *GPURenderPass) void {
|
pub inline fn endGPURenderPass(gpurenderpass: *GPURenderPass) void {
|
||||||
return c.SDL_EndGPURenderPass(@ptrCast(gpurenderpass));
|
return c.SDL_EndGPURenderPass(@ptrCast(@alignCast(gpurenderpass)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUComputePass = opaque {
|
pub const GPUComputePass = opaque {
|
||||||
pub inline fn bindGPUComputePipeline(gpucomputepass: *GPUComputePass, compute_pipeline: ?*GPUComputePipeline) void {
|
pub inline fn bindGPUComputePipeline(gpucomputepass: *GPUComputePass, compute_pipeline: ?*GPUComputePipeline) void {
|
||||||
return c.SDL_BindGPUComputePipeline(@ptrCast(gpucomputepass), @ptrCast(compute_pipeline));
|
return c.SDL_BindGPUComputePipeline(@ptrCast(@alignCast(gpucomputepass)), @ptrCast(@alignCast(compute_pipeline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUComputeSamplers(gpucomputepass: *GPUComputePass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
pub inline fn bindGPUComputeSamplers(gpucomputepass: *GPUComputePass, first_slot: u32, texture_sampler_bindings: ?*const GPUTextureSamplerBinding, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUComputeSamplers(@ptrCast(gpucomputepass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUComputeSamplers(@ptrCast(@alignCast(gpucomputepass)), first_slot, @ptrCast(@alignCast(texture_sampler_bindings)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUComputeStorageTextures(gpucomputepass: *GPUComputePass, first_slot: u32, storage_textures: [*c]?*const GPUTexture, num_bindings: u32) void {
|
pub inline fn bindGPUComputeStorageTextures(gpucomputepass: *GPUComputePass, first_slot: u32, storage_textures: [*c]const ?*GPUTexture, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUComputeStorageTextures(@ptrCast(gpucomputepass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUComputeStorageTextures(@ptrCast(@alignCast(gpucomputepass)), first_slot, @ptrCast(@alignCast(storage_textures)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUComputeStorageBuffers(gpucomputepass: *GPUComputePass, first_slot: u32, storage_buffers: [*c]?*const GPUBuffer, num_bindings: u32) void {
|
pub inline fn bindGPUComputeStorageBuffers(gpucomputepass: *GPUComputePass, first_slot: u32, storage_buffers: [*c]const ?*GPUBuffer, num_bindings: u32) void {
|
||||||
return c.SDL_BindGPUComputeStorageBuffers(@ptrCast(gpucomputepass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUComputeStorageBuffers(@ptrCast(@alignCast(gpucomputepass)), first_slot, @ptrCast(@alignCast(storage_buffers)), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn dispatchGPUCompute(gpucomputepass: *GPUComputePass, groupcount_x: u32, groupcount_y: u32, groupcount_z: u32) void {
|
pub inline fn dispatchGPUCompute(gpucomputepass: *GPUComputePass, groupcount_x: u32, groupcount_y: u32, groupcount_z: u32) void {
|
||||||
return c.SDL_DispatchGPUCompute(@ptrCast(gpucomputepass), groupcount_x, groupcount_y, groupcount_z);
|
return c.SDL_DispatchGPUCompute(@ptrCast(@alignCast(gpucomputepass)), groupcount_x, groupcount_y, groupcount_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn dispatchGPUComputeIndirect(gpucomputepass: *GPUComputePass, buffer: ?*GPUBuffer, offset: u32) void {
|
pub inline fn dispatchGPUComputeIndirect(gpucomputepass: *GPUComputePass, buffer: ?*GPUBuffer, offset: u32) void {
|
||||||
return c.SDL_DispatchGPUComputeIndirect(@ptrCast(gpucomputepass), @ptrCast(buffer), offset);
|
return c.SDL_DispatchGPUComputeIndirect(@ptrCast(@alignCast(gpucomputepass)), @ptrCast(@alignCast(buffer)), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPUComputePass(gpucomputepass: *GPUComputePass) void {
|
pub inline fn endGPUComputePass(gpucomputepass: *GPUComputePass) void {
|
||||||
return c.SDL_EndGPUComputePass(@ptrCast(gpucomputepass));
|
return c.SDL_EndGPUComputePass(@ptrCast(@alignCast(gpucomputepass)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUCopyPass = opaque {
|
pub const GPUCopyPass = opaque {
|
||||||
pub inline fn uploadToGPUTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureTransferInfo, destination: ?*const GPUTextureRegion, cycle: bool) void {
|
pub inline fn uploadToGPUTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureTransferInfo, destination: ?*const GPUTextureRegion, cycle: bool) void {
|
||||||
return c.SDL_UploadToGPUTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(cycle));
|
return c.SDL_UploadToGPUTexture(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)), @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn uploadToGPUBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUTransferBufferLocation, destination: ?*const GPUBufferRegion, cycle: bool) void {
|
pub inline fn uploadToGPUBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUTransferBufferLocation, destination: ?*const GPUBufferRegion, cycle: bool) void {
|
||||||
return c.SDL_UploadToGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(cycle));
|
return c.SDL_UploadToGPUBuffer(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)), @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyGPUTextureToTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureLocation, destination: ?*const GPUTextureLocation, w: u32, h: u32, d: u32, cycle: bool) void {
|
pub inline fn copyGPUTextureToTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureLocation, destination: ?*const GPUTextureLocation, w: u32, h: u32, d: u32, cycle: bool) void {
|
||||||
return c.SDL_CopyGPUTextureToTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), w, h, d, @bitCast(cycle));
|
return c.SDL_CopyGPUTextureToTexture(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)), w, h, d, @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyGPUBufferToBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUBufferLocation, destination: ?*const GPUBufferLocation, size: u32, cycle: bool) void {
|
pub inline fn copyGPUBufferToBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUBufferLocation, destination: ?*const GPUBufferLocation, size: u32, cycle: bool) void {
|
||||||
return c.SDL_CopyGPUBufferToBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), size, @bitCast(cycle));
|
return c.SDL_CopyGPUBufferToBuffer(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)), size, @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn downloadFromGPUTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureRegion, destination: ?*const GPUTextureTransferInfo) void {
|
pub inline fn downloadFromGPUTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureRegion, destination: ?*const GPUTextureTransferInfo) void {
|
||||||
return c.SDL_DownloadFromGPUTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
return c.SDL_DownloadFromGPUTexture(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn downloadFromGPUBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUBufferRegion, destination: ?*const GPUTransferBufferLocation) void {
|
pub inline fn downloadFromGPUBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUBufferRegion, destination: ?*const GPUTransferBufferLocation) void {
|
||||||
return c.SDL_DownloadFromGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
return c.SDL_DownloadFromGPUBuffer(@ptrCast(@alignCast(gpucopypass)), @ptrCast(@alignCast(source)), @ptrCast(@alignCast(destination)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPUCopyPass(gpucopypass: *GPUCopyPass) void {
|
pub inline fn endGPUCopyPass(gpucopypass: *GPUCopyPass) void {
|
||||||
return c.SDL_EndGPUCopyPass(@ptrCast(gpucopypass));
|
return c.SDL_EndGPUCopyPass(@ptrCast(@alignCast(gpucopypass)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -680,7 +680,7 @@ pub const GPUBlendOp = enum(c_int) {
|
||||||
blendopSubtract, //(source * source_factor) - (destination * destination_factor)
|
blendopSubtract, //(source * source_factor) - (destination * destination_factor)
|
||||||
blendopReverseSubtract, //(destination * destination_factor) - (source * source_factor)
|
blendopReverseSubtract, //(destination * destination_factor) - (source * source_factor)
|
||||||
blendopMin, //min(source, destination)
|
blendopMin, //min(source, destination)
|
||||||
blendopMax,
|
blendopMax, //max(source, destination)
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUBlendFactor = enum(c_int) {
|
pub const GPUBlendFactor = enum(c_int) {
|
||||||
|
|
@ -697,7 +697,7 @@ pub const GPUBlendFactor = enum(c_int) {
|
||||||
blendfactorOneMinusDstAlpha, //1 - destination alpha
|
blendfactorOneMinusDstAlpha, //1 - destination alpha
|
||||||
blendfactorConstantColor, //blend constant
|
blendfactorConstantColor, //blend constant
|
||||||
blendfactorOneMinusConstantColor, //1 - blend constant
|
blendfactorOneMinusConstantColor, //1 - blend constant
|
||||||
blendfactorSrcAlphaSaturate,
|
blendfactorSrcAlphaSaturate, //min(source alpha, 1 - destination alpha)
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUColorComponentFlags = packed struct(u8) {
|
pub const GPUColorComponentFlags = packed struct(u8) {
|
||||||
|
|
@ -858,9 +858,9 @@ pub const GPUVertexAttribute = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUVertexInputState = extern struct {
|
pub const GPUVertexInputState = extern struct {
|
||||||
vertex_buffer_descriptions: ?*const GPUVertexBufferDescription, // A pointer to an array of vertex buffer descriptions.
|
vertex_buffer_descriptions: [*c]const GPUVertexBufferDescription, // A pointer to an array of vertex buffer descriptions.
|
||||||
num_vertex_buffers: u32, // The number of vertex buffer descriptions in the above array.
|
num_vertex_buffers: u32, // The number of vertex buffer descriptions in the above array.
|
||||||
vertex_attributes: ?*const GPUVertexAttribute, // A pointer to an array of vertex attribute descriptions.
|
vertex_attributes: [*c]const GPUVertexAttribute, // A pointer to an array of vertex attribute descriptions.
|
||||||
num_vertex_attributes: u32, // The number of vertex attribute descriptions in the above array.
|
num_vertex_attributes: u32, // The number of vertex attribute descriptions in the above array.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -964,7 +964,7 @@ pub const GPUColorTargetDescription = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUGraphicsPipelineTargetInfo = extern struct {
|
pub const GPUGraphicsPipelineTargetInfo = extern struct {
|
||||||
color_target_descriptions: ?*const GPUColorTargetDescription, // A pointer to an array of color target descriptions.
|
color_target_descriptions: [*c]const GPUColorTargetDescription, // A pointer to an array of color target descriptions.
|
||||||
num_color_targets: u32, // The number of color target descriptions in the above array.
|
num_color_targets: u32, // The number of color target descriptions in the above array.
|
||||||
depth_stencil_format: GPUTextureFormat, // The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false.
|
depth_stencil_format: GPUTextureFormat, // The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false.
|
||||||
has_depth_stencil_target: bool, // true specifies that the pipeline uses a depth-stencil target.
|
has_depth_stencil_target: bool, // true specifies that the pipeline uses a depth-stencil target.
|
||||||
|
|
@ -1081,11 +1081,11 @@ pub inline fn gpuSupportsProperties(props: PropertiesID) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUDevice(format_flags: GPUShaderFormat, debug_mode: bool, name: [*c]const u8) ?*GPUDevice {
|
pub inline fn createGPUDevice(format_flags: GPUShaderFormat, debug_mode: bool, name: [*c]const u8) ?*GPUDevice {
|
||||||
return @ptrCast(c.SDL_CreateGPUDevice(@bitCast(format_flags), @bitCast(debug_mode), name));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUDevice(@bitCast(format_flags), @bitCast(debug_mode), name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUDeviceWithProperties(props: PropertiesID) ?*GPUDevice {
|
pub inline fn createGPUDeviceWithProperties(props: PropertiesID) ?*GPUDevice {
|
||||||
return @ptrCast(c.SDL_CreateGPUDeviceWithProperties(props));
|
return @ptrCast(@alignCast(c.SDL_CreateGPUDeviceWithProperties(props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const GPUVulkanOptions = extern struct {
|
pub const GPUVulkanOptions = extern struct {
|
||||||
|
|
@ -1107,17 +1107,17 @@ pub inline fn getGPUDriver(index: c_int) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gpuTextureFormatTexelBlockSize(format: GPUTextureFormat) u32 {
|
pub inline fn gpuTextureFormatTexelBlockSize(format: GPUTextureFormat) u32 {
|
||||||
return c.SDL_GPUTextureFormatTexelBlockSize(@bitCast(format));
|
return c.SDL_GPUTextureFormatTexelBlockSize(@intCast(@backingInt(format)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn calculateGPUTextureFormatSize(format: GPUTextureFormat, width: u32, height: u32, depth_or_layer_count: u32) u32 {
|
pub inline fn calculateGPUTextureFormatSize(format: GPUTextureFormat, width: u32, height: u32, depth_or_layer_count: u32) u32 {
|
||||||
return c.SDL_CalculateGPUTextureFormatSize(@bitCast(format), width, height, depth_or_layer_count);
|
return c.SDL_CalculateGPUTextureFormatSize(@intCast(@backingInt(format)), width, height, depth_or_layer_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPixelFormatFromGPUTextureFormat(format: GPUTextureFormat) PixelFormat {
|
pub inline fn getPixelFormatFromGPUTextureFormat(format: GPUTextureFormat) PixelFormat {
|
||||||
return @bitCast(c.SDL_GetPixelFormatFromGPUTextureFormat(@bitCast(format)));
|
return @fromBackingInt(@intCast(c.SDL_GetPixelFormatFromGPUTextureFormat(@intCast(@backingInt(format)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUTextureFormatFromPixelFormat(format: PixelFormat) GPUTextureFormat {
|
pub inline fn getGPUTextureFormatFromPixelFormat(format: PixelFormat) GPUTextureFormat {
|
||||||
return @bitCast(c.SDL_GetGPUTextureFormatFromPixelFormat(@bitCast(format)));
|
return @fromBackingInt(@intCast(c.SDL_GetGPUTextureFormatFromPixelFormat(@intCast(@backingInt(format)))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
const std = @import("std");
|
||||||
|
pub const c = @import("c.zig").c;
|
||||||
|
pub const GUID = extern struct {
|
||||||
|
data: [16]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub inline fn guidToString(guid: GUID, pszGUID: [*c]u8, cbGUID: c_int) void {
|
||||||
|
return c.SDL_GUIDToString(@as(*const c.SDL_GUID, @ptrCast(@alignCast(&guid))).*, pszGUID, cbGUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn stringToGUID(pchGUID: [*c]const u8) GUID {
|
||||||
|
return @as(*const GUID, @ptrCast(@alignCast(&c.SDL_StringToGUID(pchGUID)))).*;
|
||||||
|
}
|
||||||
|
|
@ -6,95 +6,95 @@ pub const Joystick = joystick_api.Joystick;
|
||||||
|
|
||||||
pub const Haptic = opaque {
|
pub const Haptic = opaque {
|
||||||
pub inline fn getHapticID(haptic: *Haptic) HapticID {
|
pub inline fn getHapticID(haptic: *Haptic) HapticID {
|
||||||
return c.SDL_GetHapticID(@ptrCast(haptic));
|
return c.SDL_GetHapticID(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticName(haptic: *Haptic) [*c]const u8 {
|
pub inline fn getHapticName(haptic: *Haptic) [*c]const u8 {
|
||||||
return c.SDL_GetHapticName(@ptrCast(haptic));
|
return c.SDL_GetHapticName(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeHaptic(haptic: *Haptic) void {
|
pub inline fn closeHaptic(haptic: *Haptic) void {
|
||||||
return c.SDL_CloseHaptic(@ptrCast(haptic));
|
return c.SDL_CloseHaptic(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMaxHapticEffects(haptic: *Haptic) c_int {
|
pub inline fn getMaxHapticEffects(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetMaxHapticEffects(@ptrCast(haptic));
|
return c.SDL_GetMaxHapticEffects(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMaxHapticEffectsPlaying(haptic: *Haptic) c_int {
|
pub inline fn getMaxHapticEffectsPlaying(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetMaxHapticEffectsPlaying(@ptrCast(haptic));
|
return c.SDL_GetMaxHapticEffectsPlaying(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticFeatures(haptic: *Haptic) u32 {
|
pub inline fn getHapticFeatures(haptic: *Haptic) u32 {
|
||||||
return c.SDL_GetHapticFeatures(@ptrCast(haptic));
|
return c.SDL_GetHapticFeatures(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumHapticAxes(haptic: *Haptic) c_int {
|
pub inline fn getNumHapticAxes(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetNumHapticAxes(@ptrCast(haptic));
|
return c.SDL_GetNumHapticAxes(@ptrCast(@alignCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hapticEffectSupported(haptic: *Haptic, effect: ?*const HapticEffect) bool {
|
pub inline fn hapticEffectSupported(haptic: *Haptic, effect: ?*const HapticEffect) bool {
|
||||||
return @bitCast(c.SDL_HapticEffectSupported(@ptrCast(haptic), @ptrCast(effect)));
|
return @bitCast(c.SDL_HapticEffectSupported(@ptrCast(@alignCast(haptic)), @ptrCast(@alignCast(effect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createHapticEffect(haptic: *Haptic, effect: ?*const HapticEffect) HapticEffectID {
|
pub inline fn createHapticEffect(haptic: *Haptic, effect: ?*const HapticEffect) HapticEffectID {
|
||||||
return c.SDL_CreateHapticEffect(@ptrCast(haptic), @ptrCast(effect));
|
return c.SDL_CreateHapticEffect(@ptrCast(@alignCast(haptic)), @ptrCast(@alignCast(effect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateHapticEffect(haptic: *Haptic, effect: HapticEffectID, data: ?*const HapticEffect) bool {
|
pub inline fn updateHapticEffect(haptic: *Haptic, effect: HapticEffectID, data: ?*const HapticEffect) bool {
|
||||||
return @bitCast(c.SDL_UpdateHapticEffect(@ptrCast(haptic), effect, @ptrCast(data)));
|
return @bitCast(c.SDL_UpdateHapticEffect(@ptrCast(@alignCast(haptic)), effect, @ptrCast(@alignCast(data))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn runHapticEffect(haptic: *Haptic, effect: HapticEffectID, iterations: u32) bool {
|
pub inline fn runHapticEffect(haptic: *Haptic, effect: HapticEffectID, iterations: u32) bool {
|
||||||
return @bitCast(c.SDL_RunHapticEffect(@ptrCast(haptic), effect, iterations));
|
return @bitCast(c.SDL_RunHapticEffect(@ptrCast(@alignCast(haptic)), effect, iterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticEffect(haptic: *Haptic, effect: HapticEffectID) bool {
|
pub inline fn stopHapticEffect(haptic: *Haptic, effect: HapticEffectID) bool {
|
||||||
return @bitCast(c.SDL_StopHapticEffect(@ptrCast(haptic), effect));
|
return @bitCast(c.SDL_StopHapticEffect(@ptrCast(@alignCast(haptic)), effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyHapticEffect(haptic: *Haptic, effect: HapticEffectID) void {
|
pub inline fn destroyHapticEffect(haptic: *Haptic, effect: HapticEffectID) void {
|
||||||
return c.SDL_DestroyHapticEffect(@ptrCast(haptic), effect);
|
return c.SDL_DestroyHapticEffect(@ptrCast(@alignCast(haptic)), effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticEffectStatus(haptic: *Haptic, effect: HapticEffectID) bool {
|
pub inline fn getHapticEffectStatus(haptic: *Haptic, effect: HapticEffectID) bool {
|
||||||
return @bitCast(c.SDL_GetHapticEffectStatus(@ptrCast(haptic), effect));
|
return @bitCast(c.SDL_GetHapticEffectStatus(@ptrCast(@alignCast(haptic)), effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHapticGain(haptic: *Haptic, gain: c_int) bool {
|
pub inline fn setHapticGain(haptic: *Haptic, gain: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetHapticGain(@ptrCast(haptic), gain));
|
return @bitCast(c.SDL_SetHapticGain(@ptrCast(@alignCast(haptic)), gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHapticAutocenter(haptic: *Haptic, autocenter: c_int) bool {
|
pub inline fn setHapticAutocenter(haptic: *Haptic, autocenter: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetHapticAutocenter(@ptrCast(haptic), autocenter));
|
return @bitCast(c.SDL_SetHapticAutocenter(@ptrCast(@alignCast(haptic)), autocenter));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pauseHaptic(haptic: *Haptic) bool {
|
pub inline fn pauseHaptic(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_PauseHaptic(@ptrCast(haptic)));
|
return @bitCast(c.SDL_PauseHaptic(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resumeHaptic(haptic: *Haptic) bool {
|
pub inline fn resumeHaptic(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_ResumeHaptic(@ptrCast(haptic)));
|
return @bitCast(c.SDL_ResumeHaptic(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticEffects(haptic: *Haptic) bool {
|
pub inline fn stopHapticEffects(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_StopHapticEffects(@ptrCast(haptic)));
|
return @bitCast(c.SDL_StopHapticEffects(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hapticRumbleSupported(haptic: *Haptic) bool {
|
pub inline fn hapticRumbleSupported(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_HapticRumbleSupported(@ptrCast(haptic)));
|
return @bitCast(c.SDL_HapticRumbleSupported(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn initHapticRumble(haptic: *Haptic) bool {
|
pub inline fn initHapticRumble(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_InitHapticRumble(@ptrCast(haptic)));
|
return @bitCast(c.SDL_InitHapticRumble(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn playHapticRumble(haptic: *Haptic, strength: f32, length: u32) bool {
|
pub inline fn playHapticRumble(haptic: *Haptic, strength: f32, length: u32) bool {
|
||||||
return @bitCast(c.SDL_PlayHapticRumble(@ptrCast(haptic), strength, length));
|
return @bitCast(c.SDL_PlayHapticRumble(@ptrCast(@alignCast(haptic)), strength, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticRumble(haptic: *Haptic) bool {
|
pub inline fn stopHapticRumble(haptic: *Haptic) bool {
|
||||||
return @bitCast(c.SDL_StopHapticRumble(@ptrCast(haptic)));
|
return @bitCast(c.SDL_StopHapticRumble(@ptrCast(@alignCast(haptic))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -124,6 +124,7 @@ pub const HapticConstant = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticPeriodic = extern struct {
|
pub const HapticPeriodic = extern struct {
|
||||||
|
_type: HapticEffectType,
|
||||||
direction: HapticDirection, // Direction of the effect.
|
direction: HapticDirection, // Direction of the effect.
|
||||||
length: u32, // Duration of the effect.
|
length: u32, // Duration of the effect.
|
||||||
delay: u16, // Delay before starting the effect.
|
delay: u16, // Delay before starting the effect.
|
||||||
|
|
@ -140,6 +141,7 @@ pub const HapticPeriodic = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticCondition = extern struct {
|
pub const HapticCondition = extern struct {
|
||||||
|
_type: HapticEffectType,
|
||||||
direction: HapticDirection, // Direction of the effect.
|
direction: HapticDirection, // Direction of the effect.
|
||||||
length: u32, // Duration of the effect.
|
length: u32, // Duration of the effect.
|
||||||
delay: u16, // Delay before starting the effect.
|
delay: u16, // Delay before starting the effect.
|
||||||
|
|
@ -185,7 +187,7 @@ pub const HapticCustom = extern struct {
|
||||||
channels: u8, // Axes to use, minimum of one.
|
channels: u8, // Axes to use, minimum of one.
|
||||||
period: u16, // Sample periods.
|
period: u16, // Sample periods.
|
||||||
samples: u16, // Amount of samples.
|
samples: u16, // Amount of samples.
|
||||||
data: *u16, // Should contain channels*samples items.
|
data: [*c]u16, // Should contain channels*samples items.
|
||||||
attack_length: u16, // Duration of the attack.
|
attack_length: u16, // Duration of the attack.
|
||||||
attack_level: u16, // Level at the start of the attack.
|
attack_level: u16, // Level at the start of the attack.
|
||||||
fade_length: u16, // Duration of the fade.
|
fade_length: u16, // Duration of the fade.
|
||||||
|
|
@ -204,8 +206,8 @@ pub const HapticEffect = extern union {
|
||||||
|
|
||||||
pub const HapticID = u32;
|
pub const HapticID = u32;
|
||||||
|
|
||||||
pub inline fn getHaptics(count: *c_int) ?*HapticID {
|
pub inline fn getHaptics(count: ?*c_int) ?*HapticID {
|
||||||
return @ptrCast(c.SDL_GetHaptics(@ptrCast(count)));
|
return c.SDL_GetHaptics(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
||||||
|
|
@ -213,11 +215,11 @@ pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHaptic(instance_id: HapticID) ?*Haptic {
|
pub inline fn openHaptic(instance_id: HapticID) ?*Haptic {
|
||||||
return @ptrCast(c.SDL_OpenHaptic(instance_id));
|
return @ptrCast(@alignCast(c.SDL_OpenHaptic(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticFromID(instance_id: HapticID) ?*Haptic {
|
pub inline fn getHapticFromID(instance_id: HapticID) ?*Haptic {
|
||||||
return @ptrCast(c.SDL_GetHapticFromID(instance_id));
|
return @ptrCast(@alignCast(c.SDL_GetHapticFromID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isMouseHaptic() bool {
|
pub inline fn isMouseHaptic() bool {
|
||||||
|
|
@ -225,13 +227,13 @@ pub inline fn isMouseHaptic() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHapticFromMouse() ?*Haptic {
|
pub inline fn openHapticFromMouse() ?*Haptic {
|
||||||
return @ptrCast(c.SDL_OpenHapticFromMouse());
|
return @ptrCast(@alignCast(c.SDL_OpenHapticFromMouse()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isJoystickHaptic(joystick: ?*Joystick) bool {
|
pub inline fn isJoystickHaptic(joystick: ?*Joystick) bool {
|
||||||
return @bitCast(c.SDL_IsJoystickHaptic(@ptrCast(joystick)));
|
return @bitCast(c.SDL_IsJoystickHaptic(@ptrCast(@alignCast(joystick))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHapticFromJoystick(joystick: ?*Joystick) ?*Haptic {
|
pub inline fn openHapticFromJoystick(joystick: ?*Joystick) ?*Haptic {
|
||||||
return @ptrCast(c.SDL_OpenHapticFromJoystick(@ptrCast(joystick)));
|
return @ptrCast(@alignCast(c.SDL_OpenHapticFromJoystick(@ptrCast(@alignCast(joystick)))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub const HintPriority = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn setHintWithPriority(name: [*c]const u8, value: [*c]const u8, priority: HintPriority) bool {
|
pub inline fn setHintWithPriority(name: [*c]const u8, value: [*c]const u8, priority: HintPriority) bool {
|
||||||
return @bitCast(c.SDL_SetHintWithPriority(name, value, priority));
|
return @bitCast(c.SDL_SetHintWithPriority(name, value, @intCast(@backingInt(priority))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHint(name: [*c]const u8, value: [*c]const u8) bool {
|
pub inline fn setHint(name: [*c]const u8, value: [*c]const u8) bool {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
pub const InitFlags = packed struct(u32) {
|
pub const InitFlags = packed struct(u32) {
|
||||||
|
pad0: u4 = 0,
|
||||||
initAudio: bool = false, // `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS`
|
initAudio: bool = false, // `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS`
|
||||||
initVideo: bool = false, // `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread
|
initVideo: bool = false, // `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread
|
||||||
|
pad1: u3 = 0,
|
||||||
initJoystick: bool = false, // `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`
|
initJoystick: bool = false, // `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`
|
||||||
|
pad2: u2 = 0,
|
||||||
initHaptic: bool = false,
|
initHaptic: bool = false,
|
||||||
initGamepad: bool = false, // `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK`
|
initGamepad: bool = false, // `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK`
|
||||||
initEvents: bool = false,
|
initEvents: bool = false,
|
||||||
initSensor: bool = false, // `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS`
|
initSensor: bool = false, // `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS`
|
||||||
initCamera: bool = false, // `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS`
|
initCamera: bool = false, // `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS`
|
||||||
pad0: u23 = 0,
|
pad3: u14 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
pub const None = InitFlags{};
|
pub const None = InitFlags{};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
const std = @import("std");
|
||||||
|
pub const c = @import("c.zig").c;
|
||||||
|
const properties_api = @import("properties.zig");
|
||||||
|
|
||||||
|
pub const PropertiesID = properties_api.PropertiesID;
|
||||||
|
|
||||||
|
pub const unsupported = struct {
|
||||||
|
pub const SDL_IOprintf = "varargs function is not representable in Zig";
|
||||||
|
pub const SDL_IOvprintf = "varargs function is not representable in Zig";
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const IOStatus = enum(c_int) {
|
||||||
|
ioStatusReady, //Everything is ready (no errors and not EOF).
|
||||||
|
ioStatusError, //Read or write I/O error
|
||||||
|
ioStatusEof, //End of file
|
||||||
|
ioStatusNotReady, //Non blocking I/O, not ready
|
||||||
|
ioStatusReadonly, //Tried to write a read-only buffer
|
||||||
|
ioStatusWriteonly, //Tried to read a write-only buffer
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const IOWhence = enum(c_int) {
|
||||||
|
ioSeekSet, //Seek from the beginning of data
|
||||||
|
ioSeekCur, //Seek relative to current read point
|
||||||
|
ioSeekEnd, //Seek relative to the end of data
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const IOStreamInterface = extern struct {
|
||||||
|
version: u32,
|
||||||
|
size: ?*const fn (?*anyopaque) callconv(.c) i64,
|
||||||
|
seek: ?*const fn (?*anyopaque, i64, IOWhence) callconv(.c) i64,
|
||||||
|
read: ?*const fn (?*anyopaque, ?*anyopaque, usize, ?*IOStatus) callconv(.c) usize,
|
||||||
|
write: ?*const fn (?*anyopaque, ?*const anyopaque, usize, ?*IOStatus) callconv(.c) usize,
|
||||||
|
flush: ?*const fn (?*anyopaque, ?*IOStatus) callconv(.c) bool,
|
||||||
|
close: ?*const fn (?*anyopaque) callconv(.c) bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const IOStream = opaque {
|
||||||
|
pub inline fn closeIO(iostream: *IOStream) bool {
|
||||||
|
return @bitCast(c.SDL_CloseIO(@ptrCast(@alignCast(iostream))));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getIOProperties(iostream: *IOStream) PropertiesID {
|
||||||
|
return c.SDL_GetIOProperties(@ptrCast(@alignCast(iostream)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getIOStatus(iostream: *IOStream) IOStatus {
|
||||||
|
return @fromBackingInt(@intCast(c.SDL_GetIOStatus(@ptrCast(@alignCast(iostream)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getIOSize(iostream: *IOStream) i64 {
|
||||||
|
return c.SDL_GetIOSize(@ptrCast(@alignCast(iostream)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn seekIO(iostream: *IOStream, offset: i64, whence: IOWhence) i64 {
|
||||||
|
return c.SDL_SeekIO(@ptrCast(@alignCast(iostream)), offset, @intCast(@backingInt(whence)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn tellIO(iostream: *IOStream) i64 {
|
||||||
|
return c.SDL_TellIO(@ptrCast(@alignCast(iostream)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readIO(iostream: *IOStream, ptr: ?*anyopaque, size: usize) usize {
|
||||||
|
return c.SDL_ReadIO(@ptrCast(@alignCast(iostream)), ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeIO(iostream: *IOStream, ptr: ?*const anyopaque, size: usize) usize {
|
||||||
|
return c.SDL_WriteIO(@ptrCast(@alignCast(iostream)), ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn flushIO(iostream: *IOStream) bool {
|
||||||
|
return @bitCast(c.SDL_FlushIO(@ptrCast(@alignCast(iostream))));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn loadFile_IO(iostream: *IOStream, datasize: ?*usize, closeio: bool) ?*anyopaque {
|
||||||
|
return c.SDL_LoadFile_IO(@ptrCast(@alignCast(iostream)), datasize, @bitCast(closeio));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn saveFile_IO(iostream: *IOStream, data: ?*const anyopaque, datasize: usize, closeio: bool) bool {
|
||||||
|
return @bitCast(c.SDL_SaveFile_IO(@ptrCast(@alignCast(iostream)), data, datasize, @bitCast(closeio)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU8(iostream: *IOStream, value: [*c]u8) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU8(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS8(iostream: *IOStream, value: ?*i8) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS8(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU16LE(iostream: *IOStream, value: ?*u16) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU16LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS16LE(iostream: *IOStream, value: ?*i16) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS16LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU16BE(iostream: *IOStream, value: ?*u16) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU16BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS16BE(iostream: *IOStream, value: ?*i16) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS16BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU32LE(iostream: *IOStream, value: ?*u32) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU32LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS32LE(iostream: *IOStream, value: ?*i32) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS32LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU32BE(iostream: *IOStream, value: ?*u32) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU32BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS32BE(iostream: *IOStream, value: ?*i32) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS32BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU64LE(iostream: *IOStream, value: ?*u64) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU64LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS64LE(iostream: *IOStream, value: ?*i64) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS64LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readU64BE(iostream: *IOStream, value: ?*u64) bool {
|
||||||
|
return @bitCast(c.SDL_ReadU64BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn readS64BE(iostream: *IOStream, value: ?*i64) bool {
|
||||||
|
return @bitCast(c.SDL_ReadS64BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU8(iostream: *IOStream, value: u8) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU8(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS8(iostream: *IOStream, value: i8) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS8(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU16LE(iostream: *IOStream, value: u16) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU16LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS16LE(iostream: *IOStream, value: i16) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS16LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU16BE(iostream: *IOStream, value: u16) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU16BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS16BE(iostream: *IOStream, value: i16) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS16BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU32LE(iostream: *IOStream, value: u32) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU32LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS32LE(iostream: *IOStream, value: i32) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS32LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU32BE(iostream: *IOStream, value: u32) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU32BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS32BE(iostream: *IOStream, value: i32) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS32BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU64LE(iostream: *IOStream, value: u64) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU64LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS64LE(iostream: *IOStream, value: i64) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS64LE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeU64BE(iostream: *IOStream, value: u64) bool {
|
||||||
|
return @bitCast(c.SDL_WriteU64BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn writeS64BE(iostream: *IOStream, value: i64) bool {
|
||||||
|
return @bitCast(c.SDL_WriteS64BE(@ptrCast(@alignCast(iostream)), value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pub inline fn ioFromFile(file: [*c]const u8, mode: [*c]const u8) ?*IOStream {
|
||||||
|
return @ptrCast(@alignCast(c.SDL_IOFromFile(file, mode)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn ioFromMem(mem: ?*anyopaque, size: usize) ?*IOStream {
|
||||||
|
return @ptrCast(@alignCast(c.SDL_IOFromMem(mem, size)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn ioFromConstMem(mem: ?*const anyopaque, size: usize) ?*IOStream {
|
||||||
|
return @ptrCast(@alignCast(c.SDL_IOFromConstMem(mem, size)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn ioFromDynamicMem() ?*IOStream {
|
||||||
|
return @ptrCast(@alignCast(c.SDL_IOFromDynamicMem()));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn openIO(iface: ?*const IOStreamInterface, userdata: ?*anyopaque) ?*IOStream {
|
||||||
|
return @ptrCast(@alignCast(c.SDL_OpenIO(@ptrCast(@alignCast(iface)), userdata)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn loadFile(file: [*c]const u8, datasize: ?*usize) ?*anyopaque {
|
||||||
|
return c.SDL_LoadFile(file, datasize);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn saveFile(file: [*c]const u8, data: ?*const anyopaque, datasize: usize) bool {
|
||||||
|
return @bitCast(c.SDL_SaveFile(file, data, datasize));
|
||||||
|
}
|
||||||
121
api/joystick.zig
121
api/joystick.zig
|
|
@ -12,147 +12,147 @@ pub const PowerState = power_api.PowerState;
|
||||||
|
|
||||||
pub const Joystick = opaque {
|
pub const Joystick = opaque {
|
||||||
pub inline fn setJoystickVirtualAxis(joystick: *Joystick, axis: c_int, value: i16) bool {
|
pub inline fn setJoystickVirtualAxis(joystick: *Joystick, axis: c_int, value: i16) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickVirtualAxis(@ptrCast(joystick), axis, value));
|
return @bitCast(c.SDL_SetJoystickVirtualAxis(@ptrCast(@alignCast(joystick)), axis, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualBall(joystick: *Joystick, ball: c_int, xrel: i16, yrel: i16) bool {
|
pub inline fn setJoystickVirtualBall(joystick: *Joystick, ball: c_int, xrel: i16, yrel: i16) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickVirtualBall(@ptrCast(joystick), ball, xrel, yrel));
|
return @bitCast(c.SDL_SetJoystickVirtualBall(@ptrCast(@alignCast(joystick)), ball, xrel, yrel));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualButton(joystick: *Joystick, button: c_int, down: bool) bool {
|
pub inline fn setJoystickVirtualButton(joystick: *Joystick, button: c_int, down: bool) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickVirtualButton(@ptrCast(joystick), button, @bitCast(down)));
|
return @bitCast(c.SDL_SetJoystickVirtualButton(@ptrCast(@alignCast(joystick)), button, @bitCast(down)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualHat(joystick: *Joystick, hat: c_int, value: u8) bool {
|
pub inline fn setJoystickVirtualHat(joystick: *Joystick, hat: c_int, value: u8) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickVirtualHat(@ptrCast(joystick), hat, value));
|
return @bitCast(c.SDL_SetJoystickVirtualHat(@ptrCast(@alignCast(joystick)), hat, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualTouchpad(joystick: *Joystick, touchpad: c_int, finger: c_int, down: bool, x: f32, y: f32, pressure: f32) bool {
|
pub inline fn setJoystickVirtualTouchpad(joystick: *Joystick, touchpad: c_int, finger: c_int, down: bool, x: f32, y: f32, pressure: f32) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickVirtualTouchpad(@ptrCast(joystick), touchpad, finger, @bitCast(down), x, y, pressure));
|
return @bitCast(c.SDL_SetJoystickVirtualTouchpad(@ptrCast(@alignCast(joystick)), touchpad, finger, @bitCast(down), x, y, pressure));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendJoystickVirtualSensorData(joystick: *Joystick, _type: SensorType, sensor_timestamp: u64, data: *const f32, num_values: c_int) bool {
|
pub inline fn sendJoystickVirtualSensorData(joystick: *Joystick, _type: SensorType, sensor_timestamp: u64, data: *const f32, num_values: c_int) bool {
|
||||||
return @bitCast(c.SDL_SendJoystickVirtualSensorData(@ptrCast(joystick), @intFromEnum(_type), sensor_timestamp, @ptrCast(data), num_values));
|
return @bitCast(c.SDL_SendJoystickVirtualSensorData(@ptrCast(@alignCast(joystick)), @intCast(@backingInt(_type)), sensor_timestamp, data, num_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProperties(joystick: *Joystick) PropertiesID {
|
pub inline fn getJoystickProperties(joystick: *Joystick) PropertiesID {
|
||||||
return c.SDL_GetJoystickProperties(@ptrCast(joystick));
|
return c.SDL_GetJoystickProperties(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickName(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickName(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickName(@ptrCast(joystick));
|
return c.SDL_GetJoystickName(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPath(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickPath(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickPath(@ptrCast(joystick));
|
return c.SDL_GetJoystickPath(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPlayerIndex(joystick: *Joystick) c_int {
|
pub inline fn getJoystickPlayerIndex(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetJoystickPlayerIndex(@ptrCast(joystick));
|
return c.SDL_GetJoystickPlayerIndex(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickPlayerIndex(joystick: *Joystick, player_index: c_int) bool {
|
pub inline fn setJoystickPlayerIndex(joystick: *Joystick, player_index: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickPlayerIndex(@ptrCast(joystick), player_index));
|
return @bitCast(c.SDL_SetJoystickPlayerIndex(@ptrCast(@alignCast(joystick)), player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickGUID(joystick: *Joystick) GUID {
|
pub inline fn getJoystickGUID(joystick: *Joystick) GUID {
|
||||||
return c.SDL_GetJoystickGUID(@ptrCast(joystick));
|
return @as(*const GUID, @ptrCast(@alignCast(&c.SDL_GetJoystickGUID(@ptrCast(@alignCast(joystick)))))).*;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickVendor(joystick: *Joystick) u16 {
|
pub inline fn getJoystickVendor(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickVendor(@ptrCast(joystick));
|
return c.SDL_GetJoystickVendor(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProduct(joystick: *Joystick) u16 {
|
pub inline fn getJoystickProduct(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickProduct(@ptrCast(joystick));
|
return c.SDL_GetJoystickProduct(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProductVersion(joystick: *Joystick) u16 {
|
pub inline fn getJoystickProductVersion(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickProductVersion(@ptrCast(joystick));
|
return c.SDL_GetJoystickProductVersion(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFirmwareVersion(joystick: *Joystick) u16 {
|
pub inline fn getJoystickFirmwareVersion(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickFirmwareVersion(@ptrCast(joystick));
|
return c.SDL_GetJoystickFirmwareVersion(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickSerial(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickSerial(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickSerial(@ptrCast(joystick));
|
return c.SDL_GetJoystickSerial(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickType(joystick: *Joystick) JoystickType {
|
pub inline fn getJoystickType(joystick: *Joystick) JoystickType {
|
||||||
return @intFromEnum(c.SDL_GetJoystickType(@ptrCast(joystick)));
|
return @fromBackingInt(@intCast(c.SDL_GetJoystickType(@ptrCast(@alignCast(joystick)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn joystickConnected(joystick: *Joystick) bool {
|
pub inline fn joystickConnected(joystick: *Joystick) bool {
|
||||||
return @bitCast(c.SDL_JoystickConnected(@ptrCast(joystick)));
|
return @bitCast(c.SDL_JoystickConnected(@ptrCast(@alignCast(joystick))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickID(joystick: *Joystick) JoystickID {
|
pub inline fn getJoystickID(joystick: *Joystick) JoystickID {
|
||||||
return c.SDL_GetJoystickID(@ptrCast(joystick));
|
return c.SDL_GetJoystickID(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickAxes(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickAxes(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickAxes(@ptrCast(joystick));
|
return c.SDL_GetNumJoystickAxes(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickBalls(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickBalls(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickBalls(@ptrCast(joystick));
|
return c.SDL_GetNumJoystickBalls(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickHats(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickHats(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickHats(@ptrCast(joystick));
|
return c.SDL_GetNumJoystickHats(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickButtons(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickButtons(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickButtons(@ptrCast(joystick));
|
return c.SDL_GetNumJoystickButtons(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickAxis(joystick: *Joystick, axis: c_int) i16 {
|
pub inline fn getJoystickAxis(joystick: *Joystick, axis: c_int) i16 {
|
||||||
return c.SDL_GetJoystickAxis(@ptrCast(joystick), axis);
|
return c.SDL_GetJoystickAxis(@ptrCast(@alignCast(joystick)), axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: *i16) bool {
|
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: ?*i16) bool {
|
||||||
return @bitCast(c.SDL_GetJoystickAxisInitialState(@ptrCast(joystick), axis, @ptrCast(state)));
|
return @bitCast(c.SDL_GetJoystickAxisInitialState(@ptrCast(@alignCast(joystick)), axis, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickBall(joystick: *Joystick, ball: c_int, dx: *c_int, dy: *c_int) bool {
|
pub inline fn getJoystickBall(joystick: *Joystick, ball: c_int, dx: ?*c_int, dy: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetJoystickBall(@ptrCast(joystick), ball, @ptrCast(dx), @ptrCast(dy)));
|
return @bitCast(c.SDL_GetJoystickBall(@ptrCast(@alignCast(joystick)), ball, dx, dy));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickHat(joystick: *Joystick, hat: c_int) u8 {
|
pub inline fn getJoystickHat(joystick: *Joystick, hat: c_int) u8 {
|
||||||
return c.SDL_GetJoystickHat(@ptrCast(joystick), hat);
|
return c.SDL_GetJoystickHat(@ptrCast(@alignCast(joystick)), hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickButton(joystick: *Joystick, button: c_int) bool {
|
pub inline fn getJoystickButton(joystick: *Joystick, button: c_int) bool {
|
||||||
return @bitCast(c.SDL_GetJoystickButton(@ptrCast(joystick), button));
|
return @bitCast(c.SDL_GetJoystickButton(@ptrCast(@alignCast(joystick)), button));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rumbleJoystick(joystick: *Joystick, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
|
pub inline fn rumbleJoystick(joystick: *Joystick, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
|
||||||
return @bitCast(c.SDL_RumbleJoystick(@ptrCast(joystick), low_frequency_rumble, high_frequency_rumble, duration_ms));
|
return @bitCast(c.SDL_RumbleJoystick(@ptrCast(@alignCast(joystick)), low_frequency_rumble, high_frequency_rumble, duration_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rumbleJoystickTriggers(joystick: *Joystick, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
|
pub inline fn rumbleJoystickTriggers(joystick: *Joystick, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
|
||||||
return @bitCast(c.SDL_RumbleJoystickTriggers(@ptrCast(joystick), left_rumble, right_rumble, duration_ms));
|
return @bitCast(c.SDL_RumbleJoystickTriggers(@ptrCast(@alignCast(joystick)), left_rumble, right_rumble, duration_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickLED(joystick: *Joystick, red: u8, green: u8, blue: u8) bool {
|
pub inline fn setJoystickLED(joystick: *Joystick, red: u8, green: u8, blue: u8) bool {
|
||||||
return @bitCast(c.SDL_SetJoystickLED(@ptrCast(joystick), red, green, blue));
|
return @bitCast(c.SDL_SetJoystickLED(@ptrCast(@alignCast(joystick)), red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendJoystickEffect(joystick: *Joystick, data: ?*const anyopaque, size: c_int) bool {
|
pub inline fn sendJoystickEffect(joystick: *Joystick, data: ?*const anyopaque, size: c_int) bool {
|
||||||
return @bitCast(c.SDL_SendJoystickEffect(@ptrCast(joystick), data, size));
|
return @bitCast(c.SDL_SendJoystickEffect(@ptrCast(@alignCast(joystick)), data, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeJoystick(joystick: *Joystick) void {
|
pub inline fn closeJoystick(joystick: *Joystick) void {
|
||||||
return c.SDL_CloseJoystick(@ptrCast(joystick));
|
return c.SDL_CloseJoystick(@ptrCast(@alignCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickConnectionState(joystick: *Joystick) JoystickConnectionState {
|
pub inline fn getJoystickConnectionState(joystick: *Joystick) JoystickConnectionState {
|
||||||
return c.SDL_GetJoystickConnectionState(@ptrCast(joystick));
|
return @fromBackingInt(@intCast(c.SDL_GetJoystickConnectionState(@ptrCast(@alignCast(joystick)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPowerInfo(joystick: *Joystick, percent: *c_int) PowerState {
|
pub inline fn getJoystickPowerInfo(joystick: *Joystick, percent: ?*c_int) PowerState {
|
||||||
return c.SDL_GetJoystickPowerInfo(@ptrCast(joystick), @ptrCast(percent));
|
return @fromBackingInt(@intCast(c.SDL_GetJoystickPowerInfo(@ptrCast(@alignCast(joystick)), percent)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -173,6 +173,7 @@ pub const JoystickType = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const JoystickConnectionState = enum(c_int) {
|
pub const JoystickConnectionState = enum(c_int) {
|
||||||
|
joystickConnectionInvalid = -1,
|
||||||
joystickConnectionUnknown,
|
joystickConnectionUnknown,
|
||||||
joystickConnectionWired,
|
joystickConnectionWired,
|
||||||
joystickConnectionWireless,
|
joystickConnectionWireless,
|
||||||
|
|
@ -190,8 +191,8 @@ pub inline fn hasJoystick() bool {
|
||||||
return @bitCast(c.SDL_HasJoystick());
|
return @bitCast(c.SDL_HasJoystick());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoysticks(count: *c_int) ?*JoystickID {
|
pub inline fn getJoysticks(count: ?*c_int) ?*JoystickID {
|
||||||
return @ptrCast(c.SDL_GetJoysticks(@ptrCast(count)));
|
return c.SDL_GetJoysticks(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickNameForID(instance_id: JoystickID) [*c]const u8 {
|
pub inline fn getJoystickNameForID(instance_id: JoystickID) [*c]const u8 {
|
||||||
|
|
@ -207,7 +208,7 @@ pub inline fn getJoystickPlayerIndexForID(instance_id: JoystickID) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickGUIDForID(instance_id: JoystickID) GUID {
|
pub inline fn getJoystickGUIDForID(instance_id: JoystickID) GUID {
|
||||||
return c.SDL_GetJoystickGUIDForID(instance_id);
|
return @as(*const GUID, @ptrCast(@alignCast(&c.SDL_GetJoystickGUIDForID(instance_id)))).*;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickVendorForID(instance_id: JoystickID) u16 {
|
pub inline fn getJoystickVendorForID(instance_id: JoystickID) u16 {
|
||||||
|
|
@ -223,19 +224,19 @@ pub inline fn getJoystickProductVersionForID(instance_id: JoystickID) u16 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickTypeForID(instance_id: JoystickID) JoystickType {
|
pub inline fn getJoystickTypeForID(instance_id: JoystickID) JoystickType {
|
||||||
return @intFromEnum(c.SDL_GetJoystickTypeForID(instance_id));
|
return @fromBackingInt(@intCast(c.SDL_GetJoystickTypeForID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openJoystick(instance_id: JoystickID) ?*Joystick {
|
pub inline fn openJoystick(instance_id: JoystickID) ?*Joystick {
|
||||||
return @ptrCast(c.SDL_OpenJoystick(instance_id));
|
return @ptrCast(@alignCast(c.SDL_OpenJoystick(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFromID(instance_id: JoystickID) ?*Joystick {
|
pub inline fn getJoystickFromID(instance_id: JoystickID) ?*Joystick {
|
||||||
return @ptrCast(c.SDL_GetJoystickFromID(instance_id));
|
return @ptrCast(@alignCast(c.SDL_GetJoystickFromID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFromPlayerIndex(player_index: c_int) ?*Joystick {
|
pub inline fn getJoystickFromPlayerIndex(player_index: c_int) ?*Joystick {
|
||||||
return @ptrCast(c.SDL_GetJoystickFromPlayerIndex(player_index));
|
return @ptrCast(@alignCast(c.SDL_GetJoystickFromPlayerIndex(player_index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const VirtualJoystickTouchpadDesc = extern struct {
|
pub const VirtualJoystickTouchpadDesc = extern struct {
|
||||||
|
|
@ -261,22 +262,24 @@ pub const VirtualJoystickDesc = extern struct {
|
||||||
ntouchpads: u16, // the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions
|
ntouchpads: u16, // the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions
|
||||||
nsensors: u16, // the number of sensors on this joystick, requires `sensors` to point at valid descriptions
|
nsensors: u16, // the number of sensors on this joystick, requires `sensors` to point at valid descriptions
|
||||||
padding2: [2]u16, // unused
|
padding2: [2]u16, // unused
|
||||||
|
button_mask: u32,
|
||||||
|
axis_mask: u32,
|
||||||
name: [*c]const u8, // the name of the joystick
|
name: [*c]const u8, // the name of the joystick
|
||||||
touchpads: ?*const VirtualJoystickTouchpadDesc, // A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0
|
touchpads: [*c]const VirtualJoystickTouchpadDesc, // A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0
|
||||||
sensors: ?*const VirtualJoystickSensorDesc, // A pointer to an array of sensor descriptions, required if `nsensors` is > 0
|
sensors: [*c]const VirtualJoystickSensorDesc, // A pointer to an array of sensor descriptions, required if `nsensors` is > 0
|
||||||
userdata: ?*anyopaque, // User data pointer passed to callbacks
|
userdata: ?*anyopaque, // User data pointer passed to callbacks
|
||||||
Update: ?*const anyopaque, // Called when the joystick state should be updated
|
Update: ?*const fn (?*anyopaque) callconv(.c) void, // Called when the joystick state should be updated
|
||||||
SetPlayerIndex: ?*const anyopaque, // Called when the player index is set
|
SetPlayerIndex: ?*const fn (?*anyopaque, c_int) callconv(.c) void, // Called when the player index is set
|
||||||
Rumble: ?*const anyopaque, // Implements SDL_RumbleJoystick()
|
Rumble: ?*const fn (?*anyopaque, u16, u16) callconv(.c) bool, // Implements SDL_RumbleJoystick()
|
||||||
RumbleTriggers: ?*const anyopaque, // Implements SDL_RumbleJoystickTriggers()
|
RumbleTriggers: ?*const fn (?*anyopaque, u16, u16) callconv(.c) bool, // Implements SDL_RumbleJoystickTriggers()
|
||||||
SetLED: ?*const anyopaque, // Implements SDL_SetJoystickLED()
|
SetLED: ?*const fn (?*anyopaque, u8, u8, u8) callconv(.c) bool, // Implements SDL_SetJoystickLED()
|
||||||
SendEffect: ?*const anyopaque, // Implements SDL_SendJoystickEffect()
|
SendEffect: ?*const fn (?*anyopaque, ?*const anyopaque, c_int) callconv(.c) bool, // Implements SDL_SendJoystickEffect()
|
||||||
SetSensorsEnabled: ?*const anyopaque, // Implements SDL_SetGamepadSensorEnabled()
|
SetSensorsEnabled: ?*const fn (?*anyopaque, bool) callconv(.c) bool, // Implements SDL_SetGamepadSensorEnabled()
|
||||||
Cleanup: ?*const anyopaque, // Cleans up the userdata when the joystick is detached
|
Cleanup: ?*const fn (?*anyopaque) callconv(.c) void, // Cleans up the userdata when the joystick is detached
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn attachVirtualJoystick(desc: ?*const VirtualJoystickDesc) JoystickID {
|
pub inline fn attachVirtualJoystick(desc: ?*const VirtualJoystickDesc) JoystickID {
|
||||||
return c.SDL_AttachVirtualJoystick(@ptrCast(desc));
|
return c.SDL_AttachVirtualJoystick(@ptrCast(@alignCast(desc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn detachVirtualJoystick(instance_id: JoystickID) bool {
|
pub inline fn detachVirtualJoystick(instance_id: JoystickID) bool {
|
||||||
|
|
@ -287,8 +290,8 @@ pub inline fn isJoystickVirtual(instance_id: JoystickID) bool {
|
||||||
return @bitCast(c.SDL_IsJoystickVirtual(instance_id));
|
return @bitCast(c.SDL_IsJoystickVirtual(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: *u16, product: *u16, version: *u16, crc16: *u16) void {
|
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: ?*u16, product: ?*u16, version: ?*u16, crc16: ?*u16) void {
|
||||||
return c.SDL_GetJoystickGUIDInfo(guid, @ptrCast(vendor), @ptrCast(product), @ptrCast(version), @ptrCast(crc16));
|
return c.SDL_GetJoystickGUIDInfo(@as(*const c.SDL_GUID, @ptrCast(@alignCast(&guid))).*, vendor, product, version, crc16);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickEventsEnabled(enabled: bool) void {
|
pub inline fn setJoystickEventsEnabled(enabled: bool) void {
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ pub inline fn hasKeyboard() bool {
|
||||||
return @bitCast(c.SDL_HasKeyboard());
|
return @bitCast(c.SDL_HasKeyboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyboards(count: *c_int) ?*KeyboardID {
|
pub inline fn getKeyboards(count: ?*c_int) ?*KeyboardID {
|
||||||
return @ptrCast(c.SDL_GetKeyboards(@ptrCast(count)));
|
return c.SDL_GetKeyboards(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyboardNameForID(instance_id: KeyboardID) [*c]const u8 {
|
pub inline fn getKeyboardNameForID(instance_id: KeyboardID) [*c]const u8 {
|
||||||
|
|
@ -28,11 +28,11 @@ pub inline fn getKeyboardNameForID(instance_id: KeyboardID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyboardFocus() ?*Window {
|
pub inline fn getKeyboardFocus() ?*Window {
|
||||||
return @ptrCast(c.SDL_GetKeyboardFocus());
|
return @ptrCast(@alignCast(c.SDL_GetKeyboardFocus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyboardState(numkeys: *c_int) *const bool {
|
pub inline fn getKeyboardState(numkeys: ?*c_int) *const bool {
|
||||||
return @ptrCast(c.SDL_GetKeyboardState(@ptrCast(numkeys)));
|
return @ptrCast(@alignCast(c.SDL_GetKeyboardState(numkeys)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resetKeyboard() void {
|
pub inline fn resetKeyboard() void {
|
||||||
|
|
@ -48,23 +48,23 @@ pub inline fn setModState(modstate: Keymod) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyFromScancode(scancode: Scancode, modstate: Keymod, key_event: bool) Keycode {
|
pub inline fn getKeyFromScancode(scancode: Scancode, modstate: Keymod, key_event: bool) Keycode {
|
||||||
return c.SDL_GetKeyFromScancode(scancode, modstate, @bitCast(key_event));
|
return c.SDL_GetKeyFromScancode(@intCast(@backingInt(scancode)), modstate, @bitCast(key_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getScancodeFromKey(key: Keycode, modstate: ?*Keymod) Scancode {
|
pub inline fn getScancodeFromKey(key: Keycode, modstate: ?*Keymod) Scancode {
|
||||||
return c.SDL_GetScancodeFromKey(key, @ptrCast(modstate));
|
return @fromBackingInt(@intCast(c.SDL_GetScancodeFromKey(key, modstate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setScancodeName(scancode: Scancode, name: [*c]const u8) bool {
|
pub inline fn setScancodeName(scancode: Scancode, name: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_SetScancodeName(scancode, name));
|
return @bitCast(c.SDL_SetScancodeName(@intCast(@backingInt(scancode)), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getScancodeName(scancode: Scancode) [*c]const u8 {
|
pub inline fn getScancodeName(scancode: Scancode) [*c]const u8 {
|
||||||
return c.SDL_GetScancodeName(scancode);
|
return c.SDL_GetScancodeName(@intCast(@backingInt(scancode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getScancodeFromName(name: [*c]const u8) Scancode {
|
pub inline fn getScancodeFromName(name: [*c]const u8) Scancode {
|
||||||
return c.SDL_GetScancodeFromName(name);
|
return @fromBackingInt(@intCast(c.SDL_GetScancodeFromName(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyName(key: Keycode) [*c]const u8 {
|
pub inline fn getKeyName(key: Keycode) [*c]const u8 {
|
||||||
|
|
@ -76,7 +76,7 @@ pub inline fn getKeyFromName(name: [*c]const u8) Keycode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn startTextInput(window: ?*Window) bool {
|
pub inline fn startTextInput(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_StartTextInput(@ptrCast(window)));
|
return @bitCast(c.SDL_StartTextInput(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const TextInputType = enum(c_int) {
|
pub const TextInputType = enum(c_int) {
|
||||||
|
|
@ -99,27 +99,27 @@ pub const Capitalization = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn startTextInputWithProperties(window: ?*Window, props: PropertiesID) bool {
|
pub inline fn startTextInputWithProperties(window: ?*Window, props: PropertiesID) bool {
|
||||||
return @bitCast(c.SDL_StartTextInputWithProperties(@ptrCast(window), props));
|
return @bitCast(c.SDL_StartTextInputWithProperties(@ptrCast(@alignCast(window)), props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn textInputActive(window: ?*Window) bool {
|
pub inline fn textInputActive(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_TextInputActive(@ptrCast(window)));
|
return @bitCast(c.SDL_TextInputActive(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopTextInput(window: ?*Window) bool {
|
pub inline fn stopTextInput(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_StopTextInput(@ptrCast(window)));
|
return @bitCast(c.SDL_StopTextInput(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearComposition(window: ?*Window) bool {
|
pub inline fn clearComposition(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_ClearComposition(@ptrCast(window)));
|
return @bitCast(c.SDL_ClearComposition(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextInputArea(window: ?*Window, rect: ?*const Rect, cursor: c_int) bool {
|
pub inline fn setTextInputArea(window: ?*Window, rect: ?*const Rect, cursor: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetTextInputArea(@ptrCast(window), @ptrCast(rect), cursor));
|
return @bitCast(c.SDL_SetTextInputArea(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect)), cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextInputArea(window: ?*Window, rect: ?*Rect, cursor: *c_int) bool {
|
pub inline fn getTextInputArea(window: ?*Window, rect: ?*Rect, cursor: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetTextInputArea(@ptrCast(window), @ptrCast(rect), @ptrCast(cursor)));
|
return @bitCast(c.SDL_GetTextInputArea(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect)), cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasScreenKeyboardSupport() bool {
|
pub inline fn hasScreenKeyboardSupport() bool {
|
||||||
|
|
@ -127,5 +127,5 @@ pub inline fn hasScreenKeyboardSupport() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn screenKeyboardShown(window: ?*Window) bool {
|
pub inline fn screenKeyboardShown(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_ScreenKeyboardShown(@ptrCast(window)));
|
return @bitCast(c.SDL_ScreenKeyboardShown(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ pub const FunctionPointer = stdinc_api.FunctionPointer;
|
||||||
|
|
||||||
pub const SharedObject = opaque {
|
pub const SharedObject = opaque {
|
||||||
pub inline fn loadFunction(sharedobject: *SharedObject, name: [*c]const u8) FunctionPointer {
|
pub inline fn loadFunction(sharedobject: *SharedObject, name: [*c]const u8) FunctionPointer {
|
||||||
return c.SDL_LoadFunction(@ptrCast(sharedobject), name);
|
return c.SDL_LoadFunction(@ptrCast(@alignCast(sharedobject)), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unloadObject(sharedobject: *SharedObject) void {
|
pub inline fn unloadObject(sharedobject: *SharedObject) void {
|
||||||
return c.SDL_UnloadObject(@ptrCast(sharedobject));
|
return c.SDL_UnloadObject(@ptrCast(@alignCast(sharedobject)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn loadObject(sofile: [*c]const u8) ?*SharedObject {
|
pub inline fn loadObject(sofile: [*c]const u8) ?*SharedObject {
|
||||||
return @ptrCast(c.SDL_LoadObject(sofile));
|
return @ptrCast(@alignCast(c.SDL_LoadObject(sofile)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@ const video_api = @import("video.zig");
|
||||||
pub const Window = video_api.Window;
|
pub const Window = video_api.Window;
|
||||||
|
|
||||||
pub const MessageBoxFlags = packed struct(u32) {
|
pub const MessageBoxFlags = packed struct(u32) {
|
||||||
|
pad0: u4 = 0,
|
||||||
messageboxError: bool = false, // error dialog
|
messageboxError: bool = false, // error dialog
|
||||||
messageboxWarning: bool = false, // warning dialog
|
messageboxWarning: bool = false, // warning dialog
|
||||||
messageboxInformation: bool = false, // informational dialog
|
messageboxInformation: bool = false, // informational dialog
|
||||||
messageboxButtonsLeftToRight: bool = false, // buttons placed left to right
|
messageboxButtonsLeftToRight: bool = false, // buttons placed left to right
|
||||||
messageboxButtonsRightToLeft: bool = false, // buttons placed right to left
|
messageboxButtonsRightToLeft: bool = false, // buttons placed right to left
|
||||||
pad0: u26 = 0,
|
pad1: u22 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
pub const None = MessageBoxFlags{};
|
pub const None = MessageBoxFlags{};
|
||||||
|
|
@ -56,14 +57,14 @@ pub const MessageBoxData = extern struct {
|
||||||
title: [*c]const u8, // UTF-8 title
|
title: [*c]const u8, // UTF-8 title
|
||||||
message: [*c]const u8, // UTF-8 message text
|
message: [*c]const u8, // UTF-8 message text
|
||||||
numbuttons: c_int,
|
numbuttons: c_int,
|
||||||
buttons: ?*const MessageBoxButtonData,
|
buttons: [*c]const MessageBoxButtonData,
|
||||||
colorScheme: ?*const MessageBoxColorScheme, // SDL_MessageBoxColorScheme, can be NULL to use system settings
|
colorScheme: [*c]const MessageBoxColorScheme, // SDL_MessageBoxColorScheme, can be NULL to use system settings
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn showMessageBox(messageboxdata: ?*const MessageBoxData, buttonid: *c_int) bool {
|
pub inline fn showMessageBox(messageboxdata: ?*const MessageBoxData, buttonid: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid)));
|
return @bitCast(c.SDL_ShowMessageBox(@ptrCast(@alignCast(messageboxdata)), buttonid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showSimpleMessageBox(flags: MessageBoxFlags, title: [*c]const u8, message: [*c]const u8, window: ?*Window) bool {
|
pub inline fn showSimpleMessageBox(flags: MessageBoxFlags, title: [*c]const u8, message: [*c]const u8, window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_ShowSimpleMessageBox(@bitCast(flags), title, message, @ptrCast(window)));
|
return @bitCast(c.SDL_ShowSimpleMessageBox(@bitCast(flags), title, message, @ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ pub const MouseID = u32;
|
||||||
|
|
||||||
pub const Cursor = opaque {
|
pub const Cursor = opaque {
|
||||||
pub inline fn setCursor(cursor: *Cursor) bool {
|
pub inline fn setCursor(cursor: *Cursor) bool {
|
||||||
return @bitCast(c.SDL_SetCursor(@ptrCast(cursor)));
|
return @bitCast(c.SDL_SetCursor(@ptrCast(@alignCast(cursor))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyCursor(cursor: *Cursor) void {
|
pub inline fn destroyCursor(cursor: *Cursor) void {
|
||||||
return c.SDL_DestroyCursor(@ptrCast(cursor));
|
return c.SDL_DestroyCursor(@ptrCast(@alignCast(cursor)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -70,8 +70,8 @@ pub inline fn hasMouse() bool {
|
||||||
return @bitCast(c.SDL_HasMouse());
|
return @bitCast(c.SDL_HasMouse());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMice(count: *c_int) ?*MouseID {
|
pub inline fn getMice(count: ?*c_int) ?*MouseID {
|
||||||
return @ptrCast(c.SDL_GetMice(@ptrCast(count)));
|
return c.SDL_GetMice(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
||||||
|
|
@ -79,23 +79,23 @@ pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseFocus() ?*Window {
|
pub inline fn getMouseFocus() ?*Window {
|
||||||
return @ptrCast(c.SDL_GetMouseFocus());
|
return @ptrCast(@alignCast(c.SDL_GetMouseFocus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
pub inline fn getMouseState(x: ?*f32, y: ?*f32) MouseButtonFlags {
|
||||||
return @bitCast(c.SDL_GetMouseState(@ptrCast(x), @ptrCast(y)));
|
return @bitCast(c.SDL_GetMouseState(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGlobalMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
pub inline fn getGlobalMouseState(x: ?*f32, y: ?*f32) MouseButtonFlags {
|
||||||
return @bitCast(c.SDL_GetGlobalMouseState(@ptrCast(x), @ptrCast(y)));
|
return @bitCast(c.SDL_GetGlobalMouseState(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRelativeMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
pub inline fn getRelativeMouseState(x: ?*f32, y: ?*f32) MouseButtonFlags {
|
||||||
return @bitCast(c.SDL_GetRelativeMouseState(@ptrCast(x), @ptrCast(y)));
|
return @bitCast(c.SDL_GetRelativeMouseState(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn warpMouseInWindow(window: ?*Window, x: f32, y: f32) void {
|
pub inline fn warpMouseInWindow(window: ?*Window, x: f32, y: f32) void {
|
||||||
return c.SDL_WarpMouseInWindow(@ptrCast(window), x, y);
|
return c.SDL_WarpMouseInWindow(@ptrCast(@alignCast(window)), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn warpMouseGlobal(x: f32, y: f32) bool {
|
pub inline fn warpMouseGlobal(x: f32, y: f32) bool {
|
||||||
|
|
@ -107,11 +107,11 @@ pub inline fn setRelativeMouseTransform(callback: MouseMotionTransformCallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowRelativeMouseMode(window: ?*Window, enabled: bool) bool {
|
pub inline fn setWindowRelativeMouseMode(window: ?*Window, enabled: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowRelativeMouseMode(@ptrCast(window), @bitCast(enabled)));
|
return @bitCast(c.SDL_SetWindowRelativeMouseMode(@ptrCast(@alignCast(window)), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowRelativeMouseMode(window: ?*Window) bool {
|
pub inline fn getWindowRelativeMouseMode(window: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_GetWindowRelativeMouseMode(@ptrCast(window)));
|
return @bitCast(c.SDL_GetWindowRelativeMouseMode(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn captureMouse(enabled: bool) bool {
|
pub inline fn captureMouse(enabled: bool) bool {
|
||||||
|
|
@ -119,27 +119,27 @@ pub inline fn captureMouse(enabled: bool) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createCursor(data: [*c]const u8, mask: [*c]const u8, w: c_int, h: c_int, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
pub inline fn createCursor(data: [*c]const u8, mask: [*c]const u8, w: c_int, h: c_int, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
||||||
return @ptrCast(c.SDL_CreateCursor(data, mask, w, h, hot_x, hot_y));
|
return @ptrCast(@alignCast(c.SDL_CreateCursor(data, mask, w, h, hot_x, hot_y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createColorCursor(surface: ?*Surface, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
pub inline fn createColorCursor(surface: ?*Surface, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
||||||
return @ptrCast(c.SDL_CreateColorCursor(@ptrCast(surface), hot_x, hot_y));
|
return @ptrCast(@alignCast(c.SDL_CreateColorCursor(@ptrCast(@alignCast(surface)), hot_x, hot_y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createAnimatedCursor(frames: ?*CursorFrameInfo, frame_count: c_int, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
pub inline fn createAnimatedCursor(frames: ?*CursorFrameInfo, frame_count: c_int, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
||||||
return @ptrCast(c.SDL_CreateAnimatedCursor(@ptrCast(frames), frame_count, hot_x, hot_y));
|
return @ptrCast(@alignCast(c.SDL_CreateAnimatedCursor(@ptrCast(@alignCast(frames)), frame_count, hot_x, hot_y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSystemCursor(id: SystemCursor) ?*Cursor {
|
pub inline fn createSystemCursor(id: SystemCursor) ?*Cursor {
|
||||||
return @ptrCast(c.SDL_CreateSystemCursor(id));
|
return @ptrCast(@alignCast(c.SDL_CreateSystemCursor(@intCast(@backingInt(id)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCursor() ?*Cursor {
|
pub inline fn getCursor() ?*Cursor {
|
||||||
return @ptrCast(c.SDL_GetCursor());
|
return @ptrCast(@alignCast(c.SDL_GetCursor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDefaultCursor() ?*Cursor {
|
pub inline fn getDefaultCursor() ?*Cursor {
|
||||||
return @ptrCast(c.SDL_GetDefaultCursor());
|
return @ptrCast(@alignCast(c.SDL_GetDefaultCursor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showCursor() bool {
|
pub inline fn showCursor() bool {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
const std = @import("std");
|
||||||
|
pub const c = @import("c.zig").c;
|
||||||
|
pub const PenID = u32;
|
||||||
|
|
||||||
|
pub const PenInputFlags = packed struct(u32) {
|
||||||
|
penInputDown: bool = false, // pen is pressed down
|
||||||
|
penInputButton1: bool = false, // button 1 is pressed
|
||||||
|
penInputButton2: bool = false, // button 2 is pressed
|
||||||
|
penInputButton3: bool = false, // button 3 is pressed
|
||||||
|
penInputButton4: bool = false, // button 4 is pressed
|
||||||
|
penInputButton5: bool = false, // button 5 is pressed
|
||||||
|
pad0: u24 = 0,
|
||||||
|
penInputEraserTip: bool = false, // eraser tip is used
|
||||||
|
penInputInProximity: bool = false, // pen is in proximity (since SDL 3.4.0)
|
||||||
|
|
||||||
|
pub const None = PenInputFlags{};
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const PenAxis = enum(c_int) {
|
||||||
|
penAxisPressure, //Pen pressure. Unidirectional: 0 to 1.0
|
||||||
|
penAxisXtilt, //Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right).
|
||||||
|
penAxisYtilt, //Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down).
|
||||||
|
penAxisDistance, //Pen distance to drawing surface. Unidirectional: 0.0 to 1.0
|
||||||
|
penAxisRotation, //Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down).
|
||||||
|
penAxisSlider, //Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0
|
||||||
|
penAxisTangentialPressure, //Pressure from squeezing the pen ("barrel pressure").
|
||||||
|
penAxisCount, //Total known pen axis types in this version of SDL. This number may grow in future releases!
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const PenDeviceType = enum(c_int) {
|
||||||
|
penDeviceTypeInvalid = -1, //Not a valid pen device.
|
||||||
|
penDeviceTypeUnknown, //Don't know specifics of this pen.
|
||||||
|
penDeviceTypeDirect, //Pen touches display.
|
||||||
|
penDeviceTypeIndirect, //Pen touches something that isn't the display.
|
||||||
|
};
|
||||||
|
|
||||||
|
pub inline fn getPenDeviceType(instance_id: PenID) PenDeviceType {
|
||||||
|
return @fromBackingInt(@intCast(c.SDL_GetPenDeviceType(instance_id)));
|
||||||
|
}
|
||||||
131
api/pixels.zig
131
api/pixels.zig
|
|
@ -57,6 +57,61 @@ pub const PackedLayout = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PixelFormat = enum(c_int) {
|
pub const PixelFormat = enum(c_int) {
|
||||||
|
pixelformatUnknown = 0,
|
||||||
|
pixelformatIndex1lsb = 0x11100100,
|
||||||
|
pixelformatIndex1msb = 0x11200100,
|
||||||
|
pixelformatIndex2lsb = 0x1c100200,
|
||||||
|
pixelformatIndex2msb = 0x1c200200,
|
||||||
|
pixelformatIndex4lsb = 0x12100400,
|
||||||
|
pixelformatIndex4msb = 0x12200400,
|
||||||
|
pixelformatIndex8 = 0x13000801,
|
||||||
|
pixelformatRgb332 = 0x14110801,
|
||||||
|
pixelformatXrgb4444 = 0x15120c02,
|
||||||
|
pixelformatXbgr4444 = 0x15520c02,
|
||||||
|
pixelformatXrgb1555 = 0x15130f02,
|
||||||
|
pixelformatXbgr1555 = 0x15530f02,
|
||||||
|
pixelformatArgb4444 = 0x15321002,
|
||||||
|
pixelformatRgba4444 = 0x15421002,
|
||||||
|
pixelformatAbgr4444 = 0x15721002,
|
||||||
|
pixelformatBgra4444 = 0x15821002,
|
||||||
|
pixelformatArgb1555 = 0x15331002,
|
||||||
|
pixelformatRgba5551 = 0x15441002,
|
||||||
|
pixelformatAbgr1555 = 0x15731002,
|
||||||
|
pixelformatBgra5551 = 0x15841002,
|
||||||
|
pixelformatRgb565 = 0x15151002,
|
||||||
|
pixelformatBgr565 = 0x15551002,
|
||||||
|
pixelformatRgb24 = 0x17101803,
|
||||||
|
pixelformatBgr24 = 0x17401803,
|
||||||
|
pixelformatXrgb8888 = 0x16161804,
|
||||||
|
pixelformatRgbx8888 = 0x16261804,
|
||||||
|
pixelformatXbgr8888 = 0x16561804,
|
||||||
|
pixelformatBgrx8888 = 0x16661804,
|
||||||
|
pixelformatArgb8888 = 0x16362004,
|
||||||
|
pixelformatRgba8888 = 0x16462004,
|
||||||
|
pixelformatAbgr8888 = 0x16762004,
|
||||||
|
pixelformatBgra8888 = 0x16862004,
|
||||||
|
pixelformatXrgb2101010 = 0x16172004,
|
||||||
|
pixelformatXbgr2101010 = 0x16572004,
|
||||||
|
pixelformatArgb2101010 = 0x16372004,
|
||||||
|
pixelformatAbgr2101010 = 0x16772004,
|
||||||
|
pixelformatRgb48 = 0x18103006,
|
||||||
|
pixelformatBgr48 = 0x18403006,
|
||||||
|
pixelformatRgba64 = 0x18204008,
|
||||||
|
pixelformatArgb64 = 0x18304008,
|
||||||
|
pixelformatBgra64 = 0x18504008,
|
||||||
|
pixelformatAbgr64 = 0x18604008,
|
||||||
|
pixelformatRgb48Float = 0x1a103006,
|
||||||
|
pixelformatBgr48Float = 0x1a403006,
|
||||||
|
pixelformatRgba64Float = 0x1a204008,
|
||||||
|
pixelformatArgb64Float = 0x1a304008,
|
||||||
|
pixelformatBgra64Float = 0x1a504008,
|
||||||
|
pixelformatAbgr64Float = 0x1a604008,
|
||||||
|
pixelformatRgb96Float = 0x1b10600c,
|
||||||
|
pixelformatBgr96Float = 0x1b40600c,
|
||||||
|
pixelformatRgba128Float = 0x1b208010,
|
||||||
|
pixelformatArgb128Float = 0x1b308010,
|
||||||
|
pixelformatBgra128Float = 0x1b508010,
|
||||||
|
pixelformatAbgr128Float = 0x1b608010,
|
||||||
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
|
|
@ -67,15 +122,33 @@ pub const PixelFormat = enum(c_int) {
|
||||||
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
|
|
||||||
|
pub const pixelformatRgba32 = .pixelformatAbgr8888;
|
||||||
|
pub const pixelformatArgb32 = .pixelformatBgra8888;
|
||||||
|
pub const pixelformatBgra32 = .pixelformatArgb8888;
|
||||||
|
pub const pixelformatAbgr32 = .pixelformatRgba8888;
|
||||||
|
pub const pixelformatRgbx32 = .pixelformatXbgr8888;
|
||||||
|
pub const pixelformatXrgb32 = .pixelformatBgrx8888;
|
||||||
|
pub const pixelformatBgrx32 = .pixelformatXrgb8888;
|
||||||
|
pub const pixelformatXbgr32 = .pixelformatRgbx8888;
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const ColorType = enum(c_int) {
|
||||||
|
colorTypeUnknown = 0,
|
||||||
|
colorTypeRgb = 1,
|
||||||
|
colorTypeYcbcr = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ColorRange = enum(c_int) {
|
pub const ColorRange = enum(c_int) {
|
||||||
|
colorRangeUnknown = 0,
|
||||||
colorRangeLimited = 1, //Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma
|
colorRangeLimited = 1, //Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma
|
||||||
colorRangeFull = 2,
|
colorRangeFull = 2, //Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ColorPrimaries = enum(c_int) {
|
pub const ColorPrimaries = enum(c_int) {
|
||||||
|
colorPrimariesUnknown = 0,
|
||||||
colorPrimariesBt709 = 1, //ITU-R BT.709-6
|
colorPrimariesBt709 = 1, //ITU-R BT.709-6
|
||||||
|
colorPrimariesUnspecified = 2,
|
||||||
colorPrimariesBt470m = 4, //ITU-R BT.470-6 System M
|
colorPrimariesBt470m = 4, //ITU-R BT.470-6 System M
|
||||||
colorPrimariesBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
|
colorPrimariesBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
|
||||||
colorPrimariesBt601 = 6, //ITU-R BT.601-7 525, SMPTE 170M
|
colorPrimariesBt601 = 6, //ITU-R BT.601-7 525, SMPTE 170M
|
||||||
|
|
@ -86,14 +159,20 @@ pub const ColorPrimaries = enum(c_int) {
|
||||||
colorPrimariesSmpte431 = 11, //SMPTE RP 431-2
|
colorPrimariesSmpte431 = 11, //SMPTE RP 431-2
|
||||||
colorPrimariesSmpte432 = 12, //SMPTE EG 432-1 / DCI P3
|
colorPrimariesSmpte432 = 12, //SMPTE EG 432-1 / DCI P3
|
||||||
colorPrimariesEbu3213 = 22, //EBU Tech. 3213-E
|
colorPrimariesEbu3213 = 22, //EBU Tech. 3213-E
|
||||||
|
colorPrimariesCustom = 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TransferCharacteristics = enum(c_int) {
|
pub const TransferCharacteristics = enum(c_int) {
|
||||||
|
transferCharacteristicsUnknown = 0,
|
||||||
transferCharacteristicsBt709 = 1, //Rec. ITU-R BT.709-6 / ITU-R BT1361
|
transferCharacteristicsBt709 = 1, //Rec. ITU-R BT.709-6 / ITU-R BT1361
|
||||||
|
transferCharacteristicsUnspecified = 2,
|
||||||
transferCharacteristicsGamma22 = 4, //ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
|
transferCharacteristicsGamma22 = 4, //ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
|
||||||
transferCharacteristicsGamma28 = 5, //ITU-R BT.470-6 System B, G
|
transferCharacteristicsGamma28 = 5, //ITU-R BT.470-6 System B, G
|
||||||
transferCharacteristicsBt601 = 6, //SMPTE ST 170M / ITU-R BT.601-7 525 or 625
|
transferCharacteristicsBt601 = 6, //SMPTE ST 170M / ITU-R BT.601-7 525 or 625
|
||||||
transferCharacteristicsSmpte240 = 7, //SMPTE ST 240M
|
transferCharacteristicsSmpte240 = 7, //SMPTE ST 240M
|
||||||
|
transferCharacteristicsLinear = 8,
|
||||||
|
transferCharacteristicsLog100 = 9,
|
||||||
|
transferCharacteristicsLog100Sqrt10 = 10,
|
||||||
transferCharacteristicsIec61966 = 11, //IEC 61966-2-4
|
transferCharacteristicsIec61966 = 11, //IEC 61966-2-4
|
||||||
transferCharacteristicsBt1361 = 12, //ITU-R BT1361 Extended Colour Gamut
|
transferCharacteristicsBt1361 = 12, //ITU-R BT1361 Extended Colour Gamut
|
||||||
transferCharacteristicsSrgb = 13, //IEC 61966-2-1 (sRGB or sYCC)
|
transferCharacteristicsSrgb = 13, //IEC 61966-2-1 (sRGB or sYCC)
|
||||||
|
|
@ -102,51 +181,45 @@ pub const TransferCharacteristics = enum(c_int) {
|
||||||
transferCharacteristicsPq = 16, //SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
transferCharacteristicsPq = 16, //SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
||||||
transferCharacteristicsSmpte428 = 17, //SMPTE ST 428-1
|
transferCharacteristicsSmpte428 = 17, //SMPTE ST 428-1
|
||||||
transferCharacteristicsHlg = 18, //ARIB STD-B67, known as "hybrid log-gamma" (HLG)
|
transferCharacteristicsHlg = 18, //ARIB STD-B67, known as "hybrid log-gamma" (HLG)
|
||||||
|
transferCharacteristicsCustom = 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MatrixCoefficients = enum(c_int) {
|
pub const MatrixCoefficients = enum(c_int) {
|
||||||
|
matrixCoefficientsIdentity = 0,
|
||||||
matrixCoefficientsBt709 = 1, //ITU-R BT.709-6
|
matrixCoefficientsBt709 = 1, //ITU-R BT.709-6
|
||||||
|
matrixCoefficientsUnspecified = 2,
|
||||||
matrixCoefficientsFcc = 4, //US FCC Title 47
|
matrixCoefficientsFcc = 4, //US FCC Title 47
|
||||||
matrixCoefficientsBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601
|
matrixCoefficientsBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601
|
||||||
matrixCoefficientsBt601 = 6, //ITU-R BT.601-7 525
|
matrixCoefficientsBt601 = 6, //ITU-R BT.601-7 525
|
||||||
matrixCoefficientsSmpte240 = 7, //SMPTE 240M
|
matrixCoefficientsSmpte240 = 7, //SMPTE 240M
|
||||||
|
matrixCoefficientsYcgco = 8,
|
||||||
matrixCoefficientsBt2020Ncl = 9, //ITU-R BT.2020-2 non-constant luminance
|
matrixCoefficientsBt2020Ncl = 9, //ITU-R BT.2020-2 non-constant luminance
|
||||||
matrixCoefficientsBt2020Cl = 10, //ITU-R BT.2020-2 constant luminance
|
matrixCoefficientsBt2020Cl = 10, //ITU-R BT.2020-2 constant luminance
|
||||||
matrixCoefficientsSmpte2085 = 11, //SMPTE ST 2085
|
matrixCoefficientsSmpte2085 = 11, //SMPTE ST 2085
|
||||||
|
matrixCoefficientsChromaDerivedNcl = 12,
|
||||||
|
matrixCoefficientsChromaDerivedCl = 13,
|
||||||
matrixCoefficientsIctcp = 14, //ITU-R BT.2100-0 ICTCP
|
matrixCoefficientsIctcp = 14, //ITU-R BT.2100-0 ICTCP
|
||||||
|
matrixCoefficientsCustom = 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ChromaLocation = enum(c_int) {
|
pub const ChromaLocation = enum(c_int) {
|
||||||
chromaLocationNone = 0, //RGB, no chroma sampling
|
chromaLocationNone = 0, //RGB, no chroma sampling
|
||||||
chromaLocationLeft = 1, //In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically.
|
chromaLocationLeft = 1, //In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically.
|
||||||
chromaLocationCenter = 2, //In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel.
|
chromaLocationCenter = 2, //In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel.
|
||||||
chromaLocationTopleft = 3,
|
chromaLocationTopleft = 3, //In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located").
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Colorspace = enum(c_int) {
|
pub const Colorspace = enum(c_int) {
|
||||||
|
colorspaceUnknown = 0,
|
||||||
colorspaceSrgb = 0x120005a0, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
colorspaceSrgb = 0x120005a0, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
||||||
colorRangeFull,
|
|
||||||
colorPrimariesBt709,
|
|
||||||
transferCharacteristicsSrgb,
|
|
||||||
matrixCoefficientsIdentity,
|
|
||||||
colorspaceSrgbLinear = 0x12000500, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
colorspaceSrgbLinear = 0x12000500, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
||||||
transferCharacteristicsLinear,
|
|
||||||
colorspaceHdr10 = 0x12002600, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
colorspaceHdr10 = 0x12002600, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
||||||
colorPrimariesBt2020,
|
|
||||||
transferCharacteristicsPq,
|
|
||||||
colorspaceJpeg = 0x220004c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
colorspaceJpeg = 0x220004c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
||||||
transferCharacteristicsBt601,
|
|
||||||
matrixCoefficientsBt601,
|
|
||||||
colorspaceBt601Limited = 0x211018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Limited = 0x211018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorRangeLimited,
|
|
||||||
colorPrimariesBt601,
|
|
||||||
colorspaceBt601Full = 0x221018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Full = 0x221018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorspaceBt709Limited = 0x21100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Limited = 0x21100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
transferCharacteristicsBt709,
|
|
||||||
matrixCoefficientsBt709,
|
|
||||||
colorspaceBt709Full = 0x22100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Full = 0x22100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
colorspaceBt2020Limited = 0x21102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
colorspaceBt2020Limited = 0x21102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
||||||
matrixCoefficientsBt2020Ncl,
|
|
||||||
colorspaceBt2020Full = 0x22102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
colorspaceBt2020Full = 0x22102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
||||||
|
|
||||||
pub const colorspaceRgbDefault = .colorspaceSrgb; //The default colorspace for RGB surfaces if no colorspace is specified
|
pub const colorspaceRgbDefault = .colorspaceSrgb; //The default colorspace for RGB surfaces if no colorspace is specified
|
||||||
|
|
@ -169,7 +242,7 @@ pub const FColor = extern struct {
|
||||||
|
|
||||||
pub const Palette = extern struct {
|
pub const Palette = extern struct {
|
||||||
ncolors: c_int, // number of elements in `colors`.
|
ncolors: c_int, // number of elements in `colors`.
|
||||||
colors: ?*Color, // an array of colors, `ncolors` long.
|
colors: [*c]Color, // an array of colors, `ncolors` long.
|
||||||
version: u32, // internal use only, do not touch.
|
version: u32, // internal use only, do not touch.
|
||||||
refcount: c_int, // internal use only, do not touch.
|
refcount: c_int, // internal use only, do not touch.
|
||||||
};
|
};
|
||||||
|
|
@ -194,45 +267,45 @@ pub const PixelFormatDetails = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getPixelFormatName(format: PixelFormat) [*c]const u8 {
|
pub inline fn getPixelFormatName(format: PixelFormat) [*c]const u8 {
|
||||||
return c.SDL_GetPixelFormatName(@bitCast(format));
|
return c.SDL_GetPixelFormatName(@intCast(@backingInt(format)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMasksForPixelFormat(format: PixelFormat, bpp: *c_int, Rmask: *u32, Gmask: *u32, Bmask: *u32, Amask: *u32) bool {
|
pub inline fn getMasksForPixelFormat(format: PixelFormat, bpp: ?*c_int, Rmask: ?*u32, Gmask: ?*u32, Bmask: ?*u32, Amask: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_GetMasksForPixelFormat(@bitCast(format), @ptrCast(bpp), @ptrCast(Rmask), @ptrCast(Gmask), @ptrCast(Bmask), @ptrCast(Amask)));
|
return @bitCast(c.SDL_GetMasksForPixelFormat(@intCast(@backingInt(format)), bpp, Rmask, Gmask, Bmask, Amask));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPixelFormatForMasks(bpp: c_int, Rmask: u32, Gmask: u32, Bmask: u32, Amask: u32) PixelFormat {
|
pub inline fn getPixelFormatForMasks(bpp: c_int, Rmask: u32, Gmask: u32, Bmask: u32, Amask: u32) PixelFormat {
|
||||||
return @bitCast(c.SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask));
|
return @fromBackingInt(@intCast(c.SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPixelFormatDetails(format: PixelFormat) ?*const PixelFormatDetails {
|
pub inline fn getPixelFormatDetails(format: PixelFormat) ?*const PixelFormatDetails {
|
||||||
return @ptrCast(c.SDL_GetPixelFormatDetails(@bitCast(format)));
|
return @ptrCast(@alignCast(c.SDL_GetPixelFormatDetails(@intCast(@backingInt(format)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createPalette(ncolors: c_int) ?*Palette {
|
pub inline fn createPalette(ncolors: c_int) ?*Palette {
|
||||||
return @ptrCast(c.SDL_CreatePalette(ncolors));
|
return @ptrCast(@alignCast(c.SDL_CreatePalette(ncolors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setPaletteColors(palette: ?*Palette, colors: ?*const Color, firstcolor: c_int, ncolors: c_int) bool {
|
pub inline fn setPaletteColors(palette: ?*Palette, colors: ?*const Color, firstcolor: c_int, ncolors: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetPaletteColors(@ptrCast(palette), @ptrCast(colors), firstcolor, ncolors));
|
return @bitCast(c.SDL_SetPaletteColors(@ptrCast(@alignCast(palette)), @ptrCast(@alignCast(colors)), firstcolor, ncolors));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyPalette(palette: ?*Palette) void {
|
pub inline fn destroyPalette(palette: ?*Palette) void {
|
||||||
return c.SDL_DestroyPalette(@ptrCast(palette));
|
return c.SDL_DestroyPalette(@ptrCast(@alignCast(palette)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapRGB(format: ?*const PixelFormatDetails, palette: ?*const Palette, r: u8, g: u8, b: u8) u32 {
|
pub inline fn mapRGB(format: ?*const PixelFormatDetails, palette: ?*const Palette, r: u8, g: u8, b: u8) u32 {
|
||||||
return c.SDL_MapRGB(@ptrCast(format), @ptrCast(palette), r, g, b);
|
return c.SDL_MapRGB(@ptrCast(@alignCast(format)), @ptrCast(@alignCast(palette)), r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapRGBA(format: ?*const PixelFormatDetails, palette: ?*const Palette, r: u8, g: u8, b: u8, a: u8) u32 {
|
pub inline fn mapRGBA(format: ?*const PixelFormatDetails, palette: ?*const Palette, r: u8, g: u8, b: u8, a: u8) u32 {
|
||||||
return c.SDL_MapRGBA(@ptrCast(format), @ptrCast(palette), r, g, b, a);
|
return c.SDL_MapRGBA(@ptrCast(@alignCast(format)), @ptrCast(@alignCast(palette)), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRGB(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8) void {
|
pub inline fn getRGB(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8) void {
|
||||||
return c.SDL_GetRGB(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b);
|
return c.SDL_GetRGB(pixelvalue, @ptrCast(@alignCast(format)), @ptrCast(@alignCast(palette)), r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRGBA(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) void {
|
pub inline fn getRGBA(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) void {
|
||||||
return c.SDL_GetRGBA(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b, a);
|
return c.SDL_GetRGBA(pixelvalue, @ptrCast(@alignCast(format)), @ptrCast(@alignCast(palette)), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub const PowerState = enum(c_int) {
|
||||||
powerstateOnBattery, //Not plugged in, running on the battery
|
powerstateOnBattery, //Not plugged in, running on the battery
|
||||||
powerstateNoBattery, //Plugged in, no battery available
|
powerstateNoBattery, //Plugged in, no battery available
|
||||||
powerstateCharging, //Plugged in, charging battery
|
powerstateCharging, //Plugged in, charging battery
|
||||||
powerstateCharged,
|
powerstateCharged, //Plugged in, battery charged
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getPowerInfo(seconds: *c_int, percent: *c_int) PowerState {
|
pub inline fn getPowerInfo(seconds: ?*c_int, percent: ?*c_int) PowerState {
|
||||||
return c.SDL_GetPowerInfo(@ptrCast(seconds), @ptrCast(percent));
|
return @fromBackingInt(@intCast(c.SDL_GetPowerInfo(seconds, percent)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,36 +8,36 @@ pub const IOStream = iostream_api.IOStream;
|
||||||
|
|
||||||
pub const Process = opaque {
|
pub const Process = opaque {
|
||||||
pub inline fn getProcessProperties(process: *Process) PropertiesID {
|
pub inline fn getProcessProperties(process: *Process) PropertiesID {
|
||||||
return c.SDL_GetProcessProperties(@ptrCast(process));
|
return c.SDL_GetProcessProperties(@ptrCast(@alignCast(process)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn readProcess(process: *Process, datasize: *usize, exitcode: *c_int) ?*anyopaque {
|
pub inline fn readProcess(process: *Process, datasize: ?*usize, exitcode: ?*c_int) ?*anyopaque {
|
||||||
return c.SDL_ReadProcess(@ptrCast(process), @ptrCast(datasize), @ptrCast(exitcode));
|
return c.SDL_ReadProcess(@ptrCast(@alignCast(process)), datasize, exitcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getProcessInput(process: *Process) ?*IOStream {
|
pub inline fn getProcessInput(process: *Process) ?*IOStream {
|
||||||
return @ptrCast(c.SDL_GetProcessInput(@ptrCast(process)));
|
return @ptrCast(@alignCast(c.SDL_GetProcessInput(@ptrCast(@alignCast(process)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getProcessOutput(process: *Process) ?*IOStream {
|
pub inline fn getProcessOutput(process: *Process) ?*IOStream {
|
||||||
return @ptrCast(c.SDL_GetProcessOutput(@ptrCast(process)));
|
return @ptrCast(@alignCast(c.SDL_GetProcessOutput(@ptrCast(@alignCast(process)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn killProcess(process: *Process, force: bool) bool {
|
pub inline fn killProcess(process: *Process, force: bool) bool {
|
||||||
return @bitCast(c.SDL_KillProcess(@ptrCast(process), @bitCast(force)));
|
return @bitCast(c.SDL_KillProcess(@ptrCast(@alignCast(process)), @bitCast(force)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitProcess(process: *Process, block: bool, exitcode: *c_int) bool {
|
pub inline fn waitProcess(process: *Process, block: bool, exitcode: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_WaitProcess(@ptrCast(process), @bitCast(block), @ptrCast(exitcode)));
|
return @bitCast(c.SDL_WaitProcess(@ptrCast(@alignCast(process)), @bitCast(block), exitcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyProcess(process: *Process) void {
|
pub inline fn destroyProcess(process: *Process) void {
|
||||||
return c.SDL_DestroyProcess(@ptrCast(process));
|
return c.SDL_DestroyProcess(@ptrCast(@alignCast(process)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createProcess(args: [*c]const [*c]const u8, pipe_stdio: bool) ?*Process {
|
pub inline fn createProcess(args: [*c]const [*c]const u8, pipe_stdio: bool) ?*Process {
|
||||||
return @ptrCast(c.SDL_CreateProcess(args, @bitCast(pipe_stdio)));
|
return @ptrCast(@alignCast(c.SDL_CreateProcess(args, @bitCast(pipe_stdio))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ProcessIO = enum(c_int) {
|
pub const ProcessIO = enum(c_int) {
|
||||||
|
|
@ -48,5 +48,5 @@ pub const ProcessIO = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createProcessWithProperties(props: PropertiesID) ?*Process {
|
pub inline fn createProcessWithProperties(props: PropertiesID) ?*Process {
|
||||||
return @ptrCast(c.SDL_CreateProcessWithProperties(props));
|
return @ptrCast(@alignCast(c.SDL_CreateProcessWithProperties(props)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub inline fn hasProperty(props: PropertiesID, name: [*c]const u8) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPropertyType(props: PropertiesID, name: [*c]const u8) PropertyType {
|
pub inline fn getPropertyType(props: PropertiesID, name: [*c]const u8) PropertyType {
|
||||||
return @intFromEnum(c.SDL_GetPropertyType(props, name));
|
return @fromBackingInt(@intCast(c.SDL_GetPropertyType(props, name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPointerProperty(props: PropertiesID, name: [*c]const u8, default_value: ?*anyopaque) ?*anyopaque {
|
pub inline fn getPointerProperty(props: PropertiesID, name: [*c]const u8, default_value: ?*anyopaque) ?*anyopaque {
|
||||||
|
|
|
||||||
24
api/rect.zig
24
api/rect.zig
|
|
@ -25,41 +25,41 @@ pub const FRect = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn hasRectIntersection(A: ?*const Rect, B: ?*const Rect) bool {
|
pub inline fn hasRectIntersection(A: ?*const Rect, B: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_HasRectIntersection(@ptrCast(A), @ptrCast(B)));
|
return @bitCast(c.SDL_HasRectIntersection(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectIntersection(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
pub inline fn getRectIntersection(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectIntersection(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectUnion(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
pub inline fn getRectUnion(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectUnion(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectEnclosingPoints(points: ?*const Point, count: c_int, clip: ?*const Rect, result: ?*Rect) bool {
|
pub inline fn getRectEnclosingPoints(points: ?*const Point, count: c_int, clip: ?*const Rect, result: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectEnclosingPoints(@ptrCast(@alignCast(points)), count, @ptrCast(@alignCast(clip)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectAndLineIntersection(rect: ?*const Rect, X1: *c_int, Y1: *c_int, X2: *c_int, Y2: *c_int) bool {
|
pub inline fn getRectAndLineIntersection(rect: ?*const Rect, X1: ?*c_int, Y1: ?*c_int, X2: ?*c_int, Y2: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetRectAndLineIntersection(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
return @bitCast(c.SDL_GetRectAndLineIntersection(@ptrCast(@alignCast(rect)), X1, Y1, X2, Y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect) bool {
|
pub inline fn hasRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_HasRectIntersectionFloat(@ptrCast(A), @ptrCast(B)));
|
return @bitCast(c.SDL_HasRectIntersectionFloat(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
pub inline fn getRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectIntersectionFloat(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectUnionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
pub inline fn getRectUnionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectUnionFloat(@ptrCast(@alignCast(A)), @ptrCast(@alignCast(B)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectEnclosingPointsFloat(points: ?*const FPoint, count: c_int, clip: ?*const FRect, result: ?*FRect) bool {
|
pub inline fn getRectEnclosingPointsFloat(points: ?*const FPoint, count: c_int, clip: ?*const FRect, result: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectEnclosingPointsFloat(@ptrCast(@alignCast(points)), count, @ptrCast(@alignCast(clip)), @ptrCast(@alignCast(result))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectAndLineIntersectionFloat(rect: ?*const FRect, X1: *f32, Y1: *f32, X2: *f32, Y2: *f32) bool {
|
pub inline fn getRectAndLineIntersectionFloat(rect: ?*const FRect, X1: ?*f32, Y1: ?*f32, X2: ?*f32, Y2: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
return @bitCast(c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(@alignCast(rect)), X1, Y1, X2, Y2));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
238
api/render.zig
238
api/render.zig
|
|
@ -79,6 +79,7 @@ pub const JoystickID = joystick_api.JoystickID;
|
||||||
pub const WindowID = video_api.WindowID;
|
pub const WindowID = video_api.WindowID;
|
||||||
pub const MouseID = mouse_api.MouseID;
|
pub const MouseID = mouse_api.MouseID;
|
||||||
pub const MouseButtonFlags = mouse_api.MouseButtonFlags;
|
pub const MouseButtonFlags = mouse_api.MouseButtonFlags;
|
||||||
|
pub const PenDeviceType = pen_api.PenDeviceType;
|
||||||
pub const PenInputFlags = pen_api.PenInputFlags;
|
pub const PenInputFlags = pen_api.PenInputFlags;
|
||||||
pub const PenID = pen_api.PenID;
|
pub const PenID = pen_api.PenID;
|
||||||
pub const DisplayID = video_api.DisplayID;
|
pub const DisplayID = video_api.DisplayID;
|
||||||
|
|
@ -100,6 +101,10 @@ pub const Rect = rect_api.Rect;
|
||||||
pub const Palette = pixels_api.Palette;
|
pub const Palette = pixels_api.Palette;
|
||||||
pub const Color = pixels_api.Color;
|
pub const Color = pixels_api.Color;
|
||||||
|
|
||||||
|
pub const unsupported = struct {
|
||||||
|
pub const SDL_RenderDebugTextFormat = "varargs function is not representable in Zig";
|
||||||
|
};
|
||||||
|
|
||||||
pub const Vertex = extern struct {
|
pub const Vertex = extern struct {
|
||||||
position: FPoint, // Vertex position, in SDL_Renderer coordinates
|
position: FPoint, // Vertex position, in SDL_Renderer coordinates
|
||||||
color: FColor, // Vertex color
|
color: FColor, // Vertex color
|
||||||
|
|
@ -113,6 +118,7 @@ pub const TextureAccess = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureAddressMode = enum(c_int) {
|
pub const TextureAddressMode = enum(c_int) {
|
||||||
|
textureAddressInvalid = -1,
|
||||||
textureAddressAuto, //Wrapping is enabled if texture coordinates are outside [0, 1], this is the default
|
textureAddressAuto, //Wrapping is enabled if texture coordinates are outside [0, 1], this is the default
|
||||||
textureAddressClamp, //Texture coordinates are clamped to the [0, 1] range
|
textureAddressClamp, //Texture coordinates are clamped to the [0, 1] range
|
||||||
textureAddressWrap, //The texture is repeated (tiled)
|
textureAddressWrap, //The texture is repeated (tiled)
|
||||||
|
|
@ -128,369 +134,369 @@ pub const RendererLogicalPresentation = enum(c_int) {
|
||||||
|
|
||||||
pub const Renderer = opaque {
|
pub const Renderer = opaque {
|
||||||
pub inline fn getGPURendererDevice(renderer: *Renderer) ?*GPUDevice {
|
pub inline fn getGPURendererDevice(renderer: *Renderer) ?*GPUDevice {
|
||||||
return @ptrCast(c.SDL_GetGPURendererDevice(@ptrCast(renderer)));
|
return @ptrCast(@alignCast(c.SDL_GetGPURendererDevice(@ptrCast(@alignCast(renderer)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderWindow(renderer: *Renderer) ?*Window {
|
pub inline fn getRenderWindow(renderer: *Renderer) ?*Window {
|
||||||
return @ptrCast(c.SDL_GetRenderWindow(@ptrCast(renderer)));
|
return @ptrCast(@alignCast(c.SDL_GetRenderWindow(@ptrCast(@alignCast(renderer)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRendererName(renderer: *Renderer) [*c]const u8 {
|
pub inline fn getRendererName(renderer: *Renderer) [*c]const u8 {
|
||||||
return c.SDL_GetRendererName(@ptrCast(renderer));
|
return c.SDL_GetRendererName(@ptrCast(@alignCast(renderer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRendererProperties(renderer: *Renderer) PropertiesID {
|
pub inline fn getRendererProperties(renderer: *Renderer) PropertiesID {
|
||||||
return c.SDL_GetRendererProperties(@ptrCast(renderer));
|
return c.SDL_GetRendererProperties(@ptrCast(@alignCast(renderer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderOutputSize(renderer: *Renderer, w: *c_int, h: *c_int) bool {
|
pub inline fn getRenderOutputSize(renderer: *Renderer, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetRenderOutputSize(@ptrCast(renderer), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetRenderOutputSize(@ptrCast(@alignCast(renderer)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentRenderOutputSize(renderer: *Renderer, w: *c_int, h: *c_int) bool {
|
pub inline fn getCurrentRenderOutputSize(renderer: *Renderer, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetCurrentRenderOutputSize(@ptrCast(renderer), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetCurrentRenderOutputSize(@ptrCast(@alignCast(renderer)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createTexture(renderer: *Renderer, format: PixelFormat, access: TextureAccess, w: c_int, h: c_int) ?*Texture {
|
pub inline fn createTexture(renderer: *Renderer, format: PixelFormat, access: TextureAccess, w: c_int, h: c_int) ?*Texture {
|
||||||
return @ptrCast(c.SDL_CreateTexture(@ptrCast(renderer), @bitCast(format), access, w, h));
|
return @ptrCast(@alignCast(c.SDL_CreateTexture(@ptrCast(@alignCast(renderer)), @intCast(@backingInt(format)), @intCast(@backingInt(access)), w, h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createTextureFromSurface(renderer: *Renderer, surface: ?*Surface) ?*Texture {
|
pub inline fn createTextureFromSurface(renderer: *Renderer, surface: ?*Surface) ?*Texture {
|
||||||
return @ptrCast(c.SDL_CreateTextureFromSurface(@ptrCast(renderer), @ptrCast(surface)));
|
return @ptrCast(@alignCast(c.SDL_CreateTextureFromSurface(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createTextureWithProperties(renderer: *Renderer, props: PropertiesID) ?*Texture {
|
pub inline fn createTextureWithProperties(renderer: *Renderer, props: PropertiesID) ?*Texture {
|
||||||
return @ptrCast(c.SDL_CreateTextureWithProperties(@ptrCast(renderer), props));
|
return @ptrCast(@alignCast(c.SDL_CreateTextureWithProperties(@ptrCast(@alignCast(renderer)), props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderTarget(renderer: *Renderer, texture: ?*Texture) bool {
|
pub inline fn setRenderTarget(renderer: *Renderer, texture: ?*Texture) bool {
|
||||||
return @bitCast(c.SDL_SetRenderTarget(@ptrCast(renderer), @ptrCast(texture)));
|
return @bitCast(c.SDL_SetRenderTarget(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderTarget(renderer: *Renderer) ?*Texture {
|
pub inline fn getRenderTarget(renderer: *Renderer) ?*Texture {
|
||||||
return @ptrCast(c.SDL_GetRenderTarget(@ptrCast(renderer)));
|
return @ptrCast(@alignCast(c.SDL_GetRenderTarget(@ptrCast(@alignCast(renderer)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderLogicalPresentation(renderer: *Renderer, w: c_int, h: c_int, mode: RendererLogicalPresentation) bool {
|
pub inline fn setRenderLogicalPresentation(renderer: *Renderer, w: c_int, h: c_int, mode: RendererLogicalPresentation) bool {
|
||||||
return @bitCast(c.SDL_SetRenderLogicalPresentation(@ptrCast(renderer), w, h, mode));
|
return @bitCast(c.SDL_SetRenderLogicalPresentation(@ptrCast(@alignCast(renderer)), w, h, @intCast(@backingInt(mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderLogicalPresentation(renderer: *Renderer, w: *c_int, h: *c_int, mode: ?*RendererLogicalPresentation) bool {
|
pub inline fn getRenderLogicalPresentation(renderer: *Renderer, w: ?*c_int, h: ?*c_int, mode: ?*RendererLogicalPresentation) bool {
|
||||||
return @bitCast(c.SDL_GetRenderLogicalPresentation(@ptrCast(renderer), @ptrCast(w), @ptrCast(h), @ptrCast(mode)));
|
return @bitCast(c.SDL_GetRenderLogicalPresentation(@ptrCast(@alignCast(renderer)), w, h, @ptrCast(@alignCast(mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderLogicalPresentationRect(renderer: *Renderer, rect: ?*FRect) bool {
|
pub inline fn getRenderLogicalPresentationRect(renderer: *Renderer, rect: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRenderLogicalPresentationRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetRenderLogicalPresentationRect(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderCoordinatesFromWindow(renderer: *Renderer, window_x: f32, window_y: f32, x: *f32, y: *f32) bool {
|
pub inline fn renderCoordinatesFromWindow(renderer: *Renderer, window_x: f32, window_y: f32, x: ?*f32, y: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_RenderCoordinatesFromWindow(@ptrCast(renderer), window_x, window_y, @ptrCast(x), @ptrCast(y)));
|
return @bitCast(c.SDL_RenderCoordinatesFromWindow(@ptrCast(@alignCast(renderer)), window_x, window_y, x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderCoordinatesToWindow(renderer: *Renderer, x: f32, y: f32, window_x: *f32, window_y: *f32) bool {
|
pub inline fn renderCoordinatesToWindow(renderer: *Renderer, x: f32, y: f32, window_x: ?*f32, window_y: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_RenderCoordinatesToWindow(@ptrCast(renderer), x, y, @ptrCast(window_x), @ptrCast(window_y)));
|
return @bitCast(c.SDL_RenderCoordinatesToWindow(@ptrCast(@alignCast(renderer)), x, y, window_x, window_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertEventToRenderCoordinates(renderer: *Renderer, event: ?*Event) bool {
|
pub inline fn convertEventToRenderCoordinates(renderer: *Renderer, event: ?*Event) bool {
|
||||||
return @bitCast(c.SDL_ConvertEventToRenderCoordinates(@ptrCast(renderer), @ptrCast(event)));
|
return @bitCast(c.SDL_ConvertEventToRenderCoordinates(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderViewport(renderer: *Renderer, rect: ?*const Rect) bool {
|
pub inline fn setRenderViewport(renderer: *Renderer, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetRenderViewport(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetRenderViewport(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderViewport(renderer: *Renderer, rect: ?*Rect) bool {
|
pub inline fn getRenderViewport(renderer: *Renderer, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRenderViewport(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetRenderViewport(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderViewportSet(renderer: *Renderer) bool {
|
pub inline fn renderViewportSet(renderer: *Renderer) bool {
|
||||||
return @bitCast(c.SDL_RenderViewportSet(@ptrCast(renderer)));
|
return @bitCast(c.SDL_RenderViewportSet(@ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderSafeArea(renderer: *Renderer, rect: ?*Rect) bool {
|
pub inline fn getRenderSafeArea(renderer: *Renderer, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRenderSafeArea(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetRenderSafeArea(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderClipRect(renderer: *Renderer, rect: ?*const Rect) bool {
|
pub inline fn setRenderClipRect(renderer: *Renderer, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetRenderClipRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetRenderClipRect(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderClipRect(renderer: *Renderer, rect: ?*Rect) bool {
|
pub inline fn getRenderClipRect(renderer: *Renderer, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRenderClipRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetRenderClipRect(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderClipEnabled(renderer: *Renderer) bool {
|
pub inline fn renderClipEnabled(renderer: *Renderer) bool {
|
||||||
return @bitCast(c.SDL_RenderClipEnabled(@ptrCast(renderer)));
|
return @bitCast(c.SDL_RenderClipEnabled(@ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderScale(renderer: *Renderer, scaleX: f32, scaleY: f32) bool {
|
pub inline fn setRenderScale(renderer: *Renderer, scaleX: f32, scaleY: f32) bool {
|
||||||
return @bitCast(c.SDL_SetRenderScale(@ptrCast(renderer), scaleX, scaleY));
|
return @bitCast(c.SDL_SetRenderScale(@ptrCast(@alignCast(renderer)), scaleX, scaleY));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderScale(renderer: *Renderer, scaleX: *f32, scaleY: *f32) bool {
|
pub inline fn getRenderScale(renderer: *Renderer, scaleX: ?*f32, scaleY: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetRenderScale(@ptrCast(renderer), @ptrCast(scaleX), @ptrCast(scaleY)));
|
return @bitCast(c.SDL_GetRenderScale(@ptrCast(@alignCast(renderer)), scaleX, scaleY));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderDrawColor(renderer: *Renderer, r: u8, g: u8, b: u8, a: u8) bool {
|
pub inline fn setRenderDrawColor(renderer: *Renderer, r: u8, g: u8, b: u8, a: u8) bool {
|
||||||
return @bitCast(c.SDL_SetRenderDrawColor(@ptrCast(renderer), r, g, b, a));
|
return @bitCast(c.SDL_SetRenderDrawColor(@ptrCast(@alignCast(renderer)), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderDrawColorFloat(renderer: *Renderer, r: f32, g: f32, b: f32, a: f32) bool {
|
pub inline fn setRenderDrawColorFloat(renderer: *Renderer, r: f32, g: f32, b: f32, a: f32) bool {
|
||||||
return @bitCast(c.SDL_SetRenderDrawColorFloat(@ptrCast(renderer), r, g, b, a));
|
return @bitCast(c.SDL_SetRenderDrawColorFloat(@ptrCast(@alignCast(renderer)), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderDrawColor(renderer: *Renderer, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool {
|
pub inline fn getRenderDrawColor(renderer: *Renderer, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_GetRenderDrawColor(@ptrCast(renderer), r, g, b, a));
|
return @bitCast(c.SDL_GetRenderDrawColor(@ptrCast(@alignCast(renderer)), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderDrawColorFloat(renderer: *Renderer, r: *f32, g: *f32, b: *f32, a: *f32) bool {
|
pub inline fn getRenderDrawColorFloat(renderer: *Renderer, r: ?*f32, g: ?*f32, b: ?*f32, a: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetRenderDrawColorFloat(@ptrCast(renderer), @ptrCast(r), @ptrCast(g), @ptrCast(b), @ptrCast(a)));
|
return @bitCast(c.SDL_GetRenderDrawColorFloat(@ptrCast(@alignCast(renderer)), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderColorScale(renderer: *Renderer, scale: f32) bool {
|
pub inline fn setRenderColorScale(renderer: *Renderer, scale: f32) bool {
|
||||||
return @bitCast(c.SDL_SetRenderColorScale(@ptrCast(renderer), scale));
|
return @bitCast(c.SDL_SetRenderColorScale(@ptrCast(@alignCast(renderer)), scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderColorScale(renderer: *Renderer, scale: *f32) bool {
|
pub inline fn getRenderColorScale(renderer: *Renderer, scale: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetRenderColorScale(@ptrCast(renderer), @ptrCast(scale)));
|
return @bitCast(c.SDL_GetRenderColorScale(@ptrCast(@alignCast(renderer)), scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderDrawBlendMode(renderer: *Renderer, blendMode: BlendMode) bool {
|
pub inline fn setRenderDrawBlendMode(renderer: *Renderer, blendMode: BlendMode) bool {
|
||||||
return @bitCast(c.SDL_SetRenderDrawBlendMode(@ptrCast(renderer), @intFromEnum(blendMode)));
|
return @bitCast(c.SDL_SetRenderDrawBlendMode(@ptrCast(@alignCast(renderer)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderDrawBlendMode(renderer: *Renderer, blendMode: ?*BlendMode) bool {
|
pub inline fn getRenderDrawBlendMode(renderer: *Renderer, blendMode: ?*BlendMode) bool {
|
||||||
return @bitCast(c.SDL_GetRenderDrawBlendMode(@ptrCast(renderer), @ptrCast(blendMode)));
|
return @bitCast(c.SDL_GetRenderDrawBlendMode(@ptrCast(@alignCast(renderer)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderClear(renderer: *Renderer) bool {
|
pub inline fn renderClear(renderer: *Renderer) bool {
|
||||||
return @bitCast(c.SDL_RenderClear(@ptrCast(renderer)));
|
return @bitCast(c.SDL_RenderClear(@ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderPoint(renderer: *Renderer, x: f32, y: f32) bool {
|
pub inline fn renderPoint(renderer: *Renderer, x: f32, y: f32) bool {
|
||||||
return @bitCast(c.SDL_RenderPoint(@ptrCast(renderer), x, y));
|
return @bitCast(c.SDL_RenderPoint(@ptrCast(@alignCast(renderer)), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderPoints(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
pub inline fn renderPoints(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderPoints(@ptrCast(renderer), @ptrCast(points), count));
|
return @bitCast(c.SDL_RenderPoints(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(points)), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderLine(renderer: *Renderer, x1: f32, y1: f32, x2: f32, y2: f32) bool {
|
pub inline fn renderLine(renderer: *Renderer, x1: f32, y1: f32, x2: f32, y2: f32) bool {
|
||||||
return @bitCast(c.SDL_RenderLine(@ptrCast(renderer), x1, y1, x2, y2));
|
return @bitCast(c.SDL_RenderLine(@ptrCast(@alignCast(renderer)), x1, y1, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderLines(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
pub inline fn renderLines(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderLines(@ptrCast(renderer), @ptrCast(points), count));
|
return @bitCast(c.SDL_RenderLines(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(points)), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
pub inline fn renderRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_RenderRect(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
pub inline fn renderRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderRects(@ptrCast(renderer), @ptrCast(rects), count));
|
return @bitCast(c.SDL_RenderRects(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rects)), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderFillRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
pub inline fn renderFillRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderFillRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_RenderFillRect(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderFillRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
pub inline fn renderFillRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderFillRects(@ptrCast(renderer), @ptrCast(rects), count));
|
return @bitCast(c.SDL_RenderFillRects(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rects)), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTexture(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect) bool {
|
pub inline fn renderTexture(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderTexture(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTexture(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTextureRotated(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect, angle: f64, center: ?*const FPoint, flip: FlipMode) bool {
|
pub inline fn renderTextureRotated(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect, angle: f64, center: ?*const FPoint, flip: FlipMode) bool {
|
||||||
return @bitCast(c.SDL_RenderTextureRotated(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect), angle, @ptrCast(center), @intFromEnum(flip)));
|
return @bitCast(c.SDL_RenderTextureRotated(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dstrect)), angle, @ptrCast(@alignCast(center)), @bitCast(flip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTextureAffine(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, origin: ?*const FPoint, right: ?*const FPoint, down: ?*const FPoint) bool {
|
pub inline fn renderTextureAffine(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, origin: ?*const FPoint, right: ?*const FPoint, down: ?*const FPoint) bool {
|
||||||
return @bitCast(c.SDL_RenderTextureAffine(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(origin), @ptrCast(right), @ptrCast(down)));
|
return @bitCast(c.SDL_RenderTextureAffine(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(origin)), @ptrCast(@alignCast(right)), @ptrCast(@alignCast(down))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTextureTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, scale: f32, dstrect: ?*const FRect) bool {
|
pub inline fn renderTextureTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, scale: f32, dstrect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderTextureTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), scale, @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTextureTiled(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), scale, @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTexture9Grid(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect) bool {
|
pub inline fn renderTexture9Grid(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderTexture9Grid(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTexture9Grid(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), left_width, right_width, top_height, bottom_height, scale, @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTexture9GridTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect, tileScale: f32) bool {
|
pub inline fn renderTexture9GridTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect, tileScale: f32) bool {
|
||||||
return @bitCast(c.SDL_RenderTexture9GridTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect), tileScale));
|
return @bitCast(c.SDL_RenderTexture9GridTiled(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(srcrect)), left_width, right_width, top_height, bottom_height, scale, @ptrCast(@alignCast(dstrect)), tileScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: ?*const Vertex, num_vertices: c_int, indices: [*c]const c_int, num_indices: c_int) bool {
|
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: ?*const Vertex, num_vertices: c_int, indices: [*c]const c_int, num_indices: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderGeometry(@ptrCast(renderer), @ptrCast(texture), @ptrCast(vertices), num_vertices, indices, num_indices));
|
return @bitCast(c.SDL_RenderGeometry(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), @ptrCast(@alignCast(vertices)), num_vertices, indices, num_indices));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderGeometryRaw(renderer: *Renderer, texture: ?*Texture, xy: *const f32, xy_stride: c_int, color: ?*const FColor, color_stride: c_int, uv: *const f32, uv_stride: c_int, num_vertices: c_int, indices: ?*const anyopaque, num_indices: c_int, size_indices: c_int) bool {
|
pub inline fn renderGeometryRaw(renderer: *Renderer, texture: ?*Texture, xy: *const f32, xy_stride: c_int, color: ?*const FColor, color_stride: c_int, uv: *const f32, uv_stride: c_int, num_vertices: c_int, indices: ?*const anyopaque, num_indices: c_int, size_indices: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderGeometryRaw(@ptrCast(renderer), @ptrCast(texture), @ptrCast(xy), xy_stride, @ptrCast(color), color_stride, @ptrCast(uv), uv_stride, num_vertices, indices, num_indices, size_indices));
|
return @bitCast(c.SDL_RenderGeometryRaw(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(texture)), xy, xy_stride, @ptrCast(@alignCast(color)), color_stride, uv, uv_stride, num_vertices, indices, num_indices, size_indices));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderTextureAddressMode(renderer: *Renderer, u_mode: TextureAddressMode, v_mode: TextureAddressMode) bool {
|
pub inline fn setRenderTextureAddressMode(renderer: *Renderer, u_mode: TextureAddressMode, v_mode: TextureAddressMode) bool {
|
||||||
return @bitCast(c.SDL_SetRenderTextureAddressMode(@ptrCast(renderer), @intFromEnum(u_mode), @intFromEnum(v_mode)));
|
return @bitCast(c.SDL_SetRenderTextureAddressMode(@ptrCast(@alignCast(renderer)), @intCast(@backingInt(u_mode)), @intCast(@backingInt(v_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderTextureAddressMode(renderer: *Renderer, u_mode: ?*TextureAddressMode, v_mode: ?*TextureAddressMode) bool {
|
pub inline fn getRenderTextureAddressMode(renderer: *Renderer, u_mode: ?*TextureAddressMode, v_mode: ?*TextureAddressMode) bool {
|
||||||
return @bitCast(c.SDL_GetRenderTextureAddressMode(@ptrCast(renderer), @ptrCast(u_mode), @ptrCast(v_mode)));
|
return @bitCast(c.SDL_GetRenderTextureAddressMode(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(u_mode)), @ptrCast(@alignCast(v_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderReadPixels(renderer: *Renderer, rect: ?*const Rect) ?*Surface {
|
pub inline fn renderReadPixels(renderer: *Renderer, rect: ?*const Rect) ?*Surface {
|
||||||
return @ptrCast(c.SDL_RenderReadPixels(@ptrCast(renderer), @ptrCast(rect)));
|
return @ptrCast(@alignCast(c.SDL_RenderReadPixels(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(rect)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderPresent(renderer: *Renderer) bool {
|
pub inline fn renderPresent(renderer: *Renderer) bool {
|
||||||
return @bitCast(c.SDL_RenderPresent(@ptrCast(renderer)));
|
return @bitCast(c.SDL_RenderPresent(@ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyRenderer(renderer: *Renderer) void {
|
pub inline fn destroyRenderer(renderer: *Renderer) void {
|
||||||
return c.SDL_DestroyRenderer(@ptrCast(renderer));
|
return c.SDL_DestroyRenderer(@ptrCast(@alignCast(renderer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flushRenderer(renderer: *Renderer) bool {
|
pub inline fn flushRenderer(renderer: *Renderer) bool {
|
||||||
return @bitCast(c.SDL_FlushRenderer(@ptrCast(renderer)));
|
return @bitCast(c.SDL_FlushRenderer(@ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderMetalLayer(renderer: *Renderer) ?*anyopaque {
|
pub inline fn getRenderMetalLayer(renderer: *Renderer) ?*anyopaque {
|
||||||
return c.SDL_GetRenderMetalLayer(@ptrCast(renderer));
|
return c.SDL_GetRenderMetalLayer(@ptrCast(@alignCast(renderer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderMetalCommandEncoder(renderer: *Renderer) ?*anyopaque {
|
pub inline fn getRenderMetalCommandEncoder(renderer: *Renderer) ?*anyopaque {
|
||||||
return c.SDL_GetRenderMetalCommandEncoder(@ptrCast(renderer));
|
return c.SDL_GetRenderMetalCommandEncoder(@ptrCast(@alignCast(renderer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addVulkanRenderSemaphores(renderer: *Renderer, wait_stage_mask: u32, wait_semaphore: i64, signal_semaphore: i64) bool {
|
pub inline fn addVulkanRenderSemaphores(renderer: *Renderer, wait_stage_mask: u32, wait_semaphore: i64, signal_semaphore: i64) bool {
|
||||||
return @bitCast(c.SDL_AddVulkanRenderSemaphores(@ptrCast(renderer), wait_stage_mask, wait_semaphore, signal_semaphore));
|
return @bitCast(c.SDL_AddVulkanRenderSemaphores(@ptrCast(@alignCast(renderer)), wait_stage_mask, wait_semaphore, signal_semaphore));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderVSync(renderer: *Renderer, vsync: c_int) bool {
|
pub inline fn setRenderVSync(renderer: *Renderer, vsync: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetRenderVSync(@ptrCast(renderer), vsync));
|
return @bitCast(c.SDL_SetRenderVSync(@ptrCast(@alignCast(renderer)), vsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderVSync(renderer: *Renderer, vsync: *c_int) bool {
|
pub inline fn getRenderVSync(renderer: *Renderer, vsync: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetRenderVSync(@ptrCast(renderer), @ptrCast(vsync)));
|
return @bitCast(c.SDL_GetRenderVSync(@ptrCast(@alignCast(renderer)), vsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*c]const u8) bool {
|
pub inline fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_RenderDebugText(@ptrCast(renderer), x, y, str));
|
return @bitCast(c.SDL_RenderDebugText(@ptrCast(@alignCast(renderer)), x, y, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ScaleMode) bool {
|
pub inline fn setDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_SetDefaultTextureScaleMode(@ptrCast(renderer), @intFromEnum(scale_mode)));
|
return @bitCast(c.SDL_SetDefaultTextureScaleMode(@ptrCast(@alignCast(renderer)), @intCast(@backingInt(scale_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ?*ScaleMode) bool {
|
pub inline fn getDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ?*ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_GetDefaultTextureScaleMode(@ptrCast(renderer), @ptrCast(scale_mode)));
|
return @bitCast(c.SDL_GetDefaultTextureScaleMode(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(scale_mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPURenderState(renderer: *Renderer, createinfo: ?*GPURenderStateCreateInfo) ?*GPURenderState {
|
pub inline fn createGPURenderState(renderer: *Renderer, createinfo: ?*const GPURenderStateCreateInfo) ?*GPURenderState {
|
||||||
return @ptrCast(c.SDL_CreateGPURenderState(@ptrCast(renderer), @ptrCast(createinfo)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPURenderState(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(createinfo)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPURenderState(renderer: *Renderer, state: ?*GPURenderState) bool {
|
pub inline fn setGPURenderState(renderer: *Renderer, state: ?*GPURenderState) bool {
|
||||||
return @bitCast(c.SDL_SetGPURenderState(@ptrCast(renderer), @ptrCast(state)));
|
return @bitCast(c.SDL_SetGPURenderState(@ptrCast(@alignCast(renderer)), @ptrCast(@alignCast(state))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Texture = opaque {
|
pub const Texture = opaque {
|
||||||
pub inline fn getTextureProperties(texture: *Texture) PropertiesID {
|
pub inline fn getTextureProperties(texture: *Texture) PropertiesID {
|
||||||
return c.SDL_GetTextureProperties(@ptrCast(texture));
|
return c.SDL_GetTextureProperties(@ptrCast(@alignCast(texture)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRendererFromTexture(texture: *Texture) ?*Renderer {
|
pub inline fn getRendererFromTexture(texture: *Texture) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_GetRendererFromTexture(@ptrCast(texture)));
|
return @ptrCast(@alignCast(c.SDL_GetRendererFromTexture(@ptrCast(@alignCast(texture)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureSize(texture: *Texture, w: *f32, h: *f32) bool {
|
pub inline fn getTextureSize(texture: *Texture, w: ?*f32, h: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetTextureSize(@ptrCast(texture), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetTextureSize(@ptrCast(@alignCast(texture)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTexturePalette(texture: *Texture, palette: ?*Palette) bool {
|
pub inline fn setTexturePalette(texture: *Texture, palette: ?*Palette) bool {
|
||||||
return @bitCast(c.SDL_SetTexturePalette(@ptrCast(texture), @ptrCast(palette)));
|
return @bitCast(c.SDL_SetTexturePalette(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(palette))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTexturePalette(texture: *Texture) ?*Palette {
|
pub inline fn getTexturePalette(texture: *Texture) ?*Palette {
|
||||||
return @ptrCast(c.SDL_GetTexturePalette(@ptrCast(texture)));
|
return @ptrCast(@alignCast(c.SDL_GetTexturePalette(@ptrCast(@alignCast(texture)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureColorMod(texture: *Texture, r: u8, g: u8, b: u8) bool {
|
pub inline fn setTextureColorMod(texture: *Texture, r: u8, g: u8, b: u8) bool {
|
||||||
return @bitCast(c.SDL_SetTextureColorMod(@ptrCast(texture), r, g, b));
|
return @bitCast(c.SDL_SetTextureColorMod(@ptrCast(@alignCast(texture)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureColorModFloat(texture: *Texture, r: f32, g: f32, b: f32) bool {
|
pub inline fn setTextureColorModFloat(texture: *Texture, r: f32, g: f32, b: f32) bool {
|
||||||
return @bitCast(c.SDL_SetTextureColorModFloat(@ptrCast(texture), r, g, b));
|
return @bitCast(c.SDL_SetTextureColorModFloat(@ptrCast(@alignCast(texture)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureColorMod(texture: *Texture, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
|
pub inline fn getTextureColorMod(texture: *Texture, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_GetTextureColorMod(@ptrCast(texture), r, g, b));
|
return @bitCast(c.SDL_GetTextureColorMod(@ptrCast(@alignCast(texture)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureColorModFloat(texture: *Texture, r: *f32, g: *f32, b: *f32) bool {
|
pub inline fn getTextureColorModFloat(texture: *Texture, r: ?*f32, g: ?*f32, b: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetTextureColorModFloat(@ptrCast(texture), @ptrCast(r), @ptrCast(g), @ptrCast(b)));
|
return @bitCast(c.SDL_GetTextureColorModFloat(@ptrCast(@alignCast(texture)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureAlphaMod(texture: *Texture, alpha: u8) bool {
|
pub inline fn setTextureAlphaMod(texture: *Texture, alpha: u8) bool {
|
||||||
return @bitCast(c.SDL_SetTextureAlphaMod(@ptrCast(texture), alpha));
|
return @bitCast(c.SDL_SetTextureAlphaMod(@ptrCast(@alignCast(texture)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureAlphaModFloat(texture: *Texture, alpha: f32) bool {
|
pub inline fn setTextureAlphaModFloat(texture: *Texture, alpha: f32) bool {
|
||||||
return @bitCast(c.SDL_SetTextureAlphaModFloat(@ptrCast(texture), alpha));
|
return @bitCast(c.SDL_SetTextureAlphaModFloat(@ptrCast(@alignCast(texture)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureAlphaMod(texture: *Texture, alpha: [*c]u8) bool {
|
pub inline fn getTextureAlphaMod(texture: *Texture, alpha: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_GetTextureAlphaMod(@ptrCast(texture), alpha));
|
return @bitCast(c.SDL_GetTextureAlphaMod(@ptrCast(@alignCast(texture)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureAlphaModFloat(texture: *Texture, alpha: *f32) bool {
|
pub inline fn getTextureAlphaModFloat(texture: *Texture, alpha: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetTextureAlphaModFloat(@ptrCast(texture), @ptrCast(alpha)));
|
return @bitCast(c.SDL_GetTextureAlphaModFloat(@ptrCast(@alignCast(texture)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureBlendMode(texture: *Texture, blendMode: BlendMode) bool {
|
pub inline fn setTextureBlendMode(texture: *Texture, blendMode: BlendMode) bool {
|
||||||
return @bitCast(c.SDL_SetTextureBlendMode(@ptrCast(texture), @intFromEnum(blendMode)));
|
return @bitCast(c.SDL_SetTextureBlendMode(@ptrCast(@alignCast(texture)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureBlendMode(texture: *Texture, blendMode: ?*BlendMode) bool {
|
pub inline fn getTextureBlendMode(texture: *Texture, blendMode: ?*BlendMode) bool {
|
||||||
return @bitCast(c.SDL_GetTextureBlendMode(@ptrCast(texture), @ptrCast(blendMode)));
|
return @bitCast(c.SDL_GetTextureBlendMode(@ptrCast(@alignCast(texture)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTextureScaleMode(texture: *Texture, scaleMode: ScaleMode) bool {
|
pub inline fn setTextureScaleMode(texture: *Texture, scaleMode: ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_SetTextureScaleMode(@ptrCast(texture), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_SetTextureScaleMode(@ptrCast(@alignCast(texture)), @intCast(@backingInt(scaleMode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTextureScaleMode(texture: *Texture, scaleMode: ?*ScaleMode) bool {
|
pub inline fn getTextureScaleMode(texture: *Texture, scaleMode: ?*ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_GetTextureScaleMode(@ptrCast(texture), @ptrCast(scaleMode)));
|
return @bitCast(c.SDL_GetTextureScaleMode(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(scaleMode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateTexture(texture: *Texture, rect: ?*const Rect, pixels: ?*const anyopaque, pitch: c_int) bool {
|
pub inline fn updateTexture(texture: *Texture, rect: ?*const Rect, pixels: ?*const anyopaque, pitch: c_int) bool {
|
||||||
return @bitCast(c.SDL_UpdateTexture(@ptrCast(texture), @ptrCast(rect), pixels, pitch));
|
return @bitCast(c.SDL_UpdateTexture(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(rect)), pixels, pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateYUVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, Uplane: [*c]const u8, Upitch: c_int, Vplane: [*c]const u8, Vpitch: c_int) bool {
|
pub inline fn updateYUVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, Uplane: [*c]const u8, Upitch: c_int, Vplane: [*c]const u8, Vpitch: c_int) bool {
|
||||||
return @bitCast(c.SDL_UpdateYUVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
|
return @bitCast(c.SDL_UpdateYUVTexture(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(rect)), Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateNVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, UVplane: [*c]const u8, UVpitch: c_int) bool {
|
pub inline fn updateNVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, UVplane: [*c]const u8, UVpitch: c_int) bool {
|
||||||
return @bitCast(c.SDL_UpdateNVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, UVplane, UVpitch));
|
return @bitCast(c.SDL_UpdateNVTexture(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(rect)), Yplane, Ypitch, UVplane, UVpitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockTexture(texture: *Texture, rect: ?*const Rect, pixels: [*c]?*anyopaque, pitch: *c_int) bool {
|
pub inline fn lockTexture(texture: *Texture, rect: ?*const Rect, pixels: [*c]?*anyopaque, pitch: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_LockTexture(@ptrCast(texture), @ptrCast(rect), pixels, @ptrCast(pitch)));
|
return @bitCast(c.SDL_LockTexture(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(rect)), pixels, pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockTextureToSurface(texture: *Texture, rect: ?*const Rect, surface: [*c]?*Surface) bool {
|
pub inline fn lockTextureToSurface(texture: *Texture, rect: ?*const Rect, surface: [*c]?*Surface) bool {
|
||||||
return @bitCast(c.SDL_LockTextureToSurface(@ptrCast(texture), @ptrCast(rect), surface));
|
return @bitCast(c.SDL_LockTextureToSurface(@ptrCast(@alignCast(texture)), @ptrCast(@alignCast(rect)), @ptrCast(@alignCast(surface))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockTexture(texture: *Texture) void {
|
pub inline fn unlockTexture(texture: *Texture) void {
|
||||||
return c.SDL_UnlockTexture(@ptrCast(texture));
|
return c.SDL_UnlockTexture(@ptrCast(@alignCast(texture)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyTexture(texture: *Texture) void {
|
pub inline fn destroyTexture(texture: *Texture) void {
|
||||||
return c.SDL_DestroyTexture(@ptrCast(texture));
|
return c.SDL_DestroyTexture(@ptrCast(@alignCast(texture)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -503,46 +509,46 @@ pub inline fn getRenderDriver(index: c_int) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: [*c]?*Window, renderer: [*c]?*Renderer) bool {
|
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: [*c]?*Window, renderer: [*c]?*Renderer) bool {
|
||||||
return @bitCast(c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), window, renderer));
|
return @bitCast(c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), @ptrCast(@alignCast(window)), @ptrCast(@alignCast(renderer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createRenderer(window: ?*Window, name: [*c]const u8) ?*Renderer {
|
pub inline fn createRenderer(window: ?*Window, name: [*c]const u8) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_CreateRenderer(@ptrCast(window), name));
|
return @ptrCast(@alignCast(c.SDL_CreateRenderer(@ptrCast(@alignCast(window)), name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createRendererWithProperties(props: PropertiesID) ?*Renderer {
|
pub inline fn createRendererWithProperties(props: PropertiesID) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_CreateRendererWithProperties(props));
|
return @ptrCast(@alignCast(c.SDL_CreateRendererWithProperties(props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPURenderer(device: ?*GPUDevice, window: ?*Window) ?*Renderer {
|
pub inline fn createGPURenderer(device: ?*GPUDevice, window: ?*Window) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_CreateGPURenderer(@ptrCast(device), @ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_CreateGPURenderer(@ptrCast(@alignCast(device)), @ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSoftwareRenderer(surface: ?*Surface) ?*Renderer {
|
pub inline fn createSoftwareRenderer(surface: ?*Surface) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_CreateSoftwareRenderer(@ptrCast(surface)));
|
return @ptrCast(@alignCast(c.SDL_CreateSoftwareRenderer(@ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRenderer(window: ?*Window) ?*Renderer {
|
pub inline fn getRenderer(window: ?*Window) ?*Renderer {
|
||||||
return @ptrCast(c.SDL_GetRenderer(@ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_GetRenderer(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const GPURenderStateCreateInfo = extern struct {
|
pub const GPURenderStateCreateInfo = extern struct {
|
||||||
fragment_shader: ?*GPUShader, // The fragment shader to use when this render state is active
|
fragment_shader: ?*GPUShader, // The fragment shader to use when this render state is active
|
||||||
num_sampler_bindings: i32, // The number of additional fragment samplers to bind when this render state is active
|
num_sampler_bindings: i32, // The number of additional fragment samplers to bind when this render state is active
|
||||||
sampler_bindings: ?*const GPUTextureSamplerBinding, // Additional fragment samplers to bind when this render state is active
|
sampler_bindings: [*c]const GPUTextureSamplerBinding, // Additional fragment samplers to bind when this render state is active
|
||||||
num_storage_textures: i32, // The number of storage textures to bind when this render state is active
|
num_storage_textures: i32, // The number of storage textures to bind when this render state is active
|
||||||
storage_textures: [*c]?*const GPUTexture, // Storage textures to bind when this render state is active
|
storage_textures: [*c]const ?*GPUTexture, // Storage textures to bind when this render state is active
|
||||||
num_storage_buffers: i32, // The number of storage buffers to bind when this render state is active
|
num_storage_buffers: i32, // The number of storage buffers to bind when this render state is active
|
||||||
storage_buffers: [*c]?*const GPUBuffer, // Storage buffers to bind when this render state is active
|
storage_buffers: [*c]const ?*GPUBuffer, // Storage buffers to bind when this render state is active
|
||||||
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPURenderState = opaque {
|
pub const GPURenderState = opaque {
|
||||||
pub inline fn setGPURenderStateFragmentUniforms(gpurenderstate: *GPURenderState, slot_index: u32, data: ?*const anyopaque, length: u32) bool {
|
pub inline fn setGPURenderStateFragmentUniforms(gpurenderstate: *GPURenderState, slot_index: u32, data: ?*const anyopaque, length: u32) bool {
|
||||||
return @bitCast(c.SDL_SetGPURenderStateFragmentUniforms(@ptrCast(gpurenderstate), slot_index, data, length));
|
return @bitCast(c.SDL_SetGPURenderStateFragmentUniforms(@ptrCast(@alignCast(gpurenderstate)), slot_index, data, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyGPURenderState(gpurenderstate: *GPURenderState) void {
|
pub inline fn destroyGPURenderState(gpurenderstate: *GPURenderState) void {
|
||||||
return c.SDL_DestroyGPURenderState(@ptrCast(gpurenderstate));
|
return c.SDL_DestroyGPURenderState(@ptrCast(@alignCast(gpurenderstate)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
204
api/scancode.zig
204
api/scancode.zig
|
|
@ -1,16 +1,123 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
pub const Scancode = enum(c_int) {
|
pub const Scancode = enum(c_int) {
|
||||||
scancodeBackslash = 49,
|
scancodeUnknown = 0,
|
||||||
scancodeNonushash = 50,
|
scancodeA = 4,
|
||||||
scancodeGrave = 53,
|
scancodeB = 5,
|
||||||
scancodeInsert = 73,
|
scancodeC = 6,
|
||||||
scancodeNumlockclear = 83,
|
scancodeD = 7,
|
||||||
scancodeNonusbackslash = 100,
|
scancodeE = 8,
|
||||||
|
scancodeF = 9,
|
||||||
|
scancodeG = 10,
|
||||||
|
scancodeH = 11,
|
||||||
|
scancodeI = 12,
|
||||||
|
scancodeJ = 13,
|
||||||
|
scancodeK = 14,
|
||||||
|
scancodeL = 15,
|
||||||
|
scancodeM = 16,
|
||||||
|
scancodeN = 17,
|
||||||
|
scancodeO = 18,
|
||||||
|
scancodeP = 19,
|
||||||
|
scancodeQ = 20,
|
||||||
|
scancodeR = 21,
|
||||||
|
scancodeS = 22,
|
||||||
|
scancodeT = 23,
|
||||||
|
scancodeU = 24,
|
||||||
|
scancodeV = 25,
|
||||||
|
scancodeW = 26,
|
||||||
|
scancodeX = 27,
|
||||||
|
scancodeY = 28,
|
||||||
|
scancodeZ = 29,
|
||||||
|
scancode1 = 30,
|
||||||
|
scancode2 = 31,
|
||||||
|
scancode3 = 32,
|
||||||
|
scancode4 = 33,
|
||||||
|
scancode5 = 34,
|
||||||
|
scancode6 = 35,
|
||||||
|
scancode7 = 36,
|
||||||
|
scancode8 = 37,
|
||||||
|
scancode9 = 38,
|
||||||
|
scancode0 = 39,
|
||||||
|
scancodeReturn = 40,
|
||||||
|
scancodeEscape = 41,
|
||||||
|
scancodeBackspace = 42,
|
||||||
|
scancodeTab = 43,
|
||||||
|
scancodeSpace = 44,
|
||||||
|
scancodeMinus = 45,
|
||||||
|
scancodeEquals = 46,
|
||||||
|
scancodeLeftbracket = 47,
|
||||||
|
scancodeRightbracket = 48,
|
||||||
|
scancodeBackslash = 49, //Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout.
|
||||||
|
scancodeNonushash = 50, //ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDL_SCANCODE_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards.
|
||||||
|
scancodeSemicolon = 51,
|
||||||
|
scancodeApostrophe = 52,
|
||||||
|
scancodeGrave = 53, //Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards.
|
||||||
|
scancodeComma = 54,
|
||||||
|
scancodePeriod = 55,
|
||||||
|
scancodeSlash = 56,
|
||||||
|
scancodeCapslock = 57,
|
||||||
|
scancodeF1 = 58,
|
||||||
|
scancodeF2 = 59,
|
||||||
|
scancodeF3 = 60,
|
||||||
|
scancodeF4 = 61,
|
||||||
|
scancodeF5 = 62,
|
||||||
|
scancodeF6 = 63,
|
||||||
|
scancodeF7 = 64,
|
||||||
|
scancodeF8 = 65,
|
||||||
|
scancodeF9 = 66,
|
||||||
|
scancodeF10 = 67,
|
||||||
|
scancodeF11 = 68,
|
||||||
|
scancodeF12 = 69,
|
||||||
|
scancodePrintscreen = 70,
|
||||||
|
scancodeScrolllock = 71,
|
||||||
|
scancodePause = 72,
|
||||||
|
scancodeInsert = 73, //insert on PC, help on some Mac keyboards (but does send code 73, not 117)
|
||||||
|
scancodeHome = 74,
|
||||||
|
scancodePageup = 75,
|
||||||
|
scancodeDelete = 76,
|
||||||
|
scancodeEnd = 77,
|
||||||
|
scancodePagedown = 78,
|
||||||
|
scancodeRight = 79,
|
||||||
|
scancodeLeft = 80,
|
||||||
|
scancodeDown = 81,
|
||||||
|
scancodeUp = 82,
|
||||||
|
scancodeNumlockclear = 83, //num lock on PC, clear on Mac keyboards
|
||||||
|
scancodeKpDivide = 84,
|
||||||
|
scancodeKpMultiply = 85,
|
||||||
|
scancodeKpMinus = 86,
|
||||||
|
scancodeKpPlus = 87,
|
||||||
|
scancodeKpEnter = 88,
|
||||||
|
scancodeKp1 = 89,
|
||||||
|
scancodeKp2 = 90,
|
||||||
|
scancodeKp3 = 91,
|
||||||
|
scancodeKp4 = 92,
|
||||||
|
scancodeKp5 = 93,
|
||||||
|
scancodeKp6 = 94,
|
||||||
|
scancodeKp7 = 95,
|
||||||
|
scancodeKp8 = 96,
|
||||||
|
scancodeKp9 = 97,
|
||||||
|
scancodeKp0 = 98,
|
||||||
|
scancodeKpPeriod = 99,
|
||||||
|
scancodeNonusbackslash = 100, //This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Z. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout.
|
||||||
scancodeApplication = 101, //windows contextual menu, compose
|
scancodeApplication = 101, //windows contextual menu, compose
|
||||||
scancodePower = 102,
|
scancodePower = 102, //The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key.
|
||||||
|
scancodeKpEquals = 103,
|
||||||
|
scancodeF13 = 104,
|
||||||
|
scancodeF14 = 105,
|
||||||
|
scancodeF15 = 106,
|
||||||
|
scancodeF16 = 107,
|
||||||
|
scancodeF17 = 108,
|
||||||
|
scancodeF18 = 109,
|
||||||
|
scancodeF19 = 110,
|
||||||
|
scancodeF20 = 111,
|
||||||
|
scancodeF21 = 112,
|
||||||
|
scancodeF22 = 113,
|
||||||
|
scancodeF23 = 114,
|
||||||
|
scancodeF24 = 115,
|
||||||
|
scancodeExecute = 116,
|
||||||
scancodeHelp = 117, //AL Integrated Help Center
|
scancodeHelp = 117, //AL Integrated Help Center
|
||||||
scancodeMenu = 118, //Menu (show menu)
|
scancodeMenu = 118, //Menu (show menu)
|
||||||
|
scancodeSelect = 119,
|
||||||
scancodeStop = 120, //AC Stop
|
scancodeStop = 120, //AC Stop
|
||||||
scancodeAgain = 121, //AC Redo/Repeat
|
scancodeAgain = 121, //AC Redo/Repeat
|
||||||
scancodeUndo = 122, //AC Undo
|
scancodeUndo = 122, //AC Undo
|
||||||
|
|
@ -18,8 +125,20 @@ pub const Scancode = enum(c_int) {
|
||||||
scancodeCopy = 124, //AC Copy
|
scancodeCopy = 124, //AC Copy
|
||||||
scancodePaste = 125, //AC Paste
|
scancodePaste = 125, //AC Paste
|
||||||
scancodeFind = 126, //AC Find
|
scancodeFind = 126, //AC Find
|
||||||
scancodeInternational1 = 135,
|
scancodeMute = 127,
|
||||||
|
scancodeVolumeup = 128,
|
||||||
|
scancodeVolumedown = 129,
|
||||||
|
scancodeKpComma = 133,
|
||||||
|
scancodeKpEqualsas400 = 134,
|
||||||
|
scancodeInternational1 = 135, //used on Asian keyboards, see footnotes in USB doc
|
||||||
|
scancodeInternational2 = 136,
|
||||||
scancodeInternational3 = 137, //Yen
|
scancodeInternational3 = 137, //Yen
|
||||||
|
scancodeInternational4 = 138,
|
||||||
|
scancodeInternational5 = 139,
|
||||||
|
scancodeInternational6 = 140,
|
||||||
|
scancodeInternational7 = 141,
|
||||||
|
scancodeInternational8 = 142,
|
||||||
|
scancodeInternational9 = 143,
|
||||||
scancodeLang1 = 144, //Hangul/English toggle
|
scancodeLang1 = 144, //Hangul/English toggle
|
||||||
scancodeLang2 = 145, //Hanja conversion
|
scancodeLang2 = 145, //Hanja conversion
|
||||||
scancodeLang3 = 146, //Katakana
|
scancodeLang3 = 146, //Katakana
|
||||||
|
|
@ -30,12 +149,73 @@ pub const Scancode = enum(c_int) {
|
||||||
scancodeLang8 = 151, //reserved
|
scancodeLang8 = 151, //reserved
|
||||||
scancodeLang9 = 152, //reserved
|
scancodeLang9 = 152, //reserved
|
||||||
scancodeAlterase = 153, //Erase-Eaze
|
scancodeAlterase = 153, //Erase-Eaze
|
||||||
|
scancodeSysreq = 154,
|
||||||
scancodeCancel = 155, //AC Cancel
|
scancodeCancel = 155, //AC Cancel
|
||||||
|
scancodeClear = 156,
|
||||||
|
scancodePrior = 157,
|
||||||
|
scancodeReturn2 = 158,
|
||||||
|
scancodeSeparator = 159,
|
||||||
|
scancodeOut = 160,
|
||||||
|
scancodeOper = 161,
|
||||||
|
scancodeClearagain = 162,
|
||||||
|
scancodeCrsel = 163,
|
||||||
|
scancodeExsel = 164,
|
||||||
|
scancodeFront = 165, //Front (Sun keyboards)
|
||||||
|
scancodeKp00 = 176,
|
||||||
|
scancodeKp000 = 177,
|
||||||
|
scancodeThousandsseparator = 178,
|
||||||
|
scancodeDecimalseparator = 179,
|
||||||
|
scancodeCurrencyunit = 180,
|
||||||
|
scancodeCurrencysubunit = 181,
|
||||||
|
scancodeKpLeftparen = 182,
|
||||||
|
scancodeKpRightparen = 183,
|
||||||
|
scancodeKpLeftbrace = 184,
|
||||||
|
scancodeKpRightbrace = 185,
|
||||||
|
scancodeKpTab = 186,
|
||||||
|
scancodeKpBackspace = 187,
|
||||||
|
scancodeKpA = 188,
|
||||||
|
scancodeKpB = 189,
|
||||||
|
scancodeKpC = 190,
|
||||||
|
scancodeKpD = 191,
|
||||||
|
scancodeKpE = 192,
|
||||||
|
scancodeKpF = 193,
|
||||||
|
scancodeKpXor = 194,
|
||||||
|
scancodeKpPower = 195,
|
||||||
|
scancodeKpPercent = 196,
|
||||||
|
scancodeKpLess = 197,
|
||||||
|
scancodeKpGreater = 198,
|
||||||
|
scancodeKpAmpersand = 199,
|
||||||
|
scancodeKpDblampersand = 200,
|
||||||
|
scancodeKpVerticalbar = 201,
|
||||||
|
scancodeKpDblverticalbar = 202,
|
||||||
|
scancodeKpColon = 203,
|
||||||
|
scancodeKpHash = 204,
|
||||||
|
scancodeKpSpace = 205,
|
||||||
|
scancodeKpAt = 206,
|
||||||
|
scancodeKpExclam = 207,
|
||||||
|
scancodeKpMemstore = 208,
|
||||||
|
scancodeKpMemrecall = 209,
|
||||||
|
scancodeKpMemclear = 210,
|
||||||
|
scancodeKpMemadd = 211,
|
||||||
|
scancodeKpMemsubtract = 212,
|
||||||
|
scancodeKpMemmultiply = 213,
|
||||||
|
scancodeKpMemdivide = 214,
|
||||||
|
scancodeKpPlusminus = 215,
|
||||||
|
scancodeKpClear = 216,
|
||||||
|
scancodeKpClearentry = 217,
|
||||||
|
scancodeKpBinary = 218,
|
||||||
|
scancodeKpOctal = 219,
|
||||||
|
scancodeKpDecimal = 220,
|
||||||
|
scancodeKpHexadecimal = 221,
|
||||||
|
scancodeLctrl = 224,
|
||||||
|
scancodeLshift = 225,
|
||||||
scancodeLalt = 226, //alt, option
|
scancodeLalt = 226, //alt, option
|
||||||
scancodeLgui = 227, //windows, command (apple), meta
|
scancodeLgui = 227, //windows, command (apple), meta
|
||||||
|
scancodeRctrl = 228,
|
||||||
|
scancodeRshift = 229,
|
||||||
scancodeRalt = 230, //alt gr, option
|
scancodeRalt = 230, //alt gr, option
|
||||||
scancodeRgui = 231, //windows, command (apple), meta
|
scancodeRgui = 231, //windows, command (apple), meta
|
||||||
scancodeMode = 257,
|
scancodeMode = 257, //I'm not sure if this is really not covered by any of the above, but since there's a special SDL_KMOD_MODE for it I'm adding it here
|
||||||
scancodeSleep = 258, //Sleep
|
scancodeSleep = 258, //Sleep
|
||||||
scancodeWake = 259, //Wake
|
scancodeWake = 259, //Wake
|
||||||
scancodeChannelIncrement = 260, //Channel Increment
|
scancodeChannelIncrement = 260, //Channel Increment
|
||||||
|
|
@ -65,10 +245,10 @@ pub const Scancode = enum(c_int) {
|
||||||
scancodeAcStop = 284, //AC Stop
|
scancodeAcStop = 284, //AC Stop
|
||||||
scancodeAcRefresh = 285, //AC Refresh
|
scancodeAcRefresh = 285, //AC Refresh
|
||||||
scancodeAcBookmarks = 286, //AC Bookmarks
|
scancodeAcBookmarks = 286, //AC Bookmarks
|
||||||
scancodeSoftleft = 287,
|
scancodeSoftleft = 287, //Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom left of the display.
|
||||||
scancodeSoftright = 288,
|
scancodeSoftright = 288, //Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom right of the display.
|
||||||
scancodeCall = 289, //Used for accepting phone calls.
|
scancodeCall = 289, //Used for accepting phone calls.
|
||||||
scancodeEndcall = 290, //Used for rejecting phone calls.
|
scancodeEndcall = 290, //Used for rejecting phone calls.
|
||||||
scancodeReserved = 400, //400-500 reserved for dynamic keycodes
|
scancodeReserved = 400, //400-500 reserved for dynamic keycodes
|
||||||
scancodeCount = 512,
|
scancodeCount = 512, //not a key, just marks the number of scancodes for array bounds
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,31 +6,31 @@ pub const PropertiesID = properties_api.PropertiesID;
|
||||||
|
|
||||||
pub const Sensor = opaque {
|
pub const Sensor = opaque {
|
||||||
pub inline fn getSensorProperties(sensor: *Sensor) PropertiesID {
|
pub inline fn getSensorProperties(sensor: *Sensor) PropertiesID {
|
||||||
return c.SDL_GetSensorProperties(@ptrCast(sensor));
|
return c.SDL_GetSensorProperties(@ptrCast(@alignCast(sensor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorName(sensor: *Sensor) [*c]const u8 {
|
pub inline fn getSensorName(sensor: *Sensor) [*c]const u8 {
|
||||||
return c.SDL_GetSensorName(@ptrCast(sensor));
|
return c.SDL_GetSensorName(@ptrCast(@alignCast(sensor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorType(sensor: *Sensor) SensorType {
|
pub inline fn getSensorType(sensor: *Sensor) SensorType {
|
||||||
return @intFromEnum(c.SDL_GetSensorType(@ptrCast(sensor)));
|
return @fromBackingInt(@intCast(c.SDL_GetSensorType(@ptrCast(@alignCast(sensor)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorNonPortableType(sensor: *Sensor) c_int {
|
pub inline fn getSensorNonPortableType(sensor: *Sensor) c_int {
|
||||||
return c.SDL_GetSensorNonPortableType(@ptrCast(sensor));
|
return c.SDL_GetSensorNonPortableType(@ptrCast(@alignCast(sensor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorID(sensor: *Sensor) SensorID {
|
pub inline fn getSensorID(sensor: *Sensor) SensorID {
|
||||||
return c.SDL_GetSensorID(@ptrCast(sensor));
|
return c.SDL_GetSensorID(@ptrCast(@alignCast(sensor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorData(sensor: *Sensor, data: *f32, num_values: c_int) bool {
|
pub inline fn getSensorData(sensor: *Sensor, data: ?*f32, num_values: c_int) bool {
|
||||||
return @bitCast(c.SDL_GetSensorData(@ptrCast(sensor), @ptrCast(data), num_values));
|
return @bitCast(c.SDL_GetSensorData(@ptrCast(@alignCast(sensor)), data, num_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeSensor(sensor: *Sensor) void {
|
pub inline fn closeSensor(sensor: *Sensor) void {
|
||||||
return c.SDL_CloseSensor(@ptrCast(sensor));
|
return c.SDL_CloseSensor(@ptrCast(@alignCast(sensor)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -48,8 +48,8 @@ pub const SensorType = enum(c_int) {
|
||||||
sensorCount,
|
sensorCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getSensors(count: *c_int) ?*SensorID {
|
pub inline fn getSensors(count: ?*c_int) ?*SensorID {
|
||||||
return @ptrCast(c.SDL_GetSensors(@ptrCast(count)));
|
return c.SDL_GetSensors(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorNameForID(instance_id: SensorID) [*c]const u8 {
|
pub inline fn getSensorNameForID(instance_id: SensorID) [*c]const u8 {
|
||||||
|
|
@ -57,7 +57,7 @@ pub inline fn getSensorNameForID(instance_id: SensorID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorTypeForID(instance_id: SensorID) SensorType {
|
pub inline fn getSensorTypeForID(instance_id: SensorID) SensorType {
|
||||||
return @intFromEnum(c.SDL_GetSensorTypeForID(instance_id));
|
return @fromBackingInt(@intCast(c.SDL_GetSensorTypeForID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorNonPortableTypeForID(instance_id: SensorID) c_int {
|
pub inline fn getSensorNonPortableTypeForID(instance_id: SensorID) c_int {
|
||||||
|
|
@ -65,11 +65,11 @@ pub inline fn getSensorNonPortableTypeForID(instance_id: SensorID) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openSensor(instance_id: SensorID) ?*Sensor {
|
pub inline fn openSensor(instance_id: SensorID) ?*Sensor {
|
||||||
return @ptrCast(c.SDL_OpenSensor(instance_id));
|
return @ptrCast(@alignCast(c.SDL_OpenSensor(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorFromID(instance_id: SensorID) ?*Sensor {
|
pub inline fn getSensorFromID(instance_id: SensorID) ?*Sensor {
|
||||||
return @ptrCast(c.SDL_GetSensorFromID(instance_id));
|
return @ptrCast(@alignCast(c.SDL_GetSensorFromID(instance_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateSensors() void {
|
pub inline fn updateSensors() void {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
pub const c = @import("c.zig").c;
|
||||||
|
pub const Time = i64;
|
||||||
|
pub const FunctionPointer = c.SDL_FunctionPointer;
|
||||||
|
|
@ -13,85 +13,85 @@ pub const PropertiesID = properties_api.PropertiesID;
|
||||||
|
|
||||||
pub const StorageInterface = extern struct {
|
pub const StorageInterface = extern struct {
|
||||||
version: u32,
|
version: u32,
|
||||||
close: ?*const anyopaque,
|
close: ?*const fn (?*anyopaque) callconv(.c) bool,
|
||||||
ready: ?*const anyopaque,
|
ready: ?*const fn (?*anyopaque) callconv(.c) bool,
|
||||||
enumerate: ?*const anyopaque,
|
enumerate: ?*const fn (?*anyopaque, [*c]const u8, EnumerateDirectoryCallback, ?*anyopaque) callconv(.c) bool,
|
||||||
info: ?*const anyopaque,
|
info: ?*const fn (?*anyopaque, [*c]const u8, ?*PathInfo) callconv(.c) bool,
|
||||||
read_file: ?*const anyopaque,
|
read_file: ?*const fn (?*anyopaque, [*c]const u8, ?*anyopaque, u64) callconv(.c) bool,
|
||||||
write_file: ?*const anyopaque,
|
write_file: ?*const fn (?*anyopaque, [*c]const u8, ?*const anyopaque, u64) callconv(.c) bool,
|
||||||
mkdir: ?*const anyopaque,
|
mkdir: ?*const fn (?*anyopaque, [*c]const u8) callconv(.c) bool,
|
||||||
remove: ?*const anyopaque,
|
remove: ?*const fn (?*anyopaque, [*c]const u8) callconv(.c) bool,
|
||||||
rename: ?*const anyopaque,
|
rename: ?*const fn (?*anyopaque, [*c]const u8, [*c]const u8) callconv(.c) bool,
|
||||||
copy: ?*const anyopaque,
|
copy: ?*const fn (?*anyopaque, [*c]const u8, [*c]const u8) callconv(.c) bool,
|
||||||
space_remaining: ?*const anyopaque,
|
space_remaining: ?*const fn (?*anyopaque) callconv(.c) u64,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Storage = opaque {
|
pub const Storage = opaque {
|
||||||
pub inline fn closeStorage(storage: *Storage) bool {
|
pub inline fn closeStorage(storage: *Storage) bool {
|
||||||
return @bitCast(c.SDL_CloseStorage(@ptrCast(storage)));
|
return @bitCast(c.SDL_CloseStorage(@ptrCast(@alignCast(storage))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn storageReady(storage: *Storage) bool {
|
pub inline fn storageReady(storage: *Storage) bool {
|
||||||
return @bitCast(c.SDL_StorageReady(@ptrCast(storage)));
|
return @bitCast(c.SDL_StorageReady(@ptrCast(@alignCast(storage))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStorageFileSize(storage: *Storage, path: [*c]const u8, length: *u64) bool {
|
pub inline fn getStorageFileSize(storage: *Storage, path: [*c]const u8, length: ?*u64) bool {
|
||||||
return @bitCast(c.SDL_GetStorageFileSize(@ptrCast(storage), path, @ptrCast(length)));
|
return @bitCast(c.SDL_GetStorageFileSize(@ptrCast(@alignCast(storage)), path, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn readStorageFile(storage: *Storage, path: [*c]const u8, destination: ?*anyopaque, length: u64) bool {
|
pub inline fn readStorageFile(storage: *Storage, path: [*c]const u8, destination: ?*anyopaque, length: u64) bool {
|
||||||
return @bitCast(c.SDL_ReadStorageFile(@ptrCast(storage), path, destination, length));
|
return @bitCast(c.SDL_ReadStorageFile(@ptrCast(@alignCast(storage)), path, destination, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeStorageFile(storage: *Storage, path: [*c]const u8, source: ?*const anyopaque, length: u64) bool {
|
pub inline fn writeStorageFile(storage: *Storage, path: [*c]const u8, source: ?*const anyopaque, length: u64) bool {
|
||||||
return @bitCast(c.SDL_WriteStorageFile(@ptrCast(storage), path, source, length));
|
return @bitCast(c.SDL_WriteStorageFile(@ptrCast(@alignCast(storage)), path, source, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createStorageDirectory(storage: *Storage, path: [*c]const u8) bool {
|
pub inline fn createStorageDirectory(storage: *Storage, path: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_CreateStorageDirectory(@ptrCast(storage), path));
|
return @bitCast(c.SDL_CreateStorageDirectory(@ptrCast(@alignCast(storage)), path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn enumerateStorageDirectory(storage: *Storage, path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool {
|
pub inline fn enumerateStorageDirectory(storage: *Storage, path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_EnumerateStorageDirectory(@ptrCast(storage), path, callback, userdata));
|
return @bitCast(c.SDL_EnumerateStorageDirectory(@ptrCast(@alignCast(storage)), path, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeStoragePath(storage: *Storage, path: [*c]const u8) bool {
|
pub inline fn removeStoragePath(storage: *Storage, path: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_RemoveStoragePath(@ptrCast(storage), path));
|
return @bitCast(c.SDL_RemoveStoragePath(@ptrCast(@alignCast(storage)), path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renameStoragePath(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn renameStoragePath(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_RenameStoragePath(@ptrCast(storage), oldpath, newpath));
|
return @bitCast(c.SDL_RenameStoragePath(@ptrCast(@alignCast(storage)), oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyStorageFile(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn copyStorageFile(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_CopyStorageFile(@ptrCast(storage), oldpath, newpath));
|
return @bitCast(c.SDL_CopyStorageFile(@ptrCast(@alignCast(storage)), oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStoragePathInfo(storage: *Storage, path: [*c]const u8, info: ?*PathInfo) bool {
|
pub inline fn getStoragePathInfo(storage: *Storage, path: [*c]const u8, info: ?*PathInfo) bool {
|
||||||
return @bitCast(c.SDL_GetStoragePathInfo(@ptrCast(storage), path, @ptrCast(info)));
|
return @bitCast(c.SDL_GetStoragePathInfo(@ptrCast(@alignCast(storage)), path, @ptrCast(@alignCast(info))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStorageSpaceRemaining(storage: *Storage) u64 {
|
pub inline fn getStorageSpaceRemaining(storage: *Storage) u64 {
|
||||||
return c.SDL_GetStorageSpaceRemaining(@ptrCast(storage));
|
return c.SDL_GetStorageSpaceRemaining(@ptrCast(@alignCast(storage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn globStorageDirectory(storage: *Storage, path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: *c_int) [*c][*c]u8 {
|
pub inline fn globStorageDirectory(storage: *Storage, path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: ?*c_int) [*c][*c]u8 {
|
||||||
return c.SDL_GlobStorageDirectory(@ptrCast(storage), path, pattern, @bitCast(flags), @ptrCast(count));
|
return c.SDL_GlobStorageDirectory(@ptrCast(@alignCast(storage)), path, pattern, @bitCast(flags), count);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn openTitleStorage(override: [*c]const u8, props: PropertiesID) ?*Storage {
|
pub inline fn openTitleStorage(override: [*c]const u8, props: PropertiesID) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenTitleStorage(override, props));
|
return @ptrCast(@alignCast(c.SDL_OpenTitleStorage(override, props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openUserStorage(org: [*c]const u8, app: [*c]const u8, props: PropertiesID) ?*Storage {
|
pub inline fn openUserStorage(org: [*c]const u8, app: [*c]const u8, props: PropertiesID) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenUserStorage(org, app, props));
|
return @ptrCast(@alignCast(c.SDL_OpenUserStorage(org, app, props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openFileStorage(path: [*c]const u8) ?*Storage {
|
pub inline fn openFileStorage(path: [*c]const u8) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenFileStorage(path));
|
return @ptrCast(@alignCast(c.SDL_OpenFileStorage(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openStorage(iface: ?*const StorageInterface, userdata: ?*anyopaque) ?*Storage {
|
pub inline fn openStorage(iface: ?*const StorageInterface, userdata: ?*anyopaque) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenStorage(@ptrCast(iface), userdata));
|
return @ptrCast(@alignCast(c.SDL_OpenStorage(@ptrCast(@alignCast(iface)), userdata)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
139
api/surface.zig
139
api/surface.zig
|
|
@ -27,9 +27,10 @@ pub const SurfaceFlags = packed struct(u32) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScaleMode = enum(c_int) {
|
pub const ScaleMode = enum(c_int) {
|
||||||
|
scalemodeInvalid = -1,
|
||||||
scalemodeNearest, //nearest pixel sampling
|
scalemodeNearest, //nearest pixel sampling
|
||||||
scalemodeLinear, //linear filtering
|
scalemodeLinear, //linear filtering
|
||||||
scalemodePixelart,
|
scalemodePixelart, //nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FlipMode = packed struct(u32) {
|
pub const FlipMode = packed struct(u32) {
|
||||||
|
|
@ -43,262 +44,262 @@ pub const FlipMode = packed struct(u32) {
|
||||||
|
|
||||||
pub const Surface = opaque {
|
pub const Surface = opaque {
|
||||||
pub inline fn destroySurface(surface: *Surface) void {
|
pub inline fn destroySurface(surface: *Surface) void {
|
||||||
return c.SDL_DestroySurface(@ptrCast(surface));
|
return c.SDL_DestroySurface(@ptrCast(@alignCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceProperties(surface: *Surface) PropertiesID {
|
pub inline fn getSurfaceProperties(surface: *Surface) PropertiesID {
|
||||||
return c.SDL_GetSurfaceProperties(@ptrCast(surface));
|
return c.SDL_GetSurfaceProperties(@ptrCast(@alignCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceColorspace(surface: *Surface, colorspace: Colorspace) bool {
|
pub inline fn setSurfaceColorspace(surface: *Surface, colorspace: Colorspace) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceColorspace(@ptrCast(surface), colorspace));
|
return @bitCast(c.SDL_SetSurfaceColorspace(@ptrCast(@alignCast(surface)), @intCast(@backingInt(colorspace))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceColorspace(surface: *Surface) Colorspace {
|
pub inline fn getSurfaceColorspace(surface: *Surface) Colorspace {
|
||||||
return c.SDL_GetSurfaceColorspace(@ptrCast(surface));
|
return @fromBackingInt(@intCast(c.SDL_GetSurfaceColorspace(@ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSurfacePalette(surface: *Surface) ?*Palette {
|
pub inline fn createSurfacePalette(surface: *Surface) ?*Palette {
|
||||||
return @ptrCast(c.SDL_CreateSurfacePalette(@ptrCast(surface)));
|
return @ptrCast(@alignCast(c.SDL_CreateSurfacePalette(@ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfacePalette(surface: *Surface, palette: ?*Palette) bool {
|
pub inline fn setSurfacePalette(surface: *Surface, palette: ?*Palette) bool {
|
||||||
return @bitCast(c.SDL_SetSurfacePalette(@ptrCast(surface), @ptrCast(palette)));
|
return @bitCast(c.SDL_SetSurfacePalette(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(palette))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfacePalette(surface: *Surface) ?*Palette {
|
pub inline fn getSurfacePalette(surface: *Surface) ?*Palette {
|
||||||
return @ptrCast(c.SDL_GetSurfacePalette(@ptrCast(surface)));
|
return @ptrCast(@alignCast(c.SDL_GetSurfacePalette(@ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addSurfaceAlternateImage(surface: *Surface, image: ?*Surface) bool {
|
pub inline fn addSurfaceAlternateImage(surface: *Surface, image: ?*Surface) bool {
|
||||||
return @bitCast(c.SDL_AddSurfaceAlternateImage(@ptrCast(surface), @ptrCast(image)));
|
return @bitCast(c.SDL_AddSurfaceAlternateImage(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(image))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasAlternateImages(surface: *Surface) bool {
|
pub inline fn surfaceHasAlternateImages(surface: *Surface) bool {
|
||||||
return @bitCast(c.SDL_SurfaceHasAlternateImages(@ptrCast(surface)));
|
return @bitCast(c.SDL_SurfaceHasAlternateImages(@ptrCast(@alignCast(surface))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceImages(surface: *Surface, count: *c_int) [*c]?*Surface {
|
pub inline fn getSurfaceImages(surface: *Surface, count: ?*c_int) [*c]?*Surface {
|
||||||
return c.SDL_GetSurfaceImages(@ptrCast(surface), @ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetSurfaceImages(@ptrCast(@alignCast(surface)), count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeSurfaceAlternateImages(surface: *Surface) void {
|
pub inline fn removeSurfaceAlternateImages(surface: *Surface) void {
|
||||||
return c.SDL_RemoveSurfaceAlternateImages(@ptrCast(surface));
|
return c.SDL_RemoveSurfaceAlternateImages(@ptrCast(@alignCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockSurface(surface: *Surface) bool {
|
pub inline fn lockSurface(surface: *Surface) bool {
|
||||||
return @bitCast(c.SDL_LockSurface(@ptrCast(surface)));
|
return @bitCast(c.SDL_LockSurface(@ptrCast(@alignCast(surface))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockSurface(surface: *Surface) void {
|
pub inline fn unlockSurface(surface: *Surface) void {
|
||||||
return c.SDL_UnlockSurface(@ptrCast(surface));
|
return c.SDL_UnlockSurface(@ptrCast(@alignCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn saveBMP_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
pub inline fn saveBMP_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
||||||
return @bitCast(c.SDL_SaveBMP_IO(@ptrCast(surface), @ptrCast(dst), @bitCast(closeio)));
|
return @bitCast(c.SDL_SaveBMP_IO(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(dst)), @bitCast(closeio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn saveBMP(surface: *Surface, file: [*c]const u8) bool {
|
pub inline fn saveBMP(surface: *Surface, file: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_SaveBMP(@ptrCast(surface), file));
|
return @bitCast(c.SDL_SaveBMP(@ptrCast(@alignCast(surface)), file));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn savePNG_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
pub inline fn savePNG_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
||||||
return @bitCast(c.SDL_SavePNG_IO(@ptrCast(surface), @ptrCast(dst), @bitCast(closeio)));
|
return @bitCast(c.SDL_SavePNG_IO(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(dst)), @bitCast(closeio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn savePNG(surface: *Surface, file: [*c]const u8) bool {
|
pub inline fn savePNG(surface: *Surface, file: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_SavePNG(@ptrCast(surface), file));
|
return @bitCast(c.SDL_SavePNG(@ptrCast(@alignCast(surface)), file));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceRLE(surface: *Surface, enabled: bool) bool {
|
pub inline fn setSurfaceRLE(surface: *Surface, enabled: bool) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceRLE(@ptrCast(surface), @bitCast(enabled)));
|
return @bitCast(c.SDL_SetSurfaceRLE(@ptrCast(@alignCast(surface)), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasRLE(surface: *Surface) bool {
|
pub inline fn surfaceHasRLE(surface: *Surface) bool {
|
||||||
return @bitCast(c.SDL_SurfaceHasRLE(@ptrCast(surface)));
|
return @bitCast(c.SDL_SurfaceHasRLE(@ptrCast(@alignCast(surface))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceColorKey(surface: *Surface, enabled: bool, key: u32) bool {
|
pub inline fn setSurfaceColorKey(surface: *Surface, enabled: bool, key: u32) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceColorKey(@ptrCast(surface), @bitCast(enabled), key));
|
return @bitCast(c.SDL_SetSurfaceColorKey(@ptrCast(@alignCast(surface)), @bitCast(enabled), key));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasColorKey(surface: *Surface) bool {
|
pub inline fn surfaceHasColorKey(surface: *Surface) bool {
|
||||||
return @bitCast(c.SDL_SurfaceHasColorKey(@ptrCast(surface)));
|
return @bitCast(c.SDL_SurfaceHasColorKey(@ptrCast(@alignCast(surface))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceColorKey(surface: *Surface, key: *u32) bool {
|
pub inline fn getSurfaceColorKey(surface: *Surface, key: ?*u32) bool {
|
||||||
return @bitCast(c.SDL_GetSurfaceColorKey(@ptrCast(surface), @ptrCast(key)));
|
return @bitCast(c.SDL_GetSurfaceColorKey(@ptrCast(@alignCast(surface)), key));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceColorMod(surface: *Surface, r: u8, g: u8, b: u8) bool {
|
pub inline fn setSurfaceColorMod(surface: *Surface, r: u8, g: u8, b: u8) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceColorMod(@ptrCast(surface), r, g, b));
|
return @bitCast(c.SDL_SetSurfaceColorMod(@ptrCast(@alignCast(surface)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceColorMod(surface: *Surface, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
|
pub inline fn getSurfaceColorMod(surface: *Surface, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_GetSurfaceColorMod(@ptrCast(surface), r, g, b));
|
return @bitCast(c.SDL_GetSurfaceColorMod(@ptrCast(@alignCast(surface)), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceAlphaMod(surface: *Surface, alpha: u8) bool {
|
pub inline fn setSurfaceAlphaMod(surface: *Surface, alpha: u8) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceAlphaMod(@ptrCast(surface), alpha));
|
return @bitCast(c.SDL_SetSurfaceAlphaMod(@ptrCast(@alignCast(surface)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceAlphaMod(surface: *Surface, alpha: [*c]u8) bool {
|
pub inline fn getSurfaceAlphaMod(surface: *Surface, alpha: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_GetSurfaceAlphaMod(@ptrCast(surface), alpha));
|
return @bitCast(c.SDL_GetSurfaceAlphaMod(@ptrCast(@alignCast(surface)), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceBlendMode(surface: *Surface, blendMode: BlendMode) bool {
|
pub inline fn setSurfaceBlendMode(surface: *Surface, blendMode: BlendMode) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceBlendMode(@ptrCast(surface), @intFromEnum(blendMode)));
|
return @bitCast(c.SDL_SetSurfaceBlendMode(@ptrCast(@alignCast(surface)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceBlendMode(surface: *Surface, blendMode: ?*BlendMode) bool {
|
pub inline fn getSurfaceBlendMode(surface: *Surface, blendMode: ?*BlendMode) bool {
|
||||||
return @bitCast(c.SDL_GetSurfaceBlendMode(@ptrCast(surface), @ptrCast(blendMode)));
|
return @bitCast(c.SDL_GetSurfaceBlendMode(@ptrCast(@alignCast(surface)), blendMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceClipRect(surface: *Surface, rect: ?*const Rect) bool {
|
pub inline fn setSurfaceClipRect(surface: *Surface, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetSurfaceClipRect(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceClipRect(surface: *Surface, rect: ?*Rect) bool {
|
pub inline fn getSurfaceClipRect(surface: *Surface, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetSurfaceClipRect(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flipSurface(surface: *Surface, flip: FlipMode) bool {
|
pub inline fn flipSurface(surface: *Surface, flip: FlipMode) bool {
|
||||||
return @bitCast(c.SDL_FlipSurface(@ptrCast(surface), @intFromEnum(flip)));
|
return @bitCast(c.SDL_FlipSurface(@ptrCast(@alignCast(surface)), @bitCast(flip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rotateSurface(surface: *Surface, angle: f32) ?*Surface {
|
pub inline fn rotateSurface(surface: *Surface, angle: f32) ?*Surface {
|
||||||
return @ptrCast(c.SDL_RotateSurface(@ptrCast(surface), angle));
|
return @ptrCast(@alignCast(c.SDL_RotateSurface(@ptrCast(@alignCast(surface)), angle)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn duplicateSurface(surface: *Surface) ?*Surface {
|
pub inline fn duplicateSurface(surface: *Surface) ?*Surface {
|
||||||
return @ptrCast(c.SDL_DuplicateSurface(@ptrCast(surface)));
|
return @ptrCast(@alignCast(c.SDL_DuplicateSurface(@ptrCast(@alignCast(surface)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn scaleSurface(surface: *Surface, width: c_int, height: c_int, scaleMode: ScaleMode) ?*Surface {
|
pub inline fn scaleSurface(surface: *Surface, width: c_int, height: c_int, scaleMode: ScaleMode) ?*Surface {
|
||||||
return @ptrCast(c.SDL_ScaleSurface(@ptrCast(surface), width, height, @intFromEnum(scaleMode)));
|
return @ptrCast(@alignCast(c.SDL_ScaleSurface(@ptrCast(@alignCast(surface)), width, height, @intCast(@backingInt(scaleMode)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertSurface(surface: *Surface, format: PixelFormat) ?*Surface {
|
pub inline fn convertSurface(surface: *Surface, format: PixelFormat) ?*Surface {
|
||||||
return @ptrCast(c.SDL_ConvertSurface(@ptrCast(surface), @bitCast(format)));
|
return @ptrCast(@alignCast(c.SDL_ConvertSurface(@ptrCast(@alignCast(surface)), @intCast(@backingInt(format)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertSurfaceAndColorspace(surface: *Surface, format: PixelFormat, palette: ?*Palette, colorspace: Colorspace, props: PropertiesID) ?*Surface {
|
pub inline fn convertSurfaceAndColorspace(surface: *Surface, format: PixelFormat, palette: ?*Palette, colorspace: Colorspace, props: PropertiesID) ?*Surface {
|
||||||
return @ptrCast(c.SDL_ConvertSurfaceAndColorspace(@ptrCast(surface), @bitCast(format), @ptrCast(palette), colorspace, props));
|
return @ptrCast(@alignCast(c.SDL_ConvertSurfaceAndColorspace(@ptrCast(@alignCast(surface)), @intCast(@backingInt(format)), @ptrCast(@alignCast(palette)), @intCast(@backingInt(colorspace)), props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn premultiplySurfaceAlpha(surface: *Surface, linear: bool) bool {
|
pub inline fn premultiplySurfaceAlpha(surface: *Surface, linear: bool) bool {
|
||||||
return @bitCast(c.SDL_PremultiplySurfaceAlpha(@ptrCast(surface), @bitCast(linear)));
|
return @bitCast(c.SDL_PremultiplySurfaceAlpha(@ptrCast(@alignCast(surface)), @bitCast(linear)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearSurface(surface: *Surface, r: f32, g: f32, b: f32, a: f32) bool {
|
pub inline fn clearSurface(surface: *Surface, r: f32, g: f32, b: f32, a: f32) bool {
|
||||||
return @bitCast(c.SDL_ClearSurface(@ptrCast(surface), r, g, b, a));
|
return @bitCast(c.SDL_ClearSurface(@ptrCast(@alignCast(surface)), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn fillSurfaceRect(surface: *Surface, rect: ?*const Rect, color: u32) bool {
|
pub inline fn fillSurfaceRect(surface: *Surface, rect: ?*const Rect, color: u32) bool {
|
||||||
return @bitCast(c.SDL_FillSurfaceRect(@ptrCast(surface), @ptrCast(rect), color));
|
return @bitCast(c.SDL_FillSurfaceRect(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(rect)), color));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn fillSurfaceRects(surface: *Surface, rects: ?*const Rect, count: c_int, color: u32) bool {
|
pub inline fn fillSurfaceRects(surface: *Surface, rects: ?*const Rect, count: c_int, color: u32) bool {
|
||||||
return @bitCast(c.SDL_FillSurfaceRects(@ptrCast(surface), @ptrCast(rects), count, color));
|
return @bitCast(c.SDL_FillSurfaceRects(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(rects)), count, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurface(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
pub inline fn blitSurface(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_BlitSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurface(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurfaceUnchecked(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
pub inline fn blitSurfaceUnchecked(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_BlitSurfaceUnchecked(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceUnchecked(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurfaceScaled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
pub inline fn blitSurfaceScaled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_BlitSurfaceScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_BlitSurfaceScaled(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect)), @intCast(@backingInt(scaleMode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurfaceUncheckedScaled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
pub inline fn blitSurfaceUncheckedScaled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_BlitSurfaceUncheckedScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_BlitSurfaceUncheckedScaled(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect)), @intCast(@backingInt(scaleMode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stretchSurface(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
pub inline fn stretchSurface(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect, scaleMode: ScaleMode) bool {
|
||||||
return @bitCast(c.SDL_StretchSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_StretchSurface(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect)), @intCast(@backingInt(scaleMode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurfaceTiled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
pub inline fn blitSurfaceTiled(surface: *Surface, srcrect: ?*const Rect, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_BlitSurfaceTiled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceTiled(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurfaceTiledWithScale(surface: *Surface, srcrect: ?*const Rect, scale: f32, scaleMode: ScaleMode, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
pub inline fn blitSurfaceTiledWithScale(surface: *Surface, srcrect: ?*const Rect, scale: f32, scaleMode: ScaleMode, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_BlitSurfaceTiledWithScale(@ptrCast(surface), @ptrCast(srcrect), scale, @intFromEnum(scaleMode), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceTiledWithScale(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), scale, @intCast(@backingInt(scaleMode)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitSurface9Grid(surface: *Surface, srcrect: ?*const Rect, left_width: c_int, right_width: c_int, top_height: c_int, bottom_height: c_int, scale: f32, scaleMode: ScaleMode, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
pub inline fn blitSurface9Grid(surface: *Surface, srcrect: ?*const Rect, left_width: c_int, right_width: c_int, top_height: c_int, bottom_height: c_int, scale: f32, scaleMode: ScaleMode, dst: ?*Surface, dstrect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_BlitSurface9Grid(@ptrCast(surface), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @intFromEnum(scaleMode), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurface9Grid(@ptrCast(@alignCast(surface)), @ptrCast(@alignCast(srcrect)), left_width, right_width, top_height, bottom_height, scale, @intCast(@backingInt(scaleMode)), @ptrCast(@alignCast(dst)), @ptrCast(@alignCast(dstrect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapSurfaceRGB(surface: *Surface, r: u8, g: u8, b: u8) u32 {
|
pub inline fn mapSurfaceRGB(surface: *Surface, r: u8, g: u8, b: u8) u32 {
|
||||||
return c.SDL_MapSurfaceRGB(@ptrCast(surface), r, g, b);
|
return c.SDL_MapSurfaceRGB(@ptrCast(@alignCast(surface)), r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapSurfaceRGBA(surface: *Surface, r: u8, g: u8, b: u8, a: u8) u32 {
|
pub inline fn mapSurfaceRGBA(surface: *Surface, r: u8, g: u8, b: u8, a: u8) u32 {
|
||||||
return c.SDL_MapSurfaceRGBA(@ptrCast(surface), r, g, b, a);
|
return c.SDL_MapSurfaceRGBA(@ptrCast(@alignCast(surface)), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn readSurfacePixel(surface: *Surface, x: c_int, y: c_int, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool {
|
pub inline fn readSurfacePixel(surface: *Surface, x: c_int, y: c_int, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool {
|
||||||
return @bitCast(c.SDL_ReadSurfacePixel(@ptrCast(surface), x, y, r, g, b, a));
|
return @bitCast(c.SDL_ReadSurfacePixel(@ptrCast(@alignCast(surface)), x, y, r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn readSurfacePixelFloat(surface: *Surface, x: c_int, y: c_int, r: *f32, g: *f32, b: *f32, a: *f32) bool {
|
pub inline fn readSurfacePixelFloat(surface: *Surface, x: c_int, y: c_int, r: ?*f32, g: ?*f32, b: ?*f32, a: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_ReadSurfacePixelFloat(@ptrCast(surface), x, y, @ptrCast(r), @ptrCast(g), @ptrCast(b), @ptrCast(a)));
|
return @bitCast(c.SDL_ReadSurfacePixelFloat(@ptrCast(@alignCast(surface)), x, y, r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeSurfacePixel(surface: *Surface, x: c_int, y: c_int, r: u8, g: u8, b: u8, a: u8) bool {
|
pub inline fn writeSurfacePixel(surface: *Surface, x: c_int, y: c_int, r: u8, g: u8, b: u8, a: u8) bool {
|
||||||
return @bitCast(c.SDL_WriteSurfacePixel(@ptrCast(surface), x, y, r, g, b, a));
|
return @bitCast(c.SDL_WriteSurfacePixel(@ptrCast(@alignCast(surface)), x, y, r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeSurfacePixelFloat(surface: *Surface, x: c_int, y: c_int, r: f32, g: f32, b: f32, a: f32) bool {
|
pub inline fn writeSurfacePixelFloat(surface: *Surface, x: c_int, y: c_int, r: f32, g: f32, b: f32, a: f32) bool {
|
||||||
return @bitCast(c.SDL_WriteSurfacePixelFloat(@ptrCast(surface), x, y, r, g, b, a));
|
return @bitCast(c.SDL_WriteSurfacePixelFloat(@ptrCast(@alignCast(surface)), x, y, r, g, b, a));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*Surface {
|
pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*Surface {
|
||||||
return @ptrCast(c.SDL_CreateSurface(width, height, @bitCast(format)));
|
return @ptrCast(@alignCast(c.SDL_CreateSurface(width, height, @intCast(@backingInt(format)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSurfaceFrom(width: c_int, height: c_int, format: PixelFormat, pixels: ?*anyopaque, pitch: c_int) ?*Surface {
|
pub inline fn createSurfaceFrom(width: c_int, height: c_int, format: PixelFormat, pixels: ?*anyopaque, pitch: c_int) ?*Surface {
|
||||||
return @ptrCast(c.SDL_CreateSurfaceFrom(width, height, @bitCast(format), pixels, pitch));
|
return @ptrCast(@alignCast(c.SDL_CreateSurfaceFrom(width, height, @intCast(@backingInt(format)), pixels, pitch)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadSurface_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
pub inline fn loadSurface_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadSurface_IO(@ptrCast(src), @bitCast(closeio)));
|
return @ptrCast(@alignCast(c.SDL_LoadSurface_IO(@ptrCast(@alignCast(src)), @bitCast(closeio))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadSurface(file: [*c]const u8) ?*Surface {
|
pub inline fn loadSurface(file: [*c]const u8) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadSurface(file));
|
return @ptrCast(@alignCast(c.SDL_LoadSurface(file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadBMP_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
pub inline fn loadBMP_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadBMP_IO(@ptrCast(src), @bitCast(closeio)));
|
return @ptrCast(@alignCast(c.SDL_LoadBMP_IO(@ptrCast(@alignCast(src)), @bitCast(closeio))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadBMP(file: [*c]const u8) ?*Surface {
|
pub inline fn loadBMP(file: [*c]const u8) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadBMP(file));
|
return @ptrCast(@alignCast(c.SDL_LoadBMP(file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadPNG_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
pub inline fn loadPNG_IO(src: ?*IOStream, closeio: bool) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadPNG_IO(@ptrCast(src), @bitCast(closeio)));
|
return @ptrCast(@alignCast(c.SDL_LoadPNG_IO(@ptrCast(@alignCast(src)), @bitCast(closeio))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadPNG(file: [*c]const u8) ?*Surface {
|
pub inline fn loadPNG(file: [*c]const u8) ?*Surface {
|
||||||
return @ptrCast(c.SDL_LoadPNG(file));
|
return @ptrCast(@alignCast(c.SDL_LoadPNG(file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertPixels(width: c_int, height: c_int, src_format: PixelFormat, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst: ?*anyopaque, dst_pitch: c_int) bool {
|
pub inline fn convertPixels(width: c_int, height: c_int, src_format: PixelFormat, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst: ?*anyopaque, dst_pitch: c_int) bool {
|
||||||
return @bitCast(c.SDL_ConvertPixels(width, height, @bitCast(src_format), src, src_pitch, @bitCast(dst_format), dst, dst_pitch));
|
return @bitCast(c.SDL_ConvertPixels(width, height, @intCast(@backingInt(src_format)), src, src_pitch, @intCast(@backingInt(dst_format)), dst, dst_pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertPixelsAndColorspace(width: c_int, height: c_int, src_format: PixelFormat, src_colorspace: Colorspace, src_properties: PropertiesID, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst_colorspace: Colorspace, dst_properties: PropertiesID, dst: ?*anyopaque, dst_pitch: c_int) bool {
|
pub inline fn convertPixelsAndColorspace(width: c_int, height: c_int, src_format: PixelFormat, src_colorspace: Colorspace, src_properties: PropertiesID, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst_colorspace: Colorspace, dst_properties: PropertiesID, dst: ?*anyopaque, dst_pitch: c_int) bool {
|
||||||
return @bitCast(c.SDL_ConvertPixelsAndColorspace(width, height, @bitCast(src_format), src_colorspace, src_properties, src, src_pitch, @bitCast(dst_format), dst_colorspace, dst_properties, dst, dst_pitch));
|
return @bitCast(c.SDL_ConvertPixelsAndColorspace(width, height, @intCast(@backingInt(src_format)), @intCast(@backingInt(src_colorspace)), src_properties, src, src_pitch, @intCast(@backingInt(dst_format)), @intCast(@backingInt(dst_colorspace)), dst_properties, dst, dst_pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn premultiplyAlpha(width: c_int, height: c_int, src_format: PixelFormat, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst: ?*anyopaque, dst_pitch: c_int, linear: bool) bool {
|
pub inline fn premultiplyAlpha(width: c_int, height: c_int, src_format: PixelFormat, src: ?*const anyopaque, src_pitch: c_int, dst_format: PixelFormat, dst: ?*anyopaque, dst_pitch: c_int, linear: bool) bool {
|
||||||
return @bitCast(c.SDL_PremultiplyAlpha(width, height, @bitCast(src_format), src, src_pitch, @bitCast(dst_format), dst, dst_pitch, @bitCast(linear)));
|
return @bitCast(c.SDL_PremultiplyAlpha(width, height, @intCast(@backingInt(src_format)), src, src_pitch, @intCast(@backingInt(dst_format)), dst, dst_pitch, @bitCast(linear)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ pub inline fn getDirect3D9AdapterIndex(displayID: DisplayID) c_int {
|
||||||
return c.SDL_GetDirect3D9AdapterIndex(displayID);
|
return c.SDL_GetDirect3D9AdapterIndex(displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDXGIOutputInfo(displayID: DisplayID, adapterIndex: *c_int, outputIndex: *c_int) bool {
|
pub inline fn getDXGIOutputInfo(displayID: DisplayID, adapterIndex: ?*c_int, outputIndex: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetDXGIOutputInfo(displayID, @ptrCast(adapterIndex), @ptrCast(outputIndex)));
|
return @bitCast(c.SDL_GetDXGIOutputInfo(displayID, adapterIndex, outputIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const X11EventHook = c.SDL_X11EventHook;
|
pub const X11EventHook = c.SDL_X11EventHook;
|
||||||
|
|
@ -38,7 +38,7 @@ pub inline fn setLinuxThreadPriorityAndPolicy(threadID: i64, sdlPriority: c_int,
|
||||||
pub const iOSAnimationCallback = c.SDL_iOSAnimationCallback;
|
pub const iOSAnimationCallback = c.SDL_iOSAnimationCallback;
|
||||||
|
|
||||||
pub inline fn setiOSAnimationCallback(window: ?*Window, interval: c_int, callback: iOSAnimationCallback, callbackParam: ?*anyopaque) bool {
|
pub inline fn setiOSAnimationCallback(window: ?*Window, interval: c_int, callback: iOSAnimationCallback, callbackParam: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_SetiOSAnimationCallback(@ptrCast(window), interval, callback, callbackParam));
|
return @bitCast(c.SDL_SetiOSAnimationCallback(@ptrCast(@alignCast(window)), interval, callback, callbackParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setiOSEventPump(enabled: bool) void {
|
pub inline fn setiOSEventPump(enabled: bool) void {
|
||||||
|
|
@ -108,6 +108,7 @@ pub inline fn isTV() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const Sandbox = enum(c_int) {
|
pub const Sandbox = enum(c_int) {
|
||||||
|
sandboxNone = 0,
|
||||||
sandboxUnknownContainer,
|
sandboxUnknownContainer,
|
||||||
sandboxFlatpak,
|
sandboxFlatpak,
|
||||||
sandboxSnap,
|
sandboxSnap,
|
||||||
|
|
@ -115,7 +116,7 @@ pub const Sandbox = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getSandbox() Sandbox {
|
pub inline fn getSandbox() Sandbox {
|
||||||
return c.SDL_GetSandbox();
|
return @fromBackingInt(@intCast(c.SDL_GetSandbox()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn onApplicationWillTerminate() void {
|
pub inline fn onApplicationWillTerminate() void {
|
||||||
|
|
@ -146,14 +147,14 @@ pub inline fn onApplicationDidChangeStatusBarOrientation() void {
|
||||||
return c.SDL_OnApplicationDidChangeStatusBarOrientation();
|
return c.SDL_OnApplicationDidChangeStatusBarOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const XTaskQueueHandle = *anyopaque;
|
pub const XTaskQueueHandle = ?*anyopaque;
|
||||||
|
|
||||||
pub const XUserHandle = *anyopaque;
|
pub const XUserHandle = ?*anyopaque;
|
||||||
|
|
||||||
pub inline fn getGDKTaskQueue(outTaskQueue: [*c]XTaskQueueHandle) bool {
|
pub inline fn getGDKTaskQueue(outTaskQueue: [*c]XTaskQueueHandle) bool {
|
||||||
return @bitCast(c.SDL_GetGDKTaskQueue(outTaskQueue));
|
return @bitCast(c.SDL_GetGDKTaskQueue(@ptrCast(@alignCast(outTaskQueue))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGDKDefaultUser(outUserHandle: [*c]XUserHandle) bool {
|
pub inline fn getGDKDefaultUser(outUserHandle: [*c]XUserHandle) bool {
|
||||||
return @bitCast(c.SDL_GetGDKDefaultUser(outUserHandle));
|
return @bitCast(c.SDL_GetGDKDefaultUser(@ptrCast(@alignCast(outUserHandle))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
api/time.zig
12
api/time.zig
|
|
@ -28,23 +28,23 @@ pub const TimeFormat = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
|
pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
|
||||||
return @bitCast(c.SDL_GetDateTimeLocalePreferences(@ptrCast(dateFormat), @ptrCast(timeFormat)));
|
return @bitCast(c.SDL_GetDateTimeLocalePreferences(@ptrCast(@alignCast(dateFormat)), @ptrCast(@alignCast(timeFormat))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentTime(ticks: ?*Time) bool {
|
pub inline fn getCurrentTime(ticks: ?*Time) bool {
|
||||||
return @bitCast(c.SDL_GetCurrentTime(@ptrCast(ticks)));
|
return @bitCast(c.SDL_GetCurrentTime(ticks));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
|
pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
|
||||||
return @bitCast(c.SDL_TimeToDateTime(ticks, @ptrCast(dt), @bitCast(localTime)));
|
return @bitCast(c.SDL_TimeToDateTime(ticks, @ptrCast(@alignCast(dt)), @bitCast(localTime)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn dateTimeToTime(dt: ?*const DateTime, ticks: ?*Time) bool {
|
pub inline fn dateTimeToTime(dt: ?*const DateTime, ticks: ?*Time) bool {
|
||||||
return @bitCast(c.SDL_DateTimeToTime(@ptrCast(dt), @ptrCast(ticks)));
|
return @bitCast(c.SDL_DateTimeToTime(@ptrCast(@alignCast(dt)), ticks));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn timeToWindows(ticks: Time, dwLowDateTime: *u32, dwHighDateTime: *u32) void {
|
pub inline fn timeToWindows(ticks: Time, dwLowDateTime: ?*u32, dwHighDateTime: ?*u32) void {
|
||||||
return c.SDL_TimeToWindows(ticks, @ptrCast(dwLowDateTime), @ptrCast(dwHighDateTime));
|
return c.SDL_TimeToWindows(ticks, dwLowDateTime, dwHighDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn timeFromWindows(dwLowDateTime: u32, dwHighDateTime: u32) Time {
|
pub inline fn timeFromWindows(dwLowDateTime: u32, dwHighDateTime: u32) Time {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ pub const TouchID = u64;
|
||||||
pub const FingerID = u64;
|
pub const FingerID = u64;
|
||||||
|
|
||||||
pub const TouchDeviceType = enum(c_int) {
|
pub const TouchDeviceType = enum(c_int) {
|
||||||
|
touchDeviceInvalid = -1,
|
||||||
touchDeviceDirect, //touch screen with window-relative coordinates
|
touchDeviceDirect, //touch screen with window-relative coordinates
|
||||||
touchDeviceIndirectAbsolute, //trackpad with absolute device coordinates
|
touchDeviceIndirectAbsolute, //trackpad with absolute device coordinates
|
||||||
touchDeviceIndirectRelative, //trackpad with screen cursor-relative coordinates
|
touchDeviceIndirectRelative, //trackpad with screen cursor-relative coordinates
|
||||||
|
|
@ -17,8 +18,8 @@ pub const Finger = extern struct {
|
||||||
pressure: f32, // the quantity of pressure applied, normalized (0...1)
|
pressure: f32, // the quantity of pressure applied, normalized (0...1)
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getTouchDevices(count: *c_int) ?*TouchID {
|
pub inline fn getTouchDevices(count: ?*c_int) ?*TouchID {
|
||||||
return @ptrCast(c.SDL_GetTouchDevices(@ptrCast(count)));
|
return c.SDL_GetTouchDevices(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
|
pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
|
||||||
|
|
@ -26,9 +27,9 @@ pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTouchDeviceType(touchID: TouchID) TouchDeviceType {
|
pub inline fn getTouchDeviceType(touchID: TouchID) TouchDeviceType {
|
||||||
return @intFromEnum(c.SDL_GetTouchDeviceType(touchID));
|
return @fromBackingInt(@intCast(c.SDL_GetTouchDeviceType(touchID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTouchFingers(touchID: TouchID, count: *c_int) [*c]?*Finger {
|
pub inline fn getTouchFingers(touchID: TouchID, count: ?*c_int) [*c]?*Finger {
|
||||||
return c.SDL_GetTouchFingers(touchID, @ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetTouchFingers(touchID, count)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
51
api/tray.zig
51
api/tray.zig
|
|
@ -6,91 +6,91 @@ pub const Surface = surface_api.Surface;
|
||||||
|
|
||||||
pub const Tray = opaque {
|
pub const Tray = opaque {
|
||||||
pub inline fn setTrayIcon(tray: *Tray, icon: ?*Surface) void {
|
pub inline fn setTrayIcon(tray: *Tray, icon: ?*Surface) void {
|
||||||
return c.SDL_SetTrayIcon(@ptrCast(tray), @ptrCast(icon));
|
return c.SDL_SetTrayIcon(@ptrCast(@alignCast(tray)), @ptrCast(@alignCast(icon)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTrayTooltip(tray: *Tray, tooltip: [*c]const u8) void {
|
pub inline fn setTrayTooltip(tray: *Tray, tooltip: [*c]const u8) void {
|
||||||
return c.SDL_SetTrayTooltip(@ptrCast(tray), tooltip);
|
return c.SDL_SetTrayTooltip(@ptrCast(@alignCast(tray)), tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createTrayMenu(tray: *Tray) ?*TrayMenu {
|
pub inline fn createTrayMenu(tray: *Tray) ?*TrayMenu {
|
||||||
return @ptrCast(c.SDL_CreateTrayMenu(@ptrCast(tray)));
|
return @ptrCast(@alignCast(c.SDL_CreateTrayMenu(@ptrCast(@alignCast(tray)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayMenu(tray: *Tray) ?*TrayMenu {
|
pub inline fn getTrayMenu(tray: *Tray) ?*TrayMenu {
|
||||||
return @ptrCast(c.SDL_GetTrayMenu(@ptrCast(tray)));
|
return @ptrCast(@alignCast(c.SDL_GetTrayMenu(@ptrCast(@alignCast(tray)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyTray(tray: *Tray) void {
|
pub inline fn destroyTray(tray: *Tray) void {
|
||||||
return c.SDL_DestroyTray(@ptrCast(tray));
|
return c.SDL_DestroyTray(@ptrCast(@alignCast(tray)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TrayMenu = opaque {
|
pub const TrayMenu = opaque {
|
||||||
pub inline fn getTrayEntries(traymenu: *TrayMenu, count: *c_int) [*c]?*const TrayEntry {
|
pub inline fn getTrayEntries(traymenu: *TrayMenu, count: ?*c_int) [*c]?*const TrayEntry {
|
||||||
return c.SDL_GetTrayEntries(@ptrCast(traymenu), @ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetTrayEntries(@ptrCast(@alignCast(traymenu)), count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn insertTrayEntryAt(traymenu: *TrayMenu, pos: c_int, label: [*c]const u8, flags: TrayEntryFlags) ?*TrayEntry {
|
pub inline fn insertTrayEntryAt(traymenu: *TrayMenu, pos: c_int, label: [*c]const u8, flags: TrayEntryFlags) ?*TrayEntry {
|
||||||
return @ptrCast(c.SDL_InsertTrayEntryAt(@ptrCast(traymenu), pos, label, @bitCast(flags)));
|
return @ptrCast(@alignCast(c.SDL_InsertTrayEntryAt(@ptrCast(@alignCast(traymenu)), pos, label, @bitCast(flags))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayMenuParentEntry(traymenu: *TrayMenu) ?*TrayEntry {
|
pub inline fn getTrayMenuParentEntry(traymenu: *TrayMenu) ?*TrayEntry {
|
||||||
return @ptrCast(c.SDL_GetTrayMenuParentEntry(@ptrCast(traymenu)));
|
return @ptrCast(@alignCast(c.SDL_GetTrayMenuParentEntry(@ptrCast(@alignCast(traymenu)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayMenuParentTray(traymenu: *TrayMenu) ?*Tray {
|
pub inline fn getTrayMenuParentTray(traymenu: *TrayMenu) ?*Tray {
|
||||||
return @ptrCast(c.SDL_GetTrayMenuParentTray(@ptrCast(traymenu)));
|
return @ptrCast(@alignCast(c.SDL_GetTrayMenuParentTray(@ptrCast(@alignCast(traymenu)))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TrayEntry = opaque {
|
pub const TrayEntry = opaque {
|
||||||
pub inline fn createTraySubmenu(trayentry: *TrayEntry) ?*TrayMenu {
|
pub inline fn createTraySubmenu(trayentry: *TrayEntry) ?*TrayMenu {
|
||||||
return @ptrCast(c.SDL_CreateTraySubmenu(@ptrCast(trayentry)));
|
return @ptrCast(@alignCast(c.SDL_CreateTraySubmenu(@ptrCast(@alignCast(trayentry)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTraySubmenu(trayentry: *TrayEntry) ?*TrayMenu {
|
pub inline fn getTraySubmenu(trayentry: *TrayEntry) ?*TrayMenu {
|
||||||
return @ptrCast(c.SDL_GetTraySubmenu(@ptrCast(trayentry)));
|
return @ptrCast(@alignCast(c.SDL_GetTraySubmenu(@ptrCast(@alignCast(trayentry)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeTrayEntry(trayentry: *TrayEntry) void {
|
pub inline fn removeTrayEntry(trayentry: *TrayEntry) void {
|
||||||
return c.SDL_RemoveTrayEntry(@ptrCast(trayentry));
|
return c.SDL_RemoveTrayEntry(@ptrCast(@alignCast(trayentry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTrayEntryLabel(trayentry: *TrayEntry, label: [*c]const u8) void {
|
pub inline fn setTrayEntryLabel(trayentry: *TrayEntry, label: [*c]const u8) void {
|
||||||
return c.SDL_SetTrayEntryLabel(@ptrCast(trayentry), label);
|
return c.SDL_SetTrayEntryLabel(@ptrCast(@alignCast(trayentry)), label);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayEntryLabel(trayentry: *TrayEntry) [*c]const u8 {
|
pub inline fn getTrayEntryLabel(trayentry: *TrayEntry) [*c]const u8 {
|
||||||
return c.SDL_GetTrayEntryLabel(@ptrCast(trayentry));
|
return c.SDL_GetTrayEntryLabel(@ptrCast(@alignCast(trayentry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTrayEntryChecked(trayentry: *TrayEntry, checked: bool) void {
|
pub inline fn setTrayEntryChecked(trayentry: *TrayEntry, checked: bool) void {
|
||||||
return c.SDL_SetTrayEntryChecked(@ptrCast(trayentry), @bitCast(checked));
|
return c.SDL_SetTrayEntryChecked(@ptrCast(@alignCast(trayentry)), @bitCast(checked));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayEntryChecked(trayentry: *TrayEntry) bool {
|
pub inline fn getTrayEntryChecked(trayentry: *TrayEntry) bool {
|
||||||
return @bitCast(c.SDL_GetTrayEntryChecked(@ptrCast(trayentry)));
|
return @bitCast(c.SDL_GetTrayEntryChecked(@ptrCast(@alignCast(trayentry))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTrayEntryEnabled(trayentry: *TrayEntry, enabled: bool) void {
|
pub inline fn setTrayEntryEnabled(trayentry: *TrayEntry, enabled: bool) void {
|
||||||
return c.SDL_SetTrayEntryEnabled(@ptrCast(trayentry), @bitCast(enabled));
|
return c.SDL_SetTrayEntryEnabled(@ptrCast(@alignCast(trayentry)), @bitCast(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayEntryEnabled(trayentry: *TrayEntry) bool {
|
pub inline fn getTrayEntryEnabled(trayentry: *TrayEntry) bool {
|
||||||
return @bitCast(c.SDL_GetTrayEntryEnabled(@ptrCast(trayentry)));
|
return @bitCast(c.SDL_GetTrayEntryEnabled(@ptrCast(@alignCast(trayentry))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setTrayEntryCallback(trayentry: *TrayEntry, callback: TrayCallback, userdata: ?*anyopaque) void {
|
pub inline fn setTrayEntryCallback(trayentry: *TrayEntry, callback: TrayCallback, userdata: ?*anyopaque) void {
|
||||||
return c.SDL_SetTrayEntryCallback(@ptrCast(trayentry), callback, userdata);
|
return c.SDL_SetTrayEntryCallback(@ptrCast(@alignCast(trayentry)), callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clickTrayEntry(trayentry: *TrayEntry) void {
|
pub inline fn clickTrayEntry(trayentry: *TrayEntry) void {
|
||||||
return c.SDL_ClickTrayEntry(@ptrCast(trayentry));
|
return c.SDL_ClickTrayEntry(@ptrCast(@alignCast(trayentry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTrayEntryParent(trayentry: *TrayEntry) ?*TrayMenu {
|
pub inline fn getTrayEntryParent(trayentry: *TrayEntry) ?*TrayMenu {
|
||||||
return @ptrCast(c.SDL_GetTrayEntryParent(@ptrCast(trayentry)));
|
return @ptrCast(@alignCast(c.SDL_GetTrayEntryParent(@ptrCast(@alignCast(trayentry)))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -98,10 +98,9 @@ pub const TrayEntryFlags = packed struct(u32) {
|
||||||
trayentryButton: bool = false, // Make the entry a simple button. Required.
|
trayentryButton: bool = false, // Make the entry a simple button. Required.
|
||||||
trayentryCheckbox: bool = false, // Make the entry a checkbox. Required.
|
trayentryCheckbox: bool = false, // Make the entry a checkbox. Required.
|
||||||
trayentrySubmenu: bool = false, // Prepare the entry to have a submenu. Required
|
trayentrySubmenu: bool = false, // Prepare the entry to have a submenu. Required
|
||||||
trayentryDisabled: bool = false, // Make the entry disabled. Optional.
|
pad0: u27 = 0,
|
||||||
trayentryChecked: bool = false, // Make the entry checked. This is valid only for checkboxes. Optional.
|
trayentryChecked: bool = false, // Make the entry checked. This is valid only for checkboxes. Optional.
|
||||||
pad0: u26 = 0,
|
trayentryDisabled: bool = false, // Make the entry disabled. Optional.
|
||||||
rsvd: bool = false,
|
|
||||||
|
|
||||||
pub const None = TrayEntryFlags{};
|
pub const None = TrayEntryFlags{};
|
||||||
};
|
};
|
||||||
|
|
@ -109,7 +108,7 @@ pub const TrayEntryFlags = packed struct(u32) {
|
||||||
pub const TrayCallback = c.SDL_TrayCallback;
|
pub const TrayCallback = c.SDL_TrayCallback;
|
||||||
|
|
||||||
pub inline fn createTray(icon: ?*Surface, tooltip: [*c]const u8) ?*Tray {
|
pub inline fn createTray(icon: ?*Surface, tooltip: [*c]const u8) ?*Tray {
|
||||||
return @ptrCast(c.SDL_CreateTray(@ptrCast(icon), tooltip));
|
return @ptrCast(@alignCast(c.SDL_CreateTray(@ptrCast(@alignCast(icon)), tooltip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateTrays() void {
|
pub inline fn updateTrays() void {
|
||||||
|
|
|
||||||
223
api/video.zig
223
api/video.zig
|
|
@ -42,292 +42,292 @@ pub const DisplayOrientation = enum(c_int) {
|
||||||
orientationLandscape, //The display is in landscape mode, with the right side up, relative to portrait mode
|
orientationLandscape, //The display is in landscape mode, with the right side up, relative to portrait mode
|
||||||
orientationLandscapeFlipped, //The display is in landscape mode, with the left side up, relative to portrait mode
|
orientationLandscapeFlipped, //The display is in landscape mode, with the left side up, relative to portrait mode
|
||||||
orientationPortrait, //The display is in portrait mode
|
orientationPortrait, //The display is in portrait mode
|
||||||
orientationPortraitFlipped,
|
orientationPortraitFlipped, //The display is in portrait mode, upside down
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Window = opaque {
|
pub const Window = opaque {
|
||||||
pub inline fn getDisplayForWindow(window: *Window) DisplayID {
|
pub inline fn getDisplayForWindow(window: *Window) DisplayID {
|
||||||
return c.SDL_GetDisplayForWindow(@ptrCast(window));
|
return c.SDL_GetDisplayForWindow(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPixelDensity(window: *Window) f32 {
|
pub inline fn getWindowPixelDensity(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowPixelDensity(@ptrCast(window));
|
return c.SDL_GetWindowPixelDensity(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowDisplayScale(window: *Window) f32 {
|
pub inline fn getWindowDisplayScale(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowDisplayScale(@ptrCast(window));
|
return c.SDL_GetWindowDisplayScale(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFullscreenMode(window: *Window, mode: ?*const DisplayMode) bool {
|
pub inline fn setWindowFullscreenMode(window: *Window, mode: ?*const DisplayMode) bool {
|
||||||
return @bitCast(c.SDL_SetWindowFullscreenMode(@ptrCast(window), @ptrCast(mode)));
|
return @bitCast(c.SDL_SetWindowFullscreenMode(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(mode))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFullscreenMode(window: *Window) ?*const DisplayMode {
|
pub inline fn getWindowFullscreenMode(window: *Window) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetWindowFullscreenMode(@ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_GetWindowFullscreenMode(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowICCProfile(window: *Window, size: *usize) ?*anyopaque {
|
pub inline fn getWindowICCProfile(window: *Window, size: ?*usize) ?*anyopaque {
|
||||||
return c.SDL_GetWindowICCProfile(@ptrCast(window), @ptrCast(size));
|
return c.SDL_GetWindowICCProfile(@ptrCast(@alignCast(window)), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPixelFormat(window: *Window) PixelFormat {
|
pub inline fn getWindowPixelFormat(window: *Window) PixelFormat {
|
||||||
return @bitCast(c.SDL_GetWindowPixelFormat(@ptrCast(window)));
|
return @fromBackingInt(@intCast(c.SDL_GetWindowPixelFormat(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createPopupWindow(window: *Window, offset_x: c_int, offset_y: c_int, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
|
pub inline fn createPopupWindow(window: *Window, offset_x: c_int, offset_y: c_int, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
|
||||||
return @ptrCast(c.SDL_CreatePopupWindow(@ptrCast(window), offset_x, offset_y, w, h, @bitCast(flags)));
|
return @ptrCast(@alignCast(c.SDL_CreatePopupWindow(@ptrCast(@alignCast(window)), offset_x, offset_y, w, h, @bitCast(flags))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowID(window: *Window) WindowID {
|
pub inline fn getWindowID(window: *Window) WindowID {
|
||||||
return c.SDL_GetWindowID(@ptrCast(window));
|
return c.SDL_GetWindowID(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowParent(window: *Window) ?*Window {
|
pub inline fn getWindowParent(window: *Window) ?*Window {
|
||||||
return @ptrCast(c.SDL_GetWindowParent(@ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_GetWindowParent(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowProperties(window: *Window) PropertiesID {
|
pub inline fn getWindowProperties(window: *Window) PropertiesID {
|
||||||
return c.SDL_GetWindowProperties(@ptrCast(window));
|
return c.SDL_GetWindowProperties(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFlags(window: *Window) WindowFlags {
|
pub inline fn getWindowFlags(window: *Window) WindowFlags {
|
||||||
return @bitCast(c.SDL_GetWindowFlags(@ptrCast(window)));
|
return @bitCast(c.SDL_GetWindowFlags(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowTitle(window: *Window, title: [*c]const u8) bool {
|
pub inline fn setWindowTitle(window: *Window, title: [*c]const u8) bool {
|
||||||
return @bitCast(c.SDL_SetWindowTitle(@ptrCast(window), title));
|
return @bitCast(c.SDL_SetWindowTitle(@ptrCast(@alignCast(window)), title));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowTitle(window: *Window) [*c]const u8 {
|
pub inline fn getWindowTitle(window: *Window) [*c]const u8 {
|
||||||
return c.SDL_GetWindowTitle(@ptrCast(window));
|
return c.SDL_GetWindowTitle(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowIcon(window: *Window, icon: ?*Surface) bool {
|
pub inline fn setWindowIcon(window: *Window, icon: ?*Surface) bool {
|
||||||
return @bitCast(c.SDL_SetWindowIcon(@ptrCast(window), @ptrCast(icon)));
|
return @bitCast(c.SDL_SetWindowIcon(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(icon))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowPosition(window: *Window, x: c_int, y: c_int) bool {
|
pub inline fn setWindowPosition(window: *Window, x: c_int, y: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetWindowPosition(@ptrCast(window), x, y));
|
return @bitCast(c.SDL_SetWindowPosition(@ptrCast(@alignCast(window)), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPosition(window: *Window, x: *c_int, y: *c_int) bool {
|
pub inline fn getWindowPosition(window: *Window, x: ?*c_int, y: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowPosition(@ptrCast(window), @ptrCast(x), @ptrCast(y)));
|
return @bitCast(c.SDL_GetWindowPosition(@ptrCast(@alignCast(window)), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowSize(window: *Window, w: c_int, h: c_int) bool {
|
pub inline fn setWindowSize(window: *Window, w: c_int, h: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetWindowSize(@ptrCast(window), w, h));
|
return @bitCast(c.SDL_SetWindowSize(@ptrCast(@alignCast(window)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowSize(window: *Window, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetWindowSize(@ptrCast(@alignCast(window)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSafeArea(window: *Window, rect: ?*Rect) bool {
|
pub inline fn getWindowSafeArea(window: *Window, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetWindowSafeArea(@ptrCast(window), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetWindowSafeArea(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowAspectRatio(window: *Window, min_aspect: f32, max_aspect: f32) bool {
|
pub inline fn setWindowAspectRatio(window: *Window, min_aspect: f32, max_aspect: f32) bool {
|
||||||
return @bitCast(c.SDL_SetWindowAspectRatio(@ptrCast(window), min_aspect, max_aspect));
|
return @bitCast(c.SDL_SetWindowAspectRatio(@ptrCast(@alignCast(window)), min_aspect, max_aspect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowAspectRatio(window: *Window, min_aspect: *f32, max_aspect: *f32) bool {
|
pub inline fn getWindowAspectRatio(window: *Window, min_aspect: ?*f32, max_aspect: ?*f32) bool {
|
||||||
return @bitCast(c.SDL_GetWindowAspectRatio(@ptrCast(window), @ptrCast(min_aspect), @ptrCast(max_aspect)));
|
return @bitCast(c.SDL_GetWindowAspectRatio(@ptrCast(@alignCast(window)), min_aspect, max_aspect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowBordersSize(window: *Window, top: *c_int, left: *c_int, bottom: *c_int, right: *c_int) bool {
|
pub inline fn getWindowBordersSize(window: *Window, top: ?*c_int, left: ?*c_int, bottom: ?*c_int, right: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowBordersSize(@ptrCast(window), @ptrCast(top), @ptrCast(left), @ptrCast(bottom), @ptrCast(right)));
|
return @bitCast(c.SDL_GetWindowBordersSize(@ptrCast(@alignCast(window)), top, left, bottom, right));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSizeInPixels(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowSizeInPixels(window: *Window, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowSizeInPixels(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetWindowSizeInPixels(@ptrCast(@alignCast(window)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMinimumSize(window: *Window, min_w: c_int, min_h: c_int) bool {
|
pub inline fn setWindowMinimumSize(window: *Window, min_w: c_int, min_h: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetWindowMinimumSize(@ptrCast(window), min_w, min_h));
|
return @bitCast(c.SDL_SetWindowMinimumSize(@ptrCast(@alignCast(window)), min_w, min_h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMinimumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowMinimumSize(window: *Window, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowMinimumSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetWindowMinimumSize(@ptrCast(@alignCast(window)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMaximumSize(window: *Window, max_w: c_int, max_h: c_int) bool {
|
pub inline fn setWindowMaximumSize(window: *Window, max_w: c_int, max_h: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetWindowMaximumSize(@ptrCast(window), max_w, max_h));
|
return @bitCast(c.SDL_SetWindowMaximumSize(@ptrCast(@alignCast(window)), max_w, max_h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMaximumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowMaximumSize(window: *Window, w: ?*c_int, h: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowMaximumSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
return @bitCast(c.SDL_GetWindowMaximumSize(@ptrCast(@alignCast(window)), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowBordered(window: *Window, bordered: bool) bool {
|
pub inline fn setWindowBordered(window: *Window, bordered: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowBordered(@ptrCast(window), @bitCast(bordered)));
|
return @bitCast(c.SDL_SetWindowBordered(@ptrCast(@alignCast(window)), @bitCast(bordered)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowResizable(window: *Window, resizable: bool) bool {
|
pub inline fn setWindowResizable(window: *Window, resizable: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowResizable(@ptrCast(window), @bitCast(resizable)));
|
return @bitCast(c.SDL_SetWindowResizable(@ptrCast(@alignCast(window)), @bitCast(resizable)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowAlwaysOnTop(window: *Window, on_top: bool) bool {
|
pub inline fn setWindowAlwaysOnTop(window: *Window, on_top: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowAlwaysOnTop(@ptrCast(window), @bitCast(on_top)));
|
return @bitCast(c.SDL_SetWindowAlwaysOnTop(@ptrCast(@alignCast(window)), @bitCast(on_top)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFillDocument(window: *Window, fill: bool) bool {
|
pub inline fn setWindowFillDocument(window: *Window, fill: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowFillDocument(@ptrCast(window), @bitCast(fill)));
|
return @bitCast(c.SDL_SetWindowFillDocument(@ptrCast(@alignCast(window)), @bitCast(fill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showWindow(window: *Window) bool {
|
pub inline fn showWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_ShowWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_ShowWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hideWindow(window: *Window) bool {
|
pub inline fn hideWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_HideWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_HideWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn raiseWindow(window: *Window) bool {
|
pub inline fn raiseWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_RaiseWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_RaiseWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn maximizeWindow(window: *Window) bool {
|
pub inline fn maximizeWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_MaximizeWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_MaximizeWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn minimizeWindow(window: *Window) bool {
|
pub inline fn minimizeWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_MinimizeWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_MinimizeWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn restoreWindow(window: *Window) bool {
|
pub inline fn restoreWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_RestoreWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_RestoreWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFullscreen(window: *Window, fullscreen: bool) bool {
|
pub inline fn setWindowFullscreen(window: *Window, fullscreen: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowFullscreen(@ptrCast(window), @bitCast(fullscreen)));
|
return @bitCast(c.SDL_SetWindowFullscreen(@ptrCast(@alignCast(window)), @bitCast(fullscreen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn syncWindow(window: *Window) bool {
|
pub inline fn syncWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_SyncWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_SyncWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowHasSurface(window: *Window) bool {
|
pub inline fn windowHasSurface(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_WindowHasSurface(@ptrCast(window)));
|
return @bitCast(c.SDL_WindowHasSurface(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSurface(window: *Window) ?*Surface {
|
pub inline fn getWindowSurface(window: *Window) ?*Surface {
|
||||||
return @ptrCast(c.SDL_GetWindowSurface(@ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_GetWindowSurface(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowSurfaceVSync(window: *Window, vsync: c_int) bool {
|
pub inline fn setWindowSurfaceVSync(window: *Window, vsync: c_int) bool {
|
||||||
return @bitCast(c.SDL_SetWindowSurfaceVSync(@ptrCast(window), vsync));
|
return @bitCast(c.SDL_SetWindowSurfaceVSync(@ptrCast(@alignCast(window)), vsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSurfaceVSync(window: *Window, vsync: *c_int) bool {
|
pub inline fn getWindowSurfaceVSync(window: *Window, vsync: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GetWindowSurfaceVSync(@ptrCast(window), @ptrCast(vsync)));
|
return @bitCast(c.SDL_GetWindowSurfaceVSync(@ptrCast(@alignCast(window)), vsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateWindowSurface(window: *Window) bool {
|
pub inline fn updateWindowSurface(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_UpdateWindowSurface(@ptrCast(window)));
|
return @bitCast(c.SDL_UpdateWindowSurface(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateWindowSurfaceRects(window: *Window, rects: ?*const Rect, numrects: c_int) bool {
|
pub inline fn updateWindowSurfaceRects(window: *Window, rects: ?*const Rect, numrects: c_int) bool {
|
||||||
return @bitCast(c.SDL_UpdateWindowSurfaceRects(@ptrCast(window), @ptrCast(rects), numrects));
|
return @bitCast(c.SDL_UpdateWindowSurfaceRects(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rects)), numrects));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyWindowSurface(window: *Window) bool {
|
pub inline fn destroyWindowSurface(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_DestroyWindowSurface(@ptrCast(window)));
|
return @bitCast(c.SDL_DestroyWindowSurface(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowKeyboardGrab(window: *Window, grabbed: bool) bool {
|
pub inline fn setWindowKeyboardGrab(window: *Window, grabbed: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowKeyboardGrab(@ptrCast(window), @bitCast(grabbed)));
|
return @bitCast(c.SDL_SetWindowKeyboardGrab(@ptrCast(@alignCast(window)), @bitCast(grabbed)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMouseGrab(window: *Window, grabbed: bool) bool {
|
pub inline fn setWindowMouseGrab(window: *Window, grabbed: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowMouseGrab(@ptrCast(window), @bitCast(grabbed)));
|
return @bitCast(c.SDL_SetWindowMouseGrab(@ptrCast(@alignCast(window)), @bitCast(grabbed)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowKeyboardGrab(window: *Window) bool {
|
pub inline fn getWindowKeyboardGrab(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_GetWindowKeyboardGrab(@ptrCast(window)));
|
return @bitCast(c.SDL_GetWindowKeyboardGrab(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMouseGrab(window: *Window) bool {
|
pub inline fn getWindowMouseGrab(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_GetWindowMouseGrab(@ptrCast(window)));
|
return @bitCast(c.SDL_GetWindowMouseGrab(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMouseRect(window: *Window, rect: ?*const Rect) bool {
|
pub inline fn setWindowMouseRect(window: *Window, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetWindowMouseRect(@ptrCast(window), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetWindowMouseRect(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMouseRect(window: *Window) ?*const Rect {
|
pub inline fn getWindowMouseRect(window: *Window) ?*const Rect {
|
||||||
return @ptrCast(c.SDL_GetWindowMouseRect(@ptrCast(window)));
|
return @ptrCast(@alignCast(c.SDL_GetWindowMouseRect(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowOpacity(window: *Window, opacity: f32) bool {
|
pub inline fn setWindowOpacity(window: *Window, opacity: f32) bool {
|
||||||
return @bitCast(c.SDL_SetWindowOpacity(@ptrCast(window), opacity));
|
return @bitCast(c.SDL_SetWindowOpacity(@ptrCast(@alignCast(window)), opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowOpacity(window: *Window) f32 {
|
pub inline fn getWindowOpacity(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowOpacity(@ptrCast(window));
|
return c.SDL_GetWindowOpacity(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowParent(window: *Window, parent: ?*Window) bool {
|
pub inline fn setWindowParent(window: *Window, parent: ?*Window) bool {
|
||||||
return @bitCast(c.SDL_SetWindowParent(@ptrCast(window), @ptrCast(parent)));
|
return @bitCast(c.SDL_SetWindowParent(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(parent))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowModal(window: *Window, modal: bool) bool {
|
pub inline fn setWindowModal(window: *Window, modal: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowModal(@ptrCast(window), @bitCast(modal)));
|
return @bitCast(c.SDL_SetWindowModal(@ptrCast(@alignCast(window)), @bitCast(modal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFocusable(window: *Window, focusable: bool) bool {
|
pub inline fn setWindowFocusable(window: *Window, focusable: bool) bool {
|
||||||
return @bitCast(c.SDL_SetWindowFocusable(@ptrCast(window), @bitCast(focusable)));
|
return @bitCast(c.SDL_SetWindowFocusable(@ptrCast(@alignCast(window)), @bitCast(focusable)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showWindowSystemMenu(window: *Window, x: c_int, y: c_int) bool {
|
pub inline fn showWindowSystemMenu(window: *Window, x: c_int, y: c_int) bool {
|
||||||
return @bitCast(c.SDL_ShowWindowSystemMenu(@ptrCast(window), x, y));
|
return @bitCast(c.SDL_ShowWindowSystemMenu(@ptrCast(@alignCast(window)), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowHitTest(window: *Window, callback: HitTest, callback_data: ?*anyopaque) bool {
|
pub inline fn setWindowHitTest(window: *Window, callback: HitTest, callback_data: ?*anyopaque) bool {
|
||||||
return @bitCast(c.SDL_SetWindowHitTest(@ptrCast(window), callback, callback_data));
|
return @bitCast(c.SDL_SetWindowHitTest(@ptrCast(@alignCast(window)), callback, callback_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowShape(window: *Window, shape: ?*Surface) bool {
|
pub inline fn setWindowShape(window: *Window, shape: ?*Surface) bool {
|
||||||
return @bitCast(c.SDL_SetWindowShape(@ptrCast(window), @ptrCast(shape)));
|
return @bitCast(c.SDL_SetWindowShape(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(shape))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flashWindow(window: *Window, operation: FlashOperation) bool {
|
pub inline fn flashWindow(window: *Window, operation: FlashOperation) bool {
|
||||||
return @bitCast(c.SDL_FlashWindow(@ptrCast(window), @intFromEnum(operation)));
|
return @bitCast(c.SDL_FlashWindow(@ptrCast(@alignCast(window)), @intCast(@backingInt(operation))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowProgressState(window: *Window, state: ProgressState) bool {
|
pub inline fn setWindowProgressState(window: *Window, state: ProgressState) bool {
|
||||||
return @bitCast(c.SDL_SetWindowProgressState(@ptrCast(window), state));
|
return @bitCast(c.SDL_SetWindowProgressState(@ptrCast(@alignCast(window)), @intCast(@backingInt(state))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowProgressState(window: *Window) ProgressState {
|
pub inline fn getWindowProgressState(window: *Window) ProgressState {
|
||||||
return c.SDL_GetWindowProgressState(@ptrCast(window));
|
return @fromBackingInt(@intCast(c.SDL_GetWindowProgressState(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowProgressValue(window: *Window, value: f32) bool {
|
pub inline fn setWindowProgressValue(window: *Window, value: f32) bool {
|
||||||
return @bitCast(c.SDL_SetWindowProgressValue(@ptrCast(window), value));
|
return @bitCast(c.SDL_SetWindowProgressValue(@ptrCast(@alignCast(window)), value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowProgressValue(window: *Window) f32 {
|
pub inline fn getWindowProgressValue(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowProgressValue(@ptrCast(window));
|
return c.SDL_GetWindowProgressValue(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyWindow(window: *Window) void {
|
pub inline fn destroyWindow(window: *Window) void {
|
||||||
return c.SDL_DestroyWindow(@ptrCast(window));
|
return c.SDL_DestroyWindow(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_CreateContext(window: *Window) GLContext {
|
pub inline fn gl_CreateContext(window: *Window) GLContext {
|
||||||
return c.SDL_GL_CreateContext(@ptrCast(window));
|
return @ptrCast(@alignCast(c.SDL_GL_CreateContext(@ptrCast(@alignCast(window)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_MakeCurrent(window: *Window, context: GLContext) bool {
|
pub inline fn gl_MakeCurrent(window: *Window, context: GLContext) bool {
|
||||||
return @bitCast(c.SDL_GL_MakeCurrent(@ptrCast(window), context));
|
return @bitCast(c.SDL_GL_MakeCurrent(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(context))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn egl_GetWindowSurface(window: *Window) EGLSurface {
|
pub inline fn egl_GetWindowSurface(window: *Window) EGLSurface {
|
||||||
return c.SDL_EGL_GetWindowSurface(@ptrCast(window));
|
return c.SDL_EGL_GetWindowSurface(@ptrCast(@alignCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_SwapWindow(window: *Window) bool {
|
pub inline fn gl_SwapWindow(window: *Window) bool {
|
||||||
return @bitCast(c.SDL_GL_SwapWindow(@ptrCast(window)));
|
return @bitCast(c.SDL_GL_SwapWindow(@ptrCast(@alignCast(window))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -354,11 +354,12 @@ pub const WindowFlags = packed struct(u64) {
|
||||||
windowPopupMenu: bool = false, // window should be treated as a popup menu, requires a parent window
|
windowPopupMenu: bool = false, // window should be treated as a popup menu, requires a parent window
|
||||||
windowKeyboardGrabbed: bool = false, // window has grabbed keyboard input
|
windowKeyboardGrabbed: bool = false, // window has grabbed keyboard input
|
||||||
windowFillDocument: bool = false, // window is in fill-document mode (Emscripten only), since SDL 3.4.0
|
windowFillDocument: bool = false, // window is in fill-document mode (Emscripten only), since SDL 3.4.0
|
||||||
|
pad0: u6 = 0,
|
||||||
windowVulkan: bool = false, // window usable for Vulkan surface
|
windowVulkan: bool = false, // window usable for Vulkan surface
|
||||||
windowMetal: bool = false, // window usable for Metal view
|
windowMetal: bool = false, // window usable for Metal view
|
||||||
windowTransparent: bool = false, // window with transparent buffer
|
windowTransparent: bool = false, // window with transparent buffer
|
||||||
windowNotFocusable: bool = false, // window should not be focusable
|
windowNotFocusable: bool = false, // window should not be focusable
|
||||||
pad0: u37 = 0,
|
pad1: u31 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
pub const None = WindowFlags{};
|
pub const None = WindowFlags{};
|
||||||
|
|
@ -379,7 +380,7 @@ pub const ProgressState = enum(c_int) {
|
||||||
progressStateError, //The progress bar is shown in a state indicating the application had an error
|
progressStateError, //The progress bar is shown in a state indicating the application had an error
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GLContext = *anyopaque;
|
pub const GLContext = ?*anyopaque;
|
||||||
|
|
||||||
pub const EGLDisplay = ?*anyopaque;
|
pub const EGLDisplay = ?*anyopaque;
|
||||||
|
|
||||||
|
|
@ -447,11 +448,11 @@ pub inline fn getCurrentVideoDriver() [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSystemTheme() SystemTheme {
|
pub inline fn getSystemTheme() SystemTheme {
|
||||||
return c.SDL_GetSystemTheme();
|
return @fromBackingInt(@intCast(c.SDL_GetSystemTheme()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplays(count: *c_int) ?*DisplayID {
|
pub inline fn getDisplays(count: ?*c_int) ?*DisplayID {
|
||||||
return @ptrCast(c.SDL_GetDisplays(@ptrCast(count)));
|
return c.SDL_GetDisplays(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPrimaryDisplay() DisplayID {
|
pub inline fn getPrimaryDisplay() DisplayID {
|
||||||
|
|
@ -467,67 +468,67 @@ pub inline fn getDisplayName(displayID: DisplayID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
pub inline fn getDisplayBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetDisplayBounds(displayID, @ptrCast(rect)));
|
return @bitCast(c.SDL_GetDisplayBounds(displayID, @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayUsableBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
pub inline fn getDisplayUsableBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetDisplayUsableBounds(displayID, @ptrCast(rect)));
|
return @bitCast(c.SDL_GetDisplayUsableBounds(displayID, @ptrCast(@alignCast(rect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNaturalDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
pub inline fn getNaturalDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
||||||
return c.SDL_GetNaturalDisplayOrientation(displayID);
|
return @fromBackingInt(@intCast(c.SDL_GetNaturalDisplayOrientation(displayID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
pub inline fn getCurrentDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
||||||
return c.SDL_GetCurrentDisplayOrientation(displayID);
|
return @fromBackingInt(@intCast(c.SDL_GetCurrentDisplayOrientation(displayID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayContentScale(displayID: DisplayID) f32 {
|
pub inline fn getDisplayContentScale(displayID: DisplayID) f32 {
|
||||||
return c.SDL_GetDisplayContentScale(displayID);
|
return c.SDL_GetDisplayContentScale(displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: *c_int) [*c]?*DisplayMode {
|
pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: ?*c_int) [*c]?*DisplayMode {
|
||||||
return @intFromEnum(c.SDL_GetFullscreenDisplayModes(displayID, @ptrCast(count)));
|
return @ptrCast(@alignCast(c.SDL_GetFullscreenDisplayModes(displayID, count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClosestFullscreenDisplayMode(displayID: DisplayID, w: c_int, h: c_int, refresh_rate: f32, include_high_density_modes: bool, closest: ?*DisplayMode) bool {
|
pub inline fn getClosestFullscreenDisplayMode(displayID: DisplayID, w: c_int, h: c_int, refresh_rate: f32, include_high_density_modes: bool, closest: ?*DisplayMode) bool {
|
||||||
return @bitCast(c.SDL_GetClosestFullscreenDisplayMode(displayID, w, h, refresh_rate, @bitCast(include_high_density_modes), @ptrCast(closest)));
|
return @bitCast(c.SDL_GetClosestFullscreenDisplayMode(displayID, w, h, refresh_rate, @bitCast(include_high_density_modes), @ptrCast(@alignCast(closest))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDesktopDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
pub inline fn getDesktopDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetDesktopDisplayMode(displayID));
|
return @ptrCast(@alignCast(c.SDL_GetDesktopDisplayMode(displayID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
pub inline fn getCurrentDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetCurrentDisplayMode(displayID));
|
return @ptrCast(@alignCast(c.SDL_GetCurrentDisplayMode(displayID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayForPoint(point: ?*const Point) DisplayID {
|
pub inline fn getDisplayForPoint(point: ?*const Point) DisplayID {
|
||||||
return c.SDL_GetDisplayForPoint(@ptrCast(point));
|
return c.SDL_GetDisplayForPoint(@ptrCast(@alignCast(point)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayForRect(rect: ?*const Rect) DisplayID {
|
pub inline fn getDisplayForRect(rect: ?*const Rect) DisplayID {
|
||||||
return c.SDL_GetDisplayForRect(@ptrCast(rect));
|
return c.SDL_GetDisplayForRect(@ptrCast(@alignCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindows(count: *c_int) [*c]?*Window {
|
pub inline fn getWindows(count: ?*c_int) [*c]?*Window {
|
||||||
return c.SDL_GetWindows(@ptrCast(count));
|
return @ptrCast(@alignCast(c.SDL_GetWindows(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindow(title: [*c]const u8, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
|
pub inline fn createWindow(title: [*c]const u8, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
|
||||||
return @ptrCast(c.SDL_CreateWindow(title, w, h, @bitCast(flags)));
|
return @ptrCast(@alignCast(c.SDL_CreateWindow(title, w, h, @bitCast(flags))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindowWithProperties(props: PropertiesID) ?*Window {
|
pub inline fn createWindowWithProperties(props: PropertiesID) ?*Window {
|
||||||
return @ptrCast(c.SDL_CreateWindowWithProperties(props));
|
return @ptrCast(@alignCast(c.SDL_CreateWindowWithProperties(props)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFromID(id: WindowID) ?*Window {
|
pub inline fn getWindowFromID(id: WindowID) ?*Window {
|
||||||
return @ptrCast(c.SDL_GetWindowFromID(id));
|
return @ptrCast(@alignCast(c.SDL_GetWindowFromID(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGrabbedWindow() ?*Window {
|
pub inline fn getGrabbedWindow() ?*Window {
|
||||||
return @ptrCast(c.SDL_GetGrabbedWindow());
|
return @ptrCast(@alignCast(c.SDL_GetGrabbedWindow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const HitTestResult = enum(c_int) {
|
pub const HitTestResult = enum(c_int) {
|
||||||
|
|
@ -582,19 +583,19 @@ pub inline fn gl_ResetAttributes() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_SetAttribute(attr: GLAttr, value: c_int) bool {
|
pub inline fn gl_SetAttribute(attr: GLAttr, value: c_int) bool {
|
||||||
return @bitCast(c.SDL_GL_SetAttribute(attr, value));
|
return @bitCast(c.SDL_GL_SetAttribute(@intCast(@backingInt(attr)), value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetAttribute(attr: GLAttr, value: *c_int) bool {
|
pub inline fn gl_GetAttribute(attr: GLAttr, value: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GL_GetAttribute(attr, @ptrCast(value)));
|
return @bitCast(c.SDL_GL_GetAttribute(@intCast(@backingInt(attr)), value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetCurrentWindow() ?*Window {
|
pub inline fn gl_GetCurrentWindow() ?*Window {
|
||||||
return @ptrCast(c.SDL_GL_GetCurrentWindow());
|
return @ptrCast(@alignCast(c.SDL_GL_GetCurrentWindow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetCurrentContext() GLContext {
|
pub inline fn gl_GetCurrentContext() GLContext {
|
||||||
return c.SDL_GL_GetCurrentContext();
|
return @ptrCast(@alignCast(c.SDL_GL_GetCurrentContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn egl_GetCurrentDisplay() EGLDisplay {
|
pub inline fn egl_GetCurrentDisplay() EGLDisplay {
|
||||||
|
|
@ -613,10 +614,10 @@ pub inline fn gl_SetSwapInterval(interval: c_int) bool {
|
||||||
return @bitCast(c.SDL_GL_SetSwapInterval(interval));
|
return @bitCast(c.SDL_GL_SetSwapInterval(interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetSwapInterval(interval: *c_int) bool {
|
pub inline fn gl_GetSwapInterval(interval: ?*c_int) bool {
|
||||||
return @bitCast(c.SDL_GL_GetSwapInterval(@ptrCast(interval)));
|
return @bitCast(c.SDL_GL_GetSwapInterval(interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_DestroyContext(context: GLContext) bool {
|
pub inline fn gl_DestroyContext(context: GLContext) bool {
|
||||||
return @bitCast(c.SDL_GL_DestroyContext(context));
|
return @bitCast(c.SDL_GL_DestroyContext(@ptrCast(@alignCast(context))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
232
build.zig
232
build.zig
|
|
@ -1,22 +1,22 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
fn resolveHeaderRoot(allocator: std.mem.Allocator, source_dir: []const u8) ![]const u8 {
|
fn resolveHeaderRoot(io: std.Io, allocator: std.mem.Allocator, source_dir: []const u8) ![]const u8 {
|
||||||
const include_sdl3 = try std.fs.path.join(allocator, &.{ source_dir, "include", "SDL3" });
|
const include_sdl3 = try std.fs.path.join(allocator, &.{ source_dir, "include", "SDL3" });
|
||||||
defer allocator.free(include_sdl3);
|
defer allocator.free(include_sdl3);
|
||||||
if (std.fs.cwd().access(include_sdl3, .{})) {
|
if (std.Io.Dir.cwd().access(io, include_sdl3, .{})) {
|
||||||
return try allocator.dupe(u8, "include/SDL3");
|
return try allocator.dupe(u8, "include/SDL3");
|
||||||
} else |_| {}
|
} else |_| {}
|
||||||
|
|
||||||
const sdl3_dir = try std.fs.path.join(allocator, &.{ source_dir, "SDL3" });
|
const sdl3_dir = try std.fs.path.join(allocator, &.{ source_dir, "SDL3" });
|
||||||
defer allocator.free(sdl3_dir);
|
defer allocator.free(sdl3_dir);
|
||||||
if (std.fs.cwd().access(sdl3_dir, .{})) {
|
if (std.Io.Dir.cwd().access(io, sdl3_dir, .{})) {
|
||||||
return try allocator.dupe(u8, "SDL3");
|
return try allocator.dupe(u8, "SDL3");
|
||||||
} else |_| {}
|
} else |_| {}
|
||||||
|
|
||||||
return try allocator.dupe(u8, ".");
|
return try allocator.dupe(u8, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addFetchSdlStep(b: *std.Build) *std.Build.Step {
|
fn addFetchSdlStep(b: *std.Build, helper_exe: *std.Build.Step.Compile) *std.Build.Step {
|
||||||
const default_sdl_url = "git@github.com:castholm/SDL.git";
|
const default_sdl_url = "git@github.com:castholm/SDL.git";
|
||||||
const official_sdl_url = "git@github.com:libsdl-org/SDL.git";
|
const official_sdl_url = "git@github.com:libsdl-org/SDL.git";
|
||||||
const sdl_url_option = b.option([]const u8, "sdl-url", "URL to fetch SDL3 from (use 'official' for libsdl-org/SDL)") orelse default_sdl_url;
|
const sdl_url_option = b.option([]const u8, "sdl-url", "URL to fetch SDL3 from (use 'official' for libsdl-org/SDL)") orelse default_sdl_url;
|
||||||
|
|
@ -33,13 +33,16 @@ fn addFetchSdlStep(b: *std.Build) *std.Build.Step {
|
||||||
|
|
||||||
const fetch_step = b.step("fetch-sdl", "Fetch SDL3 source from git");
|
const fetch_step = b.step("fetch-sdl", "Fetch SDL3 source from git");
|
||||||
|
|
||||||
const sdl_exists = if (std.fs.cwd().access("sdl3", .{})) true else |_| false;
|
// The build graph depends on whether sdl3/ exists right now, which the
|
||||||
|
// configuration cache cannot track.
|
||||||
|
b.graph.poisonCache();
|
||||||
|
const sdl_exists = if (std.Io.Dir.cwd().access(b.graph.io, "sdl3", .{})) true else |_| false;
|
||||||
|
|
||||||
var end_step: *std.Build.Step = undefined;
|
var end_step: *std.Build.Step = undefined;
|
||||||
if (clean_sdl) {
|
if (clean_sdl) {
|
||||||
const remove_dir = b.addRemoveDirTree(b.path("sdl3"));
|
const remove_dir = addHelperStep(b, helper_exe, "rmtree sdl3", &.{ "rmtree", "sdl3" });
|
||||||
const fetch_sdl = b.addSystemCommand(&.{ "git", "clone", sdl_url, "sdl3" });
|
const fetch_sdl = b.addSystemCommand(&.{ "git", "clone", sdl_url, "sdl3" });
|
||||||
fetch_sdl.step.dependOn(&remove_dir.step);
|
fetch_sdl.step.dependOn(remove_dir);
|
||||||
end_step = &fetch_sdl.step;
|
end_step = &fetch_sdl.step;
|
||||||
// fetch_step.dependOn(&fetch_sdl.step);
|
// fetch_step.dependOn(&fetch_sdl.step);
|
||||||
} else if (sdl_exists) {
|
} else if (sdl_exists) {
|
||||||
|
|
@ -61,166 +64,55 @@ fn addFetchSdlStep(b: *std.Build) *std.Build.Step {
|
||||||
return fetch_step;
|
return fetch_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ArchiveStep = struct {
|
/// Runs the build helper (src/build_helper.zig) with the given arguments.
|
||||||
step: std.Build.Step,
|
/// Used for filesystem work that has to happen at make time.
|
||||||
base_dir: ?[]const u8,
|
fn addHelperStep(b: *std.Build, helper_exe: *std.Build.Step.Compile, name: []const u8, args: []const []const u8) *std.Build.Step {
|
||||||
|
const run = b.addRunArtifact(helper_exe);
|
||||||
pub fn create(b: *std.Build, base_dir: ?[]const u8) *std.Build.Step {
|
run.addArgs(args);
|
||||||
const self = b.allocator.create(ArchiveStep) catch @panic("OOM");
|
run.has_side_effects = true;
|
||||||
self.* = .{
|
run.setName(name);
|
||||||
.step = std.Build.Step.init(.{
|
return &run.step;
|
||||||
.id = .custom,
|
|
||||||
.name = "archive generate outputs",
|
|
||||||
.owner = b,
|
|
||||||
.makeFn = make,
|
|
||||||
}),
|
|
||||||
.base_dir = base_dir,
|
|
||||||
};
|
|
||||||
return &self.step;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
|
pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, helper_exe: *std.Build.Step.Compile, fetch_sdl_step: *std.Build.Step) void {
|
||||||
_ = options;
|
|
||||||
|
|
||||||
const self: *ArchiveStep = @fieldParentPtr("step", step);
|
|
||||||
|
|
||||||
const cwd = std.fs.cwd();
|
|
||||||
const json_path = if (self.base_dir) |base_dir|
|
|
||||||
try std.fs.path.join(step.owner.allocator, &.{ base_dir, "json" })
|
|
||||||
else
|
|
||||||
try step.owner.allocator.dupe(u8, "json");
|
|
||||||
defer step.owner.allocator.free(json_path);
|
|
||||||
|
|
||||||
const api_path = if (self.base_dir) |base_dir|
|
|
||||||
try std.fs.path.join(step.owner.allocator, &.{ base_dir, "api" })
|
|
||||||
else
|
|
||||||
try step.owner.allocator.dupe(u8, "api");
|
|
||||||
defer step.owner.allocator.free(api_path);
|
|
||||||
|
|
||||||
const archive_root = if (self.base_dir) |base_dir|
|
|
||||||
try std.fs.path.join(step.owner.allocator, &.{ base_dir, "archive", "generate" })
|
|
||||||
else
|
|
||||||
try step.owner.allocator.dupe(u8, "archive/generate");
|
|
||||||
defer step.owner.allocator.free(archive_root);
|
|
||||||
|
|
||||||
const json_exists = if (cwd.access(json_path, .{})) true else |_| false;
|
|
||||||
const api_exists = if (cwd.access(api_path, .{})) true else |_| false;
|
|
||||||
|
|
||||||
if (!json_exists and !api_exists) return;
|
|
||||||
|
|
||||||
const timestamp = std.time.timestamp();
|
|
||||||
const timestamp_dir = try std.fmt.allocPrint(step.owner.allocator, "{d}", .{timestamp});
|
|
||||||
defer step.owner.allocator.free(timestamp_dir);
|
|
||||||
const archive_path = try std.fs.path.join(step.owner.allocator, &.{ archive_root, timestamp_dir });
|
|
||||||
defer step.owner.allocator.free(archive_path);
|
|
||||||
|
|
||||||
try cwd.makePath(archive_path);
|
|
||||||
|
|
||||||
if (json_exists) {
|
|
||||||
const json_dest = try std.fs.path.join(step.owner.allocator, &.{ archive_path, "json" });
|
|
||||||
defer step.owner.allocator.free(json_dest);
|
|
||||||
try cwd.rename(json_path, json_dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (api_exists) {
|
|
||||||
const api_dest = try std.fs.path.join(step.owner.allocator, &.{ archive_path, "api" });
|
|
||||||
defer step.owner.allocator.free(api_dest);
|
|
||||||
try cwd.rename(api_path, api_dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const MakeDirStep = struct {
|
|
||||||
step: std.Build.Step,
|
|
||||||
dir_path: []const u8,
|
|
||||||
|
|
||||||
pub fn create(b: *std.Build, dir_path: []const u8) *std.Build.Step {
|
|
||||||
const self = b.allocator.create(MakeDirStep) catch @panic("OOM");
|
|
||||||
self.* = .{
|
|
||||||
.step = std.Build.Step.init(.{
|
|
||||||
.id = .custom,
|
|
||||||
.name = b.fmt("mkdir {s}", .{dir_path}),
|
|
||||||
.owner = b,
|
|
||||||
.makeFn = make,
|
|
||||||
}),
|
|
||||||
.dir_path = dir_path,
|
|
||||||
};
|
|
||||||
return &self.step;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
|
|
||||||
_ = options;
|
|
||||||
const self: *MakeDirStep = @fieldParentPtr("step", step);
|
|
||||||
try std.fs.cwd().makePath(self.dir_path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const WriteStaticFileStep = struct {
|
|
||||||
step: std.Build.Step,
|
|
||||||
path: []const u8,
|
|
||||||
contents: []const u8,
|
|
||||||
|
|
||||||
pub fn create(b: *std.Build, path: []const u8, contents: []const u8) *std.Build.Step {
|
|
||||||
const self = b.allocator.create(WriteStaticFileStep) catch @panic("OOM");
|
|
||||||
self.* = .{
|
|
||||||
.step = std.Build.Step.init(.{
|
|
||||||
.id = .custom,
|
|
||||||
.name = b.fmt("write {s}", .{path}),
|
|
||||||
.owner = b,
|
|
||||||
.makeFn = make,
|
|
||||||
}),
|
|
||||||
.path = b.dupe(path),
|
|
||||||
.contents = b.dupe(contents),
|
|
||||||
};
|
|
||||||
return &self.step;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
|
|
||||||
_ = options;
|
|
||||||
const self: *WriteStaticFileStep = @fieldParentPtr("step", step);
|
|
||||||
|
|
||||||
if (std.fs.path.dirname(self.path)) |dir| {
|
|
||||||
try std.fs.cwd().makePath(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
try std.fs.cwd().writeFile(.{
|
|
||||||
.sub_path = self.path,
|
|
||||||
.data = self.contents,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl_step: *std.Build.Step) void {
|
|
||||||
const source_dir = b.option([]const u8, "sourceDir", "Parse SDL headers from an existing local directory instead of fetching git");
|
const source_dir = b.option([]const u8, "sourceDir", "Parse SDL headers from an existing local directory instead of fetching git");
|
||||||
const output_dir = b.option([]const u8, "outputDir", "Directory where generated api/ and json/ folders should be written");
|
const output_dir = b.option([]const u8, "outputDir", "Directory where generated api/ and json/ folders should be written");
|
||||||
const basedir = b.option([]const u8, "basedir", "Working directory for the parser to execute in");
|
const basedir = b.option([]const u8, "basedir", "Working directory for the parser to execute in");
|
||||||
const c_import_path = b.option([]const u8, "cImportPath", "Path used by generated files when importing c.zig");
|
const c_import_path = b.option([]const u8, "cImportPath", "Path used by generated files when importing c.zig");
|
||||||
const effective_output_dir = output_dir orelse source_dir;
|
const effective_output_dir = output_dir orelse source_dir;
|
||||||
const header_root_suffix = if (source_dir) |dir| resolveHeaderRoot(b.allocator, dir) catch @panic("OOM") else null;
|
const header_root_suffix = if (source_dir) |dir| resolveHeaderRoot(b.graph.io, b.allocator, dir) catch @panic("OOM") else null;
|
||||||
|
|
||||||
// Archive existing json/ and api/ directories before regenerating
|
// Archive existing json/ and api/ directories before regenerating
|
||||||
const archive_step = ArchiveStep.create(b, effective_output_dir);
|
const archive_step = addHelperStep(
|
||||||
|
b,
|
||||||
|
helper_exe,
|
||||||
|
"archive generate outputs",
|
||||||
|
if (effective_output_dir) |dir| &.{ "archive", dir } else &.{"archive"},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Generation needs the previous outputs archived and, unless a local
|
||||||
|
// source directory is used, SDL fetched. `fetch-sdl` on its own must not
|
||||||
|
// touch the generated outputs.
|
||||||
const generation_root = if (source_dir != null) archive_step else fetch_sdl_step;
|
const generation_root = if (source_dir != null) archive_step else fetch_sdl_step;
|
||||||
if (source_dir == null) {
|
|
||||||
fetch_sdl_step.dependOn(archive_step);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a build marker file after the source selection step to enable caching
|
// Write a build marker file after the source selection step to enable caching.
|
||||||
const timestamp = std.time.timestamp();
|
// The timestamp is taken at configure time, so the configuration must not be cached.
|
||||||
|
b.graph.poisonCache();
|
||||||
|
const timestamp = std.Io.Clock.real.now(b.graph.io).toSeconds();
|
||||||
const wf = b.addWriteFiles();
|
const wf = b.addWriteFiles();
|
||||||
const marker_file = wf.add(".buildmarker", b.fmt("{d}", .{timestamp}));
|
const marker_file = wf.add(".buildmarker", b.fmt("{d}", .{timestamp}));
|
||||||
_ = marker_file;
|
_ = marker_file;
|
||||||
wf.step.dependOn(generation_root);
|
wf.step.dependOn(generation_root);
|
||||||
|
wf.step.dependOn(archive_step);
|
||||||
|
|
||||||
var path_prep_step: *std.Build.Step = &wf.step;
|
var path_prep_step: *std.Build.Step = &wf.step;
|
||||||
if (effective_output_dir) |dir| {
|
if (effective_output_dir) |dir| {
|
||||||
const output_dir_step = MakeDirStep.create(b, dir);
|
const output_dir_step = addHelperStep(b, helper_exe, b.fmt("mkdir {s}", .{dir}), &.{ "mkdir", dir });
|
||||||
output_dir_step.dependOn(path_prep_step);
|
output_dir_step.dependOn(path_prep_step);
|
||||||
path_prep_step = output_dir_step;
|
path_prep_step = output_dir_step;
|
||||||
}
|
}
|
||||||
if (basedir) |dir| {
|
if (basedir) |dir| {
|
||||||
const basedir_step = MakeDirStep.create(b, dir);
|
const basedir_step = addHelperStep(b, helper_exe, b.fmt("mkdir {s}", .{dir}), &.{ "mkdir", dir });
|
||||||
basedir_step.dependOn(path_prep_step);
|
basedir_step.dependOn(path_prep_step);
|
||||||
path_prep_step = basedir_step;
|
path_prep_step = basedir_step;
|
||||||
}
|
}
|
||||||
|
|
@ -229,22 +121,24 @@ pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl
|
||||||
const json_root = if (effective_output_dir) |dir| b.fmt("{s}/json", .{dir}) else "json";
|
const json_root = if (effective_output_dir) |dir| b.fmt("{s}/json", .{dir}) else "json";
|
||||||
const effective_c_import_path = c_import_path orelse "c.zig";
|
const effective_c_import_path = c_import_path orelse "c.zig";
|
||||||
const c_bridge_target = if (c_import_path) |path| path else "../c.zig";
|
const c_bridge_target = if (c_import_path) |path| path else "../c.zig";
|
||||||
const c_bridge_step = WriteStaticFileStep.create(
|
const c_bridge_path = b.fmt("{s}/c.zig", .{output_root});
|
||||||
b,
|
const c_bridge_step = addHelperStep(b, helper_exe, b.fmt("write {s}", .{c_bridge_path}), &.{
|
||||||
b.fmt("{s}/c.zig", .{output_root}),
|
"write",
|
||||||
|
c_bridge_path,
|
||||||
b.fmt("pub const c = @import(\"{s}\").c;\n", .{c_bridge_target}),
|
b.fmt("pub const c = @import(\"{s}\").c;\n", .{c_bridge_target}),
|
||||||
);
|
});
|
||||||
c_bridge_step.dependOn(path_prep_step);
|
c_bridge_step.dependOn(path_prep_step);
|
||||||
path_prep_step = c_bridge_step;
|
path_prep_step = c_bridge_step;
|
||||||
|
|
||||||
const stdinc_bridge_step = WriteStaticFileStep.create(
|
const stdinc_bridge_path = b.fmt("{s}/stdinc.zig", .{output_root});
|
||||||
b,
|
const stdinc_bridge_step = addHelperStep(b, helper_exe, b.fmt("write {s}", .{stdinc_bridge_path}), &.{
|
||||||
b.fmt("{s}/stdinc.zig", .{output_root}),
|
"write",
|
||||||
|
stdinc_bridge_path,
|
||||||
\\pub const c = @import("c.zig").c;
|
\\pub const c = @import("c.zig").c;
|
||||||
\\pub const Time = i64;
|
\\pub const Time = i64;
|
||||||
\\pub const FunctionPointer = c.SDL_FunctionPointer;
|
\\pub const FunctionPointer = c.SDL_FunctionPointer;
|
||||||
\\
|
\\
|
||||||
);
|
});
|
||||||
stdinc_bridge_step.dependOn(path_prep_step);
|
stdinc_bridge_step.dependOn(path_prep_step);
|
||||||
path_prep_step = stdinc_bridge_step;
|
path_prep_step = stdinc_bridge_step;
|
||||||
|
|
||||||
|
|
@ -264,7 +158,7 @@ pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl
|
||||||
.{ .header = "SDL_filesystem.h", .output = "filesystem" },
|
.{ .header = "SDL_filesystem.h", .output = "filesystem" },
|
||||||
.{ .header = "SDL_gamepad.h", .output = "gamepad" },
|
.{ .header = "SDL_gamepad.h", .output = "gamepad" },
|
||||||
.{ .header = "SDL_gpu.h", .output = "gpu" },
|
.{ .header = "SDL_gpu.h", .output = "gpu" },
|
||||||
// .{ .header = "SDL_guid.h", .output = "guid" },
|
.{ .header = "SDL_guid.h", .output = "guid" },
|
||||||
.{ .header = "SDL_haptic.h", .output = "haptic" },
|
.{ .header = "SDL_haptic.h", .output = "haptic" },
|
||||||
// .{ .header = "SDL_hidapi.h", .output = "hidapi" }, // Skipped: not core API
|
// .{ .header = "SDL_hidapi.h", .output = "hidapi" }, // Skipped: not core API
|
||||||
.{ .header = "SDL_hints.h", .output = "hints" },
|
.{ .header = "SDL_hints.h", .output = "hints" },
|
||||||
|
|
@ -282,7 +176,7 @@ pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl
|
||||||
.{ .header = "SDL_mouse.h", .output = "mouse" },
|
.{ .header = "SDL_mouse.h", .output = "mouse" },
|
||||||
// .{ .header = "SDL_mutex.h", .output = "mutex" }, // Skipped: not core API
|
// .{ .header = "SDL_mutex.h", .output = "mutex" }, // Skipped: not core API
|
||||||
.{ .header = "SDL_opengl.h", .output = "opengl" },
|
.{ .header = "SDL_opengl.h", .output = "opengl" },
|
||||||
// .{ .header = "SDL_pen.h", .output = "pen" },
|
.{ .header = "SDL_pen.h", .output = "pen" },
|
||||||
.{ .header = "SDL_pixels.h", .output = "pixels" },
|
.{ .header = "SDL_pixels.h", .output = "pixels" },
|
||||||
.{ .header = "SDL_power.h", .output = "power" },
|
.{ .header = "SDL_power.h", .output = "power" },
|
||||||
.{ .header = "SDL_process.h", .output = "process" },
|
.{ .header = "SDL_process.h", .output = "process" },
|
||||||
|
|
@ -320,6 +214,7 @@ pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl
|
||||||
regenerate.addArg(b.fmt("--basedir={s}", .{dir}));
|
regenerate.addArg(b.fmt("--basedir={s}", .{dir}));
|
||||||
}
|
}
|
||||||
regenerate.addArg(b.fmt("--c-import={s}", .{effective_c_import_path}));
|
regenerate.addArg(b.fmt("--c-import={s}", .{effective_c_import_path}));
|
||||||
|
regenerate.addArg("--skip-missing");
|
||||||
// regenerate.addArg(b.fmt("--output=api/{s}.zig --mocks=mocks/{s}.c", .{ header_info.output, header_info.output }));
|
// regenerate.addArg(b.fmt("--output=api/{s}.zig --mocks=mocks/{s}.c", .{ header_info.output, header_info.output }));
|
||||||
regenerate.step.dependOn(path_prep_step);
|
regenerate.step.dependOn(path_prep_step);
|
||||||
regenerate_step.dependOn(®enerate.step);
|
regenerate_step.dependOn(®enerate.step);
|
||||||
|
|
@ -328,6 +223,7 @@ pub fn generateApi(b: *std.Build, parser_exe: *std.Build.Step.Compile, fetch_sdl
|
||||||
regenerateJson.addArg(b.fmt("{s}/{s}", .{ header_root, header_info.header }));
|
regenerateJson.addArg(b.fmt("{s}/{s}", .{ header_root, header_info.header }));
|
||||||
regenerateJson.addArg(b.fmt("--generate-json={s}/{s}.json", .{ json_root, header_info.output }));
|
regenerateJson.addArg(b.fmt("--generate-json={s}/{s}.json", .{ json_root, header_info.output }));
|
||||||
regenerateJson.addArg(timestamp_arg);
|
regenerateJson.addArg(timestamp_arg);
|
||||||
|
regenerateJson.addArg("--skip-missing");
|
||||||
if (basedir) |dir| {
|
if (basedir) |dir| {
|
||||||
regenerateJson.addArg(b.fmt("--basedir={s}", .{dir}));
|
regenerateJson.addArg(b.fmt("--basedir={s}", .{dir}));
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +236,17 @@ pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const fetch_sdl_step = addFetchSdlStep(b);
|
// Helper executable for make-time filesystem work (always built for the host).
|
||||||
|
const helper_exe = b.addExecutable(.{
|
||||||
|
.name = "build-helper",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/build_helper.zig"),
|
||||||
|
.target = b.graph.host,
|
||||||
|
.optimize = .Debug,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetch_sdl_step = addFetchSdlStep(b, helper_exe);
|
||||||
|
|
||||||
// Parser executable
|
// Parser executable
|
||||||
const parser_exe = b.addExecutable(.{
|
const parser_exe = b.addExecutable(.{
|
||||||
|
|
@ -354,15 +260,13 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
b.installArtifact(parser_exe);
|
b.installArtifact(parser_exe);
|
||||||
|
|
||||||
generateApi(b, parser_exe, fetch_sdl_step);
|
generateApi(b, parser_exe, helper_exe, fetch_sdl_step);
|
||||||
|
|
||||||
// Run command
|
// Run command
|
||||||
const run_cmd = b.addRunArtifact(parser_exe);
|
const run_cmd = b.addRunArtifact(parser_exe);
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
|
||||||
if (b.args) |args| {
|
run_cmd.addPassthruArgs();
|
||||||
run_cmd.addArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the SDL3 header parser");
|
const run_step = b.step("run", "Run the SDL3 header parser");
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
@ -371,13 +275,9 @@ pub fn build(b: *std.Build) void {
|
||||||
const test_mocks_cmd = b.addRunArtifact(parser_exe);
|
const test_mocks_cmd = b.addRunArtifact(parser_exe);
|
||||||
test_mocks_cmd.step.dependOn(b.getInstallStep());
|
test_mocks_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
|
||||||
const test_header_path = b.path("test_small.h");
|
test_mocks_cmd.addArg("test_small.h");
|
||||||
const test_output = b.path("zig-out/test_small.zig");
|
test_mocks_cmd.addArg("--output=zig-out/test_small.zig");
|
||||||
const test_mocks = b.path("zig-out/test_small_mock.c");
|
test_mocks_cmd.addArg("--mocks=zig-out/test_small_mock.c");
|
||||||
|
|
||||||
test_mocks_cmd.addArg(test_header_path.getPath(b));
|
|
||||||
test_mocks_cmd.addArg(b.fmt("--output={s}", .{test_output.getPath(b)}));
|
|
||||||
test_mocks_cmd.addArg(b.fmt("--mocks={s}", .{test_mocks.getPath(b)}));
|
|
||||||
|
|
||||||
const test_mocks_step = b.step("test-mocks", "Test mock generation with test_small.h");
|
const test_mocks_step = b.step("test-mocks", "Test mock generation with test_small.h");
|
||||||
test_mocks_step.dependOn(&test_mocks_cmd.step);
|
test_mocks_step.dependOn(&test_mocks_cmd.step);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
.{
|
.{
|
||||||
.name = .sdl3_parser,
|
.name = .sdl3_parser,
|
||||||
.version = "0.1.0",
|
.version = "0.1.0",
|
||||||
|
.minimum_zig_version = "0.17.0",
|
||||||
.fingerprint=0x2eb3fcb4d5ae107b,
|
.fingerprint=0x2eb3fcb4d5ae107b,
|
||||||
.dependencies = .{},
|
.dependencies = .{},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,18 @@
|
||||||
"name": "SDL_AUDIO_F32BE",
|
"name": "SDL_AUDIO_F32BE",
|
||||||
"value": "0x9120u",
|
"value": "0x9120u",
|
||||||
"comment": "As above, but big-endian byte order"
|
"comment": "As above, but big-endian byte order"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_AUDIO_S16",
|
||||||
|
"value": "SDL_AUDIO_S16LE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_AUDIO_S32",
|
||||||
|
"value": "SDL_AUDIO_S32LE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_AUDIO_F32",
|
||||||
|
"value": "SDL_AUDIO_F32LE"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_BLENDOPERATION_MAXIMUM",
|
"name": "SDL_BLENDOPERATION_MAXIMUM",
|
||||||
"value": "0x5"
|
"value": "0x5",
|
||||||
|
"comment": "max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -89,7 +90,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA",
|
"name": "SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA",
|
||||||
"value": "0xA"
|
"value": "0xA",
|
||||||
|
"comment": "1-dstA, 1-dstA, 1-dstA, 1-dstA"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_CameraPermissionState",
|
"name": "SDL_CameraPermissionState",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_CAMERA_PERMISSION_STATE_DENIED",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CAMERA_PERMISSION_STATE_PENDING"
|
"name": "SDL_CAMERA_PERMISSION_STATE_PENDING"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mime_types",
|
"name": "mime_types",
|
||||||
"type": "const char **"
|
"type": "const char *const *"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "num_mime_types",
|
"name": "num_mime_types",
|
||||||
|
|
|
||||||
|
|
@ -23,22 +23,28 @@
|
||||||
"comment": "User-requested quit"
|
"comment": "User-requested quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_TERMINATING"
|
"name": "SDL_EVENT_TERMINATING",
|
||||||
|
"comment": "The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillTerminate() Called on Android in onDestroy()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_LOW_MEMORY"
|
"name": "SDL_EVENT_LOW_MEMORY",
|
||||||
|
"comment": "The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onTrimMemory()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WILL_ENTER_BACKGROUND"
|
"name": "SDL_EVENT_WILL_ENTER_BACKGROUND",
|
||||||
|
"comment": "The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillResignActive() Called on Android in onPause()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_DID_ENTER_BACKGROUND"
|
"name": "SDL_EVENT_DID_ENTER_BACKGROUND",
|
||||||
|
"comment": "The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidEnterBackground() Called on Android in onPause()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WILL_ENTER_FOREGROUND"
|
"name": "SDL_EVENT_WILL_ENTER_FOREGROUND",
|
||||||
|
"comment": "The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillEnterForeground() Called on Android in onResume()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_DID_ENTER_FOREGROUND"
|
"name": "SDL_EVENT_DID_ENTER_FOREGROUND",
|
||||||
|
"comment": "The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidBecomeActive() Called on Android in onResume()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_LOCALE_CHANGED",
|
"name": "SDL_EVENT_LOCALE_CHANGED",
|
||||||
|
|
@ -81,6 +87,14 @@
|
||||||
"name": "SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED",
|
"name": "SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED",
|
||||||
"comment": "Display has changed usable bounds"
|
"comment": "Display has changed usable bounds"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_DISPLAY_FIRST",
|
||||||
|
"value": "SDL_EVENT_DISPLAY_ORIENTATION"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_DISPLAY_LAST",
|
||||||
|
"value": "SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_SHOWN",
|
"name": "SDL_EVENT_WINDOW_SHOWN",
|
||||||
"value": "0x202",
|
"value": "0x202",
|
||||||
|
|
@ -91,7 +105,8 @@
|
||||||
"comment": "Window has been hidden"
|
"comment": "Window has been hidden"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_EXPOSED"
|
"name": "SDL_EVENT_WINDOW_EXPOSED",
|
||||||
|
"comment": "Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event. data1 is 1 for live-resize expose events, 0 otherwise."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_MOVED",
|
"name": "SDL_EVENT_WINDOW_MOVED",
|
||||||
|
|
@ -174,12 +189,21 @@
|
||||||
"comment": "The window has left fullscreen mode"
|
"comment": "The window has left fullscreen mode"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_DESTROYED"
|
"name": "SDL_EVENT_WINDOW_DESTROYED",
|
||||||
|
"comment": "The window with the associated ID is being or has been destroyed. If this message is being handled in an event watcher, the window handle is still valid and can still be used to retrieve any properties associated with the window. Otherwise, the handle has already been destroyed and all resources associated with it are invalid"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_HDR_STATE_CHANGED",
|
"name": "SDL_EVENT_WINDOW_HDR_STATE_CHANGED",
|
||||||
"comment": "Window HDR properties have changed"
|
"comment": "Window HDR properties have changed"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_WINDOW_FIRST",
|
||||||
|
"value": "SDL_EVENT_WINDOW_SHOWN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_WINDOW_LAST",
|
||||||
|
"value": "SDL_EVENT_WINDOW_HDR_STATE_CHANGED"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_KEY_DOWN",
|
"name": "SDL_EVENT_KEY_DOWN",
|
||||||
"value": "0x300",
|
"value": "0x300",
|
||||||
|
|
@ -198,7 +222,8 @@
|
||||||
"comment": "Keyboard text input"
|
"comment": "Keyboard text input"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_KEYMAP_CHANGED"
|
"name": "SDL_EVENT_KEYMAP_CHANGED",
|
||||||
|
"comment": "Keymap changed due to a system event such as an input language or keyboard layout change."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_KEYBOARD_ADDED",
|
"name": "SDL_EVENT_KEYBOARD_ADDED",
|
||||||
|
|
@ -331,6 +356,10 @@
|
||||||
"name": "SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED",
|
"name": "SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED",
|
||||||
"comment": "Gamepad Steam handle has changed"
|
"comment": "Gamepad Steam handle has changed"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_FINGER_DOWN",
|
||||||
|
"value": "0x700"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_FINGER_UP"
|
"name": "SDL_EVENT_FINGER_UP"
|
||||||
},
|
},
|
||||||
|
|
@ -460,6 +489,10 @@
|
||||||
"name": "SDL_EVENT_RENDER_DEVICE_LOST",
|
"name": "SDL_EVENT_RENDER_DEVICE_LOST",
|
||||||
"comment": "The device has been lost and can't be recovered."
|
"comment": "The device has been lost and can't be recovered."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_PRIVATE0",
|
||||||
|
"value": "0x4000"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_PRIVATE1"
|
"name": "SDL_EVENT_PRIVATE1"
|
||||||
},
|
},
|
||||||
|
|
@ -473,6 +506,18 @@
|
||||||
"name": "SDL_EVENT_POLL_SENTINEL",
|
"name": "SDL_EVENT_POLL_SENTINEL",
|
||||||
"value": "0x7F00",
|
"value": "0x7F00",
|
||||||
"comment": "Signals the end of an event poll cycle"
|
"comment": "Signals the end of an event poll cycle"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_USER",
|
||||||
|
"value": "0x8000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_LAST",
|
||||||
|
"value": "0xFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_ENUM_PADDING",
|
||||||
|
"value": "0x7FFFFFFF"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -838,7 +883,7 @@
|
||||||
{
|
{
|
||||||
"name": "which",
|
"name": "which",
|
||||||
"type": "SDL_MouseID",
|
"type": "SDL_MouseID",
|
||||||
"comment": "The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0"
|
"comment": "The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, SDL_PEN_MOUSEID for pen events, or 0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "state",
|
"name": "state",
|
||||||
|
|
@ -1117,6 +1162,10 @@
|
||||||
"type": "Uint8",
|
"type": "Uint8",
|
||||||
"comment": "The joystick hat index"
|
"comment": "The joystick hat index"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint8"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "padding1",
|
"name": "padding1",
|
||||||
"type": "Uint8"
|
"type": "Uint8"
|
||||||
|
|
@ -1633,6 +1682,16 @@
|
||||||
"name": "which",
|
"name": "which",
|
||||||
"type": "SDL_PenID",
|
"type": "SDL_PenID",
|
||||||
"comment": "The pen instance id"
|
"comment": "The pen instance id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pen_state",
|
||||||
|
"type": "SDL_PenInputFlags",
|
||||||
|
"comment": "Complete pen input state at time of event (added in 3.4.16)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_type",
|
||||||
|
"type": "SDL_PenDeviceType",
|
||||||
|
"comment": "the device type of the pen, if known (added in 3.4.18)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -1677,6 +1736,11 @@
|
||||||
"name": "y",
|
"name": "y",
|
||||||
"type": "float",
|
"type": "float",
|
||||||
"comment": "Y coordinate, relative to window"
|
"comment": "Y coordinate, relative to window"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_type",
|
||||||
|
"type": "SDL_PenDeviceType",
|
||||||
|
"comment": "the device type of the pen, if known (added in 3.4.18)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -1731,6 +1795,11 @@
|
||||||
"name": "down",
|
"name": "down",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"comment": "true if the pen is touching or false if the pen is lifted off"
|
"comment": "true if the pen is touching or false if the pen is lifted off"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_type",
|
||||||
|
"type": "SDL_PenDeviceType",
|
||||||
|
"comment": "the device type of the pen, if known (added in 3.4.18)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -1785,6 +1854,11 @@
|
||||||
"name": "down",
|
"name": "down",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"comment": "true if the button is pressed"
|
"comment": "true if the button is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_type",
|
||||||
|
"type": "SDL_PenDeviceType",
|
||||||
|
"comment": "the device type of the pen, if known (added in 3.4.18)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -1839,6 +1913,11 @@
|
||||||
"name": "value",
|
"name": "value",
|
||||||
"type": "float",
|
"type": "float",
|
||||||
"comment": "New value of axis"
|
"comment": "New value of axis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_type",
|
||||||
|
"type": "SDL_PenDeviceType",
|
||||||
|
"comment": "the device type of the pen, if known (added in 3.4.18)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@
|
||||||
"comment": "Video files that can be played using a standard video player (mp4, webm...)."
|
"comment": "Video files that can be played using a standard video player (mp4, webm...)."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_FOLDER_COUNT"
|
"name": "SDL_FOLDER_COUNT",
|
||||||
|
"comment": "Total number of types in this enum, not a folder type by itself."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -77,7 +78,8 @@
|
||||||
"comment": "a directory"
|
"comment": "a directory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_PATHTYPE_OTHER"
|
"name": "SDL_PATHTYPE_OTHER",
|
||||||
|
"comment": "something completely different like a device node (not a symlink, those are always followed)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -93,7 +95,8 @@
|
||||||
"comment": "Value that requests that enumeration stop, successfully."
|
"comment": "Value that requests that enumeration stop, successfully."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ENUM_FAILURE"
|
"name": "SDL_ENUM_FAILURE",
|
||||||
|
"comment": "Value that requests that enumeration stop, as a failure."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GamepadType",
|
"name": "SDL_GamepadType",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_TYPE_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_TYPE_STANDARD"
|
"name": "SDL_GAMEPAD_TYPE_STANDARD"
|
||||||
},
|
},
|
||||||
|
|
@ -45,6 +49,9 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_TYPE_GAMECUBE"
|
"name": "SDL_GAMEPAD_TYPE_GAMECUBE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_TYPE_STEAM"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_TYPE_COUNT"
|
"name": "SDL_GAMEPAD_TYPE_COUNT"
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +60,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GamepadButton",
|
"name": "SDL_GamepadButton",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_BUTTON_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_SOUTH",
|
"name": "SDL_GAMEPAD_BUTTON_SOUTH",
|
||||||
"comment": "Bottom face button (e.g. Xbox A button)"
|
"comment": "Bottom face button (e.g. Xbox A button)"
|
||||||
|
|
@ -104,23 +115,23 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_MISC1",
|
"name": "SDL_GAMEPAD_BUTTON_MISC1",
|
||||||
"comment": "Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)"
|
"comment": "Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Steam Controller QAM button, Amazon Luna microphone button, Google Stadia capture button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1",
|
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1",
|
||||||
"comment": "Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)"
|
"comment": "Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button, Steam Controller R4 button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE1",
|
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE1",
|
||||||
"comment": "Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)"
|
"comment": "Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button, Steam Controller L4 button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2",
|
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2",
|
||||||
"comment": "Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)"
|
"comment": "Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button, Steam Controller R5 button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE2",
|
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE2",
|
||||||
"comment": "Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)"
|
"comment": "Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button, Steam Controller L5 button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_TOUCHPAD",
|
"name": "SDL_GAMEPAD_BUTTON_TOUCHPAD",
|
||||||
|
|
@ -186,6 +197,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GamepadAxis",
|
"name": "SDL_GamepadAxis",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_AXIS_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_AXIS_LEFTX"
|
"name": "SDL_GAMEPAD_AXIS_LEFTX"
|
||||||
},
|
},
|
||||||
|
|
@ -212,6 +227,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GamepadBindingType",
|
"name": "SDL_GamepadBindingType",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_BINDTYPE_NONE",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BINDTYPE_BUTTON"
|
"name": "SDL_GAMEPAD_BINDTYPE_BUTTON"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -789,7 +789,8 @@
|
||||||
"comment": "min(source, destination)"
|
"comment": "min(source, destination)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GPU_BLENDOP_MAX"
|
"name": "SDL_GPU_BLENDOP_MAX",
|
||||||
|
"comment": "max(source, destination)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -848,7 +849,8 @@
|
||||||
"comment": "1 - blend constant"
|
"comment": "1 - blend constant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE"
|
"name": "SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE",
|
||||||
|
"comment": "min(source alpha, 1 - destination alpha)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
"header": "SDL_guid.h",
|
||||||
|
"opaque_types": [],
|
||||||
|
"typedefs": [],
|
||||||
|
"function_pointers": [],
|
||||||
|
"c_type_aliases": [],
|
||||||
|
"enums": [],
|
||||||
|
"structs": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GUID",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"type": "Uint8[16]"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unions": [],
|
||||||
|
"flags": [],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GUIDToString",
|
||||||
|
"return_type": "void",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "guid",
|
||||||
|
"type": "SDL_GUID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pszGUID",
|
||||||
|
"type": "char *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cbGUID",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_StringToGUID",
|
||||||
|
"return_type": "SDL_GUID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "pchGUID",
|
||||||
|
"type": "const char *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -105,6 +105,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_HapticPeriodic",
|
"name": "SDL_HapticPeriodic",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "_type",
|
||||||
|
"type": "SDL_HapticEffectType"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type": "SDL_HapticDirection",
|
"type": "SDL_HapticDirection",
|
||||||
|
|
@ -175,6 +179,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_HapticCondition",
|
"name": "SDL_HapticCondition",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "_type",
|
||||||
|
"type": "SDL_HapticEffectType"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type": "SDL_HapticDirection",
|
"type": "SDL_HapticDirection",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,737 @@
|
||||||
|
{
|
||||||
|
"header": "SDL_iostream.h",
|
||||||
|
"opaque_types": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IOStream"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"typedefs": [],
|
||||||
|
"function_pointers": [],
|
||||||
|
"c_type_aliases": [],
|
||||||
|
"enums": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IOStatus",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_READY",
|
||||||
|
"comment": "Everything is ready (no errors and not EOF)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_ERROR",
|
||||||
|
"comment": "Read or write I/O error"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_EOF",
|
||||||
|
"comment": "End of file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_NOT_READY",
|
||||||
|
"comment": "Non blocking I/O, not ready"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_READONLY",
|
||||||
|
"comment": "Tried to write a read-only buffer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_STATUS_WRITEONLY",
|
||||||
|
"comment": "Tried to read a write-only buffer"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IOWhence",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_SEEK_SET",
|
||||||
|
"comment": "Seek from the beginning of data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_SEEK_CUR",
|
||||||
|
"comment": "Seek relative to current read point"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IO_SEEK_END",
|
||||||
|
"comment": "Seek relative to the end of data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structs": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IOStreamInterface",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "version",
|
||||||
|
"type": "Uint32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"type": "Sint64 (SDLCALL *size)(void *userdata)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "seek",
|
||||||
|
"type": "Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence whence)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "read",
|
||||||
|
"type": "size_t (SDLCALL *read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *status)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "write",
|
||||||
|
"type": "size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flush",
|
||||||
|
"type": "bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *status)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "close",
|
||||||
|
"type": "bool (SDLCALL *close)(void *userdata)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unions": [],
|
||||||
|
"flags": [],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"name": "SDL_IOFromFile",
|
||||||
|
"return_type": "SDL_IOStream *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mode",
|
||||||
|
"type": "const char *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IOFromMem",
|
||||||
|
"return_type": "SDL_IOStream *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "mem",
|
||||||
|
"type": "void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"type": "size_t"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IOFromConstMem",
|
||||||
|
"return_type": "SDL_IOStream *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "mem",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"type": "size_t"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_IOFromDynamicMem",
|
||||||
|
"return_type": "SDL_IOStream *",
|
||||||
|
"parameters": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_OpenIO",
|
||||||
|
"return_type": "SDL_IOStream *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "iface",
|
||||||
|
"type": "const SDL_IOStreamInterface *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userdata",
|
||||||
|
"type": "void *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CloseIO",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetIOProperties",
|
||||||
|
"return_type": "SDL_PropertiesID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetIOStatus",
|
||||||
|
"return_type": "SDL_IOStatus",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetIOSize",
|
||||||
|
"return_type": "Sint64",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SeekIO",
|
||||||
|
"return_type": "Sint64",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "offset",
|
||||||
|
"type": "Sint64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "whence",
|
||||||
|
"type": "SDL_IOWhence"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TellIO",
|
||||||
|
"return_type": "Sint64",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadIO",
|
||||||
|
"return_type": "size_t",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ptr",
|
||||||
|
"type": "void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"type": "size_t"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteIO",
|
||||||
|
"return_type": "size_t",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ptr",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"type": "size_t"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_FlushIO",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "context",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadFile_IO",
|
||||||
|
"return_type": "void *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasize",
|
||||||
|
"type": "size_t *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "closeio",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadFile",
|
||||||
|
"return_type": "void *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasize",
|
||||||
|
"type": "size_t *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SaveFile_IO",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasize",
|
||||||
|
"type": "size_t"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "closeio",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SaveFile",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "datasize",
|
||||||
|
"type": "size_t"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU8",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint8 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS8",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint8 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU16LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint16 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS16LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint16 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU16BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint16 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS16BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint16 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU32LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint32 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS32LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint32 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU32BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint32 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS32BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint32 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU64LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint64 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS64LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint64 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadU64BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint64 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ReadS64BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint64 *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU8",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint8"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS8",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint8"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU16LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint16"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS16LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint16"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU16BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint16"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS16BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint16"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU32LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint32"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS32LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint32"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU32BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint32"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS32BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint32"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU64LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS64LE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteU64BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Uint64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WriteS64BE",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "Sint64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_JoystickConnectionState",
|
"name": "SDL_JoystickConnectionState",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_JOYSTICK_CONNECTION_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_JOYSTICK_CONNECTION_UNKNOWN"
|
"name": "SDL_JOYSTICK_CONNECTION_UNKNOWN"
|
||||||
},
|
},
|
||||||
|
|
@ -160,6 +164,14 @@
|
||||||
"type": "Uint16[2]",
|
"type": "Uint16[2]",
|
||||||
"comment": "unused"
|
"comment": "unused"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "button_mask",
|
||||||
|
"type": "Uint32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "axis_mask",
|
||||||
|
"type": "Uint32"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": "const char *",
|
"type": "const char *",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
{
|
||||||
|
"header": "SDL_pen.h",
|
||||||
|
"opaque_types": [],
|
||||||
|
"typedefs": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PenID",
|
||||||
|
"underlying_type": "Uint32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"function_pointers": [],
|
||||||
|
"c_type_aliases": [],
|
||||||
|
"enums": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PenAxis",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_PRESSURE",
|
||||||
|
"comment": "Pen pressure. Unidirectional: 0 to 1.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_XTILT",
|
||||||
|
"comment": "Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_YTILT",
|
||||||
|
"comment": "Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_DISTANCE",
|
||||||
|
"comment": "Pen distance to drawing surface. Unidirectional: 0.0 to 1.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_ROTATION",
|
||||||
|
"comment": "Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_SLIDER",
|
||||||
|
"comment": "Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_TANGENTIAL_PRESSURE",
|
||||||
|
"comment": "Pressure from squeezing the pen (\"barrel pressure\")."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_AXIS_COUNT",
|
||||||
|
"comment": "Total known pen axis types in this version of SDL. This number may grow in future releases!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PenDeviceType",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_DEVICE_TYPE_INVALID",
|
||||||
|
"value": "-1",
|
||||||
|
"comment": "Not a valid pen device."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_DEVICE_TYPE_UNKNOWN",
|
||||||
|
"comment": "Don't know specifics of this pen."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_DEVICE_TYPE_DIRECT",
|
||||||
|
"comment": "Pen touches display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_DEVICE_TYPE_INDIRECT",
|
||||||
|
"comment": "Pen touches something that isn't the display."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structs": [],
|
||||||
|
"unions": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PenInputFlags",
|
||||||
|
"underlying_type": "Uint32",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_DOWN",
|
||||||
|
"value": "(1u << 0)",
|
||||||
|
"comment": "pen is pressed down"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_BUTTON_1",
|
||||||
|
"value": "(1u << 1)",
|
||||||
|
"comment": "button 1 is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_BUTTON_2",
|
||||||
|
"value": "(1u << 2)",
|
||||||
|
"comment": "button 2 is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_BUTTON_3",
|
||||||
|
"value": "(1u << 3)",
|
||||||
|
"comment": "button 3 is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_BUTTON_4",
|
||||||
|
"value": "(1u << 4)",
|
||||||
|
"comment": "button 4 is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_BUTTON_5",
|
||||||
|
"value": "(1u << 5)",
|
||||||
|
"comment": "button 5 is pressed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_ERASER_TIP",
|
||||||
|
"value": "(1u << 30)",
|
||||||
|
"comment": "eraser tip is used"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PEN_INPUT_IN_PROXIMITY",
|
||||||
|
"value": "(1u << 31)",
|
||||||
|
"comment": "pen is in proximity (since SDL 3.4.0)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"name": "SDL_GetPenDeviceType",
|
||||||
|
"return_type": "SDL_PenDeviceType",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "instance_id",
|
||||||
|
"type": "SDL_PenID"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
383
json/pixels.json
383
json/pixels.json
|
|
@ -156,6 +156,226 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_PixelFormat",
|
"name": "SDL_PixelFormat",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX1LSB",
|
||||||
|
"value": "0x11100100u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX1MSB",
|
||||||
|
"value": "0x11200100u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX2LSB",
|
||||||
|
"value": "0x1c100200u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX2MSB",
|
||||||
|
"value": "0x1c200200u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX4LSB",
|
||||||
|
"value": "0x12100400u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX4MSB",
|
||||||
|
"value": "0x12200400u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_INDEX8",
|
||||||
|
"value": "0x13000801u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB332",
|
||||||
|
"value": "0x14110801u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XRGB4444",
|
||||||
|
"value": "0x15120c02u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XBGR4444",
|
||||||
|
"value": "0x15520c02u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XRGB1555",
|
||||||
|
"value": "0x15130f02u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XBGR1555",
|
||||||
|
"value": "0x15530f02u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB4444",
|
||||||
|
"value": "0x15321002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA4444",
|
||||||
|
"value": "0x15421002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR4444",
|
||||||
|
"value": "0x15721002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA4444",
|
||||||
|
"value": "0x15821002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB1555",
|
||||||
|
"value": "0x15331002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA5551",
|
||||||
|
"value": "0x15441002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR1555",
|
||||||
|
"value": "0x15731002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA5551",
|
||||||
|
"value": "0x15841002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB565",
|
||||||
|
"value": "0x15151002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGR565",
|
||||||
|
"value": "0x15551002u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB24",
|
||||||
|
"value": "0x17101803u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGR24",
|
||||||
|
"value": "0x17401803u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XRGB8888",
|
||||||
|
"value": "0x16161804u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBX8888",
|
||||||
|
"value": "0x16261804u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XBGR8888",
|
||||||
|
"value": "0x16561804u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRX8888",
|
||||||
|
"value": "0x16661804u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB8888",
|
||||||
|
"value": "0x16362004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA8888",
|
||||||
|
"value": "0x16462004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR8888",
|
||||||
|
"value": "0x16762004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA8888",
|
||||||
|
"value": "0x16862004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XRGB2101010",
|
||||||
|
"value": "0x16172004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XBGR2101010",
|
||||||
|
"value": "0x16572004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB2101010",
|
||||||
|
"value": "0x16372004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR2101010",
|
||||||
|
"value": "0x16772004u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB48",
|
||||||
|
"value": "0x18103006u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGR48",
|
||||||
|
"value": "0x18403006u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA64",
|
||||||
|
"value": "0x18204008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB64",
|
||||||
|
"value": "0x18304008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA64",
|
||||||
|
"value": "0x18504008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR64",
|
||||||
|
"value": "0x18604008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB48_FLOAT",
|
||||||
|
"value": "0x1a103006u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGR48_FLOAT",
|
||||||
|
"value": "0x1a403006u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA64_FLOAT",
|
||||||
|
"value": "0x1a204008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB64_FLOAT",
|
||||||
|
"value": "0x1a304008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA64_FLOAT",
|
||||||
|
"value": "0x1a504008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR64_FLOAT",
|
||||||
|
"value": "0x1a604008u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGB96_FLOAT",
|
||||||
|
"value": "0x1b10600cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGR96_FLOAT",
|
||||||
|
"value": "0x1b40600cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA128_FLOAT",
|
||||||
|
"value": "0x1b208010u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB128_FLOAT",
|
||||||
|
"value": "0x1b308010u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA128_FLOAT",
|
||||||
|
"value": "0x1b508010u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR128_FLOAT",
|
||||||
|
"value": "0x1b608010u"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_PIXELFORMAT_YV12",
|
"name": "SDL_PIXELFORMAT_YV12",
|
||||||
"value": "0x32315659u",
|
"value": "0x32315659u",
|
||||||
|
|
@ -205,16 +425,65 @@
|
||||||
"name": "SDL_PIXELFORMAT_MJPG",
|
"name": "SDL_PIXELFORMAT_MJPG",
|
||||||
"value": "0x47504a4du",
|
"value": "0x47504a4du",
|
||||||
"comment": "Motion JPEG"
|
"comment": "Motion JPEG"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBA32",
|
||||||
|
"value": "SDL_PIXELFORMAT_ABGR8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ARGB32",
|
||||||
|
"value": "SDL_PIXELFORMAT_BGRA8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRA32",
|
||||||
|
"value": "SDL_PIXELFORMAT_ARGB8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_ABGR32",
|
||||||
|
"value": "SDL_PIXELFORMAT_RGBA8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_RGBX32",
|
||||||
|
"value": "SDL_PIXELFORMAT_XBGR8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XRGB32",
|
||||||
|
"value": "SDL_PIXELFORMAT_BGRX8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_BGRX32",
|
||||||
|
"value": "SDL_PIXELFORMAT_XRGB8888"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PIXELFORMAT_XBGR32",
|
||||||
|
"value": "SDL_PIXELFORMAT_RGBX8888"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ColorType",
|
"name": "SDL_ColorType",
|
||||||
"values": []
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_TYPE_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_TYPE_RGB",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_TYPE_YCBCR",
|
||||||
|
"value": "2"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ColorRange",
|
"name": "SDL_ColorRange",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_RANGE_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLOR_RANGE_LIMITED",
|
"name": "SDL_COLOR_RANGE_LIMITED",
|
||||||
"value": "1",
|
"value": "1",
|
||||||
|
|
@ -222,18 +491,27 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLOR_RANGE_FULL",
|
"name": "SDL_COLOR_RANGE_FULL",
|
||||||
"value": "2"
|
"value": "2",
|
||||||
|
"comment": "Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ColorPrimaries",
|
"name": "SDL_ColorPrimaries",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_PRIMARIES_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLOR_PRIMARIES_BT709",
|
"name": "SDL_COLOR_PRIMARIES_BT709",
|
||||||
"value": "1",
|
"value": "1",
|
||||||
"comment": "ITU-R BT.709-6"
|
"comment": "ITU-R BT.709-6"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_PRIMARIES_UNSPECIFIED",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLOR_PRIMARIES_BT470M",
|
"name": "SDL_COLOR_PRIMARIES_BT470M",
|
||||||
"value": "4",
|
"value": "4",
|
||||||
|
|
@ -283,17 +561,29 @@
|
||||||
"name": "SDL_COLOR_PRIMARIES_EBU3213",
|
"name": "SDL_COLOR_PRIMARIES_EBU3213",
|
||||||
"value": "22",
|
"value": "22",
|
||||||
"comment": "EBU Tech. 3213-E"
|
"comment": "EBU Tech. 3213-E"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_COLOR_PRIMARIES_CUSTOM",
|
||||||
|
"value": "31"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TransferCharacteristics",
|
"name": "SDL_TransferCharacteristics",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_BT709",
|
"name": "SDL_TRANSFER_CHARACTERISTICS_BT709",
|
||||||
"value": "1",
|
"value": "1",
|
||||||
"comment": "Rec. ITU-R BT.709-6 / ITU-R BT1361"
|
"comment": "Rec. ITU-R BT.709-6 / ITU-R BT1361"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_GAMMA22",
|
"name": "SDL_TRANSFER_CHARACTERISTICS_GAMMA22",
|
||||||
"value": "4",
|
"value": "4",
|
||||||
|
|
@ -314,6 +604,18 @@
|
||||||
"value": "7",
|
"value": "7",
|
||||||
"comment": "SMPTE ST 240M"
|
"comment": "SMPTE ST 240M"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_LINEAR",
|
||||||
|
"value": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_LOG100",
|
||||||
|
"value": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10",
|
||||||
|
"value": "10"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_IEC61966",
|
"name": "SDL_TRANSFER_CHARACTERISTICS_IEC61966",
|
||||||
"value": "11",
|
"value": "11",
|
||||||
|
|
@ -353,17 +655,29 @@
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_HLG",
|
"name": "SDL_TRANSFER_CHARACTERISTICS_HLG",
|
||||||
"value": "18",
|
"value": "18",
|
||||||
"comment": "ARIB STD-B67, known as \"hybrid log-gamma\" (HLG)"
|
"comment": "ARIB STD-B67, known as \"hybrid log-gamma\" (HLG)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TRANSFER_CHARACTERISTICS_CUSTOM",
|
||||||
|
"value": "31"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_MatrixCoefficients",
|
"name": "SDL_MatrixCoefficients",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_IDENTITY",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_BT709",
|
"name": "SDL_MATRIX_COEFFICIENTS_BT709",
|
||||||
"value": "1",
|
"value": "1",
|
||||||
"comment": "ITU-R BT.709-6"
|
"comment": "ITU-R BT.709-6"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_UNSPECIFIED",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_FCC",
|
"name": "SDL_MATRIX_COEFFICIENTS_FCC",
|
||||||
"value": "4",
|
"value": "4",
|
||||||
|
|
@ -384,6 +698,10 @@
|
||||||
"value": "7",
|
"value": "7",
|
||||||
"comment": "SMPTE 240M"
|
"comment": "SMPTE 240M"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_YCGCO",
|
||||||
|
"value": "8"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_BT2020_NCL",
|
"name": "SDL_MATRIX_COEFFICIENTS_BT2020_NCL",
|
||||||
"value": "9",
|
"value": "9",
|
||||||
|
|
@ -399,10 +717,22 @@
|
||||||
"value": "11",
|
"value": "11",
|
||||||
"comment": "SMPTE ST 2085"
|
"comment": "SMPTE ST 2085"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL",
|
||||||
|
"value": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL",
|
||||||
|
"value": "13"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_ICTCP",
|
"name": "SDL_MATRIX_COEFFICIENTS_ICTCP",
|
||||||
"value": "14",
|
"value": "14",
|
||||||
"comment": "ITU-R BT.2100-0 ICTCP"
|
"comment": "ITU-R BT.2100-0 ICTCP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_MATRIX_COEFFICIENTS_CUSTOM",
|
||||||
|
"value": "31"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -426,71 +756,43 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CHROMA_LOCATION_TOPLEFT",
|
"name": "SDL_CHROMA_LOCATION_TOPLEFT",
|
||||||
"value": "3"
|
"value": "3",
|
||||||
|
"comment": "In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel (\"co-sited\", \"co-located\")."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_Colorspace",
|
"name": "SDL_Colorspace",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_COLORSPACE_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_SRGB",
|
"name": "SDL_COLORSPACE_SRGB",
|
||||||
"value": "0x120005a0u",
|
"value": "0x120005a0u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_COLOR_RANGE_FULL"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_COLOR_PRIMARIES_BT709"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_SRGB"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_IDENTITY"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_SRGB_LINEAR",
|
"name": "SDL_COLORSPACE_SRGB_LINEAR",
|
||||||
"value": "0x12000500u",
|
"value": "0x12000500u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_LINEAR"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_HDR10",
|
"name": "SDL_COLORSPACE_HDR10",
|
||||||
"value": "0x12002600u",
|
"value": "0x12002600u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_COLOR_PRIMARIES_BT2020"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_PQ"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_JPEG",
|
"name": "SDL_COLORSPACE_JPEG",
|
||||||
"value": "0x220004c6u",
|
"value": "0x220004c6u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_BT601"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_BT601"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_BT601_LIMITED",
|
"name": "SDL_COLORSPACE_BT601_LIMITED",
|
||||||
"value": "0x211018c6u",
|
"value": "0x211018c6u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_COLOR_RANGE_LIMITED"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_COLOR_PRIMARIES_BT601"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_BT601_FULL",
|
"name": "SDL_COLORSPACE_BT601_FULL",
|
||||||
"value": "0x221018c6u",
|
"value": "0x221018c6u",
|
||||||
|
|
@ -501,12 +803,6 @@
|
||||||
"value": "0x21100421u",
|
"value": "0x21100421u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_TRANSFER_CHARACTERISTICS_BT709"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_BT709"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_BT709_FULL",
|
"name": "SDL_COLORSPACE_BT709_FULL",
|
||||||
"value": "0x22100421u",
|
"value": "0x22100421u",
|
||||||
|
|
@ -517,9 +813,6 @@
|
||||||
"value": "0x21102609u",
|
"value": "0x21102609u",
|
||||||
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020"
|
"comment": "Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "SDL_MATRIX_COEFFICIENTS_BT2020_NCL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_BT2020_FULL",
|
"name": "SDL_COLORSPACE_BT2020_FULL",
|
||||||
"value": "0x22102609u",
|
"value": "0x22102609u",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@
|
||||||
"comment": "Plugged in, charging battery"
|
"comment": "Plugged in, charging battery"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_POWERSTATE_CHARGED"
|
"name": "SDL_POWERSTATE_CHARGED",
|
||||||
|
"comment": "Plugged in, battery charged"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_TextureAddressMode",
|
"name": "SDL_TextureAddressMode",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_TEXTURE_ADDRESS_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TEXTURE_ADDRESS_AUTO",
|
"name": "SDL_TEXTURE_ADDRESS_AUTO",
|
||||||
"comment": "Wrapping is enabled if texture coordinates are outside [0, 1], this is the default"
|
"comment": "Wrapping is enabled if texture coordinates are outside [0, 1], this is the default"
|
||||||
|
|
@ -1872,7 +1876,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "createinfo",
|
"name": "createinfo",
|
||||||
"type": "SDL_GPURenderStateCreateInfo *"
|
"type": "const SDL_GPURenderStateCreateInfo *"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,29 +8,403 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_Scancode",
|
"name": "SDL_Scancode",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_UNKNOWN",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_A",
|
||||||
|
"value": "4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_B",
|
||||||
|
"value": "5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_C",
|
||||||
|
"value": "6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_D",
|
||||||
|
"value": "7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_E",
|
||||||
|
"value": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F",
|
||||||
|
"value": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_G",
|
||||||
|
"value": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_H",
|
||||||
|
"value": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_I",
|
||||||
|
"value": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_J",
|
||||||
|
"value": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_K",
|
||||||
|
"value": "14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_L",
|
||||||
|
"value": "15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_M",
|
||||||
|
"value": "16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_N",
|
||||||
|
"value": "17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_O",
|
||||||
|
"value": "18"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_P",
|
||||||
|
"value": "19"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_Q",
|
||||||
|
"value": "20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_R",
|
||||||
|
"value": "21"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_S",
|
||||||
|
"value": "22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_T",
|
||||||
|
"value": "23"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_U",
|
||||||
|
"value": "24"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_V",
|
||||||
|
"value": "25"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_W",
|
||||||
|
"value": "26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_X",
|
||||||
|
"value": "27"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_Y",
|
||||||
|
"value": "28"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_Z",
|
||||||
|
"value": "29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_1",
|
||||||
|
"value": "30"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_2",
|
||||||
|
"value": "31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_3",
|
||||||
|
"value": "32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_4",
|
||||||
|
"value": "33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_5",
|
||||||
|
"value": "34"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_6",
|
||||||
|
"value": "35"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_7",
|
||||||
|
"value": "36"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_8",
|
||||||
|
"value": "37"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_9",
|
||||||
|
"value": "38"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_0",
|
||||||
|
"value": "39"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RETURN",
|
||||||
|
"value": "40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_ESCAPE",
|
||||||
|
"value": "41"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_BACKSPACE",
|
||||||
|
"value": "42"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_TAB",
|
||||||
|
"value": "43"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SPACE",
|
||||||
|
"value": "44"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_MINUS",
|
||||||
|
"value": "45"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_EQUALS",
|
||||||
|
"value": "46"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_LEFTBRACKET",
|
||||||
|
"value": "47"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RIGHTBRACKET",
|
||||||
|
"value": "48"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_BACKSLASH",
|
"name": "SDL_SCANCODE_BACKSLASH",
|
||||||
"value": "49"
|
"value": "49",
|
||||||
|
"comment": "Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_NONUSHASH",
|
"name": "SDL_SCANCODE_NONUSHASH",
|
||||||
"value": "50"
|
"value": "50",
|
||||||
|
"comment": "ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDL_SCANCODE_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SEMICOLON",
|
||||||
|
"value": "51"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_APOSTROPHE",
|
||||||
|
"value": "52"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_GRAVE",
|
"name": "SDL_SCANCODE_GRAVE",
|
||||||
"value": "53"
|
"value": "53",
|
||||||
|
"comment": "Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_COMMA",
|
||||||
|
"value": "54"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PERIOD",
|
||||||
|
"value": "55"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SLASH",
|
||||||
|
"value": "56"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CAPSLOCK",
|
||||||
|
"value": "57"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F1",
|
||||||
|
"value": "58"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F2",
|
||||||
|
"value": "59"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F3",
|
||||||
|
"value": "60"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F4",
|
||||||
|
"value": "61"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F5",
|
||||||
|
"value": "62"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F6",
|
||||||
|
"value": "63"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F7",
|
||||||
|
"value": "64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F8",
|
||||||
|
"value": "65"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F9",
|
||||||
|
"value": "66"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F10",
|
||||||
|
"value": "67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F11",
|
||||||
|
"value": "68"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F12",
|
||||||
|
"value": "69"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PRINTSCREEN",
|
||||||
|
"value": "70"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SCROLLLOCK",
|
||||||
|
"value": "71"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PAUSE",
|
||||||
|
"value": "72"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_INSERT",
|
"name": "SDL_SCANCODE_INSERT",
|
||||||
"value": "73"
|
"value": "73",
|
||||||
|
"comment": "insert on PC, help on some Mac keyboards (but does send code 73, not 117)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_HOME",
|
||||||
|
"value": "74"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PAGEUP",
|
||||||
|
"value": "75"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_DELETE",
|
||||||
|
"value": "76"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_END",
|
||||||
|
"value": "77"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PAGEDOWN",
|
||||||
|
"value": "78"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RIGHT",
|
||||||
|
"value": "79"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_LEFT",
|
||||||
|
"value": "80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_DOWN",
|
||||||
|
"value": "81"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_UP",
|
||||||
|
"value": "82"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_NUMLOCKCLEAR",
|
"name": "SDL_SCANCODE_NUMLOCKCLEAR",
|
||||||
"value": "83"
|
"value": "83",
|
||||||
|
"comment": "num lock on PC, clear on Mac keyboards"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_DIVIDE",
|
||||||
|
"value": "84"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MULTIPLY",
|
||||||
|
"value": "85"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MINUS",
|
||||||
|
"value": "86"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_PLUS",
|
||||||
|
"value": "87"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_ENTER",
|
||||||
|
"value": "88"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_1",
|
||||||
|
"value": "89"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_2",
|
||||||
|
"value": "90"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_3",
|
||||||
|
"value": "91"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_4",
|
||||||
|
"value": "92"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_5",
|
||||||
|
"value": "93"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_6",
|
||||||
|
"value": "94"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_7",
|
||||||
|
"value": "95"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_8",
|
||||||
|
"value": "96"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_9",
|
||||||
|
"value": "97"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_0",
|
||||||
|
"value": "98"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_PERIOD",
|
||||||
|
"value": "99"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_NONUSBACKSLASH",
|
"name": "SDL_SCANCODE_NONUSBACKSLASH",
|
||||||
"value": "100"
|
"value": "100",
|
||||||
|
"comment": "This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Z. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_APPLICATION",
|
"name": "SDL_SCANCODE_APPLICATION",
|
||||||
|
|
@ -39,7 +413,64 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_POWER",
|
"name": "SDL_SCANCODE_POWER",
|
||||||
"value": "102"
|
"value": "102",
|
||||||
|
"comment": "The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_EQUALS",
|
||||||
|
"value": "103"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F13",
|
||||||
|
"value": "104"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F14",
|
||||||
|
"value": "105"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F15",
|
||||||
|
"value": "106"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F16",
|
||||||
|
"value": "107"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F17",
|
||||||
|
"value": "108"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F18",
|
||||||
|
"value": "109"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F19",
|
||||||
|
"value": "110"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F20",
|
||||||
|
"value": "111"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F21",
|
||||||
|
"value": "112"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F22",
|
||||||
|
"value": "113"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F23",
|
||||||
|
"value": "114"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_F24",
|
||||||
|
"value": "115"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_EXECUTE",
|
||||||
|
"value": "116"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_HELP",
|
"name": "SDL_SCANCODE_HELP",
|
||||||
|
|
@ -51,6 +482,10 @@
|
||||||
"value": "118",
|
"value": "118",
|
||||||
"comment": "Menu (show menu)"
|
"comment": "Menu (show menu)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SELECT",
|
||||||
|
"value": "119"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_STOP",
|
"name": "SDL_SCANCODE_STOP",
|
||||||
"value": "120",
|
"value": "120",
|
||||||
|
|
@ -86,15 +521,64 @@
|
||||||
"value": "126",
|
"value": "126",
|
||||||
"comment": "AC Find"
|
"comment": "AC Find"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_MUTE",
|
||||||
|
"value": "127"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_VOLUMEUP",
|
||||||
|
"value": "128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_VOLUMEDOWN",
|
||||||
|
"value": "129"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_COMMA",
|
||||||
|
"value": "133"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_EQUALSAS400",
|
||||||
|
"value": "134"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_INTERNATIONAL1",
|
"name": "SDL_SCANCODE_INTERNATIONAL1",
|
||||||
"value": "135"
|
"value": "135",
|
||||||
|
"comment": "used on Asian keyboards, see footnotes in USB doc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL2",
|
||||||
|
"value": "136"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_INTERNATIONAL3",
|
"name": "SDL_SCANCODE_INTERNATIONAL3",
|
||||||
"value": "137",
|
"value": "137",
|
||||||
"comment": "Yen"
|
"comment": "Yen"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL4",
|
||||||
|
"value": "138"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL5",
|
||||||
|
"value": "139"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL6",
|
||||||
|
"value": "140"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL7",
|
||||||
|
"value": "141"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL8",
|
||||||
|
"value": "142"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_INTERNATIONAL9",
|
||||||
|
"value": "143"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_LANG1",
|
"name": "SDL_SCANCODE_LANG1",
|
||||||
"value": "144",
|
"value": "144",
|
||||||
|
|
@ -145,11 +629,248 @@
|
||||||
"value": "153",
|
"value": "153",
|
||||||
"comment": "Erase-Eaze"
|
"comment": "Erase-Eaze"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SYSREQ",
|
||||||
|
"value": "154"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_CANCEL",
|
"name": "SDL_SCANCODE_CANCEL",
|
||||||
"value": "155",
|
"value": "155",
|
||||||
"comment": "AC Cancel"
|
"comment": "AC Cancel"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CLEAR",
|
||||||
|
"value": "156"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_PRIOR",
|
||||||
|
"value": "157"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RETURN2",
|
||||||
|
"value": "158"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_SEPARATOR",
|
||||||
|
"value": "159"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_OUT",
|
||||||
|
"value": "160"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_OPER",
|
||||||
|
"value": "161"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CLEARAGAIN",
|
||||||
|
"value": "162"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CRSEL",
|
||||||
|
"value": "163"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_EXSEL",
|
||||||
|
"value": "164"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_FRONT",
|
||||||
|
"value": "165",
|
||||||
|
"comment": "Front (Sun keyboards)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_00",
|
||||||
|
"value": "176"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_000",
|
||||||
|
"value": "177"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_THOUSANDSSEPARATOR",
|
||||||
|
"value": "178"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_DECIMALSEPARATOR",
|
||||||
|
"value": "179"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CURRENCYUNIT",
|
||||||
|
"value": "180"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_CURRENCYSUBUNIT",
|
||||||
|
"value": "181"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_LEFTPAREN",
|
||||||
|
"value": "182"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_RIGHTPAREN",
|
||||||
|
"value": "183"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_LEFTBRACE",
|
||||||
|
"value": "184"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_RIGHTBRACE",
|
||||||
|
"value": "185"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_TAB",
|
||||||
|
"value": "186"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_BACKSPACE",
|
||||||
|
"value": "187"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_A",
|
||||||
|
"value": "188"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_B",
|
||||||
|
"value": "189"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_C",
|
||||||
|
"value": "190"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_D",
|
||||||
|
"value": "191"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_E",
|
||||||
|
"value": "192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_F",
|
||||||
|
"value": "193"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_XOR",
|
||||||
|
"value": "194"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_POWER",
|
||||||
|
"value": "195"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_PERCENT",
|
||||||
|
"value": "196"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_LESS",
|
||||||
|
"value": "197"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_GREATER",
|
||||||
|
"value": "198"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_AMPERSAND",
|
||||||
|
"value": "199"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_DBLAMPERSAND",
|
||||||
|
"value": "200"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_VERTICALBAR",
|
||||||
|
"value": "201"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_DBLVERTICALBAR",
|
||||||
|
"value": "202"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_COLON",
|
||||||
|
"value": "203"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_HASH",
|
||||||
|
"value": "204"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_SPACE",
|
||||||
|
"value": "205"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_AT",
|
||||||
|
"value": "206"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_EXCLAM",
|
||||||
|
"value": "207"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMSTORE",
|
||||||
|
"value": "208"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMRECALL",
|
||||||
|
"value": "209"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMCLEAR",
|
||||||
|
"value": "210"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMADD",
|
||||||
|
"value": "211"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMSUBTRACT",
|
||||||
|
"value": "212"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMMULTIPLY",
|
||||||
|
"value": "213"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_MEMDIVIDE",
|
||||||
|
"value": "214"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_PLUSMINUS",
|
||||||
|
"value": "215"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_CLEAR",
|
||||||
|
"value": "216"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_CLEARENTRY",
|
||||||
|
"value": "217"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_BINARY",
|
||||||
|
"value": "218"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_OCTAL",
|
||||||
|
"value": "219"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_DECIMAL",
|
||||||
|
"value": "220"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_KP_HEXADECIMAL",
|
||||||
|
"value": "221"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_LCTRL",
|
||||||
|
"value": "224"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_LSHIFT",
|
||||||
|
"value": "225"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_LALT",
|
"name": "SDL_SCANCODE_LALT",
|
||||||
"value": "226",
|
"value": "226",
|
||||||
|
|
@ -160,6 +881,14 @@
|
||||||
"value": "227",
|
"value": "227",
|
||||||
"comment": "windows, command (apple), meta"
|
"comment": "windows, command (apple), meta"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RCTRL",
|
||||||
|
"value": "228"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCANCODE_RSHIFT",
|
||||||
|
"value": "229"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_RALT",
|
"name": "SDL_SCANCODE_RALT",
|
||||||
"value": "230",
|
"value": "230",
|
||||||
|
|
@ -172,7 +901,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_MODE",
|
"name": "SDL_SCANCODE_MODE",
|
||||||
"value": "257"
|
"value": "257",
|
||||||
|
"comment": "I'm not sure if this is really not covered by any of the above, but since there's a special SDL_KMOD_MODE for it I'm adding it here"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_SLEEP",
|
"name": "SDL_SCANCODE_SLEEP",
|
||||||
|
|
@ -320,11 +1050,13 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_SOFTLEFT",
|
"name": "SDL_SCANCODE_SOFTLEFT",
|
||||||
"value": "287"
|
"value": "287",
|
||||||
|
"comment": "Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom left of the display."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_SOFTRIGHT",
|
"name": "SDL_SCANCODE_SOFTRIGHT",
|
||||||
"value": "288"
|
"value": "288",
|
||||||
|
"comment": "Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom right of the display."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_CALL",
|
"name": "SDL_SCANCODE_CALL",
|
||||||
|
|
@ -343,7 +1075,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCANCODE_COUNT",
|
"name": "SDL_SCANCODE_COUNT",
|
||||||
"value": "512"
|
"value": "512",
|
||||||
|
"comment": "not a key, just marks the number of scancodes for array bounds"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_ScaleMode",
|
"name": "SDL_ScaleMode",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_SCALEMODE_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCALEMODE_NEAREST",
|
"name": "SDL_SCALEMODE_NEAREST",
|
||||||
"comment": "nearest pixel sampling"
|
"comment": "nearest pixel sampling"
|
||||||
|
|
@ -21,7 +25,8 @@
|
||||||
"comment": "linear filtering"
|
"comment": "linear filtering"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SCALEMODE_PIXELART"
|
"name": "SDL_SCALEMODE_PIXELART",
|
||||||
|
"comment": "nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_Sandbox",
|
"name": "SDL_Sandbox",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_SANDBOX_NONE",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SANDBOX_UNKNOWN_CONTAINER"
|
"name": "SDL_SANDBOX_UNKNOWN_CONTAINER"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_TouchDeviceType",
|
"name": "SDL_TouchDeviceType",
|
||||||
"values": [
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_TOUCH_DEVICE_INVALID",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_TOUCH_DEVICE_DIRECT",
|
"name": "SDL_TOUCH_DEVICE_DIRECT",
|
||||||
"comment": "touch screen with window-relative coordinates"
|
"comment": "touch screen with window-relative coordinates"
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,8 @@
|
||||||
"comment": "The display is in portrait mode"
|
"comment": "The display is in portrait mode"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ORIENTATION_PORTRAIT_FLIPPED"
|
"name": "SDL_ORIENTATION_PORTRAIT_FLIPPED",
|
||||||
|
"comment": "The display is in portrait mode, upside down"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,94 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"name": "v0.6.1+3.4.20",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.6.1+3.4.20",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.6.1+3.4.20",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ce475292f172d506468218f939ef607d9be5e083",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/ce475292f172d506468218f939ef607d9be5e083"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNi4xKzMuNC4yMA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.6.0+3.4.18",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.6.0+3.4.18",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.6.0+3.4.18",
|
||||||
|
"commit": {
|
||||||
|
"sha": "dbcb19aa3583c318556ecae3ecbeb29b102d37c5",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/dbcb19aa3583c318556ecae3ecbeb29b102d37c5"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNi4wKzMuNC4xOA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.5.4+3.4.16",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.5.4+3.4.16",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.5.4+3.4.16",
|
||||||
|
"commit": {
|
||||||
|
"sha": "b72b3671502a70e109350ecac90afdc480dcfcc6",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/b72b3671502a70e109350ecac90afdc480dcfcc6"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNS40KzMuNC4xNg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.5.3+3.4.14",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.5.3+3.4.14",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.5.3+3.4.14",
|
||||||
|
"commit": {
|
||||||
|
"sha": "fb2d799c4778832a34ccb3739e40dded700684bd",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/fb2d799c4778832a34ccb3739e40dded700684bd"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNS4zKzMuNC4xNA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.5.2+3.4.12",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.5.2+3.4.12",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.5.2+3.4.12",
|
||||||
|
"commit": {
|
||||||
|
"sha": "1b67d371a531ecb0499d4b80a865631c299f472a",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/1b67d371a531ecb0499d4b80a865631c299f472a"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNS4yKzMuNC4xMg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.5.1+3.4.10",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.5.1+3.4.10",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.5.1+3.4.10",
|
||||||
|
"commit": {
|
||||||
|
"sha": "018241066ffdae90d8b11f8bdc6242202f0f5451",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/018241066ffdae90d8b11f8bdc6242202f0f5451"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7dyZWZzL3RhZ3MvdjAuNS4xKzMuNC4xMA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.5.0+3.4.8",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.5.0+3.4.8",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.5.0+3.4.8",
|
||||||
|
"commit": {
|
||||||
|
"sha": "21c6b79840d123e94a9f183f4b0fa1731668f48d",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/21c6b79840d123e94a9f183f4b0fa1731668f48d"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7ZyZWZzL3RhZ3MvdjAuNS4wKzMuNC44"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.4.2+3.4.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.4.2+3.4.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.4.2+3.4.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "76ee7f13177b5dfad124e7066dec29c90f7db275",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/76ee7f13177b5dfad124e7066dec29c90f7db275"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7ZyZWZzL3RhZ3MvdjAuNC4yKzMuNC40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v0.4.1+3.4.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.4.1+3.4.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/castholm/SDL/tarball/refs/tags/v0.4.1+3.4.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "701da66369221654c501e9661c648dd3aa2cfe52",
|
||||||
|
"url": "https://api.github.com/repos/castholm/SDL/commits/701da66369221654c501e9661c648dd3aa2cfe52"
|
||||||
|
},
|
||||||
|
"node_id": "REF_kwDONdlsr7ZyZWZzL3RhZ3MvdjAuNC4xKzMuNC4y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "v0.4.0+3.4.0",
|
"name": "v0.4.0+3.4.0",
|
||||||
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.4.0+3.4.0",
|
"zipball_url": "https://api.github.com/repos/castholm/SDL/zipball/refs/tags/v0.4.0+3.4.0",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,104 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"name": "release-3.4.20",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.20",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.20",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f00dc919ca35b9756316e86c4777392de442f9b2",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f00dc919ca35b9756316e86c4777392de442f9b2"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4yMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.18",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.18",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.18",
|
||||||
|
"commit": {
|
||||||
|
"sha": "829a65d769d935c4852f8159e964312c0957260a",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/829a65d769d935c4852f8159e964312c0957260a"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4xOA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.16",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.16",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.16",
|
||||||
|
"commit": {
|
||||||
|
"sha": "fa2c02bb6e21974a89ea9824bc53c9932abe5f9c",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/fa2c02bb6e21974a89ea9824bc53c9932abe5f9c"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4xNg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.14",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.14",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.14",
|
||||||
|
"commit": {
|
||||||
|
"sha": "147a8ee32dbf9ac02f3794964490687b6bbda1bc",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/147a8ee32dbf9ac02f3794964490687b6bbda1bc"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4xNA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.12",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.12",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.12",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f87239e71e42da91ca317a12eefb82cfbf3393eb",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f87239e71e42da91ca317a12eefb82cfbf3393eb"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4xMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.10",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.10",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.10",
|
||||||
|
"commit": {
|
||||||
|
"sha": "8e37db5e797b6167f3a00d697d816a684bd259c7",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/8e37db5e797b6167f3a00d697d816a684bd259c7"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4xMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.8",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.8",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.8",
|
||||||
|
"commit": {
|
||||||
|
"sha": "d9d5536704d585616d4db3c8ba3c4ff6fc2757e1",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/d9d5536704d585616d4db3c8ba3c4ff6fc2757e1"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC44"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.6",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.6",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.6",
|
||||||
|
"commit": {
|
||||||
|
"sha": "3aabb7bc5307324b67db9d45b6e0c48e7ad3a400",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/3aabb7bc5307324b67db9d45b6e0c48e7ad3a400"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC42"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "5848e584a1b606de26e3dbd1c7e4ecbc34f807a6",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/5848e584a1b606de26e3dbd1c7e4ecbc34f807a6"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-3.4.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-3.4.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "683181b47cfabd293e3ea409f838915b8297a4fd",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/683181b47cfabd293e3ea409f838915b8297a4fd"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTMuNC4y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "release-3.4.0",
|
"name": "release-3.4.0",
|
||||||
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.0",
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-3.4.0",
|
||||||
|
|
@ -298,5 +398,555 @@
|
||||||
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ba2f78a0069118a6c583f1fbf1420144ffa35bad"
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ba2f78a0069118a6c583f1fbf1420144ffa35bad"
|
||||||
},
|
},
|
||||||
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuNg=="
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuNg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.5",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.5",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.5",
|
||||||
|
"commit": {
|
||||||
|
"sha": "2eef7ca475decd2b864214cdbfe72b143b16d459",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/2eef7ca475decd2b864214cdbfe72b143b16d459"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuNQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "92fe3b19c868ad062c323dde2cfc9d8b4bfdd785",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/92fe3b19c868ad062c323dde2cfc9d8b4bfdd785"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuNA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "fb1497566c5a05e2babdcf45ef0ab5c7cca2c4ae",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/fb1497566c5a05e2babdcf45ef0ab5c7cca2c4ae"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuMw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f461d91cd265d7b9a44b4d472b1df0c0ad2855a0",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f461d91cd265d7b9a44b4d472b1df0c0ad2855a0"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "5adbf3765a57dc5931c2a3137390bfee2370c945",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/5adbf3765a57dc5931c2a3137390bfee2370c945"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.30.0",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.30.0",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.30.0",
|
||||||
|
"commit": {
|
||||||
|
"sha": "859844eae358447be8d66e6da59b6fb3df0ed778",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/859844eae358447be8d66e6da59b6fb3df0ed778"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMzAuMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.5",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.5",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.5",
|
||||||
|
"commit": {
|
||||||
|
"sha": "15ead9a40d09a1eb9972215cceac2bf29c9b77f6",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/15ead9a40d09a1eb9972215cceac2bf29c9b77f6"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguNQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "cc016b0046d563287f0aa9f09b958b5e70d43696",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/cc016b0046d563287f0aa9f09b958b5e70d43696"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguNA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "8a5ba43d00252c6c8b33c9aa4f1048222955ab4d",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/8a5ba43d00252c6c8b33c9aa4f1048222955ab4d"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguMw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "031912c4b6c5db80b443f04aa56fec3e4e645153",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/031912c4b6c5db80b443f04aa56fec3e4e645153"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "4761467b2e8cc7db3d6bc98747daca0051858f09",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/4761467b2e8cc7db3d6bc98747daca0051858f09"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.28.0",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.28.0",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.28.0",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ffa78e6bead23e2ba3adf8ec2367ff2218d4343c",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ffa78e6bead23e2ba3adf8ec2367ff2218d4343c"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjguMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.5",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.5",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.5",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ac13ca9ab691e13e8eebe9684740ddcb0d716203",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ac13ca9ab691e13e8eebe9684740ddcb0d716203"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuNQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "07d0f51fa292895443f563f0cbde4cb3802d87fa",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/07d0f51fa292895443f563f0cbde4cb3802d87fa"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuNA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "adf31f6ec0be0f9ba562889398f71172c7941023",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/adf31f6ec0be0f9ba562889398f71172c7941023"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuMw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f070c83a6059c604cbd098680ddaee391b0a7341",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f070c83a6059c604cbd098680ddaee391b0a7341"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f17058b562c8a1090c0c996b42982721ace90903",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f17058b562c8a1090c0c996b42982721ace90903"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.26.0",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.26.0",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.26.0",
|
||||||
|
"commit": {
|
||||||
|
"sha": "0bfeed061b10ea7dd37c88d9bae1824bad760f3a",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/0bfeed061b10ea7dd37c88d9bae1824bad760f3a"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjYuMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.24.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.24.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.24.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "55b03c7493a7abed33cf803d1380a40fa8af903f",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/55b03c7493a7abed33cf803d1380a40fa8af903f"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjQuMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.24.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.24.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.24.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "a1d1946dcba6509f0679f507b57e7b228d32e6f8",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/a1d1946dcba6509f0679f507b57e7b228d32e6f8"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjQuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.24.0",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.24.0",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.24.0",
|
||||||
|
"commit": {
|
||||||
|
"sha": "8c9beb0c873f6ca5efbd88f1ad2648bfc793b2ac",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/8c9beb0c873f6ca5efbd88f1ad2648bfc793b2ac"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMjQuMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.22",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.22",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.22",
|
||||||
|
"commit": {
|
||||||
|
"sha": "53dea9830964eee8b5c2a7ee0a65d6e268dc78a1",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/53dea9830964eee8b5c2a7ee0a65d6e268dc78a1"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4yMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.20",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.20",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.20",
|
||||||
|
"commit": {
|
||||||
|
"sha": "b424665e0899769b200231ba943353a5fee1b6b6",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/b424665e0899769b200231ba943353a5fee1b6b6"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4yMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.18",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.18",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.18",
|
||||||
|
"commit": {
|
||||||
|
"sha": "2e9821423a237a1206e3c09020778faacfe430be",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/2e9821423a237a1206e3c09020778faacfe430be"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4xOA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.16",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.16",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.16",
|
||||||
|
"commit": {
|
||||||
|
"sha": "25f9ed87ff6947d9576fc9d79dee0784e638ac58",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/25f9ed87ff6947d9576fc9d79dee0784e638ac58"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4xNg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.14",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.14",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.14",
|
||||||
|
"commit": {
|
||||||
|
"sha": "4cd981609b50ed273d80c635c1ca4c1e5518fb21",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/4cd981609b50ed273d80c635c1ca4c1e5518fb21"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4xNA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.12",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.12",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.12",
|
||||||
|
"commit": {
|
||||||
|
"sha": "983bbf9ef3e572a073a6f5877faf1c0b4803527c",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/983bbf9ef3e572a073a6f5877faf1c0b4803527c"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4xMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.10",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.10",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.10",
|
||||||
|
"commit": {
|
||||||
|
"sha": "0e9560aea22818884921e5e5064953257bfe7fa7",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/0e9560aea22818884921e5e5064953257bfe7fa7"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4xMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.9",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.9",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.9",
|
||||||
|
"commit": {
|
||||||
|
"sha": "c49ecf6f7c10b668ebd87b89dfc3c7bfd215cb75",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/c49ecf6f7c10b668ebd87b89dfc3c7bfd215cb75"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC45"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.8",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.8",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.8",
|
||||||
|
"commit": {
|
||||||
|
"sha": "e9fc66a038304be0b892b83c16d6dcf5ee36f388",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/e9fc66a038304be0b892b83c16d6dcf5ee36f388"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC44"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.7",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.7",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.7",
|
||||||
|
"commit": {
|
||||||
|
"sha": "b89cac6761e9ab48e1b6149a0da90d47baf6f925",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/b89cac6761e9ab48e1b6149a0da90d47baf6f925"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC43"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.6",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.6",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.6",
|
||||||
|
"commit": {
|
||||||
|
"sha": "fe6b8f1c314e94f58db8119e40ad4e1f849fb667",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/fe6b8f1c314e94f58db8119e40ad4e1f849fb667"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC42"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.5",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.5",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.5",
|
||||||
|
"commit": {
|
||||||
|
"sha": "54eb9067e15adcf0d978d0b672fe70cef0c05528",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/54eb9067e15adcf0d978d0b672fe70cef0c05528"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC41"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "e2fd1c0fe39d83ecdee1e0c6359a299f0afad13b",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/e2fd1c0fe39d83ecdee1e0c6359a299f0afad13b"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "d4f2f01580454deef8ac43d8939ebc907d4ad759",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/d4f2f01580454deef8ac43d8939ebc907d4ad759"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "2b92d9b431fa8620807a48a90df578fa80d61d4b",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/2b92d9b431fa8620807a48a90df578fa80d61d4b"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4y"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "7108aac5ac1060a32d785ef63f2f3bfaa91d7c06",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/7108aac5ac1060a32d785ef63f2f3bfaa91d7c06"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-2.0.0",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/release-2.0.0",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/release-2.0.0",
|
||||||
|
"commit": {
|
||||||
|
"sha": "1ad936eb29cf4506a7a103e8288d732f23e9c2b0",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/1ad936eb29cf4506a7a103e8288d732f23e9c2b0"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9yZWxlYXNlLTIuMC4w"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "preview-3.3.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/preview-3.3.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/preview-3.3.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "b31c4b70b3031dc4eb873612d65595a31b439a30",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/b31c4b70b3031dc4eb873612d65595a31b439a30"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmV2aWV3LTMuMy4y"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "preview-3.1.8",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/preview-3.1.8",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/preview-3.1.8",
|
||||||
|
"commit": {
|
||||||
|
"sha": "22422f7748d5128135995ed34c8f8012861c7332",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/22422f7748d5128135995ed34c8f8012861c7332"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmV2aWV3LTMuMS44"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "preview-3.1.6",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/preview-3.1.6",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/preview-3.1.6",
|
||||||
|
"commit": {
|
||||||
|
"sha": "78cc5c173404488d80751af226d1eaf67033bcc4",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/78cc5c173404488d80751af226d1eaf67033bcc4"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmV2aWV3LTMuMS42"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "preview-3.1.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/preview-3.1.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/preview-3.1.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmV2aWV3LTMuMS4z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-3.3.6",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-3.3.6",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-3.3.6",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ef0a604d44f5e44d4c1b34c215d68be5a985cd7e",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ef0a604d44f5e44d4c1b34c215d68be5a985cd7e"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTMuMy42"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-3.3.4",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-3.3.4",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-3.3.4",
|
||||||
|
"commit": {
|
||||||
|
"sha": "f173fd28f04cb64ae054d6a97edb5d33925f539b",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/f173fd28f04cb64ae054d6a97edb5d33925f539b"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTMuMy40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-3.1.10",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-3.1.10",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-3.1.10",
|
||||||
|
"commit": {
|
||||||
|
"sha": "b96bb152c2dffd39f49cec431f23ac60cec395b4",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/b96bb152c2dffd39f49cec431f23ac60cec395b4"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTMuMS4xMA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.29.3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.29.3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.29.3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "4a62e1c0ca60052e78a7e843f2522f8831999e08",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/4a62e1c0ca60052e78a7e843f2522f8831999e08"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjkuMw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.29.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.29.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.29.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ef7261bc41e23a2c16d7219ccf7bc1e7bce61da4",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ef7261bc41e23a2c16d7219ccf7bc1e7bce61da4"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjkuMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.29.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.29.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.29.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "cfc22ac7d7a1fb898096236fe8eabf0062616055",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/cfc22ac7d7a1fb898096236fe8eabf0062616055"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjkuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.27.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.27.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.27.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "d4f9be44160b4767753bc8756b9819d47e957121",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/d4f9be44160b4767753bc8756b9819d47e957121"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjcuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.25.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.25.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.25.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "78ea6af2cddfa050a394ff9030d0ddd631099848",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/78ea6af2cddfa050a394ff9030d0ddd631099848"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjUuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.23.2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.23.2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.23.2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "cb46e1b3f06a08d57b4ccd83127d1ec3139e1c0f",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/cb46e1b3f06a08d57b4ccd83127d1ec3139e1c0f"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjMuMg=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prerelease-2.23.1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/prerelease-2.23.1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/prerelease-2.23.1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "59fb7acbf7af9d64a2d5432bb6677585a0ddd50a",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/59fb7acbf7af9d64a2d5432bb6677585a0ddd50a"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy9wcmVyZWxlYXNlLTIuMjMuMQ=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2.0.22-RC3",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/2.0.22-RC3",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/2.0.22-RC3",
|
||||||
|
"commit": {
|
||||||
|
"sha": "981e1e3c4489add5bf6d4df5415af3cf1ef2773d",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/981e1e3c4489add5bf6d4df5415af3cf1ef2773d"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy8yLjAuMjItUkMz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2.0.22-RC2",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/2.0.22-RC2",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/2.0.22-RC2",
|
||||||
|
"commit": {
|
||||||
|
"sha": "ba62ead5ecc111070381c4d32d7b21dfc9bb1493",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/ba62ead5ecc111070381c4d32d7b21dfc9bb1493"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy8yLjAuMjItUkMy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2.0.22-RC1",
|
||||||
|
"zipball_url": "https://api.github.com/repos/libsdl-org/SDL/zipball/refs/tags/2.0.22-RC1",
|
||||||
|
"tarball_url": "https://api.github.com/repos/libsdl-org/SDL/tarball/refs/tags/2.0.22-RC1",
|
||||||
|
"commit": {
|
||||||
|
"sha": "505d6a4a052592b2676f87456c1f564daa8d2c50",
|
||||||
|
"url": "https://api.github.com/repos/libsdl-org/SDL/commits/505d6a4a052592b2676f87456c1f564daa8d2c50"
|
||||||
|
},
|
||||||
|
"node_id": "MDM6UmVmMzMwMDA4ODAxOnJlZnMvdGFncy8yLjAuMjItUkMx"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,15 @@
|
||||||
"castholm": {
|
"castholm": {
|
||||||
"url": "git@github.com:castholm/SDL.git",
|
"url": "git@github.com:castholm/SDL.git",
|
||||||
"tags": [
|
"tags": [
|
||||||
|
"v0.6.1+3.4.20",
|
||||||
|
"v0.6.0+3.4.18",
|
||||||
|
"v0.5.4+3.4.16",
|
||||||
|
"v0.5.3+3.4.14",
|
||||||
|
"v0.5.2+3.4.12",
|
||||||
|
"v0.5.1+3.4.10",
|
||||||
|
"v0.5.0+3.4.8",
|
||||||
|
"v0.4.2+3.4.4",
|
||||||
|
"v0.4.1+3.4.2",
|
||||||
"v0.4.0+3.4.0",
|
"v0.4.0+3.4.0",
|
||||||
"v0.3.3+3.2.28",
|
"v0.3.3+3.2.28",
|
||||||
"v0.3.2+3.2.26",
|
"v0.3.2+3.2.26",
|
||||||
|
|
@ -26,6 +35,16 @@
|
||||||
"official": {
|
"official": {
|
||||||
"url": "git@github.com:libsdl-org/SDL.git",
|
"url": "git@github.com:libsdl-org/SDL.git",
|
||||||
"tags": [
|
"tags": [
|
||||||
|
"release-3.4.20",
|
||||||
|
"release-3.4.18",
|
||||||
|
"release-3.4.16",
|
||||||
|
"release-3.4.14",
|
||||||
|
"release-3.4.12",
|
||||||
|
"release-3.4.10",
|
||||||
|
"release-3.4.8",
|
||||||
|
"release-3.4.6",
|
||||||
|
"release-3.4.4",
|
||||||
|
"release-3.4.2",
|
||||||
"release-3.4.0",
|
"release-3.4.0",
|
||||||
"release-3.2.30",
|
"release-3.2.30",
|
||||||
"release-3.2.28",
|
"release-3.2.28",
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ def test_release(repo_name, tag, sdl_url_flag, clean=False):
|
||||||
"zig", "build", "generate",
|
"zig", "build", "generate",
|
||||||
f"-Dref={tag}",
|
f"-Dref={tag}",
|
||||||
f"-Dbasedir={basedir}",
|
f"-Dbasedir={basedir}",
|
||||||
|
f"-DoutputDir={basedir}",
|
||||||
sdl_url_flag
|
sdl_url_flag
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
//! Small helper executable used by build.zig for filesystem work that has to
|
||||||
|
//! happen at make time (the build system no longer supports custom steps).
|
||||||
|
//!
|
||||||
|
//! Usage:
|
||||||
|
//! build-helper archive [base_dir] move <base>/json and <base>/api to <base>/archive/generate/<timestamp>/
|
||||||
|
//! build-helper mkdir <dir> create a directory and its parents
|
||||||
|
//! build-helper write <path> <contents> write a file, creating parent directories
|
||||||
|
//! build-helper rmtree <dir> recursively delete a directory
|
||||||
|
const std = @import("std");
|
||||||
|
const Dir = std.Io.Dir;
|
||||||
|
|
||||||
|
pub fn main(init: std.process.Init) !void {
|
||||||
|
const io = init.io;
|
||||||
|
const arena = init.arena.allocator();
|
||||||
|
const args = try init.minimal.args.toSlice(arena);
|
||||||
|
|
||||||
|
if (args.len < 2) return usage();
|
||||||
|
const command = args[1];
|
||||||
|
const rest = args[2..];
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, command, "archive")) {
|
||||||
|
if (rest.len > 1) return usage();
|
||||||
|
try archive(io, arena, if (rest.len == 1) rest[0] else null);
|
||||||
|
} else if (std.mem.eql(u8, command, "mkdir")) {
|
||||||
|
if (rest.len != 1) return usage();
|
||||||
|
try Dir.cwd().createDirPath(io, rest[0]);
|
||||||
|
} else if (std.mem.eql(u8, command, "write")) {
|
||||||
|
if (rest.len != 2) return usage();
|
||||||
|
if (std.fs.path.dirname(rest[0])) |dir| {
|
||||||
|
try Dir.cwd().createDirPath(io, dir);
|
||||||
|
}
|
||||||
|
try Dir.cwd().writeFile(io, .{ .sub_path = rest[0], .data = rest[1] });
|
||||||
|
} else if (std.mem.eql(u8, command, "rmtree")) {
|
||||||
|
if (rest.len != 1) return usage();
|
||||||
|
try Dir.cwd().deleteTree(io, rest[0]);
|
||||||
|
} else {
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage() error{InvalidArgument} {
|
||||||
|
std.debug.print("usage: build-helper (archive [base_dir] | mkdir <dir> | write <path> <contents> | rmtree <dir>)\n", .{});
|
||||||
|
return error.InvalidArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exists(io: std.Io, path: []const u8) bool {
|
||||||
|
Dir.cwd().access(io, path, .{}) catch return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Moves existing json/ and api/ directories out of the way before regenerating.
|
||||||
|
fn archive(io: std.Io, arena: std.mem.Allocator, base_dir: ?[]const u8) !void {
|
||||||
|
const base = base_dir orelse ".";
|
||||||
|
const cwd = Dir.cwd();
|
||||||
|
|
||||||
|
const json_path = try std.fs.path.join(arena, &.{ base, "json" });
|
||||||
|
const api_path = try std.fs.path.join(arena, &.{ base, "api" });
|
||||||
|
|
||||||
|
const json_exists = exists(io, json_path);
|
||||||
|
const api_exists = exists(io, api_path);
|
||||||
|
if (!json_exists and !api_exists) return;
|
||||||
|
|
||||||
|
const timestamp = std.Io.Clock.real.now(io).toSeconds();
|
||||||
|
const timestamp_dir = try std.fmt.allocPrint(arena, "{d}", .{timestamp});
|
||||||
|
const archive_path = try std.fs.path.join(arena, &.{ base, "archive", "generate", timestamp_dir });
|
||||||
|
try cwd.createDirPath(io, archive_path);
|
||||||
|
|
||||||
|
if (json_exists) {
|
||||||
|
try cwd.rename(json_path, cwd, try std.fs.path.join(arena, &.{ archive_path, "json" }), io);
|
||||||
|
}
|
||||||
|
if (api_exists) {
|
||||||
|
try cwd.rename(api_path, cwd, try std.fs.path.join(arena, &.{ archive_path, "api" }), io);
|
||||||
|
}
|
||||||
|
}
|
||||||
551
src/codegen.zig
551
src/codegen.zig
|
|
@ -22,6 +22,39 @@ const TypeAlias = struct {
|
||||||
target_name: []const u8,
|
target_name: []const u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Conversion applied to a value crossing the Zig <-> C boundary.
|
||||||
|
const Cast = enum {
|
||||||
|
none,
|
||||||
|
/// Pointer to a type that is declared differently on the Zig side.
|
||||||
|
ptr,
|
||||||
|
/// Same-sized value: bool or packed flags.
|
||||||
|
bit,
|
||||||
|
/// Extern struct/union passed by value; reinterpreted through a pointer
|
||||||
|
/// because `@bitCast` does not accept extern aggregates.
|
||||||
|
aggregate,
|
||||||
|
/// Zig `enum(c_int)` <-> C enum (whose integer type is platform dependent).
|
||||||
|
enumeration,
|
||||||
|
|
||||||
|
fn returnPrefix(cast: Cast) []const u8 {
|
||||||
|
return switch (cast) {
|
||||||
|
.none => "",
|
||||||
|
.ptr => "@ptrCast(@alignCast(",
|
||||||
|
.bit => "@bitCast(",
|
||||||
|
.enumeration => "@fromBackingInt(@intCast(",
|
||||||
|
.aggregate => unreachable, // needs the type name, see writeReturnPrefix
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn returnSuffix(cast: Cast) []const u8 {
|
||||||
|
return switch (cast) {
|
||||||
|
.none => "",
|
||||||
|
.bit => ")",
|
||||||
|
.ptr, .enumeration => "))",
|
||||||
|
.aggregate => "))).*",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
pub const CodeGenOptions = struct {
|
pub const CodeGenOptions = struct {
|
||||||
decls: []const ResolvedDecl,
|
decls: []const ResolvedDecl,
|
||||||
module_name: []const u8,
|
module_name: []const u8,
|
||||||
|
|
@ -177,14 +210,14 @@ pub const CodeGen = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeHeader(self: *CodeGen) !void {
|
fn writeHeader(self: *CodeGen) !void {
|
||||||
try self.output.writer(self.allocator).print(
|
try self.output.print(self.allocator,
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
\\pub const c = @import("{s}").c;
|
\\pub const c = @import("{s}").c;
|
||||||
\\
|
\\
|
||||||
, .{self.c_import_path});
|
, .{self.c_import_path});
|
||||||
|
|
||||||
for (self.import_modules.items) |module| {
|
for (self.import_modules.items) |module| {
|
||||||
try self.output.writer(self.allocator).print("const {s} = @import(\"{s}.zig\");\n", .{
|
try self.output.print(self.allocator, "const {s} = @import(\"{s}.zig\");\n", .{
|
||||||
module.import_name,
|
module.import_name,
|
||||||
module.module_name,
|
module.module_name,
|
||||||
});
|
});
|
||||||
|
|
@ -194,7 +227,7 @@ pub const CodeGen = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (self.aliases.items) |alias_decl| {
|
for (self.aliases.items) |alias_decl| {
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = {s}.{s};\n", .{
|
try self.output.print(self.allocator, "pub const {s} = {s}.{s};\n", .{
|
||||||
alias_decl.name,
|
alias_decl.name,
|
||||||
alias_decl.import_name,
|
alias_decl.import_name,
|
||||||
alias_decl.target_name,
|
alias_decl.target_name,
|
||||||
|
|
@ -207,7 +240,7 @@ pub const CodeGen = struct {
|
||||||
if (self.skipped.len > 0) {
|
if (self.skipped.len > 0) {
|
||||||
try self.output.appendSlice(self.allocator, "pub const unsupported = struct {\n");
|
try self.output.appendSlice(self.allocator, "pub const unsupported = struct {\n");
|
||||||
for (self.skipped) |item| {
|
for (self.skipped) |item| {
|
||||||
try self.output.writer(self.allocator).print(" pub const @\"{s}\" = \"{s}\";\n", .{ item.name, item.reason });
|
try self.output.print(self.allocator, " pub const @\"{s}\" = \"{s}\";\n", .{ item.name, item.reason });
|
||||||
}
|
}
|
||||||
try self.output.appendSlice(self.allocator, "};\n\n");
|
try self.output.appendSlice(self.allocator, "};\n\n");
|
||||||
}
|
}
|
||||||
|
|
@ -258,7 +291,7 @@ pub const CodeGen = struct {
|
||||||
|
|
||||||
if (self.opaque_methods.get(zig_name)) |method_list| {
|
if (self.opaque_methods.get(zig_name)) |method_list| {
|
||||||
if (method_list.items.len > 0) {
|
if (method_list.items.len > 0) {
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = opaque {{\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = opaque {{\n", .{zig_name});
|
||||||
for (method_list.items) |func| {
|
for (method_list.items) |func| {
|
||||||
try self.writeFunctionAsMethod(func, zig_name);
|
try self.writeFunctionAsMethod(func, zig_name);
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +300,7 @@ pub const CodeGen = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = opaque {{}};\n\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = opaque {{}};\n\n", .{zig_name});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeTypedef(self: *CodeGen, typedef_decl: patterns.TypedefDecl) !void {
|
fn writeTypedef(self: *CodeGen, typedef_decl: patterns.TypedefDecl) !void {
|
||||||
|
|
@ -289,20 +322,20 @@ pub const CodeGen = struct {
|
||||||
const return_type = try types.convertType(func_ptr_decl.return_type, self.allocator);
|
const return_type = try types.convertType(func_ptr_decl.return_type, self.allocator);
|
||||||
defer self.allocator.free(return_type);
|
defer self.allocator.free(return_type);
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = *const fn(", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = *const fn(", .{zig_name});
|
||||||
for (func_ptr_decl.params, 0..) |param, i| {
|
for (func_ptr_decl.params, 0..) |param, i| {
|
||||||
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
||||||
const param_type = try types.convertType(param.type_name, self.allocator);
|
const param_type = try types.convertType(param.type_name, self.allocator);
|
||||||
defer self.allocator.free(param_type);
|
defer self.allocator.free(param_type);
|
||||||
try self.output.writer(self.allocator).print("{s}: {s}", .{ param.name, param_type });
|
try self.output.print(self.allocator, "{s}: {s}", .{ param.name, param_type });
|
||||||
}
|
}
|
||||||
try self.output.writer(self.allocator).print(") callconv(.C) {s};\n\n", .{return_type});
|
try self.output.print(self.allocator, ") callconv(.c) {s};\n\n", .{return_type});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeCTypeAlias(self: *CodeGen, alias: patterns.CTypeAlias) !void {
|
fn writeCTypeAlias(self: *CodeGen, alias: patterns.CTypeAlias) !void {
|
||||||
if (alias.doc_comment) |doc| try self.writeDocComment(doc);
|
if (alias.doc_comment) |doc| try self.writeDocComment(doc);
|
||||||
const zig_name = naming.typeNameToZig(alias.name);
|
const zig_name = naming.typeNameToZig(alias.name);
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = c.{s};\n\n", .{ zig_name, alias.name });
|
try self.output.print(self.allocator, "pub const {s} = c.{s};\n\n", .{ zig_name, alias.name });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumShouldBeFlags(self: *CodeGen, enum_decl: EnumDecl) bool {
|
fn enumShouldBeFlags(self: *CodeGen, enum_decl: EnumDecl) bool {
|
||||||
|
|
@ -354,6 +387,14 @@ pub const CodeGen = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parses an integer literal as written in a C enum (`12`, `-1`, `0x8000u`).
|
||||||
|
fn parseEnumLiteral(text: []const u8) ?i128 {
|
||||||
|
var trimmed = std.mem.trim(u8, text, " \t()");
|
||||||
|
trimmed = std.mem.trimEnd(u8, trimmed, "uUlL");
|
||||||
|
if (trimmed.len == 0) return null;
|
||||||
|
return std.fmt.parseInt(i128, trimmed, 0) catch null;
|
||||||
|
}
|
||||||
|
|
||||||
fn writeEnum(self: *CodeGen, enum_decl: EnumDecl) !void {
|
fn writeEnum(self: *CodeGen, enum_decl: EnumDecl) !void {
|
||||||
if (enum_decl.values.len == 0) return;
|
if (enum_decl.values.len == 0) return;
|
||||||
if (self.enumShouldBeFlags(enum_decl)) {
|
if (self.enumShouldBeFlags(enum_decl)) {
|
||||||
|
|
@ -364,7 +405,7 @@ pub const CodeGen = struct {
|
||||||
|
|
||||||
const zig_name = naming.typeNameToZig(enum_decl.name);
|
const zig_name = naming.typeNameToZig(enum_decl.name);
|
||||||
if (enum_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
if (enum_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = enum(c_int) {{\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = enum(c_int) {{\n", .{zig_name});
|
||||||
|
|
||||||
const value_names = try self.allocator.alloc([]const u8, enum_decl.values.len);
|
const value_names = try self.allocator.alloc([]const u8, enum_decl.values.len);
|
||||||
defer self.allocator.free(value_names);
|
defer self.allocator.free(value_names);
|
||||||
|
|
@ -372,60 +413,68 @@ pub const CodeGen = struct {
|
||||||
const prefix = try naming.detectCommonPrefix(value_names, self.allocator);
|
const prefix = try naming.detectCommonPrefix(value_names, self.allocator);
|
||||||
defer self.allocator.free(prefix);
|
defer self.allocator.free(prefix);
|
||||||
|
|
||||||
var identifier_to_value = std.StringHashMap([]const u8).init(self.allocator);
|
// Work out the numeric value of every enumerator the way a C compiler
|
||||||
defer identifier_to_value.deinit();
|
// would, so that duplicates (which Zig does not allow) become aliases
|
||||||
var value_to_name = std.StringHashMap([]const u8).init(self.allocator);
|
// and implicit values stay correct.
|
||||||
|
var name_to_value = std.StringHashMap(i128).init(self.allocator);
|
||||||
|
defer name_to_value.deinit();
|
||||||
|
var value_to_name = std.AutoHashMap(i128, []const u8).init(self.allocator);
|
||||||
defer value_to_name.deinit();
|
defer value_to_name.deinit();
|
||||||
|
|
||||||
for (enum_decl.values) |value| {
|
|
||||||
if (value.value) |explicit_value| {
|
|
||||||
const clean_value = if (std.mem.endsWith(u8, explicit_value, "u")) explicit_value[0 .. explicit_value.len - 1] else explicit_value;
|
|
||||||
try identifier_to_value.put(value.name, clean_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const resolved_values = try self.allocator.alloc(?[]const u8, enum_decl.values.len);
|
|
||||||
defer self.allocator.free(resolved_values);
|
|
||||||
for (enum_decl.values, 0..) |value, i| {
|
|
||||||
if (value.value) |explicit_value| {
|
|
||||||
const clean_value = if (std.mem.endsWith(u8, explicit_value, "u")) explicit_value[0 .. explicit_value.len - 1] else explicit_value;
|
|
||||||
if (clean_value.len > 0 and !std.ascii.isDigit(clean_value[0])) {
|
|
||||||
resolved_values[i] = identifier_to_value.get(clean_value) orelse clean_value;
|
|
||||||
} else {
|
|
||||||
resolved_values[i] = clean_value;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
resolved_values[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const EnumAlias = struct { name: []const u8, target: []const u8, comment: ?[]const u8 };
|
const EnumAlias = struct { name: []const u8, target: []const u8, comment: ?[]const u8 };
|
||||||
var aliases: std.ArrayList(EnumAlias) = .empty;
|
var aliases: std.ArrayList(EnumAlias) = .empty;
|
||||||
defer aliases.deinit(self.allocator);
|
defer aliases.deinit(self.allocator);
|
||||||
|
|
||||||
for (enum_decl.values, 0..) |value, i| {
|
// Value the next enumerator gets in C / in the emitted Zig enum when no
|
||||||
|
// explicit value is written. Null when a value could not be evaluated.
|
||||||
|
var next_c_value: ?i128 = 0;
|
||||||
|
var next_zig_value: ?i128 = 0;
|
||||||
|
|
||||||
|
for (enum_decl.values) |value| {
|
||||||
const zig_value = try naming.enumValueToZig(value.name, prefix, self.allocator);
|
const zig_value = try naming.enumValueToZig(value.name, prefix, self.allocator);
|
||||||
defer self.allocator.free(zig_value);
|
defer self.allocator.free(zig_value);
|
||||||
|
|
||||||
if (resolved_values[i]) |numeric_value| {
|
const numeric: ?i128 = if (value.value) |explicit_value|
|
||||||
if (value_to_name.get(numeric_value)) |first_name| {
|
parseEnumLiteral(explicit_value) orelse name_to_value.get(std.mem.trim(u8, explicit_value, " \t()"))
|
||||||
|
else
|
||||||
|
next_c_value;
|
||||||
|
next_c_value = if (numeric) |n| n + 1 else null;
|
||||||
|
|
||||||
|
if (numeric) |n| {
|
||||||
|
try name_to_value.put(value.name, n);
|
||||||
|
|
||||||
|
if (value_to_name.get(n)) |first_name| {
|
||||||
try aliases.append(self.allocator, .{
|
try aliases.append(self.allocator, .{
|
||||||
.name = try self.allocator.dupe(u8, zig_value),
|
.name = try self.allocator.dupe(u8, zig_value),
|
||||||
.target = try naming.enumValueToZig(first_name, prefix, self.allocator),
|
.target = try naming.enumValueToZig(first_name, prefix, self.allocator),
|
||||||
.comment = if (value.comment) |c| try self.allocator.dupe(u8, c) else null,
|
.comment = if (value.comment) |c| try self.allocator.dupe(u8, c) else null,
|
||||||
});
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try value_to_name.put(n, value.name);
|
||||||
|
|
||||||
|
try self.output.print(self.allocator, " {s}", .{zig_value});
|
||||||
|
if (value.value != null or next_zig_value == null or next_zig_value.? != n) {
|
||||||
|
if (value.value != null and parseEnumLiteral(value.value.?) != null) {
|
||||||
|
// Keep the spelling used in the header (hex stays hex).
|
||||||
|
const literal = std.mem.trim(u8, value.value.?, " \t()");
|
||||||
|
const clean = std.mem.trimEnd(u8, literal, "uUlL");
|
||||||
|
try self.output.print(self.allocator, " = {s}", .{clean});
|
||||||
} else {
|
} else {
|
||||||
try value_to_name.put(numeric_value, value.name);
|
try self.output.print(self.allocator, " = {d}", .{n});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_zig_value = n + 1;
|
||||||
|
} else {
|
||||||
|
// Not evaluable (e.g. a macro expression): emit it verbatim.
|
||||||
|
try self.output.print(self.allocator, " {s} = {s}", .{ zig_value, value.value.? });
|
||||||
|
next_zig_value = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (value.comment) |comment| {
|
if (value.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" {s} = {s}, //{s}\n", .{ zig_value, numeric_value, comment });
|
try self.output.print(self.allocator, ", //{s}\n", .{comment});
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" {s} = {s},\n", .{ zig_value, numeric_value });
|
try self.output.appendSlice(self.allocator, ",\n");
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (value.comment) |comment| {
|
|
||||||
try self.output.writer(self.allocator).print(" {s}, //{s}\n", .{ zig_value, comment });
|
|
||||||
} else {
|
|
||||||
try self.output.writer(self.allocator).print(" {s},\n", .{zig_value});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -433,9 +482,9 @@ pub const CodeGen = struct {
|
||||||
try self.output.appendSlice(self.allocator, "\n");
|
try self.output.appendSlice(self.allocator, "\n");
|
||||||
for (aliases.items) |alias_decl| {
|
for (aliases.items) |alias_decl| {
|
||||||
if (alias_decl.comment) |comment| {
|
if (alias_decl.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" pub const {s} = .{s}; //{s}\n", .{ alias_decl.name, alias_decl.target, comment });
|
try self.output.print(self.allocator, " pub const {s} = .{s}; //{s}\n", .{ alias_decl.name, alias_decl.target, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" pub const {s} = .{s};\n", .{ alias_decl.name, alias_decl.target });
|
try self.output.print(self.allocator, " pub const {s} = .{s};\n", .{ alias_decl.name, alias_decl.target });
|
||||||
}
|
}
|
||||||
self.allocator.free(alias_decl.name);
|
self.allocator.free(alias_decl.name);
|
||||||
self.allocator.free(alias_decl.target);
|
self.allocator.free(alias_decl.target);
|
||||||
|
|
@ -451,18 +500,18 @@ pub const CodeGen = struct {
|
||||||
if (struct_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
if (struct_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
||||||
|
|
||||||
if (struct_decl.has_unions) {
|
if (struct_decl.has_unions) {
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = opaque {{}};\n\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = opaque {{}};\n\n", .{zig_name});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = extern struct {{\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = extern struct {{\n", .{zig_name});
|
||||||
for (struct_decl.fields) |field| {
|
for (struct_decl.fields) |field| {
|
||||||
const zig_type = try self.convertAggregateFieldType(field.type_name);
|
const zig_type = try self.convertAggregateFieldType(field.type_name);
|
||||||
defer self.allocator.free(zig_type);
|
defer self.allocator.free(zig_type);
|
||||||
if (field.comment) |comment| {
|
if (field.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" {s}: {s}, // {s}\n", .{ field.name, zig_type, comment });
|
try self.output.print(self.allocator, " {s}: {s}, // {s}\n", .{ field.name, zig_type, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" {s}: {s},\n", .{ field.name, zig_type });
|
try self.output.print(self.allocator, " {s}: {s},\n", .{ field.name, zig_type });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try self.output.appendSlice(self.allocator, "};\n\n");
|
try self.output.appendSlice(self.allocator, "};\n\n");
|
||||||
|
|
@ -471,14 +520,14 @@ pub const CodeGen = struct {
|
||||||
fn writeUnion(self: *CodeGen, union_decl: patterns.UnionDecl) !void {
|
fn writeUnion(self: *CodeGen, union_decl: patterns.UnionDecl) !void {
|
||||||
const zig_name = naming.typeNameToZig(union_decl.name);
|
const zig_name = naming.typeNameToZig(union_decl.name);
|
||||||
if (union_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
if (union_decl.doc_comment) |doc| try self.writeDocComment(doc);
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = extern union {{\n", .{zig_name});
|
try self.output.print(self.allocator, "pub const {s} = extern union {{\n", .{zig_name});
|
||||||
for (union_decl.fields) |field| {
|
for (union_decl.fields) |field| {
|
||||||
const zig_type = try self.convertAggregateFieldType(field.type_name);
|
const zig_type = try self.convertAggregateFieldType(field.type_name);
|
||||||
defer self.allocator.free(zig_type);
|
defer self.allocator.free(zig_type);
|
||||||
if (field.comment) |comment| {
|
if (field.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" {s}: {s}, // {s}\n", .{ field.name, zig_type, comment });
|
try self.output.print(self.allocator, " {s}: {s}, // {s}\n", .{ field.name, zig_type, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" {s}: {s},\n", .{ field.name, zig_type });
|
try self.output.print(self.allocator, " {s}: {s},\n", .{ field.name, zig_type });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try self.output.appendSlice(self.allocator, "};\n\n");
|
try self.output.appendSlice(self.allocator, "};\n\n");
|
||||||
|
|
@ -506,7 +555,7 @@ pub const CodeGen = struct {
|
||||||
else
|
else
|
||||||
32;
|
32;
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = packed struct({s}) {{\n", .{ zig_name, underlying_type });
|
try self.output.print(self.allocator, "pub const {s} = packed struct({s}) {{\n", .{ zig_name, underlying_type });
|
||||||
|
|
||||||
const flag_names = try self.allocator.alloc([]const u8, flag_decl.flags.len);
|
const flag_names = try self.allocator.alloc([]const u8, flag_decl.flags.len);
|
||||||
defer self.allocator.free(flag_names);
|
defer self.allocator.free(flag_names);
|
||||||
|
|
@ -514,25 +563,66 @@ pub const CodeGen = struct {
|
||||||
const prefix = try naming.detectCommonPrefix(flag_names, self.allocator);
|
const prefix = try naming.detectCommonPrefix(flag_names, self.allocator);
|
||||||
defer self.allocator.free(prefix);
|
defer self.allocator.free(prefix);
|
||||||
|
|
||||||
var used_bits = std.bit_set.IntegerBitSet(64).initEmpty();
|
// Fields of a packed struct are laid out in declaration order, so the
|
||||||
for (flag_decl.flags) |flag| {
|
// flags have to be emitted by bit position with padding for the gaps.
|
||||||
|
const FlagBit = struct { bit: u6, index: usize };
|
||||||
|
var flag_bits: std.ArrayList(FlagBit) = .empty;
|
||||||
|
defer flag_bits.deinit(self.allocator);
|
||||||
|
// Flags that share a bit with an earlier flag become constants.
|
||||||
|
var duplicate_flags: std.ArrayList(FlagBit) = .empty;
|
||||||
|
defer duplicate_flags.deinit(self.allocator);
|
||||||
|
|
||||||
|
var used_bits = std.bit_set.Integer(64).empty;
|
||||||
|
for (flag_decl.flags, 0..) |flag, i| {
|
||||||
|
const bit_pos = self.parseBitPosition(flag.value) catch continue;
|
||||||
|
if (bit_pos >= type_bits) continue;
|
||||||
|
if (used_bits.isSet(bit_pos)) {
|
||||||
|
try duplicate_flags.append(self.allocator, .{ .bit = bit_pos, .index = i });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
used_bits.set(bit_pos);
|
||||||
|
try flag_bits.append(self.allocator, .{ .bit = bit_pos, .index = i });
|
||||||
|
}
|
||||||
|
std.mem.sort(FlagBit, flag_bits.items, {}, struct {
|
||||||
|
fn lessThan(_: void, lhs: FlagBit, rhs: FlagBit) bool {
|
||||||
|
return lhs.bit < rhs.bit;
|
||||||
|
}
|
||||||
|
}.lessThan);
|
||||||
|
|
||||||
|
var next_bit: u32 = 0;
|
||||||
|
var pad_index: u32 = 0;
|
||||||
|
for (flag_bits.items) |flag_bit| {
|
||||||
|
if (flag_bit.bit > next_bit) {
|
||||||
|
try self.output.print(self.allocator, " pad{d}: u{d} = 0,\n", .{ pad_index, flag_bit.bit - next_bit });
|
||||||
|
pad_index += 1;
|
||||||
|
}
|
||||||
|
const flag = flag_decl.flags[flag_bit.index];
|
||||||
const zig_flag = try naming.flagNameToZig(flag.name, prefix, self.allocator);
|
const zig_flag = try naming.flagNameToZig(flag.name, prefix, self.allocator);
|
||||||
defer self.allocator.free(zig_flag);
|
defer self.allocator.free(zig_flag);
|
||||||
const bit_pos = self.parseBitPosition(flag.value) catch continue;
|
|
||||||
used_bits.set(bit_pos);
|
|
||||||
if (flag.comment) |comment| {
|
if (flag.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" {s}: bool = false, // {s}\n", .{ zig_flag, comment });
|
try self.output.print(self.allocator, " {s}: bool = false, // {s}\n", .{ zig_flag, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" {s}: bool = false,\n", .{zig_flag});
|
try self.output.print(self.allocator, " {s}: bool = false,\n", .{zig_flag});
|
||||||
}
|
}
|
||||||
|
next_bit = @as(u32, flag_bit.bit) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const padding_bits = type_bits - used_bits.count() - 1;
|
if (next_bit < type_bits) {
|
||||||
if (padding_bits > 0) {
|
const remaining = type_bits - next_bit;
|
||||||
try self.output.writer(self.allocator).print(" pad0: u{d} = 0,\n", .{padding_bits});
|
if (remaining > 1) {
|
||||||
|
try self.output.print(self.allocator, " pad{d}: u{d} = 0,\n", .{ pad_index, remaining - 1 });
|
||||||
|
}
|
||||||
|
try self.output.appendSlice(self.allocator, " rsvd: bool = false,\n");
|
||||||
|
}
|
||||||
|
try self.output.appendSlice(self.allocator, "\n");
|
||||||
|
try self.output.print(self.allocator, " pub const None = {s}{{}};\n", .{zig_name});
|
||||||
|
|
||||||
|
for (duplicate_flags.items) |flag_bit| {
|
||||||
|
const flag = flag_decl.flags[flag_bit.index];
|
||||||
|
const zig_flag = try naming.flagNameToZig(flag.name, prefix, self.allocator);
|
||||||
|
defer self.allocator.free(zig_flag);
|
||||||
|
try self.output.print(self.allocator, " pub const {s}: {s} = @bitCast(@as({s}, 1 << {d}));\n", .{ zig_flag, zig_name, underlying_type, flag_bit.bit });
|
||||||
}
|
}
|
||||||
try self.output.appendSlice(self.allocator, " rsvd: bool = false,\n\n");
|
|
||||||
try self.output.writer(self.allocator).print(" pub const None = {s}{{}};\n", .{zig_name});
|
|
||||||
|
|
||||||
for (flag_decl.constants) |constant| {
|
for (flag_decl.constants) |constant| {
|
||||||
const zig_const_camel = try naming.flagNameToZig(constant.name, prefix, self.allocator);
|
const zig_const_camel = try naming.flagNameToZig(constant.name, prefix, self.allocator);
|
||||||
|
|
@ -542,9 +632,9 @@ pub const CodeGen = struct {
|
||||||
if (zig_const.len > 0) zig_const[0] = std.ascii.toUpper(zig_const[0]);
|
if (zig_const.len > 0) zig_const[0] = std.ascii.toUpper(zig_const[0]);
|
||||||
|
|
||||||
if (constant.comment) |comment| {
|
if (constant.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" pub const {s}: {s} = @bitCast(@as({s}, {s})); // {s}\n", .{ zig_const, zig_name, underlying_type, constant.value, comment });
|
try self.output.print(self.allocator, " pub const {s}: {s} = @bitCast(@as({s}, {s})); // {s}\n", .{ zig_const, zig_name, underlying_type, constant.value, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" pub const {s}: {s} = @bitCast(@as({s}, {s}));\n", .{ zig_const, zig_name, underlying_type, constant.value });
|
try self.output.print(self.allocator, " pub const {s}: {s} = @bitCast(@as({s}, {s}));\n", .{ zig_const, zig_name, underlying_type, constant.value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -559,7 +649,7 @@ pub const CodeGen = struct {
|
||||||
const zig_return_type = try types.convertType(func.return_type, self.allocator);
|
const zig_return_type = try types.convertType(func.return_type, self.allocator);
|
||||||
defer self.allocator.free(zig_return_type);
|
defer self.allocator.free(zig_return_type);
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print(" pub inline fn {s}(", .{zig_name});
|
try self.output.print(self.allocator, " pub inline fn {s}(", .{zig_name});
|
||||||
for (func.params, 0..) |param, i| {
|
for (func.params, 0..) |param, i| {
|
||||||
const zig_type = try self.convertFunctionParamType(func, param);
|
const zig_type = try self.convertFunctionParamType(func, param);
|
||||||
defer self.allocator.free(zig_type);
|
defer self.allocator.free(zig_type);
|
||||||
|
|
@ -569,22 +659,20 @@ pub const CodeGen = struct {
|
||||||
const lower_name = try std.ascii.allocLowerString(self.allocator, owner_type);
|
const lower_name = try std.ascii.allocLowerString(self.allocator, owner_type);
|
||||||
defer self.allocator.free(lower_name);
|
defer self.allocator.free(lower_name);
|
||||||
const non_nullable = if (std.mem.startsWith(u8, zig_type, "?*")) zig_type[1..] else zig_type;
|
const non_nullable = if (std.mem.startsWith(u8, zig_type, "?*")) zig_type[1..] else zig_type;
|
||||||
try self.output.writer(self.allocator).print("{s}: {s}", .{ lower_name, non_nullable });
|
try self.output.print(self.allocator, "{s}: {s}", .{ lower_name, non_nullable });
|
||||||
} else if (param.name.len > 0) {
|
} else if (param.name.len > 0) {
|
||||||
try self.output.writer(self.allocator).print("{s}: {s}", .{ param.name, zig_type });
|
try self.output.print(self.allocator, "{s}: {s}", .{ param.name, zig_type });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print("{s}", .{zig_type});
|
try self.output.print(self.allocator, "{s}", .{zig_type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type});
|
try self.output.print(self.allocator, ") {s} {{\n", .{zig_return_type});
|
||||||
try self.output.appendSlice(self.allocator, " return ");
|
try self.output.appendSlice(self.allocator, " return ");
|
||||||
|
|
||||||
const return_cast = if (!std.mem.eql(u8, zig_return_type, "void")) types.getReturnCastType(zig_return_type) else .none;
|
const return_cast: Cast = if (!std.mem.eql(u8, zig_return_type, "void")) self.castForCType(func.return_type) else .none;
|
||||||
if (return_cast != .none) {
|
try self.writeReturnPrefix(return_cast, zig_return_type);
|
||||||
try self.output.writer(self.allocator).print("{s}(", .{castTypeToString(return_cast)});
|
|
||||||
}
|
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("c.{s}(", .{func.name});
|
try self.output.print(self.allocator, "c.{s}(", .{func.name});
|
||||||
for (func.params, 0..) |param, i| {
|
for (func.params, 0..) |param, i| {
|
||||||
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
||||||
if (param.name.len > 0 or i == 0) {
|
if (param.name.len > 0 or i == 0) {
|
||||||
|
|
@ -595,23 +683,13 @@ pub const CodeGen = struct {
|
||||||
} else try self.allocator.dupe(u8, param.name);
|
} else try self.allocator.dupe(u8, param.name);
|
||||||
defer self.allocator.free(param_name);
|
defer self.allocator.free(param_name);
|
||||||
|
|
||||||
const zig_param_type = try self.convertFunctionParamType(func, param);
|
try self.writeCallArg(param_name, param.type_name);
|
||||||
defer self.allocator.free(zig_param_type);
|
|
||||||
const param_cast = self.getFunctionParamCastType(param, zig_param_type);
|
|
||||||
|
|
||||||
if (param_cast == .none) {
|
|
||||||
try self.output.writer(self.allocator).print("{s}", .{param_name});
|
|
||||||
} else {
|
|
||||||
try self.output.writer(self.allocator).print("{s}({s})", .{ castTypeToString(param_cast), param_name });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (return_cast != .none) {
|
try self.output.appendSlice(self.allocator, ")");
|
||||||
try self.output.appendSlice(self.allocator, "));\n");
|
try self.output.appendSlice(self.allocator, return_cast.returnSuffix());
|
||||||
} else {
|
try self.output.appendSlice(self.allocator, ";\n");
|
||||||
try self.output.appendSlice(self.allocator, ");\n");
|
|
||||||
}
|
|
||||||
try self.output.appendSlice(self.allocator, " }\n\n");
|
try self.output.appendSlice(self.allocator, " }\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -622,47 +700,35 @@ pub const CodeGen = struct {
|
||||||
|
|
||||||
const zig_return_type = try types.convertType(func.return_type, self.allocator);
|
const zig_return_type = try types.convertType(func.return_type, self.allocator);
|
||||||
defer self.allocator.free(zig_return_type);
|
defer self.allocator.free(zig_return_type);
|
||||||
try self.output.writer(self.allocator).print("pub inline fn {s}(", .{zig_name});
|
try self.output.print(self.allocator, "pub inline fn {s}(", .{zig_name});
|
||||||
|
|
||||||
for (func.params, 0..) |param, i| {
|
for (func.params, 0..) |param, i| {
|
||||||
const zig_type = try self.convertFunctionParamType(func, param);
|
const zig_type = try self.convertFunctionParamType(func, param);
|
||||||
defer self.allocator.free(zig_type);
|
defer self.allocator.free(zig_type);
|
||||||
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
||||||
if (param.name.len > 0) {
|
if (param.name.len > 0) {
|
||||||
try self.output.writer(self.allocator).print("{s}: {s}", .{ param.name, zig_type });
|
try self.output.print(self.allocator, "{s}: {s}", .{ param.name, zig_type });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print("{s}", .{zig_type});
|
try self.output.print(self.allocator, "{s}", .{zig_type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type});
|
try self.output.print(self.allocator, ") {s} {{\n", .{zig_return_type});
|
||||||
try self.output.appendSlice(self.allocator, " return ");
|
try self.output.appendSlice(self.allocator, " return ");
|
||||||
|
|
||||||
const return_cast = if (!std.mem.eql(u8, zig_return_type, "void")) types.getReturnCastType(zig_return_type) else .none;
|
const return_cast: Cast = if (!std.mem.eql(u8, zig_return_type, "void")) self.castForCType(func.return_type) else .none;
|
||||||
if (return_cast != .none) {
|
try self.writeReturnPrefix(return_cast, zig_return_type);
|
||||||
try self.output.writer(self.allocator).print("{s}(", .{castTypeToString(return_cast)});
|
|
||||||
}
|
|
||||||
|
|
||||||
try self.output.writer(self.allocator).print("c.{s}(", .{func.name});
|
try self.output.print(self.allocator, "c.{s}(", .{func.name});
|
||||||
for (func.params, 0..) |param, i| {
|
for (func.params, 0..) |param, i| {
|
||||||
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
if (i > 0) try self.output.appendSlice(self.allocator, ", ");
|
||||||
if (param.name.len > 0) {
|
if (param.name.len > 0) {
|
||||||
const zig_param_type = try self.convertFunctionParamType(func, param);
|
try self.writeCallArg(param.name, param.type_name);
|
||||||
defer self.allocator.free(zig_param_type);
|
|
||||||
const param_cast = self.getFunctionParamCastType(param, zig_param_type);
|
|
||||||
|
|
||||||
if (param_cast == .none) {
|
|
||||||
try self.output.writer(self.allocator).print("{s}", .{param.name});
|
|
||||||
} else {
|
|
||||||
try self.output.writer(self.allocator).print("{s}({s})", .{ castTypeToString(param_cast), param.name });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (return_cast != .none) {
|
try self.output.appendSlice(self.allocator, ")");
|
||||||
try self.output.appendSlice(self.allocator, "));\n");
|
try self.output.appendSlice(self.allocator, return_cast.returnSuffix());
|
||||||
} else {
|
try self.output.appendSlice(self.allocator, ";\n");
|
||||||
try self.output.appendSlice(self.allocator, ");\n");
|
|
||||||
}
|
|
||||||
try self.output.appendSlice(self.allocator, "}\n\n");
|
try self.output.appendSlice(self.allocator, "}\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -694,11 +760,78 @@ pub const CodeGen = struct {
|
||||||
return zig_type;
|
return zig_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getFunctionParamCastType(self: *CodeGen, param: patterns.ParamDecl, zig_param_type: []const u8) types.CastType {
|
fn writeCallArg(self: *CodeGen, name: []const u8, c_type: []const u8) !void {
|
||||||
if (self.isSDLPointerArrayParam(param.type_name)) {
|
switch (self.castForCType(c_type)) {
|
||||||
return .ptr_cast;
|
.none => try self.output.appendSlice(self.allocator, name),
|
||||||
|
.ptr => try self.output.print(self.allocator, "@ptrCast(@alignCast({s}))", .{name}),
|
||||||
|
.bit => try self.output.print(self.allocator, "@bitCast({s})", .{name}),
|
||||||
|
.enumeration => try self.output.print(self.allocator, "@intCast(@backingInt({s}))", .{name}),
|
||||||
|
.aggregate => try self.output.print(self.allocator, "@as(*const c.{s}, @ptrCast(@alignCast(&{s}))).*", .{
|
||||||
|
std.mem.trim(u8, c_type, " \t"),
|
||||||
|
name,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
return types.getParamCastType(zig_param_type);
|
}
|
||||||
|
|
||||||
|
fn writeReturnPrefix(self: *CodeGen, cast: Cast, zig_return_type: []const u8) !void {
|
||||||
|
switch (cast) {
|
||||||
|
.aggregate => try self.output.print(self.allocator, "@as(*const {s}, @ptrCast(@alignCast(&", .{zig_return_type}),
|
||||||
|
else => try self.output.appendSlice(self.allocator, cast.returnPrefix()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Finds the declaration of an SDL C type (e.g. "SDL_Window") among the
|
||||||
|
/// primary and dependency declarations of this module.
|
||||||
|
fn findTypeDecl(self: *CodeGen, c_name: []const u8) ?patterns.Declaration {
|
||||||
|
for (self.decls) |resolved| {
|
||||||
|
const name = resolved.typeName() orelse continue;
|
||||||
|
if (std.mem.eql(u8, name, c_name)) return resolved.decl;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determines how a value of the given C type has to be converted when it
|
||||||
|
/// crosses between the generated Zig API and the translated C API. The
|
||||||
|
/// decision is based on how the type is declared rather than on its name.
|
||||||
|
fn castForCType(self: *CodeGen, c_type: []const u8) Cast {
|
||||||
|
return self.castForCTypeDepth(c_type, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn castForCTypeDepth(self: *CodeGen, c_type: []const u8, depth: u32) Cast {
|
||||||
|
if (depth > 8) return .none;
|
||||||
|
const trimmed = std.mem.trim(u8, c_type, " \t");
|
||||||
|
|
||||||
|
// Inline function pointer types are re-declared with Zig types.
|
||||||
|
if (std.mem.indexOfScalar(u8, trimmed, '(') != null) return .ptr;
|
||||||
|
if (std.mem.indexOfScalar(u8, trimmed, '[') != null) return .none;
|
||||||
|
|
||||||
|
if (std.mem.indexOfScalar(u8, trimmed, '*')) |first_star| {
|
||||||
|
var base = std.mem.trim(u8, trimmed[0..first_star], " \t");
|
||||||
|
if (std.mem.startsWith(u8, base, "const ")) base = std.mem.trim(u8, base[6..], " \t");
|
||||||
|
if (std.mem.endsWith(u8, base, " const")) base = std.mem.trim(u8, base[0 .. base.len - 6], " \t");
|
||||||
|
// Pointers to forward declared structs are exposed as `?*anyopaque`.
|
||||||
|
if (std.mem.startsWith(u8, base, "struct ")) return .ptr;
|
||||||
|
// SDL uses C bool, but pointers to it are not guaranteed to coerce.
|
||||||
|
return switch (self.castForCTypeDepth(base, depth + 1)) {
|
||||||
|
.none => .none,
|
||||||
|
else => .ptr,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, trimmed, "bool") or std.mem.eql(u8, trimmed, "SDL_bool")) return .bit;
|
||||||
|
|
||||||
|
const decl = self.findTypeDecl(trimmed) orelse return .none;
|
||||||
|
return switch (decl) {
|
||||||
|
.opaque_type => .ptr,
|
||||||
|
.typedef_decl => |typedef_decl| self.castForCTypeDepth(typedef_decl.underlying_type, depth + 1),
|
||||||
|
.function_pointer_decl => .ptr,
|
||||||
|
.c_type_alias => .none,
|
||||||
|
.enum_decl => |enum_decl| if (self.enumShouldBeFlags(enum_decl)) .bit else .enumeration,
|
||||||
|
.struct_decl => |struct_decl| if (struct_decl.has_unions) .ptr else .aggregate,
|
||||||
|
.union_decl => .aggregate,
|
||||||
|
.flag_decl => .bit,
|
||||||
|
.function_decl => .none,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paramMayBeNull(self: *CodeGen, func: patterns.FunctionDecl, param_name: []const u8) bool {
|
fn paramMayBeNull(self: *CodeGen, func: patterns.FunctionDecl, param_name: []const u8) bool {
|
||||||
|
|
@ -758,36 +891,6 @@ pub const CodeGen = struct {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn isSDLPointerArrayParam(self: *CodeGen, c_type: []const u8) bool {
|
|
||||||
_ = self;
|
|
||||||
const trimmed = std.mem.trim(u8, c_type, " \t");
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "(SDLCALL *") != null or std.mem.indexOf(u8, trimmed, "(*") != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (std.mem.count(u8, trimmed, "*") < 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rest = trimmed;
|
|
||||||
if (std.mem.startsWith(u8, rest, "const ")) {
|
|
||||||
rest = std.mem.trim(u8, rest[6..], " \t");
|
|
||||||
}
|
|
||||||
|
|
||||||
const first_star = std.mem.indexOfScalar(u8, rest, '*') orelse return false;
|
|
||||||
const base_type = std.mem.trim(u8, rest[0..first_star], " \t");
|
|
||||||
return std.mem.startsWith(u8, base_type, "SDL_");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn castTypeToString(cast_type: types.CastType) []const u8 {
|
|
||||||
return switch (cast_type) {
|
|
||||||
.none => "none",
|
|
||||||
.ptr_cast => "@ptrCast",
|
|
||||||
.bit_cast => "@bitCast",
|
|
||||||
.int_from_enum => "@intFromEnum",
|
|
||||||
.enum_from_int => "@enumFromInt",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn writeDocComment(self: *CodeGen, comment: []const u8) !void {
|
fn writeDocComment(self: *CodeGen, comment: []const u8) !void {
|
||||||
_ = self;
|
_ = self;
|
||||||
_ = comment;
|
_ = comment;
|
||||||
|
|
@ -986,5 +1089,147 @@ test "opaque methods cast enum params to C ABI" {
|
||||||
});
|
});
|
||||||
defer allocator.free(output);
|
defer allocator.free(output);
|
||||||
|
|
||||||
try std.testing.expect(std.mem.indexOf(u8, output, "@intFromEnum(index_element_size)") != null);
|
try std.testing.expect(std.mem.indexOf(u8, output, "@intCast(@backingInt(index_element_size))") != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn testGenerate(allocator: Allocator, decls: []const ResolvedDecl) ![]const u8 {
|
||||||
|
return CodeGen.generate(allocator, .{ .decls = decls, .module_name = "video", .c_import_path = "c.zig" });
|
||||||
|
}
|
||||||
|
|
||||||
|
test "flags are laid out by bit position with padding for gaps" {
|
||||||
|
const allocator = std.testing.allocator;
|
||||||
|
|
||||||
|
var decls: std.ArrayList(ResolvedDecl) = .empty;
|
||||||
|
defer {
|
||||||
|
for (decls.items) |decl| decl.deinit(allocator);
|
||||||
|
decls.deinit(allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
const flags = try allocator.alloc(patterns.FlagValue, 3);
|
||||||
|
flags[0] = .{ .name = try allocator.dupe(u8, "SDL_WINDOW_FULLSCREEN"), .value = try allocator.dupe(u8, "SDL_UINT64_C(0x0000000000000001)"), .comment = null };
|
||||||
|
flags[1] = .{ .name = try allocator.dupe(u8, "SDL_WINDOW_VULKAN"), .value = try allocator.dupe(u8, "SDL_UINT64_C(0x0000000010000000)"), .comment = null };
|
||||||
|
flags[2] = .{ .name = try allocator.dupe(u8, "SDL_WINDOW_OPENGL"), .value = try allocator.dupe(u8, "SDL_UINT64_C(0x0000000000000002)"), .comment = null };
|
||||||
|
try decls.append(allocator, .{
|
||||||
|
.decl = .{ .flag_decl = .{
|
||||||
|
.name = try allocator.dupe(u8, "SDL_WindowFlags"),
|
||||||
|
.underlying_type = try allocator.dupe(u8, "Uint64"),
|
||||||
|
.flags = flags,
|
||||||
|
.constants = &.{},
|
||||||
|
.doc_comment = null,
|
||||||
|
} },
|
||||||
|
.source_header = try allocator.dupe(u8, "SDL_video.h"),
|
||||||
|
.is_primary_header_decl = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = try testGenerate(allocator, decls.items);
|
||||||
|
defer allocator.free(output);
|
||||||
|
|
||||||
|
const expected =
|
||||||
|
\\pub const WindowFlags = packed struct(u64) {
|
||||||
|
\\ windowFullscreen: bool = false,
|
||||||
|
\\ windowOpengl: bool = false,
|
||||||
|
\\ pad0: u26 = 0,
|
||||||
|
\\ windowVulkan: bool = false,
|
||||||
|
\\ pad1: u34 = 0,
|
||||||
|
\\ rsvd: bool = false,
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
try std.testing.expect(std.mem.indexOf(u8, output, expected) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "enum values are numbered like C and duplicates become aliases" {
|
||||||
|
const allocator = std.testing.allocator;
|
||||||
|
|
||||||
|
var decls: std.ArrayList(ResolvedDecl) = .empty;
|
||||||
|
defer {
|
||||||
|
for (decls.items) |decl| decl.deinit(allocator);
|
||||||
|
decls.deinit(allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
const names = [_][]const u8{ "SDL_EVENT_FIRST", "SDL_EVENT_QUIT", "SDL_EVENT_DISPLAY_ADDED", "SDL_EVENT_DISPLAY_FIRST", "SDL_EVENT_DISPLAY_REMOVED" };
|
||||||
|
const raw_values = [_]?[]const u8{ "0", "0x100", null, "SDL_EVENT_DISPLAY_ADDED", null };
|
||||||
|
const values = try allocator.alloc(patterns.EnumValue, names.len);
|
||||||
|
for (names, raw_values, 0..) |name, raw, i| {
|
||||||
|
values[i] = .{
|
||||||
|
.name = try allocator.dupe(u8, name),
|
||||||
|
.value = if (raw) |r| try allocator.dupe(u8, r) else null,
|
||||||
|
.comment = null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
try decls.append(allocator, .{
|
||||||
|
.decl = .{ .enum_decl = .{
|
||||||
|
.name = try allocator.dupe(u8, "SDL_EventType"),
|
||||||
|
.values = values,
|
||||||
|
.doc_comment = null,
|
||||||
|
} },
|
||||||
|
.source_header = try allocator.dupe(u8, "SDL_video.h"),
|
||||||
|
.is_primary_header_decl = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = try testGenerate(allocator, decls.items);
|
||||||
|
defer allocator.free(output);
|
||||||
|
|
||||||
|
const expected =
|
||||||
|
\\pub const EventType = enum(c_int) {
|
||||||
|
\\ eventFirst = 0,
|
||||||
|
\\ eventQuit = 0x100,
|
||||||
|
\\ eventDisplayAdded,
|
||||||
|
\\ eventDisplayRemoved,
|
||||||
|
\\
|
||||||
|
\\ pub const eventDisplayFirst = .eventDisplayAdded;
|
||||||
|
\\};
|
||||||
|
;
|
||||||
|
try std.testing.expect(std.mem.indexOf(u8, output, expected) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "casts follow how a type is declared" {
|
||||||
|
const allocator = std.testing.allocator;
|
||||||
|
|
||||||
|
var decls: std.ArrayList(ResolvedDecl) = .empty;
|
||||||
|
defer {
|
||||||
|
for (decls.items) |decl| decl.deinit(allocator);
|
||||||
|
decls.deinit(allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
try decls.append(allocator, .{
|
||||||
|
.decl = .{ .struct_decl = .{
|
||||||
|
.name = try allocator.dupe(u8, "SDL_GUID"),
|
||||||
|
.fields = &.{},
|
||||||
|
.doc_comment = null,
|
||||||
|
.has_unions = false,
|
||||||
|
} },
|
||||||
|
.source_header = try allocator.dupe(u8, "SDL_video.h"),
|
||||||
|
.is_primary_header_decl = true,
|
||||||
|
});
|
||||||
|
const enum_values = try allocator.alloc(patterns.EnumValue, 1);
|
||||||
|
enum_values[0] = .{ .name = try allocator.dupe(u8, "SDL_POWERSTATE_UNKNOWN"), .value = null, .comment = null };
|
||||||
|
try decls.append(allocator, .{
|
||||||
|
.decl = .{ .enum_decl = .{
|
||||||
|
.name = try allocator.dupe(u8, "SDL_PowerState"),
|
||||||
|
.values = enum_values,
|
||||||
|
.doc_comment = null,
|
||||||
|
} },
|
||||||
|
.source_header = try allocator.dupe(u8, "SDL_video.h"),
|
||||||
|
.is_primary_header_decl = true,
|
||||||
|
});
|
||||||
|
const params = try allocator.alloc(patterns.ParamDecl, 3);
|
||||||
|
params[0] = .{ .name = try allocator.dupe(u8, "guid"), .type_name = try allocator.dupe(u8, "SDL_GUID") };
|
||||||
|
params[1] = .{ .name = try allocator.dupe(u8, "out"), .type_name = try allocator.dupe(u8, "SDL_GUID *") };
|
||||||
|
params[2] = .{ .name = try allocator.dupe(u8, "percent"), .type_name = try allocator.dupe(u8, "int *") };
|
||||||
|
try decls.append(allocator, .{
|
||||||
|
.decl = .{ .function_decl = .{
|
||||||
|
.name = try allocator.dupe(u8, "SDL_Example"),
|
||||||
|
.return_type = try allocator.dupe(u8, "SDL_PowerState"),
|
||||||
|
.params = params,
|
||||||
|
.doc_comment = null,
|
||||||
|
} },
|
||||||
|
.source_header = try allocator.dupe(u8, "SDL_video.h"),
|
||||||
|
.is_primary_header_decl = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = try testGenerate(allocator, decls.items);
|
||||||
|
defer allocator.free(output);
|
||||||
|
|
||||||
|
const expected = "return @fromBackingInt(@intCast(c.SDL_Example(@as(*const c.SDL_GUID, @ptrCast(@alignCast(&guid))).*, @ptrCast(@alignCast(out)), percent)));";
|
||||||
|
try std.testing.expect(std.mem.indexOf(u8, output, expected) != null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ pub const DependencyResolver = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getMissingTypes(self: *DependencyResolver, allocator: Allocator) ![][]const u8 {
|
pub fn getMissingTypes(self: *DependencyResolver, allocator: Allocator) ![][]const u8 {
|
||||||
var missing = std.ArrayList([]const u8){};
|
var missing = std.ArrayList([]const u8).empty;
|
||||||
|
|
||||||
var it = self.referenced_types.keyIterator();
|
var it = self.referenced_types.keyIterator();
|
||||||
while (it.next()) |key| {
|
while (it.next()) |key| {
|
||||||
|
|
@ -220,7 +220,7 @@ fn isSDLType(type_str: []const u8) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parseIncludes(allocator: Allocator, source: []const u8) ![][]const u8 {
|
pub fn parseIncludes(allocator: Allocator, source: []const u8) ![][]const u8 {
|
||||||
var includes = std.ArrayList([]const u8){};
|
var includes = std.ArrayList([]const u8).empty;
|
||||||
|
|
||||||
var lines = std.mem.splitScalar(u8, source, '\n');
|
var lines = std.mem.splitScalar(u8, source, '\n');
|
||||||
while (lines.next()) |line| {
|
while (lines.next()) |line| {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const patterns = @import("patterns.zig");
|
const patterns = @import("patterns.zig");
|
||||||
|
const io = @import("io.zig");
|
||||||
const resolved_decl = @import("resolved_decl.zig");
|
const resolved_decl = @import("resolved_decl.zig");
|
||||||
|
|
||||||
const Declaration = patterns.Declaration;
|
const Declaration = patterns.Declaration;
|
||||||
|
|
@ -70,7 +71,7 @@ pub const HeaderCache = struct {
|
||||||
|
|
||||||
std.debug.print(" Caching types from: {s}\n", .{filename});
|
std.debug.print(" Caching types from: {s}\n", .{filename});
|
||||||
|
|
||||||
const content = std.fs.cwd().readFileAlloc(self.allocator, full_path, 10_000_000) catch |err| {
|
const content = io.cwd().readFileAlloc(io.get(), full_path, self.allocator, .limited(10_000_000)) catch |err| {
|
||||||
std.debug.print(" Warning: Could not read {s}: {}\n", .{ filename, err });
|
std.debug.print(" Warning: Could not read {s}: {}\n", .{ filename, err });
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
29
src/io.zig
29
src/io.zig
|
|
@ -1,14 +1,22 @@
|
||||||
var stdout_buffer: [1024]u8 = undefined;
|
//! Process-wide I/O context, set once from `main`.
|
||||||
var stdout_writer: *std.Io.Writer = undefined;
|
pub const std = @import("std");
|
||||||
var stdout_file: std.fs.Writer = undefined;
|
|
||||||
|
|
||||||
pub fn stdout() *std.Io.Writer {
|
var global_io: std.Io = undefined;
|
||||||
return stdout_writer;
|
|
||||||
|
pub fn init(new_io: std.Io) void {
|
||||||
|
global_io = new_io;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initWriter() void {
|
pub fn get() std.Io {
|
||||||
stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
|
return global_io;
|
||||||
stdout = &stdout_writer.interface;
|
}
|
||||||
|
|
||||||
|
pub fn cwd() std.Io.Dir {
|
||||||
|
return std.Io.Dir.cwd();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn writeStdout(bytes: []const u8) !void {
|
||||||
|
try std.Io.File.stdout().writeStreamingAll(global_io, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emitError(src: std.builtin.SourceLocation, errorMessage: []const u8) void {
|
pub fn emitError(src: std.builtin.SourceLocation, errorMessage: []const u8) void {
|
||||||
|
|
@ -16,9 +24,6 @@ pub fn emitError(src: std.builtin.SourceLocation, errorMessage: []const u8) void
|
||||||
std.debug.print("in {s}:{d} module: {s}", .{ src.file, src.line, src.module });
|
std.debug.print("in {s}:{d} module: {s}", .{ src.file, src.line, src.module });
|
||||||
std.debug.print("function: {s}", .{src.fn_name});
|
std.debug.print("function: {s}", .{src.fn_name});
|
||||||
std.debug.print("message: '{s}'", .{errorMessage});
|
std.debug.print("message: '{s}'", .{errorMessage});
|
||||||
std.debug.dumpCurrentStackTrace(null);
|
std.debug.dumpCurrentStackTrace(.{});
|
||||||
std.debug.print("---- /Error occured -----\n", .{});
|
std.debug.print("---- /Error occured -----\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const std = @import("std");
|
|
||||||
const buildOptions = @import("buildOptions");
|
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,17 @@ pub const JsonSerializer = struct {
|
||||||
pub fn init(allocator: std.mem.Allocator, header_name: []const u8) JsonSerializer {
|
pub fn init(allocator: std.mem.Allocator, header_name: []const u8) JsonSerializer {
|
||||||
return .{
|
return .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.output = .{},
|
.output = .empty,
|
||||||
.header_name = header_name,
|
.header_name = header_name,
|
||||||
.opaque_types = .{},
|
.opaque_types = .empty,
|
||||||
.typedefs = .{},
|
.typedefs = .empty,
|
||||||
.function_pointers = .{},
|
.function_pointers = .empty,
|
||||||
.c_type_aliases = .{},
|
.c_type_aliases = .empty,
|
||||||
.enums = .{},
|
.enums = .empty,
|
||||||
.structs = .{},
|
.structs = .empty,
|
||||||
.unions = .{},
|
.unions = .empty,
|
||||||
.flags = .{},
|
.flags = .empty,
|
||||||
.functions = .{},
|
.functions = .empty,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,9 @@ pub const JsonSerializer = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(self: *JsonSerializer) ![]const u8 {
|
pub fn finalize(self: *JsonSerializer) ![]const u8 {
|
||||||
var writer = self.output.writer(self.allocator);
|
var allocating: std.Io.Writer.Allocating = .fromArrayList(self.allocator, &self.output);
|
||||||
|
errdefer self.output = allocating.toArrayList();
|
||||||
|
const writer = &allocating.writer;
|
||||||
|
|
||||||
try writer.writeAll("{\n");
|
try writer.writeAll("{\n");
|
||||||
try writer.writeAll(" \"header\": ");
|
try writer.writeAll(" \"header\": ");
|
||||||
|
|
@ -161,6 +163,7 @@ pub const JsonSerializer = struct {
|
||||||
|
|
||||||
try writer.writeAll("}\n");
|
try writer.writeAll("}\n");
|
||||||
|
|
||||||
|
self.output = allocating.toArrayList();
|
||||||
return self.output.items;
|
return self.output.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,9 @@ pub const MockCodeGen = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeFunctionMock(self: *MockCodeGen, func: patterns.FunctionDecl) !void {
|
fn writeFunctionMock(self: *MockCodeGen, func: patterns.FunctionDecl) !void {
|
||||||
const writer = self.output.writer(self.allocator);
|
var allocating: std.Io.Writer.Allocating = .fromArrayList(self.allocator, &self.output);
|
||||||
|
defer self.output = allocating.toArrayList();
|
||||||
|
const writer = &allocating.writer;
|
||||||
|
|
||||||
// Write return type and function name
|
// Write return type and function name
|
||||||
try writer.print("{s} {s}(", .{ func.return_type, func.name });
|
try writer.print("{s} {s}(", .{ func.return_type, func.name });
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ test "mock generation - void function" {
|
||||||
try testing.expect(std.mem.indexOf(u8, output, "(void)device") != null);
|
try testing.expect(std.mem.indexOf(u8, output, "(void)device") != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "mock generation - opaque type forward declaration" {
|
test "mock generation - opaque types are not redeclared" {
|
||||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
const allocator = arena.allocator();
|
const allocator = arena.allocator();
|
||||||
|
|
@ -79,8 +79,8 @@ test "mock generation - opaque type forward declaration" {
|
||||||
|
|
||||||
const output = try mock_codegen.MockCodeGen.generate(allocator, decls);
|
const output = try mock_codegen.MockCodeGen.generate(allocator, decls);
|
||||||
|
|
||||||
// Should have typedef struct
|
// Opaque types come from the SDL headers and must not be redeclared
|
||||||
try testing.expect(std.mem.indexOf(u8, output, "typedef struct SDL_GPUDevice SDL_GPUDevice") != null);
|
try testing.expect(std.mem.indexOf(u8, output, "typedef struct SDL_GPUDevice") == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "mock generation - header and includes" {
|
test "mock generation - header and includes" {
|
||||||
|
|
@ -91,9 +91,8 @@ test "mock generation - header and includes" {
|
||||||
const decls = try allocator.dupe(patterns.Declaration, &[_]patterns.Declaration{});
|
const decls = try allocator.dupe(patterns.Declaration, &[_]patterns.Declaration{});
|
||||||
const output = try mock_codegen.MockCodeGen.generate(allocator, decls);
|
const output = try mock_codegen.MockCodeGen.generate(allocator, decls);
|
||||||
|
|
||||||
// Should have standard headers
|
// Types are provided by the SDL headers
|
||||||
try testing.expect(std.mem.indexOf(u8, output, "#include <stdint.h>") != null);
|
try testing.expect(std.mem.indexOf(u8, output, "#include <SDL3/SDL_stdinc.h>") != null);
|
||||||
try testing.expect(std.mem.indexOf(u8, output, "#include <stdbool.h>") != null);
|
|
||||||
// Should have auto-generated comment
|
// Should have auto-generated comment
|
||||||
try testing.expect(std.mem.indexOf(u8, output, "Auto-generated") != null);
|
try testing.expect(std.mem.indexOf(u8, output, "Auto-generated") != null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
118
src/parser.zig
118
src/parser.zig
|
|
@ -14,14 +14,14 @@ pub fn freeDecls(allocator: std.mem.Allocator, decls: []patterns.Declaration) vo
|
||||||
allocator.free(decls);
|
allocator.free(decls);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main(init: std.process.Init) !void {
|
||||||
const allocator = std.heap.smp_allocator;
|
const allocator = std.heap.smp_allocator;
|
||||||
|
io.init(init.io);
|
||||||
|
|
||||||
const args = try std.process.argsAlloc(allocator);
|
const args = try init.minimal.args.toSlice(init.arena.allocator());
|
||||||
defer std.process.argsFree(allocator, args);
|
|
||||||
|
|
||||||
if (args.len < 2) {
|
if (args.len < 2) {
|
||||||
std.debug.print("Usage: {s} <header-file> [--output=<output-file>] [--mocks=<mock-file>] [--generate-json=<json-file>] [--timestamp=<timestamp>] [--basedir=<directory>]\n", .{args[0]});
|
std.debug.print("Usage: {s} <header-file> [--output=<output-file>] [--mocks=<mock-file>] [--generate-json=<json-file>] [--timestamp=<timestamp>] [--basedir=<directory>] [--c-import=<path>] [--skip-missing]\n", .{args[0]});
|
||||||
std.debug.print("Example: {s} ../SDL/include/SDL3/SDL_gpu.h --output=gpu.zig\n", .{args[0]});
|
std.debug.print("Example: {s} ../SDL/include/SDL3/SDL_gpu.h --output=gpu.zig\n", .{args[0]});
|
||||||
std.debug.print(" {s} ../SDL/include/SDL3/SDL_gpu.h --output=gpu.zig --mocks=gpu_mock.c\n", .{args[0]});
|
std.debug.print(" {s} ../SDL/include/SDL3/SDL_gpu.h --output=gpu.zig --mocks=gpu_mock.c\n", .{args[0]});
|
||||||
std.debug.print(" {s} ../SDL/include/SDL3/SDL_gpu.h --generate-json=gpu.json\n", .{args[0]});
|
std.debug.print(" {s} ../SDL/include/SDL3/SDL_gpu.h --generate-json=gpu.json\n", .{args[0]});
|
||||||
|
|
@ -30,7 +30,7 @@ pub fn main() !void {
|
||||||
return error.MissingArgument;
|
return error.MissingArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
const header_path = args[1];
|
var header_path: []const u8 = args[1];
|
||||||
|
|
||||||
var output_file: ?[]const u8 = null;
|
var output_file: ?[]const u8 = null;
|
||||||
var mock_output_file: ?[]const u8 = null;
|
var mock_output_file: ?[]const u8 = null;
|
||||||
|
|
@ -38,6 +38,7 @@ pub fn main() !void {
|
||||||
var timestamp: ?i64 = null;
|
var timestamp: ?i64 = null;
|
||||||
var basedir: ?[]const u8 = null;
|
var basedir: ?[]const u8 = null;
|
||||||
var c_import_path: []const u8 = "c.zig";
|
var c_import_path: []const u8 = "c.zig";
|
||||||
|
var skip_missing = false;
|
||||||
|
|
||||||
// Parse additional flags
|
// Parse additional flags
|
||||||
for (args[2..]) |arg| {
|
for (args[2..]) |arg| {
|
||||||
|
|
@ -59,16 +60,27 @@ pub fn main() !void {
|
||||||
basedir = arg[basedir_prefix.len..];
|
basedir = arg[basedir_prefix.len..];
|
||||||
} else if (std.mem.startsWith(u8, arg, c_import_prefix)) {
|
} else if (std.mem.startsWith(u8, arg, c_import_prefix)) {
|
||||||
c_import_path = arg[c_import_prefix.len..];
|
c_import_path = arg[c_import_prefix.len..];
|
||||||
|
} else if (std.mem.eql(u8, arg, "--skip-missing")) {
|
||||||
|
skip_missing = true;
|
||||||
} else {
|
} else {
|
||||||
std.debug.print("Error: Unknown argument '{s}'\n", .{arg});
|
std.debug.print("Error: Unknown argument '{s}'\n", .{arg});
|
||||||
std.debug.print("Usage: {s} <header-file> [--output=<output-file>] [--mocks=<mock-file>] [--generate-json=<json-file>] [--timestamp=<timestamp>] [--basedir=<directory>]\n", .{args[0]});
|
std.debug.print("Usage: {s} <header-file> [--output=<output-file>] [--mocks=<mock-file>] [--generate-json=<json-file>] [--timestamp=<timestamp>] [--basedir=<directory>] [--c-import=<path>] [--skip-missing]\n", .{args[0]});
|
||||||
return error.InvalidArgument;
|
return error.InvalidArgument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change working directory if --basedir is specified
|
// Change working directory if --basedir is specified. The base directory
|
||||||
|
// only decides where tmp/, debug/ and archive/ end up: input and output
|
||||||
|
// paths keep referring to the directory the parser was started from.
|
||||||
if (basedir) |dir| {
|
if (basedir) |dir| {
|
||||||
try std.posix.chdir(dir);
|
const arena = init.arena.allocator();
|
||||||
|
const original_cwd = try std.process.currentPathAlloc(io.get(), arena);
|
||||||
|
header_path = try std.fs.path.resolve(arena, &.{ original_cwd, header_path });
|
||||||
|
if (output_file) |path| output_file = try std.fs.path.resolve(arena, &.{ original_cwd, path });
|
||||||
|
if (mock_output_file) |path| mock_output_file = try std.fs.path.resolve(arena, &.{ original_cwd, path });
|
||||||
|
if (json_output_file) |path| json_output_file = try std.fs.path.resolve(arena, &.{ original_cwd, path });
|
||||||
|
|
||||||
|
try std.process.setCurrentPath(io.get(), dir);
|
||||||
std.debug.print("Changed working directory to: {s}\n\n", .{dir});
|
std.debug.print("Changed working directory to: {s}\n\n", .{dir});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +92,14 @@ pub fn main() !void {
|
||||||
std.debug.print("Parsing: {s}\n\n", .{header_path});
|
std.debug.print("Parsing: {s}\n\n", .{header_path});
|
||||||
|
|
||||||
// Read the header file
|
// Read the header file
|
||||||
const source = try std.fs.cwd().readFileAlloc(allocator, header_path, 10 * 1024 * 1024); // 10MB max
|
const source = io.cwd().readFileAlloc(io.get(), header_path, allocator, .limited(10 * 1024 * 1024)) catch |err| switch (err) {
|
||||||
|
// Not every SDL release ships every header (e.g. SDL_tray.h is newer).
|
||||||
|
error.FileNotFound => if (skip_missing) {
|
||||||
|
std.debug.print("Skipping {s}: header does not exist in this SDL version\n", .{header_path});
|
||||||
|
return;
|
||||||
|
} else return err,
|
||||||
|
else => return err,
|
||||||
|
}; // 10MB max
|
||||||
defer allocator.free(source);
|
defer allocator.free(source);
|
||||||
|
|
||||||
// Parse declarations
|
// Parse declarations
|
||||||
|
|
@ -150,16 +169,14 @@ pub fn main() !void {
|
||||||
const parsed = try std.json.parseFromSlice(std.json.Value, allocator, json_output, .{});
|
const parsed = try std.json.parseFromSlice(std.json.Value, allocator, json_output, .{});
|
||||||
defer parsed.deinit();
|
defer parsed.deinit();
|
||||||
|
|
||||||
var formatted_output: std.ArrayList(u8) = .empty;
|
|
||||||
defer formatted_output.deinit(allocator);
|
|
||||||
|
|
||||||
const formatter = std.json.fmt(parsed.value, .{ .whitespace = .indent_2 });
|
const formatter = std.json.fmt(parsed.value, .{ .whitespace = .indent_2 });
|
||||||
try std.fmt.format(formatted_output.writer(allocator), "{f}", .{formatter});
|
const formatted_output = try std.fmt.allocPrint(allocator, "{f}", .{formatter});
|
||||||
|
defer allocator.free(formatted_output);
|
||||||
|
|
||||||
try ensureParentDirExists(json_path);
|
try ensureParentDirExists(json_path);
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = json_path,
|
.sub_path = json_path,
|
||||||
.data = formatted_output.items,
|
.data = formatted_output,
|
||||||
});
|
});
|
||||||
serializer.deinit();
|
serializer.deinit();
|
||||||
std.debug.print("Generated JSON: {s}\n", .{json_path});
|
std.debug.print("Generated JSON: {s}\n", .{json_path});
|
||||||
|
|
@ -297,10 +314,10 @@ pub fn main() !void {
|
||||||
defer allocator.free(output);
|
defer allocator.free(output);
|
||||||
|
|
||||||
// Parse and format the AST for validation
|
// Parse and format the AST for validation
|
||||||
const output_z = try allocator.dupeZ(u8, output);
|
const output_z = try allocator.dupeSentinel(u8, output, 0);
|
||||||
defer allocator.free(output_z);
|
defer allocator.free(output_z);
|
||||||
|
|
||||||
var ast = try std.zig.Ast.parse(allocator, output_z, .zig);
|
var ast = try std.zig.Ast.parse(allocator, output_z, .{});
|
||||||
defer ast.deinit(allocator);
|
defer ast.deinit(allocator);
|
||||||
|
|
||||||
// Check for parse errors
|
// Check for parse errors
|
||||||
|
|
@ -317,7 +334,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
// Write unformatted output for debugging
|
// Write unformatted output for debugging
|
||||||
if (output_file) |file_path| {
|
if (output_file) |file_path| {
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = file_path,
|
.sub_path = file_path,
|
||||||
.data = output,
|
.data = output,
|
||||||
});
|
});
|
||||||
|
|
@ -339,7 +356,7 @@ pub fn main() !void {
|
||||||
if (output_file) |file_path| {
|
if (output_file) |file_path| {
|
||||||
try writeZigFileWithFmt(allocator, header_path, file_path, formatted_output);
|
try writeZigFileWithFmt(allocator, header_path, file_path, formatted_output);
|
||||||
} else {
|
} else {
|
||||||
_ = try io.stdout().write(formatted_output);
|
try io.writeStdout(formatted_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate C mocks if requested (with flat declarations)
|
// Generate C mocks if requested (with flat declarations)
|
||||||
|
|
@ -361,7 +378,7 @@ pub fn main() !void {
|
||||||
defer allocator.free(mock_output);
|
defer allocator.free(mock_output);
|
||||||
|
|
||||||
try ensureParentDirExists(mock_path);
|
try ensureParentDirExists(mock_path);
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = mock_path,
|
.sub_path = mock_path,
|
||||||
.data = mock_output,
|
.data = mock_output,
|
||||||
});
|
});
|
||||||
|
|
@ -374,7 +391,7 @@ fn writeZigFileWithFmt(allocator: std.mem.Allocator, header_path: []const u8, ou
|
||||||
const output_basename = std.fs.path.basename(output_path);
|
const output_basename = std.fs.path.basename(output_path);
|
||||||
|
|
||||||
// Create tmp directory
|
// Create tmp directory
|
||||||
std.fs.cwd().makePath("tmp") catch |err| switch (err) {
|
io.cwd().createDirPath(io.get(), "tmp") catch |err| switch (err) {
|
||||||
error.PathAlreadyExists => {},
|
error.PathAlreadyExists => {},
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
@ -383,20 +400,21 @@ fn writeZigFileWithFmt(allocator: std.mem.Allocator, header_path: []const u8, ou
|
||||||
const tmp_path = try std.fmt.allocPrint(allocator, "tmp/{s}", .{output_basename});
|
const tmp_path = try std.fmt.allocPrint(allocator, "tmp/{s}", .{output_basename});
|
||||||
defer allocator.free(tmp_path);
|
defer allocator.free(tmp_path);
|
||||||
|
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = tmp_path,
|
.sub_path = tmp_path,
|
||||||
.data = content,
|
.data = content,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run zig ast-check on tmp file
|
// Run zig ast-check on tmp file
|
||||||
var ast_check = std.process.Child.init(&.{ "zig", "ast-check", tmp_path }, allocator);
|
var ast_check = try std.process.spawn(io.get(), .{
|
||||||
ast_check.stderr_behavior = .Pipe;
|
.argv = &.{ "zig", "ast-check", tmp_path },
|
||||||
try ast_check.spawn();
|
.stderr = .ignore,
|
||||||
const ast_result = try ast_check.wait();
|
});
|
||||||
|
const ast_result = try ast_check.wait(io.get());
|
||||||
|
|
||||||
if (ast_result.Exited != 0) {
|
if (!ast_result.success()) {
|
||||||
// zig ast-check failed - copy to debug folder
|
// zig ast-check failed - copy to debug folder
|
||||||
std.fs.cwd().makePath("debug") catch |err| switch (err) {
|
io.cwd().createDirPath(io.get(), "debug") catch |err| switch (err) {
|
||||||
error.PathAlreadyExists => {},
|
error.PathAlreadyExists => {},
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
@ -411,7 +429,7 @@ fn writeZigFileWithFmt(allocator: std.mem.Allocator, header_path: []const u8, ou
|
||||||
const debug_path = try std.fmt.allocPrint(allocator, "debug/{s}_fmterror.zig", .{safe_name});
|
const debug_path = try std.fmt.allocPrint(allocator, "debug/{s}_fmterror.zig", .{safe_name});
|
||||||
defer allocator.free(debug_path);
|
defer allocator.free(debug_path);
|
||||||
|
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = debug_path,
|
.sub_path = debug_path,
|
||||||
.data = content,
|
.data = content,
|
||||||
});
|
});
|
||||||
|
|
@ -420,18 +438,19 @@ fn writeZigFileWithFmt(allocator: std.mem.Allocator, header_path: []const u8, ou
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run zig fmt on tmp file
|
// Run zig fmt on tmp file
|
||||||
var fmt = std.process.Child.init(&.{ "zig", "fmt", tmp_path }, allocator);
|
var fmt = try std.process.spawn(io.get(), .{
|
||||||
fmt.stderr_behavior = .Pipe;
|
.argv = &.{ "zig", "fmt", tmp_path },
|
||||||
try fmt.spawn();
|
.stderr = .ignore,
|
||||||
_ = try fmt.wait();
|
});
|
||||||
|
_ = try fmt.wait(io.get());
|
||||||
|
|
||||||
// Copy formatted file to final destination
|
// Copy formatted file to final destination
|
||||||
try ensureParentDirExists(output_path);
|
try ensureParentDirExists(output_path);
|
||||||
|
|
||||||
const formatted_content = try std.fs.cwd().readFileAlloc(allocator, tmp_path, 10 * 1024 * 1024);
|
const formatted_content = try io.cwd().readFileAlloc(io.get(), tmp_path, allocator, .limited(10 * 1024 * 1024));
|
||||||
defer allocator.free(formatted_content);
|
defer allocator.free(formatted_content);
|
||||||
|
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = output_path,
|
.sub_path = output_path,
|
||||||
.data = formatted_content,
|
.data = formatted_content,
|
||||||
});
|
});
|
||||||
|
|
@ -440,7 +459,7 @@ fn writeZigFileWithFmt(allocator: std.mem.Allocator, header_path: []const u8, ou
|
||||||
|
|
||||||
fn ensureParentDirExists(path: []const u8) !void {
|
fn ensureParentDirExists(path: []const u8) !void {
|
||||||
if (std.fs.path.dirname(path)) |dir| {
|
if (std.fs.path.dirname(path)) |dir| {
|
||||||
std.fs.cwd().makePath(dir) catch |err| switch (err) {
|
io.cwd().createDirPath(io.get(), dir) catch |err| switch (err) {
|
||||||
error.PathAlreadyExists => {},
|
error.PathAlreadyExists => {},
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
@ -449,19 +468,19 @@ fn ensureParentDirExists(path: []const u8) !void {
|
||||||
|
|
||||||
fn archiveExistingDebugDir(allocator: std.mem.Allocator, provided_timestamp: ?i64) void {
|
fn archiveExistingDebugDir(allocator: std.mem.Allocator, provided_timestamp: ?i64) void {
|
||||||
// Check if debug/ directory exists
|
// Check if debug/ directory exists
|
||||||
var debug_dir = std.fs.cwd().openDir("debug", .{}) catch return;
|
var debug_dir = io.cwd().openDir(io.get(), "debug", .{}) catch return;
|
||||||
debug_dir.close();
|
debug_dir.close(io.get());
|
||||||
|
|
||||||
// Use provided timestamp or generate one
|
// Use provided timestamp or generate one
|
||||||
const timestamp = provided_timestamp orelse std.time.timestamp();
|
const timestamp = provided_timestamp orelse std.Io.Clock.real.now(io.get()).toSeconds();
|
||||||
const archive_path = std.fmt.allocPrint(allocator, "archive/debug/{d}", .{timestamp}) catch return;
|
const archive_path = std.fmt.allocPrint(allocator, "archive/debug/{d}", .{timestamp}) catch return;
|
||||||
defer allocator.free(archive_path);
|
defer allocator.free(archive_path);
|
||||||
|
|
||||||
// Create archive/debug directory if needed
|
// Create archive/debug directory if needed
|
||||||
std.fs.cwd().makePath("archive/debug") catch return;
|
io.cwd().createDirPath(io.get(), "archive/debug") catch return;
|
||||||
|
|
||||||
// Move debug/ to archive/debug/<timestamp>/
|
// Move debug/ to archive/debug/<timestamp>/
|
||||||
std.fs.cwd().rename("debug", archive_path) catch |err| {
|
io.cwd().rename("debug", io.cwd(), archive_path, io.get()) catch |err| {
|
||||||
std.debug.print("Warning: Failed to archive existing debug dir: {}\n", .{err});
|
std.debug.print("Warning: Failed to archive existing debug dir: {}\n", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -484,12 +503,12 @@ fn writeDebugFile(allocator: std.mem.Allocator, header_path: []const u8, output:
|
||||||
defer allocator.free(debug_filename);
|
defer allocator.free(debug_filename);
|
||||||
|
|
||||||
// Create debug directory if it doesn't exist
|
// Create debug directory if it doesn't exist
|
||||||
std.fs.cwd().makeDir("debug") catch |err| switch (err) {
|
io.cwd().createDir(io.get(), "debug", .default_dir) catch |err| switch (err) {
|
||||||
error.PathAlreadyExists => {},
|
error.PathAlreadyExists => {},
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
||||||
try std.fs.cwd().writeFile(.{
|
try io.cwd().writeFile(io.get(), .{
|
||||||
.sub_path = debug_filename,
|
.sub_path = debug_filename,
|
||||||
.data = output,
|
.data = output,
|
||||||
});
|
});
|
||||||
|
|
@ -502,6 +521,15 @@ fn freeDeclDeep(allocator: std.mem.Allocator, decl: patterns.Declaration) void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test "basic test" {
|
test {
|
||||||
try std.testing.expect(true);
|
// Pull in the tests of every module.
|
||||||
|
_ = patterns;
|
||||||
|
_ = codegen;
|
||||||
|
_ = dependency_resolver;
|
||||||
|
_ = json_serializer;
|
||||||
|
_ = header_cache;
|
||||||
|
_ = resolved_decl;
|
||||||
|
_ = @import("types.zig");
|
||||||
|
_ = @import("naming.zig");
|
||||||
|
_ = @import("mock_codegen_test.zig");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
451
src/patterns.zig
451
src/patterns.zig
|
|
@ -357,7 +357,7 @@ pub const Scanner = struct {
|
||||||
// Check they match and end with semicolon
|
// Check they match and end with semicolon
|
||||||
// Or accept mismatched names as long as we have a semicolon (e.g., typedef struct tagMSG MSG;)
|
// Or accept mismatched names as long as we have a semicolon (e.g., typedef struct tagMSG MSG;)
|
||||||
// But reject pointer typedefs (e.g., typedef struct X *Y;) - those should be handled by scanTypedef
|
// But reject pointer typedefs (e.g., typedef struct X *Y;) - those should be handled by scanTypedef
|
||||||
const name2_clean = std.mem.trimRight(u8, name2, ";");
|
const name2_clean = std.mem.trimEnd(u8, name2, ";");
|
||||||
|
|
||||||
// Check if it's a pointer typedef - if either name starts with *, reject it
|
// Check if it's a pointer typedef - if either name starts with *, reject it
|
||||||
if (std.mem.startsWith(u8, name1, "*") or std.mem.startsWith(u8, name2_clean, "*")) {
|
if (std.mem.startsWith(u8, name1, "*") or std.mem.startsWith(u8, name2_clean, "*")) {
|
||||||
|
|
@ -493,7 +493,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
// Parse: typedef Type Name; or typedef struct X *Name;
|
// Parse: typedef Type Name; or typedef struct X *Name;
|
||||||
const trimmed = std.mem.trim(u8, line, " \t\r\n");
|
const trimmed = std.mem.trim(u8, line, " \t\r\n");
|
||||||
const no_semi = std.mem.trimRight(u8, trimmed, ";");
|
const no_semi = std.mem.trimEnd(u8, trimmed, ";");
|
||||||
|
|
||||||
// Find the last token as the name
|
// Find the last token as the name
|
||||||
var tokens = std.mem.tokenizeScalar(u8, no_semi, ' ');
|
var tokens = std.mem.tokenizeScalar(u8, no_semi, ' ');
|
||||||
|
|
@ -558,17 +558,6 @@ pub const Scanner = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn countChar(need: u8, haystack: []const u8) u32 {
|
|
||||||
var i: u32 = 0;
|
|
||||||
for (haystack) |h| {
|
|
||||||
if (h == need) {
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pattern: typedef enum SDL_Foo { ... } SDL_Foo;
|
|
||||||
fn scanEnum(self: *Scanner) !?EnumDecl {
|
fn scanEnum(self: *Scanner) !?EnumDecl {
|
||||||
const start = self.pos;
|
const start = self.pos;
|
||||||
|
|
||||||
|
|
@ -606,127 +595,205 @@ pub const Scanner = struct {
|
||||||
const body = try self.readBracedBlock();
|
const body = try self.readBracedBlock();
|
||||||
defer self.allocator.free(body);
|
defer self.allocator.free(body);
|
||||||
|
|
||||||
// Parse enum values from body
|
const values = try self.parseEnumBody(body);
|
||||||
var values = try std.ArrayList(EnumValue).initCapacity(self.allocator, 20);
|
|
||||||
var seen_names = std.StringHashMap(void).init(self.allocator);
|
|
||||||
defer {
|
|
||||||
var it = seen_names.keyIterator();
|
|
||||||
while (it.next()) |key| {
|
|
||||||
self.allocator.free(key.*);
|
|
||||||
}
|
|
||||||
seen_names.deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
var lines = std.mem.splitScalar(u8, body, '\n');
|
|
||||||
var in_multiline_comment = false;
|
|
||||||
|
|
||||||
while (lines.next()) |line| {
|
|
||||||
var trimmed = std.mem.trim(u8, line, " \t\r");
|
|
||||||
if (trimmed.len == 0) continue;
|
|
||||||
|
|
||||||
if (in_multiline_comment) {
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "*/")) |x| {
|
|
||||||
in_multiline_comment = false;
|
|
||||||
if (trimmed.len == 2)
|
|
||||||
continue;
|
|
||||||
trimmed = trimmed[x + 2 ..];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Track multi-line comments (both /** and /* styles)
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "/*")) |_| {
|
|
||||||
in_multiline_comment = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_multiline_comment) {
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "*/")) |_| {
|
|
||||||
in_multiline_comment = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "/*")) |x| {
|
|
||||||
if (x == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// special case for those weirder multiline comments
|
|
||||||
if (std.mem.indexOf(u8, trimmed, "/*") == null and std.mem.indexOf(u8, trimmed, "*/") == null) {
|
|
||||||
if (countChar(' ', trimmed) > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip various comment/bracket/preprocessor lines
|
|
||||||
if (std.mem.startsWith(u8, trimmed, "//")) continue;
|
|
||||||
if (std.mem.startsWith(u8, trimmed, "*")) continue; // Lines inside comments
|
|
||||||
if (std.mem.startsWith(u8, trimmed, "#")) continue; // Preprocessor directives
|
|
||||||
if (std.mem.startsWith(u8, trimmed, "{")) continue;
|
|
||||||
if (std.mem.startsWith(u8, trimmed, "}")) continue;
|
|
||||||
|
|
||||||
if (try self.parseEnumValue(trimmed)) |value| {
|
|
||||||
// Check for duplicate names (from #if/#else branches)
|
|
||||||
if (!seen_names.contains(value.name)) {
|
|
||||||
const name_copy = try self.allocator.dupe(u8, value.name);
|
|
||||||
try seen_names.put(name_copy, {});
|
|
||||||
try values.append(self.allocator, value);
|
|
||||||
} else {
|
|
||||||
// Skip duplicate, free the value
|
|
||||||
self.allocator.free(value.name);
|
|
||||||
if (value.value) |v| self.allocator.free(v);
|
|
||||||
if (value.comment) |c| self.allocator.free(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const doc = self.consumePendingDocComment();
|
const doc = self.consumePendingDocComment();
|
||||||
|
|
||||||
return EnumDecl{
|
return EnumDecl{
|
||||||
.name = try self.allocator.dupe(u8, name),
|
.name = try self.allocator.dupe(u8, name),
|
||||||
.values = try values.toOwnedSlice(self.allocator),
|
.values = values,
|
||||||
.doc_comment = doc,
|
.doc_comment = doc,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseEnumValue(self: *Scanner, line: []const u8) !?EnumValue {
|
/// Parses the enumerators of an enum body (`{ A, B = 2, ... } SDL_Name;`).
|
||||||
// Format: SDL_GPU_PRIMITIVETYPE_TRIANGLELIST, /**< comment */
|
///
|
||||||
// or: SDL_GPU_PRIMITIVETYPE_TRIANGLELIST = 5, /**< comment */
|
/// Works on the token level rather than line by line so that enumerators
|
||||||
// or: SDL_GPU_PRIMITIVETYPE_POINTLIST /**< comment */ (last value, no comma)
|
/// are found regardless of how comments and values are laid out:
|
||||||
|
/// - `/**< ... */` comments (possibly spanning lines) document the
|
||||||
|
/// enumerator they follow, all other comments are ignored
|
||||||
|
/// - enumerators are separated by commas outside of parentheses
|
||||||
|
/// - preprocessor conditionals keep every branch (duplicates are dropped),
|
||||||
|
/// except byte order checks where the little endian branch is used
|
||||||
|
fn parseEnumBody(self: *Scanner, body: []const u8) ![]EnumValue {
|
||||||
|
const open = std.mem.indexOfScalar(u8, body, '{') orelse return &.{};
|
||||||
|
const close = std.mem.lastIndexOfScalar(u8, body, '}') orelse body.len;
|
||||||
|
const text = body[open + 1 .. close];
|
||||||
|
|
||||||
var parts = std.mem.splitScalar(u8, line, ',');
|
var values: std.ArrayList(EnumValue) = .empty;
|
||||||
const first = std.mem.trim(u8, parts.next() orelse return null, " \t");
|
errdefer {
|
||||||
if (first.len == 0) return null;
|
for (values.items) |value| {
|
||||||
|
self.allocator.free(value.name);
|
||||||
// Extract inline comment if present (check both before and after comma)
|
if (value.value) |v| self.allocator.free(v);
|
||||||
var comment: ?[]const u8 = null;
|
if (value.comment) |c| self.allocator.free(c);
|
||||||
const comment_search = if (parts.rest().len > 0) parts.rest() else first;
|
|
||||||
if (std.mem.indexOf(u8, comment_search, "/**<")) |start| {
|
|
||||||
if (std.mem.indexOf(u8, comment_search[start..], "*/")) |end_offset| {
|
|
||||||
const comment_text = comment_search[start + 4 .. start + end_offset];
|
|
||||||
comment = try self.allocator.dupe(u8, std.mem.trim(u8, comment_text, " \t"));
|
|
||||||
}
|
}
|
||||||
|
values.deinit(self.allocator);
|
||||||
|
}
|
||||||
|
var seen_names = std.StringHashMap(void).init(self.allocator);
|
||||||
|
defer seen_names.deinit();
|
||||||
|
|
||||||
|
var current: std.ArrayList(u8) = .empty;
|
||||||
|
defer current.deinit(self.allocator);
|
||||||
|
|
||||||
|
// Index into `values` of the enumerator a trailing comment belongs to.
|
||||||
|
var last_index: ?usize = null;
|
||||||
|
var pending_comment: ?[]const u8 = null;
|
||||||
|
defer if (pending_comment) |c| self.allocator.free(c);
|
||||||
|
|
||||||
|
// Stack of preprocessor conditionals; `true` means "skip this branch".
|
||||||
|
const Conditional = struct { is_byte_order: bool, skipping: bool };
|
||||||
|
var conditionals: std.ArrayList(Conditional) = .empty;
|
||||||
|
defer conditionals.deinit(self.allocator);
|
||||||
|
|
||||||
|
var paren_depth: usize = 0;
|
||||||
|
var at_line_start = true;
|
||||||
|
var i: usize = 0;
|
||||||
|
while (i < text.len) {
|
||||||
|
const ch = text[i];
|
||||||
|
const skipping = for (conditionals.items) |cond| {
|
||||||
|
if (cond.skipping) break true;
|
||||||
|
} else false;
|
||||||
|
|
||||||
|
// Preprocessor directive
|
||||||
|
if (at_line_start and ch == '#') {
|
||||||
|
var end = i;
|
||||||
|
while (end < text.len and text[end] != '\n') : (end += 1) {
|
||||||
|
if (text[end] == '\\' and end + 1 < text.len and text[end + 1] == '\n') end += 1;
|
||||||
|
}
|
||||||
|
const directive = std.mem.trim(u8, text[i + 1 .. end], " \t\r");
|
||||||
|
// A branch may end without a trailing comma.
|
||||||
|
if (!skipping) {
|
||||||
|
last_index = try self.finishEnumValue(&values, &seen_names, current.items, &pending_comment) orelse last_index;
|
||||||
|
}
|
||||||
|
current.clearRetainingCapacity();
|
||||||
|
if (std.mem.startsWith(u8, directive, "if")) {
|
||||||
|
const big_endian = std.mem.indexOf(u8, directive, "SDL_BIG_ENDIAN") != null;
|
||||||
|
const little_endian = std.mem.indexOf(u8, directive, "SDL_LIL_ENDIAN") != null;
|
||||||
|
try conditionals.append(self.allocator, .{ .is_byte_order = big_endian or little_endian, .skipping = big_endian });
|
||||||
|
} else if (std.mem.startsWith(u8, directive, "el")) {
|
||||||
|
if (conditionals.items.len > 0) {
|
||||||
|
const cond = &conditionals.items[conditionals.items.len - 1];
|
||||||
|
if (cond.is_byte_order) cond.skipping = !cond.skipping;
|
||||||
|
}
|
||||||
|
} else if (std.mem.startsWith(u8, directive, "endif")) {
|
||||||
|
if (conditionals.items.len > 0) _ = conditionals.pop();
|
||||||
|
}
|
||||||
|
i = end;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract name and optional value (strip comment if it was in first part)
|
// Comments
|
||||||
var name_part = first;
|
if (ch == '/' and i + 1 < text.len and text[i + 1] == '*') {
|
||||||
if (std.mem.indexOf(u8, first, "/**<")) |comment_pos| {
|
const end = if (std.mem.indexOfPos(u8, text, i + 2, "*/")) |e| e else text.len;
|
||||||
name_part = std.mem.trim(u8, first[0..comment_pos], " \t");
|
if (!skipping and std.mem.startsWith(u8, text[i..], "/**<")) {
|
||||||
}
|
const comment = try collapseComment(self.allocator, text[i + 4 .. end]);
|
||||||
|
const has_pending_entry = std.mem.trim(u8, current.items, " \t\r\n").len > 0;
|
||||||
var name: []const u8 = undefined;
|
if (has_pending_entry) {
|
||||||
var value: ?[]const u8 = null;
|
if (pending_comment) |old| self.allocator.free(old);
|
||||||
|
pending_comment = comment;
|
||||||
if (std.mem.indexOf(u8, name_part, "=")) |eq_pos| {
|
} else if (last_index) |index| {
|
||||||
name = std.mem.trim(u8, name_part[0..eq_pos], " \t");
|
if (values.items[index].comment == null) {
|
||||||
value = try self.allocator.dupe(u8, std.mem.trim(u8, name_part[eq_pos + 1 ..], " \t"));
|
values.items[index].comment = comment;
|
||||||
} else {
|
} else {
|
||||||
name = name_part;
|
self.allocator.free(comment);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.allocator.free(comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i = @min(end + 2, text.len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ch == '/' and i + 1 < text.len and text[i + 1] == '/') {
|
||||||
|
while (i < text.len and text[i] != '\n') i += 1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumValue{
|
if (ch == '\n') {
|
||||||
.name = fixupZigName(name),
|
at_line_start = true;
|
||||||
.value = value,
|
} else if (ch != ' ' and ch != '\t' and ch != '\r') {
|
||||||
|
at_line_start = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skipping) {
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == '(') paren_depth += 1;
|
||||||
|
if (ch == ')' and paren_depth > 0) paren_depth -= 1;
|
||||||
|
|
||||||
|
if (ch == ',' and paren_depth == 0) {
|
||||||
|
last_index = try self.finishEnumValue(&values, &seen_names, current.items, &pending_comment) orelse last_index;
|
||||||
|
current.clearRetainingCapacity();
|
||||||
|
} else {
|
||||||
|
try current.append(self.allocator, if (ch == '\n' or ch == '\r' or ch == '\t') ' ' else ch);
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
_ = try self.finishEnumValue(&values, &seen_names, current.items, &pending_comment);
|
||||||
|
|
||||||
|
return try values.toOwnedSlice(self.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds the enumerator described by `text` (`NAME` or `NAME = value`) to
|
||||||
|
/// `values` and returns its index, or null if there was nothing to add.
|
||||||
|
fn finishEnumValue(
|
||||||
|
self: *Scanner,
|
||||||
|
values: *std.ArrayList(EnumValue),
|
||||||
|
seen_names: *std.StringHashMap(void),
|
||||||
|
text: []const u8,
|
||||||
|
pending_comment: *?[]const u8,
|
||||||
|
) !?usize {
|
||||||
|
const comment = pending_comment.*;
|
||||||
|
pending_comment.* = null;
|
||||||
|
errdefer if (comment) |c| self.allocator.free(c);
|
||||||
|
|
||||||
|
const entry = std.mem.trim(u8, text, " \t\r\n");
|
||||||
|
var name = entry;
|
||||||
|
var value_text: ?[]const u8 = null;
|
||||||
|
if (std.mem.indexOfScalar(u8, entry, '=')) |eq_pos| {
|
||||||
|
name = std.mem.trim(u8, entry[0..eq_pos], " \t");
|
||||||
|
value_text = std.mem.trim(u8, entry[eq_pos + 1 ..], " \t");
|
||||||
|
}
|
||||||
|
|
||||||
|
const valid_name = name.len > 0 and for (name) |c| {
|
||||||
|
if (!std.ascii.isAlphanumeric(c) and c != '_') break false;
|
||||||
|
} else true;
|
||||||
|
|
||||||
|
// Duplicates come from #if/#else branches that are both kept.
|
||||||
|
if (!valid_name or seen_names.contains(name)) {
|
||||||
|
if (comment) |c| self.allocator.free(c);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const owned_name = fixupZigName(name);
|
||||||
|
errdefer self.allocator.free(owned_name);
|
||||||
|
const owned_value = if (value_text) |v| try self.allocator.dupe(u8, v) else null;
|
||||||
|
errdefer if (owned_value) |v| self.allocator.free(v);
|
||||||
|
|
||||||
|
try values.append(self.allocator, .{
|
||||||
|
.name = owned_name,
|
||||||
|
.value = owned_value,
|
||||||
.comment = comment,
|
.comment = comment,
|
||||||
};
|
});
|
||||||
|
try seen_names.put(owned_name, {});
|
||||||
|
return values.items.len - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Turns the text of a (possibly multi-line) comment into a single line.
|
||||||
|
fn collapseComment(allocator: Allocator, text: []const u8) ![]const u8 {
|
||||||
|
var result: std.ArrayList(u8) = .empty;
|
||||||
|
errdefer result.deinit(allocator);
|
||||||
|
|
||||||
|
var lines = std.mem.splitScalar(u8, text, '\n');
|
||||||
|
while (lines.next()) |line| {
|
||||||
|
var part = std.mem.trim(u8, line, " \t\r");
|
||||||
|
if (std.mem.startsWith(u8, part, "*")) part = std.mem.trim(u8, part[1..], " \t");
|
||||||
|
if (part.len == 0) continue;
|
||||||
|
if (result.items.len > 0) try result.append(allocator, ' ');
|
||||||
|
try result.appendSlice(allocator, part);
|
||||||
|
}
|
||||||
|
return try result.toOwnedSlice(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pattern: typedef struct SDL_Foo { ... } SDL_Foo;
|
// Pattern: typedef struct SDL_Foo { ... } SDL_Foo;
|
||||||
|
|
@ -781,6 +848,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
while (lines.next()) |line| {
|
while (lines.next()) |line| {
|
||||||
const trimmed = std.mem.trim(u8, line, " \t\r");
|
const trimmed = std.mem.trim(u8, line, " \t\r");
|
||||||
|
var field_line = line;
|
||||||
|
|
||||||
// Track multi-line comments (both /** and /*)
|
// Track multi-line comments (both /** and /*)
|
||||||
// Only start tracking if /* appears without */ on the same line
|
// Only start tracking if /* appears without */ on the same line
|
||||||
|
|
@ -794,7 +862,10 @@ pub const Scanner = struct {
|
||||||
} else {
|
} else {
|
||||||
// Found /* without */ - start of multi-line comment
|
// Found /* without */ - start of multi-line comment
|
||||||
in_multiline_comment = true;
|
in_multiline_comment = true;
|
||||||
continue;
|
if (start_pos == 0) continue;
|
||||||
|
// A field followed by a comment that continues on the
|
||||||
|
// next lines: still parse the field itself.
|
||||||
|
field_line = trimmed[0..start_pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -812,11 +883,11 @@ pub const Scanner = struct {
|
||||||
if (std.mem.startsWith(u8, trimmed, "#")) continue;
|
if (std.mem.startsWith(u8, trimmed, "#")) continue;
|
||||||
|
|
||||||
// First try single-field parsing
|
// First try single-field parsing
|
||||||
if (try self.parseStructField(line)) |field| {
|
if (try self.parseStructField(field_line)) |field| {
|
||||||
try fields.append(self.allocator, field);
|
try fields.append(self.allocator, field);
|
||||||
} else {
|
} else {
|
||||||
// If single-field fails, try multi-field parsing
|
// If single-field fails, try multi-field parsing
|
||||||
const multi_fields = try self.parseMultiFieldLine(line);
|
const multi_fields = try self.parseMultiFieldLine(field_line);
|
||||||
if (multi_fields.len > 0) {
|
if (multi_fields.len > 0) {
|
||||||
for (multi_fields) |field| {
|
for (multi_fields) |field| {
|
||||||
try fields.append(self.allocator, field);
|
try fields.append(self.allocator, field);
|
||||||
|
|
@ -881,6 +952,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
while (lines.next()) |line| {
|
while (lines.next()) |line| {
|
||||||
const trimmed = std.mem.trim(u8, line, " \t\r");
|
const trimmed = std.mem.trim(u8, line, " \t\r");
|
||||||
|
var field_line = line;
|
||||||
|
|
||||||
// Track multi-line comments (both /** and /*)
|
// Track multi-line comments (both /** and /*)
|
||||||
// Only start tracking if /* appears without */ on the same line
|
// Only start tracking if /* appears without */ on the same line
|
||||||
|
|
@ -894,7 +966,10 @@ pub const Scanner = struct {
|
||||||
} else {
|
} else {
|
||||||
// Found /* without */ - start of multi-line comment
|
// Found /* without */ - start of multi-line comment
|
||||||
in_multiline_comment = true;
|
in_multiline_comment = true;
|
||||||
continue;
|
if (start_pos == 0) continue;
|
||||||
|
// A field followed by a comment that continues on the
|
||||||
|
// next lines: still parse the field itself.
|
||||||
|
field_line = trimmed[0..start_pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -912,10 +987,10 @@ pub const Scanner = struct {
|
||||||
if (std.mem.startsWith(u8, trimmed, "#")) continue;
|
if (std.mem.startsWith(u8, trimmed, "#")) continue;
|
||||||
|
|
||||||
// Reuse struct field parsing since unions have same field syntax
|
// Reuse struct field parsing since unions have same field syntax
|
||||||
if (try self.parseStructField(line)) |field| {
|
if (try self.parseStructField(field_line)) |field| {
|
||||||
try fields.append(self.allocator, field);
|
try fields.append(self.allocator, field);
|
||||||
} else {
|
} else {
|
||||||
const multi_fields = try self.parseMultiFieldLine(line);
|
const multi_fields = try self.parseMultiFieldLine(field_line);
|
||||||
if (multi_fields.len > 0) {
|
if (multi_fields.len > 0) {
|
||||||
for (multi_fields) |field| {
|
for (multi_fields) |field| {
|
||||||
try fields.append(self.allocator, field);
|
try fields.append(self.allocator, field);
|
||||||
|
|
@ -943,7 +1018,7 @@ pub const Scanner = struct {
|
||||||
if (std.mem.startsWith(u8, trimmed, "}")) return null; // Skip closing brace and typedef name
|
if (std.mem.startsWith(u8, trimmed, "}")) return null; // Skip closing brace and typedef name
|
||||||
|
|
||||||
// Remove trailing semicolon
|
// Remove trailing semicolon
|
||||||
const no_semi = std.mem.trimRight(u8, trimmed, ";");
|
const no_semi = std.mem.trimEnd(u8, trimmed, ";");
|
||||||
|
|
||||||
// Extract inline comment
|
// Extract inline comment
|
||||||
var comment: ?[]const u8 = null;
|
var comment: ?[]const u8 = null;
|
||||||
|
|
@ -951,7 +1026,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
var field_part = no_semi;
|
var field_part = no_semi;
|
||||||
if (std.mem.indexOf(u8, no_semi, "/**<")) |comment_start| {
|
if (std.mem.indexOf(u8, no_semi, "/**<")) |comment_start| {
|
||||||
field_part = std.mem.trimRight(u8, no_semi[0..comment_start], "; \t");
|
field_part = std.mem.trimEnd(u8, no_semi[0..comment_start], "; \t");
|
||||||
if (std.mem.indexOf(u8, no_semi[comment_start..], "*/")) |end_offset| {
|
if (std.mem.indexOf(u8, no_semi[comment_start..], "*/")) |end_offset| {
|
||||||
const comment_text = no_semi[comment_start + 4 .. comment_start + end_offset];
|
const comment_text = no_semi[comment_start + 4 .. comment_start + end_offset];
|
||||||
comment = try self.allocator.dupe(u8, std.mem.trim(u8, comment_text, " \t"));
|
comment = try self.allocator.dupe(u8, std.mem.trim(u8, comment_text, " \t"));
|
||||||
|
|
@ -1014,7 +1089,7 @@ pub const Scanner = struct {
|
||||||
if (std.mem.indexOf(u8, field_trimmed, "[")) |bracket_pos| {
|
if (std.mem.indexOf(u8, field_trimmed, "[")) |bracket_pos| {
|
||||||
// Extract array size and append to type
|
// Extract array size and append to type
|
||||||
// Pattern: "Uint8 padding[2]" -> parse as type="Uint8[2]" name="padding"
|
// Pattern: "Uint8 padding[2]" -> parse as type="Uint8[2]" name="padding"
|
||||||
const before_bracket = std.mem.trimRight(u8, field_trimmed[0..bracket_pos], " \t");
|
const before_bracket = std.mem.trimEnd(u8, field_trimmed[0..bracket_pos], " \t");
|
||||||
const bracket_part = field_trimmed[bracket_pos..]; // "[2]"
|
const bracket_part = field_trimmed[bracket_pos..]; // "[2]"
|
||||||
|
|
||||||
// Split before_bracket into type and name
|
// Split before_bracket into type and name
|
||||||
|
|
@ -1042,8 +1117,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
// Reconstruct type with array notation
|
// Reconstruct type with array notation
|
||||||
var type_buf: [256]u8 = undefined;
|
var type_buf: [256]u8 = undefined;
|
||||||
var fbs = std.io.fixedBufferStream(&type_buf);
|
var writer: std.Io.Writer = .fixed(&type_buf);
|
||||||
const writer = fbs.writer();
|
|
||||||
for (type_parts, 0..) |part, i| {
|
for (type_parts, 0..) |part, i| {
|
||||||
if (i > 0) writer.writeByte(' ') catch {
|
if (i > 0) writer.writeByte(' ') catch {
|
||||||
if (comment) |c| self.allocator.free(c);
|
if (comment) |c| self.allocator.free(c);
|
||||||
|
|
@ -1060,7 +1134,7 @@ pub const Scanner = struct {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const type_str = fbs.getWritten();
|
const type_str = writer.buffered();
|
||||||
|
|
||||||
return FieldDecl{
|
return FieldDecl{
|
||||||
.name = fixupZigName(name),
|
.name = fixupZigName(name),
|
||||||
|
|
@ -1127,13 +1201,13 @@ pub const Scanner = struct {
|
||||||
if (std.mem.startsWith(u8, trimmed, "}")) return &[_]FieldDecl{};
|
if (std.mem.startsWith(u8, trimmed, "}")) return &[_]FieldDecl{};
|
||||||
|
|
||||||
// Remove trailing semicolon
|
// Remove trailing semicolon
|
||||||
const no_semi = std.mem.trimRight(u8, trimmed, ";");
|
const no_semi = std.mem.trimEnd(u8, trimmed, ";");
|
||||||
|
|
||||||
// Extract inline comment if present
|
// Extract inline comment if present
|
||||||
var comment: ?[]const u8 = null;
|
var comment: ?[]const u8 = null;
|
||||||
var field_part = no_semi;
|
var field_part = no_semi;
|
||||||
if (std.mem.indexOf(u8, no_semi, "/**<")) |comment_start| {
|
if (std.mem.indexOf(u8, no_semi, "/**<")) |comment_start| {
|
||||||
field_part = std.mem.trimRight(u8, no_semi[0..comment_start], "; \t");
|
field_part = std.mem.trimEnd(u8, no_semi[0..comment_start], "; \t");
|
||||||
if (std.mem.indexOf(u8, no_semi[comment_start..], "*/")) |end_offset| {
|
if (std.mem.indexOf(u8, no_semi[comment_start..], "*/")) |end_offset| {
|
||||||
const comment_text = no_semi[comment_start + 4 .. comment_start + end_offset];
|
const comment_text = no_semi[comment_start + 4 .. comment_start + end_offset];
|
||||||
comment = try self.allocator.dupe(u8, std.mem.trim(u8, comment_text, " \t"));
|
comment = try self.allocator.dupe(u8, std.mem.trim(u8, comment_text, " \t"));
|
||||||
|
|
@ -1173,7 +1247,7 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
// Now parse the comma-separated field names
|
// Now parse the comma-separated field names
|
||||||
const names_part = field_trimmed[type_end..];
|
const names_part = field_trimmed[type_end..];
|
||||||
var field_list = std.ArrayList(FieldDecl){};
|
var field_list = std.ArrayList(FieldDecl).empty;
|
||||||
|
|
||||||
var name_iter = std.mem.splitScalar(u8, names_part, ',');
|
var name_iter = std.mem.splitScalar(u8, names_part, ',');
|
||||||
while (name_iter.next()) |name_raw| {
|
while (name_iter.next()) |name_raw| {
|
||||||
|
|
@ -1212,7 +1286,7 @@ pub const Scanner = struct {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clean_name = std.mem.trimRight(u8, name, ";");
|
const clean_name = std.mem.trimEnd(u8, name, ";");
|
||||||
|
|
||||||
// Skip any whitespace/newlines before looking for #define
|
// Skip any whitespace/newlines before looking for #define
|
||||||
self.skipWhitespace();
|
self.skipWhitespace();
|
||||||
|
|
@ -1277,7 +1351,7 @@ pub const Scanner = struct {
|
||||||
// 2. Check if they have a common prefix
|
// 2. Check if they have a common prefix
|
||||||
// 3. Check if the prefix relates to the typedef name
|
// 3. Check if the prefix relates to the typedef name
|
||||||
|
|
||||||
var bitshift_defines = std.ArrayList([]const u8){};
|
var bitshift_defines = std.ArrayList([]const u8).empty;
|
||||||
defer {
|
defer {
|
||||||
for (bitshift_defines.items) |item| {
|
for (bitshift_defines.items) |item| {
|
||||||
self.allocator.free(item);
|
self.allocator.free(item);
|
||||||
|
|
@ -1351,7 +1425,7 @@ pub const Scanner = struct {
|
||||||
// For types ending in "Flags", look for simple numeric defines
|
// For types ending in "Flags", look for simple numeric defines
|
||||||
// Example: SDL_MouseButtonFlags with SDL_BUTTON_LEFT = 1, SDL_BUTTON_MIDDLE = 2
|
// Example: SDL_MouseButtonFlags with SDL_BUTTON_LEFT = 1, SDL_BUTTON_MIDDLE = 2
|
||||||
|
|
||||||
var numeric_defines = std.ArrayList([]const u8){};
|
var numeric_defines = std.ArrayList([]const u8).empty;
|
||||||
defer {
|
defer {
|
||||||
for (numeric_defines.items) |item| {
|
for (numeric_defines.items) |item| {
|
||||||
self.allocator.free(item);
|
self.allocator.free(item);
|
||||||
|
|
@ -1382,7 +1456,8 @@ pub const Scanner = struct {
|
||||||
// Check if it's a macro wrapper like SDL_UINT64_C(0x...)
|
// Check if it's a macro wrapper like SDL_UINT64_C(0x...)
|
||||||
const is_macro_wrapped_hex = blk: {
|
const is_macro_wrapped_hex = blk: {
|
||||||
if (std.mem.startsWith(u8, value_part, "SDL_UINT64_C(") or
|
if (std.mem.startsWith(u8, value_part, "SDL_UINT64_C(") or
|
||||||
std.mem.startsWith(u8, value_part, "SDL_UINT32_C(")) {
|
std.mem.startsWith(u8, value_part, "SDL_UINT32_C("))
|
||||||
|
{
|
||||||
// Extract hex value from SDL_UINT64_C(0x0000000000000001)
|
// Extract hex value from SDL_UINT64_C(0x0000000000000001)
|
||||||
if (std.mem.indexOf(u8, value_part, "0x")) |hex_start| {
|
if (std.mem.indexOf(u8, value_part, "0x")) |hex_start| {
|
||||||
if (std.mem.indexOf(u8, value_part[hex_start..], ")")) |paren_pos| {
|
if (std.mem.indexOf(u8, value_part[hex_start..], ")")) |paren_pos| {
|
||||||
|
|
@ -1557,7 +1632,8 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
// Handle SDL_UINT64_C(0x...) or SDL_UINT32_C(0x...) macros
|
// Handle SDL_UINT64_C(0x...) or SDL_UINT32_C(0x...) macros
|
||||||
if (std.mem.startsWith(u8, value_str, "SDL_UINT64_C(") or
|
if (std.mem.startsWith(u8, value_str, "SDL_UINT64_C(") or
|
||||||
std.mem.startsWith(u8, value_str, "SDL_UINT32_C(")) {
|
std.mem.startsWith(u8, value_str, "SDL_UINT32_C("))
|
||||||
|
{
|
||||||
// Extract hex value
|
// Extract hex value
|
||||||
if (std.mem.indexOf(u8, value_str, "0x")) |hex_start| {
|
if (std.mem.indexOf(u8, value_str, "0x")) |hex_start| {
|
||||||
if (std.mem.indexOf(u8, value_str[hex_start..], ")")) |paren_pos| {
|
if (std.mem.indexOf(u8, value_str[hex_start..], ")")) |paren_pos| {
|
||||||
|
|
@ -1824,7 +1900,7 @@ pub const Scanner = struct {
|
||||||
// Find matching ]
|
// Find matching ]
|
||||||
if (std.mem.indexOfScalar(u8, working_param[bracket_pos..], ']')) |_| {
|
if (std.mem.indexOfScalar(u8, working_param[bracket_pos..], ']')) |_| {
|
||||||
is_array = true;
|
is_array = true;
|
||||||
working_param = std.mem.trimRight(u8, working_param[0..bracket_pos], " \t");
|
working_param = std.mem.trimEnd(u8, working_param[0..bracket_pos], " \t");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1876,7 +1952,7 @@ pub const Scanner = struct {
|
||||||
while (param_name.len > 0 and param_name[0] == '*') {
|
while (param_name.len > 0 and param_name[0] == '*') {
|
||||||
const new_type = try std.fmt.bufPrint(&type_buf, "{s} *", .{param_type});
|
const new_type = try std.fmt.bufPrint(&type_buf, "{s} *", .{param_type});
|
||||||
param_type = new_type;
|
param_type = new_type;
|
||||||
param_name = std.mem.trimLeft(u8, param_name[1..], " \t");
|
param_name = std.mem.trimStart(u8, param_name[1..], " \t");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this was an array parameter, convert pointer level
|
// If this was an array parameter, convert pointer level
|
||||||
|
|
@ -1887,7 +1963,7 @@ pub const Scanner = struct {
|
||||||
// Output type should be: "[*c][*c]char"
|
// Output type should be: "[*c][*c]char"
|
||||||
// But for simplicity in generated code, we can use the original type + pointer
|
// But for simplicity in generated code, we can use the original type + pointer
|
||||||
// Check if type already ends with *
|
// Check if type already ends with *
|
||||||
const trimmed_type = std.mem.trimRight(u8, param_type, " \t");
|
const trimmed_type = std.mem.trimEnd(u8, param_type, " \t");
|
||||||
if (std.mem.endsWith(u8, trimmed_type, "*")) {
|
if (std.mem.endsWith(u8, trimmed_type, "*")) {
|
||||||
// Already has pointer, add another without space
|
// Already has pointer, add another without space
|
||||||
const type_copy = try std.fmt.bufPrint(&type_buf, "{s}*", .{trimmed_type});
|
const type_copy = try std.fmt.bufPrint(&type_buf, "{s}*", .{trimmed_type});
|
||||||
|
|
@ -2050,3 +2126,96 @@ pub const Scanner = struct {
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test "enum values without comments, with plain comments and without trailing comma" {
|
||||||
|
const allocator = std.heap.smp_allocator;
|
||||||
|
const source =
|
||||||
|
\\typedef enum SDL_TouchDeviceType
|
||||||
|
\\{
|
||||||
|
\\ SDL_TOUCH_DEVICE_INVALID = -1,
|
||||||
|
\\ SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */
|
||||||
|
\\ SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /**< trackpad with absolute
|
||||||
|
\\ device coordinates */
|
||||||
|
\\ SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */
|
||||||
|
\\} SDL_TouchDeviceType;
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
var scanner = Scanner.init(allocator, source);
|
||||||
|
defer scanner.deinit();
|
||||||
|
const decls = try scanner.scan();
|
||||||
|
defer {
|
||||||
|
for (decls) |decl| switch (decl) {
|
||||||
|
inline else => |*d| d.deinit(allocator),
|
||||||
|
};
|
||||||
|
allocator.free(decls);
|
||||||
|
}
|
||||||
|
|
||||||
|
try std.testing.expectEqual(1, decls.len);
|
||||||
|
const values = decls[0].enum_decl.values;
|
||||||
|
try std.testing.expectEqual(4, values.len);
|
||||||
|
try std.testing.expectEqualStrings("SDL_TOUCH_DEVICE_INVALID", values[0].name);
|
||||||
|
try std.testing.expectEqualStrings("-1", values[0].value.?);
|
||||||
|
try std.testing.expectEqualStrings("SDL_TOUCH_DEVICE_DIRECT", values[1].name);
|
||||||
|
try std.testing.expect(values[1].comment == null);
|
||||||
|
try std.testing.expectEqualStrings("trackpad with absolute device coordinates", values[2].comment.?);
|
||||||
|
try std.testing.expectEqualStrings("SDL_TOUCH_DEVICE_INDIRECT_RELATIVE", values[3].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "enum byte order conditionals use the little endian branch" {
|
||||||
|
const allocator = std.heap.smp_allocator;
|
||||||
|
const source =
|
||||||
|
\\typedef enum SDL_AudioFormat
|
||||||
|
\\{
|
||||||
|
\\ SDL_AUDIO_S16LE = 0x8010u, /**< Signed 16-bit samples */
|
||||||
|
\\ /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 16), */
|
||||||
|
\\ SDL_AUDIO_S16BE = 0x9010u, /**< As above, but big-endian byte order */
|
||||||
|
\\ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
|
\\ SDL_AUDIO_S16 = SDL_AUDIO_S16LE
|
||||||
|
\\ #else
|
||||||
|
\\ SDL_AUDIO_S16 = SDL_AUDIO_S16BE
|
||||||
|
\\ #endif
|
||||||
|
\\} SDL_AudioFormat;
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
var scanner = Scanner.init(allocator, source);
|
||||||
|
defer scanner.deinit();
|
||||||
|
const decls = try scanner.scan();
|
||||||
|
defer {
|
||||||
|
for (decls) |decl| switch (decl) {
|
||||||
|
inline else => |*d| d.deinit(allocator),
|
||||||
|
};
|
||||||
|
allocator.free(decls);
|
||||||
|
}
|
||||||
|
|
||||||
|
const values = decls[0].enum_decl.values;
|
||||||
|
try std.testing.expectEqual(3, values.len);
|
||||||
|
try std.testing.expectEqualStrings("SDL_AUDIO_S16", values[2].name);
|
||||||
|
try std.testing.expectEqualStrings("SDL_AUDIO_S16LE", values[2].value.?);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "struct fields followed by a multi-line comment are kept" {
|
||||||
|
const allocator = std.heap.smp_allocator;
|
||||||
|
const source =
|
||||||
|
\\typedef struct SDL_Example
|
||||||
|
\\{
|
||||||
|
\\ Uint32 button_mask; /**< A mask of which buttons are valid
|
||||||
|
\\ e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
|
||||||
|
\\ const char *name; /**< the name */
|
||||||
|
\\} SDL_Example;
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
var scanner = Scanner.init(allocator, source);
|
||||||
|
defer scanner.deinit();
|
||||||
|
const decls = try scanner.scan();
|
||||||
|
defer {
|
||||||
|
for (decls) |decl| switch (decl) {
|
||||||
|
inline else => |*d| d.deinit(allocator),
|
||||||
|
};
|
||||||
|
allocator.free(decls);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fields = decls[0].struct_decl.fields;
|
||||||
|
try std.testing.expectEqual(2, fields.len);
|
||||||
|
try std.testing.expectEqualStrings("button_mask", fields[0].name);
|
||||||
|
try std.testing.expectEqualStrings("name", fields[1].name);
|
||||||
|
}
|
||||||
|
|
|
||||||
132
src/types.zig
132
src/types.zig
|
|
@ -5,9 +5,16 @@ const Allocator = std.mem.Allocator;
|
||||||
pub fn convertType(c_type: []const u8, allocator: Allocator) Allocator.Error![]const u8 {
|
pub fn convertType(c_type: []const u8, allocator: Allocator) Allocator.Error![]const u8 {
|
||||||
const trimmed = std.mem.trim(u8, c_type, " \t");
|
const trimmed = std.mem.trim(u8, c_type, " \t");
|
||||||
|
|
||||||
// Handle opaque struct pointers: "struct X *" -> "*anyopaque"
|
// Normalize `*const` to `* const` so both spellings hit the same rules.
|
||||||
|
if (std.mem.indexOf(u8, trimmed, "*const") != null and std.mem.indexOfScalar(u8, trimmed, '(') == null) {
|
||||||
|
const normalized = try std.mem.replaceOwned(u8, allocator, trimmed, "*const", "* const");
|
||||||
|
defer allocator.free(normalized);
|
||||||
|
return convertType(normalized, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle opaque struct pointers: "struct X *" -> "?*anyopaque"
|
||||||
if (std.mem.startsWith(u8, trimmed, "struct ") and std.mem.endsWith(u8, trimmed, " *")) {
|
if (std.mem.startsWith(u8, trimmed, "struct ") and std.mem.endsWith(u8, trimmed, " *")) {
|
||||||
return try allocator.dupe(u8, "*anyopaque");
|
return try allocator.dupe(u8, "?*anyopaque");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle function pointers used in callbacks and interface structs.
|
// Handle function pointers used in callbacks and interface structs.
|
||||||
|
|
@ -236,7 +243,10 @@ pub fn convertStructFieldType(c_type: []const u8, allocator: Allocator) Allocato
|
||||||
const base_type = std.mem.trim(u8, rest[0..first_star], " \t");
|
const base_type = std.mem.trim(u8, rest[0..first_star], " \t");
|
||||||
const star_count = std.mem.count(u8, rest[first_star..], "*");
|
const star_count = std.mem.count(u8, rest[first_star..], "*");
|
||||||
|
|
||||||
const zig_base = if (std.mem.eql(u8, base_type, "void"))
|
// `[*c]anyopaque` is not a valid Zig type (C pointers cannot point to opaque
|
||||||
|
// types), so the pointer directly to void becomes `?*anyopaque`.
|
||||||
|
const is_void = std.mem.eql(u8, base_type, "void");
|
||||||
|
const zig_base = if (is_void)
|
||||||
try allocator.dupe(u8, "anyopaque")
|
try allocator.dupe(u8, "anyopaque")
|
||||||
else
|
else
|
||||||
try convertType(base_type, allocator);
|
try convertType(base_type, allocator);
|
||||||
|
|
@ -245,8 +255,9 @@ pub fn convertStructFieldType(c_type: []const u8, allocator: Allocator) Allocato
|
||||||
var result: std.ArrayList(u8) = .empty;
|
var result: std.ArrayList(u8) = .empty;
|
||||||
defer result.deinit(allocator);
|
defer result.deinit(allocator);
|
||||||
|
|
||||||
for (0..star_count) |_| {
|
for (0..star_count) |i| {
|
||||||
try result.appendSlice(allocator, "[*c]");
|
const innermost = i + 1 == star_count;
|
||||||
|
try result.appendSlice(allocator, if (is_void and innermost) "?*" else "[*c]");
|
||||||
}
|
}
|
||||||
if (pointee_const) {
|
if (pointee_const) {
|
||||||
try result.appendSlice(allocator, "const ");
|
try result.appendSlice(allocator, "const ");
|
||||||
|
|
@ -256,83 +267,8 @@ pub fn convertStructFieldType(c_type: []const u8, allocator: Allocator) Allocato
|
||||||
return try result.toOwnedSlice(allocator);
|
return try result.toOwnedSlice(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn isOpaquePointerLike(zig_type: []const u8) bool {
|
|
||||||
if (!(std.mem.startsWith(u8, zig_type, "?*") or std.mem.startsWith(u8, zig_type, "*"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std.mem.indexOf(u8, zig_type, "anyopaque") != null or
|
|
||||||
std.mem.startsWith(u8, zig_type, "[*c]") or
|
|
||||||
std.mem.startsWith(u8, zig_type, "?[*c]"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn isEnumLikeType(zig_type: []const u8) bool {
|
|
||||||
if (isPackedFlagsLikeType(zig_type)) return false;
|
|
||||||
|
|
||||||
return std.mem.indexOf(u8, zig_type, "Type") != null or
|
|
||||||
std.mem.indexOf(u8, zig_type, "Size") != null or
|
|
||||||
std.mem.indexOf(u8, zig_type, "Mode") != null or
|
|
||||||
std.mem.indexOf(u8, zig_type, "Op") != null or
|
|
||||||
std.mem.endsWith(u8, zig_type, "Format");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn isPackedFlagsLikeType(zig_type: []const u8) bool {
|
|
||||||
return std.mem.endsWith(u8, zig_type, "Flags") or
|
|
||||||
std.mem.eql(u8, zig_type, "GPUShaderFormat") or
|
|
||||||
std.mem.eql(u8, zig_type, "FlipMode");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determine the appropriate cast for a Zig parameter passed into a C function.
|
|
||||||
pub fn getParamCastType(zig_type: []const u8) CastType {
|
|
||||||
// Bool needs @bitCast
|
|
||||||
if (std.mem.eql(u8, zig_type, "bool")) {
|
|
||||||
return .bit_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Opaque pointers need @ptrCast (both ?*Type and *Type)
|
|
||||||
if (isOpaquePointerLike(zig_type)) {
|
|
||||||
return .ptr_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEnumLikeType(zig_type)) {
|
|
||||||
return .int_from_enum;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPackedFlagsLikeType(zig_type)) {
|
|
||||||
return .bit_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
return .none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determine the appropriate cast for a C return value exposed as a Zig type.
|
|
||||||
pub fn getReturnCastType(zig_type: []const u8) CastType {
|
|
||||||
if (std.mem.eql(u8, zig_type, "bool")) {
|
|
||||||
return .bit_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isOpaquePointerLike(zig_type)) {
|
|
||||||
return .ptr_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEnumLikeType(zig_type)) {
|
|
||||||
return .enum_from_int;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPackedFlagsLikeType(zig_type)) {
|
|
||||||
return .bit_cast;
|
|
||||||
}
|
|
||||||
|
|
||||||
return .none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert C function pointer type to Zig function pointer syntax
|
/// Convert C function pointer type to Zig function pointer syntax
|
||||||
/// Example: Sint64 (SDLCALL *size)(void *userdata) -> *const fn (?*anyopaque) callconv(.C) i64
|
/// Example: Sint64 (SDLCALL *size)(void *userdata) -> *const fn (?*anyopaque) callconv(.c) i64
|
||||||
fn convertFunctionPointerType(c_type: []const u8, allocator: Allocator) Allocator.Error![]const u8 {
|
fn convertFunctionPointerType(c_type: []const u8, allocator: Allocator) Allocator.Error![]const u8 {
|
||||||
// Pattern: ReturnType (SDLCALL *name)(params) or ReturnType (*name)(params)
|
// Pattern: ReturnType (SDLCALL *name)(params) or ReturnType (*name)(params)
|
||||||
|
|
||||||
|
|
@ -391,7 +327,7 @@ fn convertFunctionPointerType(c_type: []const u8, allocator: Allocator) Allocato
|
||||||
try result.appendSlice(allocator, param);
|
try result.appendSlice(allocator, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
try result.appendSlice(allocator, ") callconv(.C) ");
|
try result.appendSlice(allocator, ") callconv(.c) ");
|
||||||
try result.appendSlice(allocator, zig_return);
|
try result.appendSlice(allocator, zig_return);
|
||||||
|
|
||||||
return try result.toOwnedSlice(allocator);
|
return try result.toOwnedSlice(allocator);
|
||||||
|
|
@ -413,20 +349,12 @@ fn stripParamName(param: []const u8) []const u8 {
|
||||||
|
|
||||||
if (ident_start == param.len or ident_start == 0) return param;
|
if (ident_start == param.len or ident_start == 0) return param;
|
||||||
|
|
||||||
const before_name = std.mem.trimRight(u8, param[0..ident_start], " \t");
|
const before_name = std.mem.trimEnd(u8, param[0..ident_start], " \t");
|
||||||
if (before_name.len == 0) return param;
|
if (before_name.len == 0) return param;
|
||||||
|
|
||||||
return before_name;
|
return before_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const CastType = enum {
|
|
||||||
none,
|
|
||||||
ptr_cast,
|
|
||||||
bit_cast,
|
|
||||||
int_from_enum,
|
|
||||||
enum_from_int,
|
|
||||||
};
|
|
||||||
|
|
||||||
test "convert const SDL double pointer" {
|
test "convert const SDL double pointer" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
const zig_type = try convertType("const SDL_TrayEntry **", allocator);
|
const zig_type = try convertType("const SDL_TrayEntry **", allocator);
|
||||||
|
|
@ -440,7 +368,7 @@ test "convert function pointer callback type" {
|
||||||
const zig_type = try convertType("Sint64 (SDLCALL *size)(void *userdata)", allocator);
|
const zig_type = try convertType("Sint64 (SDLCALL *size)(void *userdata)", allocator);
|
||||||
defer allocator.free(zig_type);
|
defer allocator.free(zig_type);
|
||||||
|
|
||||||
try std.testing.expectEqualStrings("?*const fn(?*anyopaque) callconv(.C) i64", zig_type);
|
try std.testing.expectEqualStrings("?*const fn(?*anyopaque) callconv(.c) i64", zig_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "convert SDL pointer arrays preserves const on outer sequence" {
|
test "convert SDL pointer arrays preserves const on outer sequence" {
|
||||||
|
|
@ -455,15 +383,11 @@ test "convert SDL pointer arrays preserves const on outer sequence" {
|
||||||
try std.testing.expectEqualStrings("[*c]const ?*const GPUBuffer", const_zig_type);
|
try std.testing.expectEqualStrings("[*c]const ?*const GPUBuffer", const_zig_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "enum cast direction differs for params and returns" {
|
test "pointer const spelling without space" {
|
||||||
try std.testing.expectEqual(.int_from_enum, getParamCastType("GPUTextureFormat"));
|
const allocator = std.testing.allocator;
|
||||||
try std.testing.expectEqual(.enum_from_int, getReturnCastType("GPUTextureFormat"));
|
const a = try convertType("const char *const *", allocator);
|
||||||
try std.testing.expectEqual(.int_from_enum, getParamCastType("GPUIndexElementSize"));
|
defer allocator.free(a);
|
||||||
try std.testing.expectEqual(.enum_from_int, getReturnCastType("GPUIndexElementSize"));
|
try std.testing.expectEqualStrings("[*c]const [*c]const u8", a);
|
||||||
try std.testing.expectEqual(.bit_cast, getParamCastType("GPUShaderFormat"));
|
|
||||||
try std.testing.expectEqual(.bit_cast, getReturnCastType("GPUShaderFormat"));
|
|
||||||
try std.testing.expectEqual(.bit_cast, getParamCastType("FlipMode"));
|
|
||||||
try std.testing.expectEqual(.bit_cast, getReturnCastType("FlipMode"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test "struct fields use C pointers" {
|
test "struct fields use C pointers" {
|
||||||
|
|
@ -475,5 +399,9 @@ test "struct fields use C pointers" {
|
||||||
|
|
||||||
const generic = try convertStructFieldType("const void *", allocator);
|
const generic = try convertStructFieldType("const void *", allocator);
|
||||||
defer allocator.free(generic);
|
defer allocator.free(generic);
|
||||||
try std.testing.expectEqualStrings("[*c]const anyopaque", generic);
|
try std.testing.expectEqualStrings("?*const anyopaque", generic);
|
||||||
|
|
||||||
|
const nested = try convertStructFieldType("void **", allocator);
|
||||||
|
defer allocator.free(nested);
|
||||||
|
try std.testing.expectEqualStrings("[*c]?*anyopaque", nested);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue