summaryrefslogtreecommitdiff
path: root/src/abi.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:07:39 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitbc6fe168278957ad15cf87826c8410e7358e0849 (patch)
tree7b6ec8e9f3030ba77344c24f8ce387daca287ed5 /src/abi.zig
parent87e8d3dee3bd57d28c42672d35ae214bbc058b9a (diff)
downloadsketchbook-bc6fe168278957ad15cf87826c8410e7358e0849.tar.gz
sketchbook-bc6fe168278957ad15cf87826c8410e7358e0849.zip
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 <[email protected]>
Diffstat (limited to 'src/abi.zig')
-rw-r--r--src/abi.zig5
1 files changed, 5 insertions, 0 deletions
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