No description
|
Mikael Säker
1297c859a4
deps: repin sokol to the reachable deadkeys head
The old pin (78fdd365) predates a force-push and is unreachable from any ref — cold fetches failed. 8bed105f is the current deadkeys branch head. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| src | Expose translateLogical for ad-hoc lookups | |
| .gitignore | Initial sokey: sokol keyboard event coalescing with layout-aware logical keys | |
| build.zig | Initial sokey: sokol keyboard event coalescing with layout-aware logical keys | |
| build.zig.zon | deps: repin sokol to the reachable deadkeys head | |
| README.md | Initial sokey: sokol keyboard event coalescing with layout-aware logical keys | |
sokey
Sokol keyboard event coalescing with layout-aware logical keys.
What it does
sokol_app delivers keyboard input as three separate event types
(KEY_DOWN, CHAR, KEY_UP). sokey coalesces them into a single
KeyEvent per logical press/release that carries:
physical— sokol's positional keycode (right answer for arrows, F-keys, modifier-only chords like Cmd+Q)logical— layout-aware unmodified key (right answer for game action bindings and vim-style commands; matches the cap the user sees with the active layout)text— UTF-8 of what the OS would type into a text field (right answer for in-game text input, with shift, dead-keys, IME applied)mods— modifier state at event timekind—down/up/repeat
Both game-style action mapping and text input read from the same stream; each consumer picks the field it needs.
Status
- macOS: layout-aware via Carbon's TIS /
UCKeyTranslate. - Windows: stub —
logicalreturns null. Falls back to positional. - Linux: stub — same.
Usage
constsapp=@import("sokol").app;constsokey=@import("sokey");exportfnevent(ev_ptr:[*c]constsapp.Event)void{sokey.feed(&ev_ptr[0]);}fnframe()void{sokey.flushPending();while(sokey.poll())|ke|{// ke.physical, ke.logical, ke.text(), ke.mods, ke.kind}}pubfnmain()void{sokey.disablePressAndHold();// macOS QoL: hold-to-repeatsapp.run(.{.event_cb=event,.frame_cb=frame,...});}Tests
zig build test