From 172eb56fee0b6bde698e72be2bca55a90fe81ce9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 8 Jul 2026 12:25:04 -0300 Subject: steam deck nice version --- test/deck/schema.zig | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/deck/schema.zig (limited to 'test/deck/schema.zig') 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); +} -- cgit v1.3