summaryrefslogtreecommitdiff
path: root/test/deck/schema.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-08 12:25:04 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit172eb56fee0b6bde698e72be2bca55a90fe81ce9 (patch)
treef2fd94709facf134c3670db4c1a20a5eaca1d53d /test/deck/schema.zig
parentb91e5ebf8b529d0ced0bf18e83b17df0bd2374ce (diff)
downloadpardes-172eb56fee0b6bde698e72be2bca55a90fe81ce9.tar.gz
pardes-172eb56fee0b6bde698e72be2bca55a90fe81ce9.zip
steam deck nice version
Diffstat (limited to 'test/deck/schema.zig')
-rw-r--r--test/deck/schema.zig70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/deck/schema.zig b/test/deck/schema.zig
new file mode 100644
index 00000000..782c829a
--- /dev/null
+++ b/test/deck/schema.zig
@@ -0,0 +1,70 @@
+//! deckcap's capture format (schema.zig v1), trimmed to the types + parse
+//! the replay test needs. The .zon slices beside this file are windows cut
+//! from real Steam Deck recordings made with deckcap.
+
+const std = @import("std");
+
+pub const Recording = struct {
+ version: u32 = 1,
+ events: []const Event = &.{},
+};
+
+pub const Event = struct {
+ /// Nanoseconds since SDL init (SDL_Event.common.timestamp).
+ t: u64,
+ /// SDL joystick instance id the event came from.
+ pad: u32,
+ ev: Payload,
+
+ pub const Payload = union(enum) {
+ added: Added,
+ removed: void,
+ button: Button,
+ axis: Axis,
+ gyro: Imu,
+ accel: Imu,
+ touch: Touch,
+ };
+
+ pub const Added = struct {
+ name: []const u8,
+ vendor: u16,
+ product: u16,
+ gyro_hz: f32,
+ accel_hz: f32,
+ touchpads: u8,
+ };
+ pub const Button = struct {
+ /// SDL_GamepadButton index.
+ idx: u8,
+ down: bool,
+ };
+ pub const Axis = struct {
+ /// SDL_GamepadAxis index (sticks + triggers).
+ idx: u8,
+ value: i16,
+ };
+ pub const Imu = struct {
+ x: f32,
+ y: f32,
+ z: f32,
+ st: u64,
+ };
+ pub const Touch = struct {
+ touchpad: u8,
+ finger: u8,
+ phase: enum { down, motion, up },
+ /// Normalized 0..1.
+ x: f32,
+ y: f32,
+ pressure: f32,
+ };
+};
+
+pub fn parse(gpa: std.mem.Allocator, src: [:0]const u8) error{ OutOfMemory, ParseZon }!Recording {
+ return std.zon.parse.fromSliceAlloc(Recording, gpa, src, null, .{});
+}
+
+pub fn free(gpa: std.mem.Allocator, rec: Recording) void {
+ std.zon.parse.free(gpa, rec);
+}