From bc6fe168278957ad15cf87826c8410e7358e0849 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:07:39 -0300 Subject: anim: Event.key, and the talk example runs in a window An Event says its key (abi.Event.key), which the player and the talk example each spelled out by hand; `zig build talk` shows examples/talk.zig in a window on the generic host, its state under .zig-cache, and `zig build talk-lib --watch` beside it reloads every edit in place. Co-Authored-By: Claude Fable 5.2 --- src/abi.zig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/abi.zig') diff --git a/src/abi.zig b/src/abi.zig index 7177f14..af106af 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -114,6 +114,11 @@ pub const Event = extern struct { /// `flags` bit for a held key's auto-repeat. pub const repeat: u8 = 1; + /// The key of a `key_down` or `key_up`. + pub fn key(e: Event) Key { + return @fromBackingInt(@intCast(@as(u8, @truncate(e.code)))); + } + /// For mouse and wheel events: the modifier keys held as it happened, /// as `Key.Mod` bits. Read this rather than `Input.held`, which is the /// state after the frame's events, and misses modifiers that come with -- cgit v1.3