[core] WIP: frames, detect, hotkey modules with tests; caps, docs, version 0.2.0 (fmt/clippy/wasm/android not yet run)

This commit is contained in:
2026-11-25 14:32:16 +01:00
parent 871d69de1c
commit 43701bbadc
13 changed files with 1394 additions and 7 deletions
+25
View File
@@ -27,6 +27,9 @@ reads capped bytes and passes them in.
| `MAX_URL` | 2048 bytes | a web-game URL | `TooLong("url")` |
| `MAX_HOST` | 253 bytes | the URL's host | `BadValue("url")` |
| `MAX_GAMES` | 100 000 | games one `merge` call considers | the rest are dropped |
| `MAX_FRAMES` | 1 048 576 | frametimes one `frames::stats` call takes | `None` |
| `MAX_MARKS` | 4096 | exes marked as games (`detect::Marks`) | `TooMany("marks")` |
| `MAX_HOTKEY` | 64 bytes | shortcut text for `hotkey::parse` | `HotkeyError::TooLong` |
## Errors
@@ -201,3 +204,25 @@ the allow-list, so launching a stored web game goes through `uri_checked`.
Steam > Epic > GOG > Domi > Manual. Games of the same source are never dropped for sharing a folder; games
without an install folder are never dropped here.
3. The result is sorted by title (lowercased, by code point), then by id, so it does not depend on scan order.
## Overlay: frametimes, detection, shortcut
**`frames::stats(&[f32])`** (milliseconds, presentation order) → `FrameStats { avg_fps, low_1, low_0_1, stutters,
frames, seconds }`. `avg_fps = frames / seconds`; the lows are `1000 / frametime` at the nearest-rank 99th and
99.9th percentile (rank `ceil(p × n)`), each capped so `low_0_1 <= low_1 <= avg_fps`; a stutter is a frame
`>= 2.5 ×` the median of the 60 frames before it (mean of the 30th and 31st smallest) **and** `>= 25 ms`; the first
60 frames are never stutters. `None` for an empty series, over `MAX_FRAMES`, any NaN, infinite or negative value,
or no time at all (zeros alone).
**`detect::detect(exe, launched_by_arena, library, marks)`**, first match wins: `Launched` (Arena started it; the
game if its folder holds the exe), `InstallDir` (the game's own launch exe, else the deepest `install_dir` strictly
containing the exe; drive roots never count as a containing folder), `Marked` (exactly this exe, `game: None`).
Otherwise `None`: an exe outside every install folder is never auto-detected. Comparison is component-wise and
ignores case; `WinPath` already refuses `..`, `.`, UNC and `\\?\`. `Marks` serialises as a sorted JSON array of
paths; loading re-checks each path and folds spellings of one exe.
**`hotkey::parse(&str)`**: `Mod+...+Key`, spaces around parts ignored, names ignore case. Modifiers `Ctrl Alt Shift
Win` (each once); key `A`–`Z`, `0`–`9`, `F1`–`F24`, last. Errors: `Empty`, `TooLong`, `Malformed` (empty part),
`UnknownModifier`, `DuplicateModifier`, `MissingKey`, `UnknownKey`, `NoModifier` (a letter or digit without Ctrl,
Alt or Win), `Reserved` (`Ctrl+Alt+Del`, `Ctrl+Shift+Esc`, `Win+L`, `Alt+F4`, any `F12`). `Display` is canonical
(`Ctrl+Alt+Shift+Win+<KEY>`); serde uses that text.