* feat(input): the arithmetic of controller statistics - classes, batteries, makers, one pad seen twice (D155-D163) Nothing reads a device yet. Domain.Input says whether an XInput state or a DualSense report is a pad in use and what its battery is, adds a battery's readings up, counts switches and decides when two entries are one pad; Application.Input holds one session's slices and turns them into a reading a second; InputSessionBuilder turns a session's readings into its totals, its controllers as JSON and its timeline. TelemetrySample can carry a reading. Every byte and reading under test was written by hand: no report from a real controller has passed through this code. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * feat(input): a session can store what it was played with - schema 0024, the .partial file's chunk 11, both tiers (D160) Nine columns on sessions (the time in front and its four classes, the switches of method, the sources that answered, the controllers as JSON) and three on games (what a store lists of controller support), ADD COLUMN only. The .partial file gains chunk 11, so a session recovered after the Agent died keeps its readings. SessionFinalizer.Build stores them before the tier branch: hooked, unhooked and recovered sessions alike. The input series are sensor_blobs rows named input.*, which the sensors' read now leaves out and FindInputSensorsAsync returns. Nothing produces a reading yet. A ledger this build has opened cannot be opened by 0.1.0-beta.49 or earlier. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * feat(input): the input reader, which the Agent does not start yet - raw input for controllers, XInput, the time of the last input (D155, D158, D159) Application.Input.InputReader takes a slice about ten times a second from Infrastructure.Input.Win32InputBackend, on the thread of InputDeviceHub, which exists only while a session has a view of it. It opens no device, sends nothing to one and registers for no keyboard or mouse. tools/input-readonly-check.ps1 holds its Windows calls to a list. With no controller at hand, what the reader does with one connected is not established. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix(input): an arm of XInputPad.Battery's switch said what the default says (Qodana, on #464 after it merged) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * test(input): no using that makes the file's own qualified names redundant (InspectCode) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * test(input): what InspectCode reported in the reader's tests - redundant casts, a hub disposed twice, a suppression not needed Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * wip(input): the Agent records what a session was played with - the switch, the terms, the legal texts Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * style(input): import order in the Agent's composition; no redundant qualifier in a test (InspectCode) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
316 lines
14 KiB
C#
316 lines
14 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||
|
||
namespace FrameLedger.Application.Settings;
|
||
|
||
/// <summary>
|
||
/// The settings registry — HANDOFF §P3 decision D16, closing <c>20_OPEN_QUESTIONS</c> §G's row and written into
|
||
/// <c>06_DATA_MODEL</c> §settings with P3 PR-3. Every key the <c>settings</c> table may hold, with its kind,
|
||
/// default and range. The UI owns <c>ui.*</c>, <c>update.*</c>, <c>privacy.*</c> and <c>log.*</c>; the Agent
|
||
/// reads <c>hooking.*</c>, <c>capture.*</c>, <c>telemetry.*</c> and <c>retention.*</c> at each session start.
|
||
/// </summary>
|
||
public static class SettingsRegistry
|
||
{
|
||
/// <summary><c>09_I18N</c>: en (neutral), vi, ja.</summary>
|
||
public static readonly SettingDefinition UiLanguage = new()
|
||
{
|
||
Key = "ui.language",
|
||
Kind = SettingKind.Choice,
|
||
Default = "en",
|
||
Choices = ["en", "vi", "ja"],
|
||
};
|
||
|
||
/// <summary><c>16_WPFUI_SYNTAX</c> §Theme rules.</summary>
|
||
public static readonly SettingDefinition UiTheme = new()
|
||
{
|
||
Key = "ui.theme",
|
||
Kind = SettingKind.Choice,
|
||
Default = "system",
|
||
Choices = ["system", "light", "dark"],
|
||
};
|
||
|
||
public static readonly SettingDefinition UiStartWithWindows = new()
|
||
{
|
||
Key = "ui.start_with_windows",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
public static readonly SettingDefinition UiMinimizeToTray = new()
|
||
{
|
||
Key = "ui.minimize_to_tray",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether a game the guard found anti-cheat in shows its Hooking card, or only the finding (beta.8, owner request
|
||
/// 2026-09-25). On by default: the card's switch can never be turned on for such a game, so hiding it leaves the
|
||
/// finding — which is always shown (FR-2.2) — and nothing that looks usable.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiHideAntiCheatHooking = new()
|
||
{
|
||
Key = "ui.hide_anticheat_hooking",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether every FPS figure the App shows has two decimals ("62.40") or is a whole number ("62") — beta.8, owner request
|
||
/// 2026-09-25. Off by default: the whole number is what every page showed until then.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiFpsDecimals = new()
|
||
{
|
||
Key = "ui.fps_decimals",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether the App draws no scroll bars (beta.14, owner request 2026-10-05): every scroller still scrolls with the wheel,
|
||
/// the keyboard and touch, it only stops showing its bar. Off by default — the bars are what every page showed until then.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiHideScrollBars = new()
|
||
{
|
||
Key = "ui.hide_scrollbars",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
/// <summary>
|
||
/// How the Games library is shown (beta.11, owner request 2026-10-03): a grid of cards that fills the width, or a list.
|
||
/// The page's own switch writes it; Settings has no row for it.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiLibraryView = new()
|
||
{
|
||
Key = "ui.library_view",
|
||
Kind = SettingKind.Choice,
|
||
Default = "grid",
|
||
Choices = ["grid", "list"],
|
||
};
|
||
|
||
/// <summary>
|
||
/// What the Play button does (beta.21, owner decision D59): <c>store</c> hands the game to the app of the store that
|
||
/// installed it — Steam and the Epic Games Launcher start it, GOG GALAXY runs it as its own shortcuts do, itch asks
|
||
/// first — and has the capture agent start it when no store did; <c>direct</c> has the capture agent start it, recorded
|
||
/// from its first frame and never as administrator. Settings ▸ Games; the Agent never reads it.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiPlayMode = new()
|
||
{
|
||
Key = "ui.play_mode",
|
||
Kind = SettingKind.Choice,
|
||
Default = "store",
|
||
Choices = ["store", "direct"],
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether a game's page shows its artwork (beta.23, owner decision D60): the image the user chose for it, else the one
|
||
/// the app of the store that installed it keeps on this PC — Steam's and GOG GALAXY's; nothing is downloaded. On by
|
||
/// default. Settings ▸ Games; the Agent never reads it.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiGameArt = new()
|
||
{
|
||
Key = "ui.game_art",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether the band at the top of a game's page takes the colour of its artwork (beta.23, owner decision D61), at the
|
||
/// strongest opacity that keeps every text on it readable. On by default (owner's choice). Settings ▸ Games.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UiGameArtTint = new()
|
||
{
|
||
Key = "ui.game_art_tint",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether the Agent's watcher records tracked games that the App did not launch (FR-3.1/FR-3.3). <b>Reserved since
|
||
/// beta.12:</b> the App showed a switch for it ("Record games launched outside FrameLedger") and no Agent code ever read
|
||
/// it, so turning it off recorded every game anyway; and the App had no way to start a game, so "off" could only have
|
||
/// meant recording nothing. The switch is gone and the key stays, read by nobody, until a launch path exists
|
||
/// (<c>06_DATA_MODEL</c> §Settings registry). One does since beta.21 — Play, through the store or the capture agent —
|
||
/// and the key stays reserved: a game Play starts is recorded exactly as a game started any other way.
|
||
/// </summary>
|
||
public static readonly SettingDefinition CaptureBackground = new()
|
||
{
|
||
Key = "capture.background",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
AgentReads = false,
|
||
};
|
||
|
||
/// <summary>FR-2.4. The one key that existed before the registry (P2 PR-F, <c>SettingsKillSwitch</c>): exactly "1" is engaged.</summary>
|
||
public static readonly SettingDefinition HookingKillSwitch = new()
|
||
{
|
||
Key = "hooking.kill_switch",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// D33 (owner decision 2026-09-26): whether a game's user-mode anti-cheat exception may apply at all. Off by default;
|
||
/// on, the user still grants each eligible game through its disclosure, and off suspends every grant without deleting
|
||
/// any (<c>19_SAFETY</c> §The user-mode exception). Exactly "1" is on.
|
||
/// </summary>
|
||
public static readonly SettingDefinition HookingUserModeExceptions = new()
|
||
{
|
||
Key = "hooking.usermode_ac_exceptions",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// The Agent's admin mode (beta.10, owner decision D34; ADR-9): whether the Agent is started as administrator — Windows
|
||
/// asks, a UAC prompt, every time it starts, whoever starts it. Off by default. Read before the Agent exists, by the App
|
||
/// and by an Agent the logon task started (<c>Infrastructure.Startup.RunElevatedSetting</c>, which names the same key);
|
||
/// exactly "1" is on. It unlocks attaching to games that run as administrator and the CPU temperature (with PawnIO); it
|
||
/// never lets a game started from FrameLedger run elevated.
|
||
/// </summary>
|
||
public static readonly SettingDefinition CaptureRunElevated = new()
|
||
{
|
||
Key = "capture.run_elevated",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>FR-3.6: sessions shorter than this are discarded. Seconds.</summary>
|
||
public static readonly SettingDefinition CaptureMinSessionSeconds = new()
|
||
{
|
||
Key = "capture.min_session_s",
|
||
Kind = SettingKind.WholeNumber,
|
||
Default = "30",
|
||
Minimum = 5,
|
||
Maximum = 600,
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// "Advanced metrics" (owner decision D101, 2026-11-11): whether the Agent reads, and a session stores, what the
|
||
/// vendor interfaces make available beyond the fixed sensors — NVAPI's facts and figures, every sensor
|
||
/// LibreHardwareMonitor has for the card and, as administrator with PawnIO, for the processor, memory and
|
||
/// motherboard (<c>18_GPU_VENDOR_APIS</c> §Advanced metrics). <b>Off by default, and off means nothing more is
|
||
/// read or stored</b>; a session recorded while it was off is never filled in afterwards. Read at each session's
|
||
/// start like every key the Agent reads. Exactly "1" is on.
|
||
/// </summary>
|
||
public static readonly SettingDefinition TelemetryAdvanced = new()
|
||
{
|
||
Key = "telemetry.advanced",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// "Controllers and input" (owner decisions D155 and D156, 2026-11-14): whether the Agent reads, from outside the
|
||
/// game, which controllers are connected and in use, their batteries and the time of the last keyboard or mouse
|
||
/// input, and a session stores what it was played with (<c>21_INPUT_DEVICES</c>). <b>On by default</b> - and read
|
||
/// only once the Privacy Policy that describes it has been accepted on the PC (<c>Input.InputTerms</c>), which is
|
||
/// the recorder policy's to check, not this key's. Off means nothing is read or stored; a session recorded while
|
||
/// it was off is never filled in afterwards. Read at each session's start. Exactly "0" is off.
|
||
/// </summary>
|
||
public static readonly SettingDefinition CaptureInputDevices = new()
|
||
{
|
||
Key = "capture.input_devices",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>FR-3.5: telemetry at 1 Hz, configurable 0.5–2 s. Milliseconds.</summary>
|
||
public static readonly SettingDefinition TelemetryIntervalMs = new()
|
||
{
|
||
Key = "telemetry.interval_ms",
|
||
Kind = SettingKind.WholeNumber,
|
||
Default = "1000",
|
||
Minimum = 500,
|
||
Maximum = 2000,
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary><c>06_DATA_MODEL</c> §Retention: raw blobs for the last N sessions per game; 0 = unlimited.</summary>
|
||
public static readonly SettingDefinition RetentionRawSessionsPerGame = new()
|
||
{
|
||
Key = "retention.raw_sessions_per_game",
|
||
Kind = SettingKind.WholeNumber,
|
||
Default = "20",
|
||
Minimum = 0,
|
||
Maximum = 10_000,
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// Whether the Agent removes a library entry whose game is no longer installed and that has no session (beta.19, owner
|
||
/// decision D55, amending D41's "nothing is removed"): its executable gone at sweeps ten minutes apart, on a drive that is
|
||
/// connected, from a folder whose parents are still there — never an entry carrying an anti-cheat block or exception.
|
||
/// On by default; off, such an entry stays and reads <i>Not installed</i>. The Agent reads it at every sweep (15 s).
|
||
/// </summary>
|
||
public static readonly SettingDefinition RetentionRemoveUninstalledGames = new()
|
||
{
|
||
Key = "retention.remove_uninstalled_games",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
AgentReads = true,
|
||
};
|
||
|
||
/// <summary>
|
||
/// <c>11_UPDATER</c>: the release feed's channel — <c>stable</c> is the releases GitHub does not mark pre-release, <c>beta</c>
|
||
/// adds the ones it does (P4 PR-5 reads it). <c>auto</c>, the default since beta.14 (owner decision D47), follows the
|
||
/// running copy: a pre-release asks for pre-releases. The default was <c>stable</c> until then, while every release is a
|
||
/// pre-release — a copy left on its defaults never found one.
|
||
/// </summary>
|
||
public static readonly SettingDefinition UpdateChannel = new()
|
||
{
|
||
Key = "update.channel",
|
||
Kind = SettingKind.Choice,
|
||
Default = "auto",
|
||
Choices = ["auto", "stable", "beta"],
|
||
};
|
||
|
||
/// <summary><c>11_UPDATER</c> §Flow: the startup silent check, "if enabled" — on by default, one request to GitHub Releases after start (P4 PR-5).</summary>
|
||
public static readonly SettingDefinition UpdateAutoCheck = new()
|
||
{
|
||
Key = "update.auto_check",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "1",
|
||
};
|
||
|
||
/// <summary>CLAUDE.md rule 8: the opt-in store-metadata fetch, off by default.</summary>
|
||
public static readonly SettingDefinition PrivacyOnlineMetadata = new()
|
||
{
|
||
Key = "privacy.online_metadata",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
/// <summary><c>10_LOGGING</c>: Debug level on the file sinks.</summary>
|
||
public static readonly SettingDefinition LogDebug = new()
|
||
{
|
||
Key = "log.debug",
|
||
Kind = SettingKind.Boolean,
|
||
Default = "0",
|
||
};
|
||
|
||
/// <summary>Every definition, in the order <c>06_DATA_MODEL</c> lists them.</summary>
|
||
public static IReadOnlyList<SettingDefinition> All { get; } =
|
||
[
|
||
UiLanguage, UiTheme, UiStartWithWindows, UiMinimizeToTray, UiHideAntiCheatHooking, UiFpsDecimals, UiHideScrollBars, UiLibraryView, UiPlayMode,
|
||
UiGameArt, UiGameArtTint, CaptureBackground, HookingKillSwitch, HookingUserModeExceptions, CaptureRunElevated, CaptureMinSessionSeconds, CaptureInputDevices, TelemetryIntervalMs, TelemetryAdvanced, RetentionRawSessionsPerGame,
|
||
RetentionRemoveUninstalledGames, UpdateChannel, UpdateAutoCheck, PrivacyOnlineMetadata, LogDebug,
|
||
];
|
||
|
||
private static readonly Dictionary<string, SettingDefinition> _byKey = All.ToDictionary(static d => d.Key, StringComparer.Ordinal);
|
||
|
||
/// <summary>The definition for a key, or null for a key the registry does not know — which no writer may use.</summary>
|
||
public static SettingDefinition? Find(string key)
|
||
{
|
||
ArgumentNullException.ThrowIfNull(key);
|
||
return _byKey.GetValueOrDefault(key);
|
||
}
|
||
}
|