Something went wrong. Try again.
A Zig library for driving Elgato Stream Deck devices over USB HID.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631// SPDX-FileCopyrightText: © 2025 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! The keys of a Stream Deck: the grid of push buttons, and on some//! models a row of touch keys beside it. This is where key presses are//! decoded and where images are prepared and sent to individual keys.//!//! A `Keys` lives as the `keys` field of a `StreamDeck` and carries no//! state of its own. It recovers the device it belongs to with//! `@fieldParentPtr`, so the layout and image requirements reported//! here depend on the model of that device.
const Keys = @This();
const std = @import("std");
const z2d = @import("z2d");
const bmp = @import("bmp.zig");const ImageFormat = @import("root.zig").ImageFormat;const ImageHeaderV1 = @import("image.zig").ImageHeaderV1;const ImageHeaderV2 = @import("image.zig").ImageHeaderV2;const jpeg = @import("jpeg.zig");const Rotation = @import("root.zig").ImageRotation;const StreamDeck = @import("StreamDeck.zig");const devices = @import("devices.zig");const diagnostic = @import("diagnostic.zig");// const svg = @import("svg.zig");const image = @import("image.zig");
/// The value to initialize the `keys` field of a `StreamDeck` with.pub const init: Keys = .{};
/// Whether a key is currently pressed.pub const State = enum(u8) { up = 0, down = 1,};
/// The kind of key event. The devices only ever report presses and/// releases, but the tag is kept so that `Event` matches the shape of/// `Encoders.Event`.pub const EventType = enum(u8) { push = 0,};
/// A single report of key activity. The device describes every key at/// once rather than just the one that changed, so `states` holds one/// entry per key, in the order the keys are numbered.pub const Event = struct { timestamp: std.Io.Timestamp, event: union(EventType) { push: struct { states: []State, }, },
/// Parse the key portion of an input report, which `data` must /// point at, one byte per key. A byte that is not a state this /// library knows about reads as `up`, deliberately: the devices /// only ever send 0 and 1, and one odd byte is not a reason to /// throw away the state of every other key in the report. The /// caller owns the result and must release it with `deinit`. pub fn init(alloc: std.mem.Allocator, timestamp: std.Io.Timestamp, data: []const u8) !*Event { const self = try alloc.create(Event); errdefer alloc.destroy(self);
self.* = .{ .timestamp = timestamp, .event = .{ .push = .{ .states = try alloc.alloc(State, data.len), }, }, }; errdefer alloc.free(self.event.push.states);
for (data, 0..) |state, i| { self.event.push.states[i] = std.enums.fromInt(State, state) orelse .up; }
return self; }
/// Free the event and the states it holds. `alloc` must be the /// allocator the event was created with. pub fn deinit(self: *const Event, alloc: std.mem.Allocator) void { switch (self.event) { .push => |p| alloc.free(p.states), } alloc.destroy(self); }};
/// The number of columns in the key grid.pub fn cols(self: *const Keys) u5 { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); return switch (sd.type) { inline else => |t| @field(devices, @tagName(t)).keys.cols, }; // return switch (sd.type) { // .ElgatoStreamDeckMK2 => 5, // .ElgatoStreamDeckMini => 3, // .ElgatoStreamDeckMiniMK2 => 3, // .ElgatoStreamDeckNeo => 4, // .ElgatoStreamDeckOriginal => 5, // .ElgatoStreamDeckOriginalV2 => 5, // .ElgatoStreamDeckPedal => 3, // .ElgatoStreamDeckPlus => 4, // .ElgatoStreamDeckPlusXL => 9, // .ElgatoStreamDeckStudio => 16, // .ElgatoStreamDeckXL => 8, // .ElgatoStreamDeckXLV2 => 8, // };}
/// The number of rows in the key grid.pub fn rows(self: *const Keys) u5 { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); return switch (sd.type) { inline else => |t| @field(devices, @tagName(t)).keys.rows, }; // return switch (sd.type) { // .ElgatoStreamDeckMK2 => 3, // .ElgatoStreamDeckMini => 2, // .ElgatoStreamDeckMiniMK2 => 2, // .ElgatoStreamDeckNeo => 2, // .ElgatoStreamDeckOriginal => 3, // .ElgatoStreamDeckOriginalV2 => 3, // .ElgatoStreamDeckPedal => 1, // .ElgatoStreamDeckPlus => 2, // .ElgatoStreamDeckPlusXL => 4, // .ElgatoStreamDeckStudio => 2, // .ElgatoStreamDeckXL => 4, // .ElgatoStreamDeckXLV2 => 4, // };}
/// The number of touch keys the device has in addition to its grid./// These are numbered after the grid keys, so on a Stream Deck Neo the/// grid occupies keys 0 through 7 and the two touch keys are 8 and 9.pub fn touch(self: *const Keys) u5 { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); return switch (sd.type) { inline else => |t| @field(devices, @tagName(t)).keys.touch, }; // return switch (sd.type) { // .ElgatoStreamDeckMK2 => 0, // .ElgatoStreamDeckMini => 0, // .ElgatoStreamDeckMiniMK2 => 0, // .ElgatoStreamDeckNeo => 2, // .ElgatoStreamDeckOriginal => 0, // .ElgatoStreamDeckOriginalV2 => 0, // .ElgatoStreamDeckPedal => 0, // .ElgatoStreamDeckPlus => 0, // .ElgatoStreamDeckPlusXL => 0, // .ElgatoStreamDeckStudio => 16, // .ElgatoStreamDeckXL => 0, // .ElgatoStreamDeckXLV2 => 0, // };}
/// The total number of keys, the grid and the touch keys together.pub fn count(self: *const Keys) u8 { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); return switch (sd.type) { inline else => |t| @field(devices, @tagName(t)).keys.count, }; // return (self.rows() * self.cols()) + self.touch();}
/// The number of bytes that key state occupies in the body of an input/// report, one per key. `Events.bodySize` takes the largest of these/// across all of the control groups to size its read buffer.pub fn readSize(self: *const Keys) usize { return @intCast(self.count());}
/// The layout of the header that prefixes each page of image data sent/// to a key. Which one a device wants comes from `KeyImageFeature`.pub const KeyImageHeaderFormat = enum { v1, v2,
/// The size of the header in bytes, which is also how much of each /// packet is unavailable for image data. pub fn headerSize(self: KeyImageHeaderFormat) usize { return switch (self) { .v1 => 16, .v2 => 8, }; }};
/// Everything needed to put an image on a key: how large it has to be,/// how it has to be encoded, and the rotation and flips that have to be/// applied first, since the displays are not all mounted the same way/// around. `setImage` performs those steps in that order.pub const KeyImageFeature = struct { header_format: KeyImageHeaderFormat, image_format: ImageFormat, width: usize, height: usize, rotation: ?Rotation, flip_top_bottom: bool, flip_left_right: bool,};
/// What a key is capable of: nothing at all, as on the Stream Deck/// Pedal, an image display, or a touch key whose backlight color can be/// set with `setTouchKeyColor`.pub const KeyFeature = union(enum) { none, image: KeyImageFeature, touchled,};
/// What the given key is capable of, or null if the device has no such/// key. Keys are numbered from zero.pub fn getFeature(self: *const Keys, key: u8) ?KeyFeature { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); return switch (sd.type) { inline else => |t| @field(devices, @tagName(t)).keys.getFeature(key), }; // return switch (sd.type) { // .ElgatoStreamDeckMK2 => @import("devices/ElgatoStreamDeckMK2.zig").getKeyFeature(key), // .ElgatoStreamDeckMini => @import("devices/ElgatoStreamDeckMini.zig").getKeyFeature(key), // .ElgatoStreamDeckMiniMK2 => @import("devices/ElgatoStreamDeckMiniMK2.zig").getKeyFeature(key), // .ElgatoStreamDeckOriginal => @import("devices/ElgatoStreamDeckOriginal.zig").getKeyFeature(key), // .ElgatoStreamDeckOriginalV2 => @import("devices/ElgatoStreamDeckOriginalV2.zig").getKeyFeature(key), // .ElgatoStreamDeckPedal => @import("devices/ElgatoStreamDeckPedal.zig").getKeyFeature(key), // .ElgatoStreamDeckPlus => @import("devices/ElgatoStreamDeckPlus.zig").getKeyFeature(key), // .ElgatoStreamDeckPlusXL => @import("devices/ElgatoStreamDeckPlusXL.zig").getKeyFeature(key), // .ElgatoStreamDeckStudio => @import("devices/ElgatoStreamDeckStudio.zig").getKeyFeature(key), // .ElgatoStreamDeckXL => @import("devices/ElgatoStreamDeckXL.zig").getKeyFeature(key), // .ElgatoStreamDeckXLV2 => @import("devices/ElgatoStreamDeckXLV2.zig").getKeyFeature(key), // .ElgatoStreamDeckNeo => @import("devices/ElgatoStreamDeckNeo.zig").getKeyFeature(key), // };}
/// Like `getFeature`, but null unless the key is one that displays an/// image. Useful for the callers that only care about that case.pub fn getImageFeature(self: *const Keys, key: u8) ?KeyImageFeature { const features = self.getFeature(key) orelse return null;
switch (features) { .image => |i| return i, else => return null, }}
/// Write the header for one page of image data in whichever format the/// key wants. `length` is the size of the page that follows and `last`/// marks the final page of the image. Writes nothing for a key that/// does not display images.fn writeImageHeader(self: *const Keys, writer: *std.Io.Writer, key: u8, last: bool, length: u16, page_number: u16) !void { const feature = self.getImageFeature(key) orelse return; switch (feature.header_format) { .v1 => { const packet: ImageHeaderV1 = .{ .page_number = @intCast(page_number), .last = last, .key = key + 1, }; std.debug.assert(@sizeOf(@TypeOf(packet)) == 16); try writer.writeStruct(packet, .little); }, .v2 => { const packet: ImageHeaderV2 = .{ .key = key, .last = last, .length = length, .page_number = page_number, }; std.debug.assert(@sizeOf(@TypeOf(packet)) == 8); try writer.writeStruct(packet, .little); }, }}
/// Display an image on a key. The image is rotated, flipped and/// encoded as that key requires, then split into pages small enough to/// fit in a packet alongside their header and written to the device one/// at a time. Does nothing if the key does not display images, and/// returns `error.ImageFormatError` if the encoder produced something/// other than the expected format. `surface` is left untouched; the/// transformations are made on the way out of it.pub fn setImage(self: *const Keys, io: std.Io, alloc: std.mem.Allocator, key: u8, surface: z2d.Surface) !void { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self));
const features = self.getImageFeature(key) orelse return;
const image_data = try encodeImage(alloc, surface, features); defer alloc.free(image_data);
// How big a report is, and what the first page is numbered, are the // model's to say: the Original takes 8191 byte reports and counts // its pages from one, where everything else takes 1024 and counts // from zero. const report = sd.type.imageReport(); const max = report.size - features.header_format.headerSize();
var iter = std.mem.window(u8, image_data, max, max); var page_number: u16 = report.first_page; while (iter.next()) |page| : (page_number += 1) { var buffer = std.mem.zeroes([StreamDeck.MAX_IMAGE_REPORT_SIZE]u8); const packet = buffer[0..report.size]; var writer = std.Io.Writer.fixed(packet); const last = page.len < max; try self.writeImageHeader(&writer, key, last, @intCast(page.len), page_number); try writer.writeAll(page); _ = try sd.device.write(io, packet); }}
/// A black image of the right size for the given key, ready to be/// drawn on and handed to `setImage`. Null if the key does not display/// images. The caller owns the result.pub fn blankImage(self: *const Keys, alloc: std.mem.Allocator, key: u8) !?z2d.Surface { const feature = self.getImageFeature(key) orelse return null; return try image.blankImage(alloc, feature.width, feature.height);}
/// Encode a surface the way a key wants it: rotated and flipped as/// that display is mounted, in the channel order its encoder takes, and/// then as BMP or JPEG bytes ready to be paged out to the device.////// This is the half of `setImage` that does not touch the device, split/// out so that it can be tested and fuzzed without one. Returns/// `error.ImageFormatError` if the encoder produced something other/// than the format that was asked of it. The caller owns the result.pub fn encodeImage( alloc: std.mem.Allocator, surface: z2d.Surface, feature: KeyImageFeature,) ![]const u8 { // The rotation and the flips this display needs, undone again by // the way it is physically mounted. var turned = try image.transform(alloc, surface, .{ .rotation = feature.rotation, .flip_left_right = feature.flip_left_right, .flip_top_bottom = feature.flip_top_bottom, }); defer turned.deinit(alloc);
const image_data = switch (feature.image_format) { .BMP => try bmp.encode(alloc, turned), .JPEG => try jpeg.encode(alloc, turned, .{}), }; errdefer alloc.free(image_data);
// Sanity check the image data: the encoder should have produced the // format that was asked of it. The test is the marker each format // begins with -- "BM" for BMP, and the start of image marker for // JPEG. switch (feature.image_format) { .BMP => if (!std.mem.eql(u8, image_data[0..2], &.{ 0x42, 0x4d })) return error.ImageFormatError, .JPEG => if (!std.mem.eql(u8, image_data[0..2], &.{ 0xff, 0xd8 })) return error.ImageFormatError, }
return image_data;}
/// A diagnostic image for the given key: the key's own index in seven/// segment figures with a rule under it, sized for that key and ready/// to hand to `setImage`. Null if the key displays no image.////// This is for telling which key is which, and for telling whether a/// key image arrived the right way up: an underlined 6 turned upside/// down is a 9 with a line over it, which is unmistakable where a bare/// 6 and 9 are not. The caller owns the result.pub fn indexImage( self: *const Keys, alloc: std.mem.Allocator, key: u8, polarity: diagnostic.Polarity,) !?z2d.Surface { const feature = self.getImageFeature(key) orelse return null; return try diagnostic.keyIndexImage(alloc, feature.width, feature.height, key, polarity);}
test indexImage { const alloc = std.testing.allocator;
var sd = testDeck(.ElgatoStreamDeckMK2);
// A key with a display gets an image of that display's size. var img = (try sd.keys.indexImage(alloc, 0, .yellow_on_black)).?; defer img.deinit(alloc); try std.testing.expectEqual(72, img.getWidth()); try std.testing.expectEqual(72, img.getHeight());
// And a key without one gets nothing rather than a blank image. try std.testing.expectEqual(null, try sd.keys.indexImage(alloc, 99, .yellow_on_black));
var pedal = testDeck(.ElgatoStreamDeckPedal); try std.testing.expectEqual(null, try pedal.keys.indexImage(alloc, 0, .yellow_on_black));}
test "every key with a display can be given its own index" { const alloc = std.testing.allocator;
inline for (comptime std.enums.values(StreamDeck.Type)) |t| { var sd = testDeck(t);
for (0..sd.keys.count()) |i| { const key: u8 = @intCast(i); var img = (try sd.keys.indexImage(alloc, key, .yellow_on_black)) orelse continue; defer img.deinit(alloc);
const feature = sd.keys.getImageFeature(key).?; try std.testing.expectEqual(@as(i32, @intCast(feature.width)), img.getWidth()); try std.testing.expectEqual(@as(i32, @intCast(feature.height)), img.getHeight()); } }}
/// Set the backlight color of one of the touch keys. Returns/// `error.NotTouchKey` if the key is not one of them.pub fn setTouchKeyColor(self: *const Keys, io: std.Io, key: u8, r: u8, g: u8, b: u8) !void { const sd: *const StreamDeck = @alignCast(@fieldParentPtr("keys", self)); const feature = self.getFeature(key) orelse return error.NotTouchKey; if (feature != .touchled) return error.NotTouchKey; const packet: extern struct { byte0: u8 = 0x03, byte1: u8 = 0x06, key: u8, r: u8, g: u8, b: u8, } = .{ .key = key, .r = r, .g = g, .b = b, }; std.debug.assert(@sizeOf(@TypeOf(packet)) == 6); _ = try sd.device.sendFeatureReport(io, std.mem.asBytes(&packet));}
/// A `StreamDeck` of the given model with nothing behind it. The/// functions that only depend on which model a device is never touch/// the handle, so they can be tested without one; anything that talks/// to the device cannot, and is only compiled here rather than run.fn testDeck(t: StreamDeck.Type) StreamDeck { return .{ .type = t, .device = .none };}
test cols { var sd = testDeck(.ElgatoStreamDeckMK2); try std.testing.expectEqual(5, sd.keys.cols()); try std.testing.expectEqual(3, sd.keys.rows()); try std.testing.expectEqual(0, sd.keys.touch()); try std.testing.expectEqual(15, sd.keys.count()); try std.testing.expectEqual(15, sd.keys.readSize());}
test count { // Every model, so that a `Keys` reports what its device module // says whichever one it is attached to, and so that the switches // here stay exhaustive as models are added. inline for (comptime std.enums.values(StreamDeck.Type)) |t| { const device = @field(devices, @tagName(t)); var sd = testDeck(t);
try std.testing.expectEqual(device.keys.cols, sd.keys.cols()); try std.testing.expectEqual(device.keys.rows, sd.keys.rows()); try std.testing.expectEqual(device.keys.touch, sd.keys.touch()); try std.testing.expectEqual(device.keys.count, sd.keys.count());
// One byte of the report body per key. try std.testing.expectEqual(device.keys.count, sd.keys.readSize());
// And every key the device has reports a feature, through the // `@fieldParentPtr` hop rather than straight off the module. for (0..sd.keys.count()) |key| { try std.testing.expect(sd.keys.getFeature(@intCast(key)) != null); } }}
test getFeature { var sd = testDeck(.ElgatoStreamDeckNeo);
// The grid keys take an image, the two after it take a color, and // there is nothing past them. try std.testing.expectEqual(96, sd.keys.getImageFeature(0).?.width); try std.testing.expectEqual(KeyFeature.touchled, sd.keys.getFeature(8).?); try std.testing.expectEqual(null, sd.keys.getImageFeature(8)); try std.testing.expectEqual(null, sd.keys.getFeature(10));
// The Pedal has keys but no displays, so every one of them reports // `none` and none of them has an image feature. var pedal = testDeck(.ElgatoStreamDeckPedal); try std.testing.expectEqual(3, pedal.keys.count()); try std.testing.expectEqual(KeyFeature.none, pedal.keys.getFeature(0).?); try std.testing.expectEqual(null, pedal.keys.getImageFeature(0));}
test KeyImageHeaderFormat { // The header sizes are written out by hand but have to match the // structs they describe, because they are what is subtracted from // the packet size to size a page of image data. try std.testing.expectEqual(@sizeOf(ImageHeaderV1), KeyImageHeaderFormat.v1.headerSize()); try std.testing.expectEqual(@sizeOf(ImageHeaderV2), KeyImageHeaderFormat.v2.headerSize());}
test writeImageHeader { var buf: [32]u8 = undefined;
{ // The Original wants a v1 header, which numbers keys from one. var sd = testDeck(.ElgatoStreamDeckOriginal); var writer = std.Io.Writer.fixed(&buf); try sd.keys.writeImageHeader(&writer, 3, true, 0, 1); try std.testing.expectEqualSlices(u8, &.{ 0x02, 0x01, 0x01, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, writer.buffered()); }
{ // The MK2 wants a v2 header, which numbers keys from zero and // carries the length of the page. var sd = testDeck(.ElgatoStreamDeckMK2); var writer = std.Io.Writer.fixed(&buf); try sd.keys.writeImageHeader(&writer, 3, false, 0x3f8, 2); try std.testing.expectEqualSlices(u8, &.{ 0x02, 0x07, 0x03, 0x00, 0xf8, 0x03, 0x02, 0x00, }, writer.buffered()); }
{ // A key that shows no image gets no header at all. var sd = testDeck(.ElgatoStreamDeckPedal); var writer = std.Io.Writer.fixed(&buf); try sd.keys.writeImageHeader(&writer, 0, true, 0, 0); try std.testing.expectEqual(0, writer.buffered().len); }}
test Event { const alloc = std.testing.allocator;
const event = try Event.init(alloc, .{ .nanoseconds = 0 }, &.{ 0, 1, 0 }); defer event.deinit(alloc);
try std.testing.expectEqualSlices(State, &.{ .up, .down, .up }, event.event.push.states);}
test "an unknown key state is treated as up" { const alloc = std.testing.allocator;
// The parser logs the byte it did not recognize, which is the // point of it; quieten that so a passing run stays silent. const saved = std.testing.log_level; std.testing.log_level = .err; defer std.testing.log_level = saved;
const event = try Event.init(alloc, .{ .nanoseconds = 0 }, &.{ 1, 0x7f }); defer event.deinit(alloc);
try std.testing.expectEqualSlices(State, &.{ .down, .up }, event.event.push.states);}
test "a report with no keys in it parses to no states" { const alloc = std.testing.allocator;
const event = try Event.init(alloc, .{ .nanoseconds = 0 }, &.{}); defer event.deinit(alloc);
try std.testing.expectEqual(0, event.event.push.states.len);}
test "a key report cleans up after a failed allocation" { // `Event.init` makes two allocations and has to unwind the first // if the second fails. A test with a working allocator never takes // that path, so it is checked by failing each allocation in turn. try std.testing.checkAllAllocationFailures(std.testing.allocator, struct { fn run(alloc: std.mem.Allocator) !void { const event = try Event.init(alloc, .{ .nanoseconds = 0 }, &.{ 0, 1, 0, 1, 0 }); defer event.deinit(alloc); } }.run, .{});}
test "encoding a key image cleans up after a failed allocation" { // The longest allocating path in the library: a surface, a // transformed copy of it, the encoder's growing buffer, and the // slice handed back. inline for (.{ StreamDeck.Type.ElgatoStreamDeckMK2, StreamDeck.Type.ElgatoStreamDeckOriginal, StreamDeck.Type.ElgatoStreamDeckMini, }) |t| { try std.testing.checkAllAllocationFailures(std.testing.allocator, struct { fn run(alloc: std.mem.Allocator) !void { var sd: StreamDeck = .{ .type = t, .device = .none }; const feature = sd.keys.getImageFeature(0).?;
var surface = try image.blankImage(alloc, feature.width, feature.height); defer surface.deinit(alloc);
const data = try encodeImage(alloc, surface, feature); defer alloc.free(data); } }.run, .{}); }}
test "a diagnostic key image cleans up after a failed allocation" { try std.testing.checkAllAllocationFailures(std.testing.allocator, struct { fn run(alloc: std.mem.Allocator) !void { var sd: StreamDeck = .{ .type = .ElgatoStreamDeckMK2, .device = .none }; var img = (try sd.keys.indexImage(alloc, 6, .yellow_on_black)).?; defer img.deinit(alloc); } }.run, .{});}
test { // `setImage` and `setTouchKeyColor` need a device to talk to, so // they cannot be run here. Referring to them still puts them in // front of the compiler, which is the point: Zig does not check a // function nothing calls, and that is how this file came to hold // a call to a `copy.tra` that does not exist. std.testing.refAllDecls(@This()); std.testing.refAllDecls(Event);}