config

package
v2.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName              = "zaparoo"
	MediaDbFile          = "media.db"
	UserDbFile           = "user.db"
	LogFile              = "core.log"
	PidFile              = "core.pid"
	CfgFile              = "config.toml"
	AuthFile             = "auth.toml"
	TUIFile              = "tui.toml"
	UserDir              = "user"
	LogsDir              = "logs"
	APIRequestTimeout    = 30 * time.Second
	SuccessSoundFilename = "success.ogg"
	FailSoundFilename    = "fail.ogg"
	LimitSoundFilename   = "limit.ogg"
	PendingSoundFilename = "pending.ogg"
	ReadySoundFilename   = "ready.ogg"
	AssetsDir            = "assets"
	MappingsDir          = "mappings"
	LaunchersDir         = "launchers"
	MediaDir             = "media"
	CacheDir             = "cache"
	LogUploadURL         = "https://logs.zaparoo.org/"
	MinFreeDiskBytes     = 500 * 1024 * 1024 // 500 MB
)
View Source
const (
	SchemaVersion       = 1
	CfgEnv              = "ZAPAROO_CFG"
	AppEnv              = "ZAPAROO_APP"
	ScanModeTap         = "tap"
	ScanModeHold        = "hold"
	UpdateChannelStable = "stable"
	UpdateChannelBeta   = "beta"
)
View Source
const (
	InputModeCombos       = "combos"
	InputModeUnrestricted = "unrestricted"
)
View Source
const (
	DefaultBackupRemoteBaseURL  = "https://api.zaparoo.com"
	DefaultBackupRemoteSchedule = "daily"
)
View Source
const (
	// BackupScopePlatform includes platform files (settings, inputs,
	// saves, savestates) alongside Zaparoo's own data.
	BackupScopePlatform = "platform"
	// BackupScopeZaparoo restricts backups to Zaparoo's own data:
	// user.db, Core config, frontend/TUI config, launchers, mappings.
	BackupScopeZaparoo = "zaparoo"
)

Backup scopes select what a backup job collects.

View Source
const (
	DefaultGmcProxyPort           = 32106
	DefaultGmcProxyBeaconInterval = "2s"
)
View Source
const (
	CustomLauncherKindLauncher      = "launcher"
	CustomLauncherKindVirtualSystem = "virtual_system"
	CustomLauncherBackendCommand    = "command"
	CustomLauncherBackendMisterCore = "mister_core"
)
View Source
const (
	IndexDuringMediaThrottle = "throttle"
	IndexDuringMediaPause    = "pause"
)

Values for IndexDuringMedia/IndexDuringStreamingMedia: how background media work (indexing, scraping) behaves while media is playing in the primary slot.

View Source
const (
	DefaultAPIPort = 7497
	MinAPIPort     = 1024
	MaxAPIPort     = 65535
)
View Source
const DefaultLaunchGuardTimeout float32 = 15

DefaultLaunchGuardTimeout is the default timeout in seconds for staged tokens when launch_guard is enabled and no custom timeout is set.

View Source
const DefaultPlaytimeBaseURL = "https://api.zaparoo.com"

Variables

View Source
var AppVersion = "DEVELOPMENT"
View Source
var BaseDefaults = Values{
	ConfigSchema: SchemaVersion,
	Audio: Audio{
		ScanFeedback: true,
	},
	Backup: Backup{
		Remote: BackupRemote{
			Schedule: DefaultBackupRemoteSchedule,
		},
	},
	Readers: Readers{
		AutoDetect: true,
		Scan: ReadersScan{
			Mode: ScanModeTap,
		},
	},
}
View Source
var OfficialAuthHosts = []string{
	"api.zaparoo.com",
	"edge.zaparoo.com",
	"zpr.au",
}

OfficialAuthHosts are the hosts of the official hosted API services. settings.auth.status only answers link probes for these hosts (over HTTPS) and the configured backup server; other URLs report linked=false without revealing whether a credential exists. The claim flow's trusted-domain extension may store credentials under further domains — those are found at unlink time by linked_via provenance tags, never by this list.

Functions

func BackupAuthLookupURL added in v2.16.0

func BackupAuthLookupURL(rawURL string) string

func ClearAuthCfgForTesting

func ClearAuthCfgForTesting()

ClearAuthCfgForTesting clears the global auth config for testing purposes

func GetAPIKeys added in v2.9.0

func GetAPIKeys() []string

func GetAuthCfg

func GetAuthCfg() map[string]CredentialEntry

func IsDevelopmentVersion added in v2.10.0

func IsDevelopmentVersion() bool

IsDevelopmentVersion returns true if AppVersion indicates a non-release build. This includes the literal "DEVELOPMENT" default and "<hash>-dev" builds.

func IsStreamingSystem added in v2.16.0

func IsStreamingSystem(systemID string) bool

IsStreamingSystem reports whether systemID streams continuously from storage during play (CD-based/optical cores), which needs a heavier indexing throttle (or pause) to avoid audible dropouts.

func LoadAPIKeysFromData added in v2.9.0

func LoadAPIKeysFromData(data []byte) []string

LoadAPIKeysFromData parses root-level api_keys from auth.toml and returns valid API keys. Empty strings are filtered out.

func LoadAuthFromData added in v2.8.0

func LoadAuthFromData(data []byte) map[string]CredentialEntry

LoadAuthFromData parses auth.toml data supporting all three formats. Formats are merged, allowing users to mix formats in the same file.

Supported formats:

func LoadTUIConfig added in v2.9.0

func LoadTUIConfig(configDir, platformID string) error

LoadTUIConfig loads the TUI configuration from disk. If the file doesn't exist, it creates one with default values. Missing values in the file are filled with defaults. Platform ID is used to apply platform-specific defaults (e.g., CRT mode on MiSTer).

func PreserveRestoreOverrides added in v2.16.0

func PreserveRestoreOverrides(data []byte, deviceID string, encryption bool) ([]byte, error)

PreserveRestoreOverrides forces destination-owned service values into restored config data: the device identity and the encryption requirement. Everything else in the restored config wins.

func RemoteAuthLookupURL added in v2.16.0

func RemoteAuthLookupURL(rawURL string) string

func SaveTUIConfig added in v2.9.0

func SaveTUIConfig(configDir string) error

SaveTUIConfig saves the current TUI configuration to disk.

func SetAuthCfgForTesting

func SetAuthCfgForTesting(creds map[string]CredentialEntry)

SetAuthCfgForTesting sets the global auth config for testing purposes

func SetTUIConfig added in v2.9.0

func SetTUIConfig(cfg TUIConfig)

SetTUIConfig updates the TUI configuration in memory.

func ValidateBackupRemoteBaseURL added in v2.16.0

func ValidateBackupRemoteBaseURL(rawURL string) error

func ValidatePlaytimeBaseURL added in v2.16.0

func ValidatePlaytimeBaseURL(rawURL string) error

func ValidateRenderResolution added in v2.16.0

func ValidateRenderResolution(value string) (width, height int, err error)

ValidateRenderResolution validates and parses a positive WIDTHxHEIGHT render target.

Types

type Audio

type Audio struct {
	SuccessSound *string `toml:"success_sound,omitempty"`
	FailSound    *string `toml:"fail_sound,omitempty"`
	LimitSound   *string `toml:"limit_sound,omitempty"`
	PendingSound *string `toml:"pending_sound,omitempty"`
	ReadySound   *string `toml:"ready_sound,omitempty"`
	Volume       *int    `toml:"volume,omitempty"`
	ScanFeedback bool    `toml:"scan_feedback"`
}

type Backup added in v2.16.0

type Backup struct {
	LocalDir string       `toml:"local_dir,omitempty"`
	Scope    string       `toml:"scope,omitempty"`
	Remote   BackupRemote `toml:"remote,omitempty"`
}

type BackupRemote added in v2.16.0

type BackupRemote struct {
	BaseURL  string `toml:"base_url,omitempty"`
	Schedule string `toml:"schedule,omitempty"`
	Enabled  bool   `toml:"enabled,omitempty"`
}

type CredentialEntry

type CredentialEntry struct {
	Username string `toml:"username,omitempty"`
	Password string `toml:"password,omitempty"` //nolint:gosec // G117: auth config struct field
	Bearer   string `toml:"bearer,omitempty"`
	// LinkedVia records which auth root domain created this entry during a
	// claim/link flow — the root tags itself and every trusted-domain copy
	// it extends to. Unlink removes entries by this provenance. Empty for
	// hand-written entries.
	LinkedVia string `toml:"linked_via,omitempty"`
}

CredentialEntry holds authentication credentials for a URL.

func LookupAuth

func LookupAuth(creds map[string]CredentialEntry, reqURL string) *CredentialEntry

LookupAuth finds credentials for a URL using fallback matching.

The lookup tries 3 match types in order of decreasing specificity:

  1. Exact scheme match - scheme, host, and path prefix must match exactly
  2. Canonical scheme match - normalized schemes match (e.g., tcp://x matches mqtt://x config)
  3. Schemeless host:port match - for entries like "broker:1883" that match any scheme

This design allows:

  • Strict scheme matching for security-sensitive protocols (http vs https)
  • Flexible matching for protocols with multiple equivalent schemes (mqtt/tcp/ssl)
  • Simple host:port entries for services where scheme doesn't matter

type Discovery added in v2.8.0

type Discovery struct {
	Enabled      *bool  `toml:"enabled,omitempty"`
	InstanceName string `toml:"instance_name,omitempty"`
}

type DriverConfig

type DriverConfig struct {
	Enabled    *bool `toml:"enabled,omitempty"`
	AutoDetect *bool `toml:"auto_detect,omitempty"`
}

type DriverInfo added in v2.8.0

type DriverInfo struct {
	ID                string
	DefaultEnabled    bool
	DefaultAutoDetect bool
}

DriverInfo contains driver metadata needed for enabled/auto-detect checks. This is a subset of reader metadata to avoid circular imports.

type Groovy

type Groovy struct {
	GmcProxyBeaconInterval *string `toml:"gmc_proxy_beacon_interval,omitempty"`
	GmcProxyPort           *int    `toml:"gmc_proxy_port,omitempty"`
	GmcProxyEnabled        *bool   `toml:"gmc_proxy_enabled,omitempty"`
}

type Input added in v2.7.1

type Input struct {
	GamepadEnabled *bool `toml:"gamepad_enabled,omitempty"`
}

type InputConfig added in v2.11.0

type InputConfig struct {
	Mode  *string  `toml:"mode,omitempty"`
	Allow []string `toml:"allow,omitempty,multiline"`
	Block []string `toml:"block,omitempty,multiline"`
}

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(configDir string, defaults Values) (*Instance, error)

func NewConfigWithFs added in v2.9.1

func NewConfigWithFs(configDir string, defaults Values, fs afero.Fs) (*Instance, error)

NewConfigWithFs creates a new config instance using the provided filesystem. This allows tests to use an in-memory filesystem instead of the real OS filesystem.

func (*Instance) APIListen added in v2.7.0

func (c *Instance) APIListen() string

func (*Instance) APIPort

func (c *Instance) APIPort() int

func (*Instance) AllowedIPs added in v2.7.0

func (c *Instance) AllowedIPs() []string

func (*Instance) AllowedOrigins

func (c *Instance) AllowedOrigins() []string

func (*Instance) AudioFeedback

func (c *Instance) AudioFeedback() bool

func (*Instance) AudioPauseOnLaunch added in v2.15.0

func (c *Instance) AudioPauseOnLaunch() bool

AudioPauseOnLaunch reports whether background music should be paused when a game launches on the primary slot. Defaults to true when unset.

func (*Instance) AudioVolume added in v2.11.0

func (c *Instance) AudioVolume() int

AudioVolume returns the configured volume level (0-200). Defaults to 100 if unset. Values above 100 amplify the audio. Clamped to [0, 200].

func (*Instance) AutoDetect

func (c *Instance) AutoDetect() bool

func (*Instance) AutoUpdate added in v2.10.0

func (c *Instance) AutoUpdate(defaultEnabled bool) bool

AutoUpdate returns whether automatic update checking is enabled. The defaultEnabled parameter allows platforms to specify their own default (e.g. package-managed installs default to false). An explicit user setting always takes precedence.

func (*Instance) BackupLocalDir added in v2.16.0

func (c *Instance) BackupLocalDir() string

func (*Instance) BackupRemoteBaseURL added in v2.16.0

func (c *Instance) BackupRemoteBaseURL() string

func (*Instance) BackupRemoteEnabled added in v2.16.0

func (c *Instance) BackupRemoteEnabled() bool

func (*Instance) BackupRemoteSchedule added in v2.16.0

func (c *Instance) BackupRemoteSchedule() string

func (*Instance) BackupScope added in v2.16.0

func (c *Instance) BackupScope() string

BackupScope returns the configured backup scope. Only an explicit "zaparoo" value narrows the scope; anything else (including unset) means the full platform scope.

func (*Instance) CustomLaunchers

func (c *Instance) CustomLaunchers() []LaunchersCustom

func (*Instance) DailyLimit added in v2.7.0

func (c *Instance) DailyLimit() time.Duration

DailyLimit returns the daily time limit as a duration. Returns 0 if not configured or if the duration cannot be parsed.

func (*Instance) DebugLogging

func (c *Instance) DebugLogging() bool

func (*Instance) DefaultLangs added in v2.7.0

func (c *Instance) DefaultLangs() []string

DefaultLangs returns the list of default languages for media matching.

func (*Instance) DefaultMediaDir

func (c *Instance) DefaultMediaDir() string

func (*Instance) DefaultRegions added in v2.7.0

func (c *Instance) DefaultRegions() []string

DefaultRegions returns the list of default regions for media matching.

func (*Instance) DeleteAuthEntries added in v2.16.0

func (c *Instance) DeleteAuthEntries(domains []string) error

DeleteAuthEntries removes the credential entries for the given domains from auth.toml, matching stored keys case-insensitively. API keys and entries for other domains are preserved. Missing domains are a no-op; the in-memory auth config is reloaded when anything was removed.

func (*Instance) DeviceID added in v2.8.0

func (c *Instance) DeviceID() string

func (*Instance) DiscoveryEnabled added in v2.8.0

func (c *Instance) DiscoveryEnabled() bool

func (*Instance) DiscoveryInstanceName added in v2.8.0

func (c *Instance) DiscoveryInstanceName() string

func (*Instance) EncryptionEnabled added in v2.11.0

func (c *Instance) EncryptionEnabled() bool

EncryptionEnabled returns whether WebSocket encryption is enabled. When true, remote WebSocket clients must send an encrypted first frame derived from a paired key; plaintext WebSocket connections from non-loopback addresses are rejected. When false (the default), plaintext and encrypted WebSocket connections are both accepted.

Localhost connections are always allowed plaintext regardless of this setting.

func (*Instance) ErrorReporting added in v2.8.0

func (c *Instance) ErrorReporting() bool

ErrorReporting returns whether error reporting is enabled. Defaults to false (opt-in).

func (*Instance) FailSoundPath added in v2.7.0

func (c *Instance) FailSoundPath(dataDir string) (string, bool)

FailSoundPath resolves the fail sound file path. See SuccessSoundPath for return semantics.

func (*Instance) FilenameTags added in v2.7.0

func (c *Instance) FilenameTags() bool

FilenameTags returns whether filename tag parsing is enabled.

func (*Instance) GetMQTTPublishers added in v2.7.0

func (c *Instance) GetMQTTPublishers() []MQTTPublisher

func (*Instance) GetPixelCadePublishers added in v2.11.0

func (c *Instance) GetPixelCadePublishers() []PixelCadePublisher

func (*Instance) GmcProxyBeaconInterval

func (c *Instance) GmcProxyBeaconInterval() string

func (*Instance) GmcProxyEnabled

func (c *Instance) GmcProxyEnabled() bool

func (*Instance) GmcProxyPort

func (c *Instance) GmcProxyPort() int

func (*Instance) HasAllowRun added in v2.11.0

func (c *Instance) HasAllowRun() bool

HasAllowRun returns true if the allow_run list is configured (non-empty).

func (*Instance) HoldModeEnabled

func (c *Instance) HoldModeEnabled() bool

func (*Instance) IndexRoots

func (c *Instance) IndexRoots() []string

func (*Instance) InputAllowList added in v2.11.0

func (c *Instance) InputAllowList() []string

InputAllowList returns the input allow list for "allow" mode.

func (*Instance) InputBlockList added in v2.11.0

func (c *Instance) InputBlockList() []string

InputBlockList returns the input block list for "unrestricted" mode.

func (*Instance) InputMode added in v2.11.0

func (c *Instance) InputMode(defaultMode string) string

InputMode returns the configured input restriction mode. defaultMode is the platform-provided default (e.g., "hotkeys" for desktop, "unrestricted" for embedded).

func (*Instance) IsCommandBlocked added in v2.11.0

func (c *Instance) IsCommandBlocked(name string) bool

IsCommandBlocked returns true if the command name is in the block list. An empty block list means no commands are blocked.

func (*Instance) IsExecuteAllowed

func (c *Instance) IsExecuteAllowed(s string) bool

func (*Instance) IsHTTPAllowed added in v2.11.0

func (c *Instance) IsHTTPAllowed(url string) bool

IsHTTPAllowed returns true if the URL matches the HTTP allow list. When the allow list is empty (not configured), all URLs are allowed.

func (*Instance) IsHoldModeIgnoredSystem

func (c *Instance) IsHoldModeIgnoredSystem(systemID string) bool

func (*Instance) IsLauncherFileAllowed

func (c *Instance) IsLauncherFileAllowed(s string) bool

func (*Instance) IsReaderEnabled added in v2.11.0

func (c *Instance) IsReaderEnabled(driver DriverInfo, context ReaderEnableContext) bool

IsReaderEnabled centralizes reader enablement rules across platform lists, manual connections, and auto-detection.

func (*Instance) IsRunAllowed

func (c *Instance) IsRunAllowed(s string) bool

IsRunAllowed checks whether a ZapScript text is permitted by the allow_run patterns. Each command in the script is parsed and checked individually against the patterns — all commands must match for the text to be allowed. Returns false when allow_run is empty (not configured).

func (*Instance) LaunchGuardDelay added in v2.11.0

func (c *Instance) LaunchGuardDelay() float32

func (*Instance) LaunchGuardEnabled added in v2.11.0

func (c *Instance) LaunchGuardEnabled() bool

func (*Instance) LaunchGuardRequireConfirm added in v2.11.0

func (c *Instance) LaunchGuardRequireConfirm() bool

func (*Instance) LaunchGuardTimeout added in v2.11.0

func (c *Instance) LaunchGuardTimeout() float32

func (*Instance) LauncherPreference added in v2.16.0

func (c *Instance) LauncherPreference() []string

func (*Instance) LaunchersBeforeMediaStart added in v2.8.0

func (c *Instance) LaunchersBeforeMediaStart() string

func (*Instance) LaunchersOnMediaStart

func (c *Instance) LaunchersOnMediaStart() string

func (*Instance) LimitSoundPath added in v2.7.0

func (c *Instance) LimitSoundPath(dataDir string) (string, bool)

LimitSoundPath resolves the limit sound file path. See SuccessSoundPath for return semantics.

func (*Instance) Load

func (c *Instance) Load() error

func (*Instance) LoadCustomLaunchers

func (c *Instance) LoadCustomLaunchers(launchersDir string) error

func (*Instance) LoadMappings

func (c *Instance) LoadMappings(mappingsDir string) error

func (*Instance) LoadTOML added in v2.11.0

func (c *Instance) LoadTOML(data string) error

LoadTOML unmarshals a TOML string onto the current config values and rebuilds derived fields (compiled regexes, lookup maps). Fields not present in the TOML are left unchanged.

func (*Instance) LookupLauncherDefaults

func (c *Instance) LookupLauncherDefaults(launcherID string, groups []string) LaunchersDefault

LookupLauncherDefaults merges configuration defaults for a launcher by iterating through config entries in order. Entries match if their launcher field equals either the launcher ID or any of the launcher's groups (case-insensitive). Later matching entries override earlier ones, allowing hierarchical configuration like: set defaults for all "Kodi" launchers, then override for specific "KodiTV" group.

func (*Instance) LookupSystemDefaults

func (c *Instance) LookupSystemDefaults(systemID string) (SystemsDefault, bool)

func (*Instance) Mappings

func (c *Instance) Mappings() []MappingsEntry

func (*Instance) PendingSoundPath added in v2.11.0

func (c *Instance) PendingSoundPath(dataDir string) (string, bool)

PendingSoundPath resolves the launch guard sound file path. See SuccessSoundPath for return semantics.

func (*Instance) PlaytimeBaseURL added in v2.16.0

func (c *Instance) PlaytimeBaseURL() string

PlaytimeBaseURL returns the API base URL used for play-history sync.

func (*Instance) PlaytimeLimitsEnabled added in v2.7.0

func (c *Instance) PlaytimeLimitsEnabled() bool

PlaytimeLimitsEnabled returns true if play time limits are enabled.

func (*Instance) PlaytimeRetention added in v2.7.0

func (c *Instance) PlaytimeRetention() int

PlaytimeRetention returns the number of days to retain play time history. Returns 0 if cleanup is disabled, or 365 (1 year) by default.

func (*Instance) PlaytimeSyncEnabled added in v2.16.0

func (c *Instance) PlaytimeSyncEnabled() bool

PlaytimeSyncEnabled reports whether the user explicitly consented to upload play history to the linked online account. Unset defaults to false: account linking alone never grants play-history upload consent.

func (*Instance) ProfilesRequireForLaunch added in v2.16.0

func (c *Instance) ProfilesRequireForLaunch() bool

ProfilesRequireForLaunch returns true when media launches are blocked while no profile is active. Defaults to false: a profile-less device behaves exactly as before profiles existed.

func (*Instance) ProfilesSwapData added in v2.16.0

func (c *Instance) ProfilesSwapData() bool

ProfilesSwapData returns true when profile switches also swap profile-scoped data (save files, save states) on platforms that support it. Defaults to true: data ownership is the point of profiles.

func (*Instance) Readers

func (c *Instance) Readers() Readers

func (*Instance) ReadersScan

func (c *Instance) ReadersScan() ReadersScan

func (*Instance) ReadySoundPath added in v2.11.0

func (c *Instance) ReadySoundPath(dataDir string) (string, bool)

ReadySoundPath resolves the launch guard ready sound file path. See SuccessSoundPath for return semantics.

func (*Instance) ResolveMediaPausePolicy added in v2.16.0

func (*Instance) ResolveMediaPausePolicy(systemID string) MediaPausePolicy

ResolveMediaPausePolicy returns the background media work policy to apply while systemID is playing in the primary slot. This is fixed per tier and not user-configurable: on-device testing showed pause-tier systems still glitch or crash under a heavy throttle, so letting it be overridden down to a throttle risks reintroducing that failure.

  • pauseByDefaultSystems (the most storage-sensitive CD/optical cores) get a full pause.
  • heavyThrottleSystems (other CD/optical cores) get a heavy throttle.
  • all other systems get a light throttle.

func (*Instance) Save

func (c *Instance) Save() error

func (*Instance) SaveAuthEntry added in v2.10.0

func (c *Instance) SaveAuthEntry(domain string, entry CredentialEntry) error

SaveAuthEntry writes or updates a credential entry in auth.toml for the given domain. Creates the file with 0600 permissions if it doesn't exist. Preserves existing entries and reloads the in-memory auth config.

func (*Instance) ScanHistory added in v2.7.0

func (c *Instance) ScanHistory() int

func (*Instance) ScanIgnoreOnConnect added in v2.10.0

func (c *Instance) ScanIgnoreOnConnect() bool

func (*Instance) ScraperGamelistXMLCustomPath added in v2.16.0

func (c *Instance) ScraperGamelistXMLCustomPath() string

ScraperGamelistXMLCustomPath returns the optional directory containing per-system gamelist bundles at {custom_path}/{system_id}/gamelist.xml.

func (*Instance) ServiceOnBoot added in v2.14.0

func (c *Instance) ServiceOnBoot() string

func (*Instance) ServiceOnReady added in v2.14.0

func (c *Instance) ServiceOnReady() string

func (*Instance) SessionLimit added in v2.7.0

func (c *Instance) SessionLimit() time.Duration

SessionLimit returns the per-session time limit as a duration. Returns 0 if not configured or if the duration cannot be parsed.

func (*Instance) SessionResetTimeout added in v2.7.0

func (c *Instance) SessionResetTimeout() time.Duration

SessionResetTimeout returns the idle timeout before a session resets. Returns 20 minutes by default if not configured (nil). Returns 0 if explicitly set to "0" (no timeout, session never resets).

func (*Instance) SetAPIPort added in v2.7.1

func (c *Instance) SetAPIPort(port int) error

func (*Instance) SetAudioFeedback

func (c *Instance) SetAudioFeedback(enabled bool)

func (*Instance) SetAudioVolume added in v2.11.0

func (c *Instance) SetAudioVolume(v int)

SetAudioVolume sets the audio volume level (0-200, default 100).

func (*Instance) SetAutoDetect

func (c *Instance) SetAutoDetect(enabled bool)

func (*Instance) SetAutoUpdate added in v2.10.0

func (c *Instance) SetAutoUpdate(enabled bool)

SetAutoUpdate sets whether automatic update checking is enabled.

func (*Instance) SetBackupLocalDir added in v2.16.0

func (c *Instance) SetBackupLocalDir(localDir string)

func (*Instance) SetBackupRemoteBaseURL added in v2.16.0

func (c *Instance) SetBackupRemoteBaseURL(rawURL string) error

func (*Instance) SetBackupRemoteEnabled added in v2.16.0

func (c *Instance) SetBackupRemoteEnabled(enabled bool)

func (*Instance) SetBackupRemoteSchedule added in v2.16.0

func (c *Instance) SetBackupRemoteSchedule(schedule string)

func (*Instance) SetBackupScope added in v2.16.0

func (c *Instance) SetBackupScope(scope string)

func (*Instance) SetDailyLimit added in v2.7.0

func (c *Instance) SetDailyLimit(duration string) error

SetDailyLimit sets the daily time limit from a duration string (e.g., "2h30m"). Returns an error if the duration string is invalid. Pass empty string to disable daily limit.

func (*Instance) SetDebugLogging

func (c *Instance) SetDebugLogging(enabled bool)

func (*Instance) SetDiscoveryEnabled added in v2.8.0

func (c *Instance) SetDiscoveryEnabled(enabled bool)

func (*Instance) SetDiscoveryInstanceName added in v2.8.0

func (c *Instance) SetDiscoveryInstanceName(name string)

func (*Instance) SetEncryptionEnabled added in v2.11.0

func (c *Instance) SetEncryptionEnabled(enabled bool)

SetEncryptionEnabled toggles WebSocket encryption. The caller is responsible for calling Save() to persist the change.

func (*Instance) SetErrorReporting added in v2.8.0

func (c *Instance) SetErrorReporting(enabled bool)

SetErrorReporting sets whether error reporting is enabled.

func (*Instance) SetFilenameTags added in v2.7.0

func (c *Instance) SetFilenameTags(enabled bool)

SetFilenameTags sets whether filename tag parsing is enabled.

func (*Instance) SetLaunchGuard added in v2.11.0

func (c *Instance) SetLaunchGuard(enabled bool)

func (*Instance) SetLaunchGuardDelay added in v2.11.0

func (c *Instance) SetLaunchGuardDelay(delay float32)

func (*Instance) SetLaunchGuardRequireConfirm added in v2.11.0

func (c *Instance) SetLaunchGuardRequireConfirm(enabled bool)

func (*Instance) SetLaunchGuardTimeout added in v2.11.0

func (c *Instance) SetLaunchGuardTimeout(timeout float32)

func (*Instance) SetPlaytimeBaseURL added in v2.16.0

func (c *Instance) SetPlaytimeBaseURL(rawURL string) error

SetPlaytimeBaseURL validates, normalizes, and stores the play-history API base URL.

func (*Instance) SetPlaytimeLimitsEnabled added in v2.7.0

func (c *Instance) SetPlaytimeLimitsEnabled(enabled bool)

SetPlaytimeLimitsEnabled enables or disables playtime limits.

func (*Instance) SetPlaytimeRetention added in v2.7.0

func (c *Instance) SetPlaytimeRetention(days int)

SetPlaytimeRetention sets the number of days to retain play time history. Pass 0 to disable cleanup.

func (*Instance) SetPlaytimeSync added in v2.16.0

func (c *Instance) SetPlaytimeSync(enabled bool)

SetPlaytimeSync enables or disables play-history sync.

func (*Instance) SetProfilesRequireForLaunch added in v2.16.0

func (c *Instance) SetProfilesRequireForLaunch(required bool)

SetProfilesRequireForLaunch enables or disables the require-profile launch gate.

func (*Instance) SetProfilesSwapData added in v2.16.0

func (c *Instance) SetProfilesSwapData(swap bool)

SetProfilesSwapData enables or disables profile data swapping.

func (*Instance) SetReaderConnections

func (c *Instance) SetReaderConnections(rcs []ReadersConnect)

func (*Instance) SetScanExitDelay

func (c *Instance) SetScanExitDelay(exitDelay float32)

func (*Instance) SetScanIgnoreOnConnect added in v2.10.0

func (c *Instance) SetScanIgnoreOnConnect(enabled bool)

func (*Instance) SetScanIgnoreSystem

func (c *Instance) SetScanIgnoreSystem(ignoreSystem []string)

func (*Instance) SetScanMode

func (c *Instance) SetScanMode(mode string)

func (*Instance) SetSessionLimit added in v2.7.0

func (c *Instance) SetSessionLimit(duration string) error

SetSessionLimit sets the session time limit from a duration string (e.g., "45m"). Returns an error if the duration string is invalid. Pass empty string to disable session limit.

func (*Instance) SetSessionResetTimeout added in v2.7.0

func (c *Instance) SetSessionResetTimeout(duration *string) error

SetSessionResetTimeout sets the idle timeout before a session resets (e.g., "20m", "1h", "0"). Returns an error if the duration string is invalid. Pass nil to use default (20 minutes). Pass "0" to disable session reset timeout.

func (*Instance) SetSystemDefaults added in v2.12.0

func (c *Instance) SetSystemDefaults(defaults []SystemsDefault)

func (*Instance) SetUpdateChannel added in v2.11.0

func (c *Instance) SetUpdateChannel(channel string)

SetUpdateChannel sets the update channel. Valid values are "stable" and "beta".

func (*Instance) SetVirtualGamepadEnabled added in v2.7.1

func (c *Instance) SetVirtualGamepadEnabled(enabled bool)

SetVirtualGamepadEnabled sets whether virtual gamepad emulation is enabled.

func (*Instance) SetWarningIntervals added in v2.7.0

func (c *Instance) SetWarningIntervals(intervals []string) error

SetWarningIntervals sets the warning intervals from duration strings (e.g., ["10m", "5m", "2m"]). Returns an error if any duration string is invalid. Pass empty slice to use defaults [5m, 2m, 1m].

func (*Instance) SuccessSoundPath added in v2.7.0

func (c *Instance) SuccessSoundPath(dataDir string) (string, bool)

SuccessSoundPath resolves the success sound file path based on config and disk overrides. Returns (path, enabled) where:

  • ("", false) = ScanFeedback disabled or sound explicitly disabled (empty string config)
  • ("", true) = use embedded default (nil config, no file override on disk)
  • (path, true) = use file at path (explicit config or auto-detected in dataDir/assets/)

func (*Instance) SystemDefaults

func (c *Instance) SystemDefaults() []SystemsDefault

func (*Instance) TapModeEnabled

func (c *Instance) TapModeEnabled() bool

func (*Instance) UpdateChannel added in v2.11.0

func (c *Instance) UpdateChannel() string

UpdateChannel returns the configured update channel. Defaults to "stable" when not explicitly set.

func (*Instance) VirtualGamepadEnabled added in v2.7.1

func (c *Instance) VirtualGamepadEnabled(defaultEnabled bool) bool

VirtualGamepadEnabled returns whether virtual gamepad emulation is enabled. The defaultEnabled parameter allows platforms to specify their own default.

func (*Instance) WarningIntervals added in v2.7.0

func (c *Instance) WarningIntervals() []time.Duration

WarningIntervals returns the warning intervals as durations. Returns default intervals [5m, 2m, 1m] if not configured. Skips any intervals that cannot be parsed.

type Launchers

type Launchers struct {
	IndexRoot  []string `toml:"index_root,omitempty,multiline"`
	Preference []string `toml:"preference,omitempty,multiline"`
	AllowFile  []string `toml:"allow_file,omitempty,multiline"`

	MediaDir         string             `toml:"media_dir,omitempty"`
	BeforeMediaStart string             `toml:"before_media_start,omitempty"`
	OnMediaStart     string             `toml:"on_media_start,omitempty"`
	Default          []LaunchersDefault `toml:"default,omitempty"`
	Custom           []LaunchersCustom  `toml:"custom,omitempty"`
	// contains filtered or unexported fields
}

type LaunchersCustom

type LaunchersCustom struct {
	Controls   map[string]string `toml:"controls"`
	ID         string            `toml:"id"`
	Kind       string            `toml:"kind,omitempty"`
	Backend    string            `toml:"backend,omitempty"`
	System     string            `toml:"system,omitempty"`
	Name       string            `toml:"name,omitempty"`
	Category   string            `toml:"category,omitempty"`
	Execute    string            `toml:"execute,omitempty"`
	Lifecycle  string            `toml:"lifecycle,omitempty"`
	LoadPath   string            `toml:"load_path,omitempty"`
	MediaDirs  []string          `toml:"media_dirs,omitempty"`
	FileExts   []string          `toml:"file_exts,omitempty"`
	Groups     []string          `toml:"groups,omitempty"`
	Schemes    []string          `toml:"schemes,omitempty"`
	Restricted bool              `toml:"restricted,omitempty"`
}

type LaunchersDefault

type LaunchersDefault struct {
	RenderScale      *int   `toml:"render_scale,omitempty"`
	Launcher         string `toml:"launcher"`
	InstallDir       string `toml:"install_dir,omitempty"`
	ServerURL        string `toml:"server_url,omitempty"`
	RenderResolution string `toml:"render_resolution,omitempty"`
	// Action specifies the default launch action. Common values:
	// - "" or "run": Default behavior (launch/play the media)
	// - "details": Show media details/info page instead of launching
	Action string `toml:"action,omitempty"`
	// LoadPath specifies the implementation file the launcher should load.
	// Format is launcher-specific. For MiSTer, this is an MGL-form RBF path
	// like "_Unstable/SNES" (no extension, relative to /media/fat). Launchers
	// that do not load an implementation file ignore this field.
	LoadPath string `toml:"load_path,omitempty"`
}

type MQTTPublisher added in v2.7.0

type MQTTPublisher struct {
	Enabled *bool    `toml:"enabled,omitempty"`
	Broker  string   `toml:"broker"`
	Topic   string   `toml:"topic"`
	Filter  []string `toml:"filter,omitempty,multiline"`
}

type Mappings

type Mappings struct {
	Entry []MappingsEntry `toml:"entry,omitempty"`
}

type MappingsEntry

type MappingsEntry struct {
	TokenKey     string `toml:"token_key,omitempty"`
	MatchPattern string `toml:"match_pattern"`
	ZapScript    string `toml:"zapscript"`
}

type Media added in v2.7.0

type Media struct {
	FilenameTags   *bool    `toml:"filename_tags,omitempty"`
	DefaultRegions []string `toml:"default_regions,omitempty,multiline"`
	DefaultLangs   []string `toml:"default_langs,omitempty,multiline"`
}

type MediaPausePolicy added in v2.16.0

type MediaPausePolicy struct {
	Mode  string
	Level syncutil.ThrottleLevel
}

MediaPausePolicy is the resolved background-work policy for the currently active SystemID: whether to pause entirely or throttle, and at what throttle level.

type PixelCadePublisher added in v2.11.0

type PixelCadePublisher struct {
	Enabled *bool    `toml:"enabled,omitempty"`
	Host    string   `toml:"host"`
	Mode    string   `toml:"mode,omitempty"`
	Filter  []string `toml:"filter,omitempty,multiline"`
	Port    int      `toml:"port,omitempty"`
}

type Playtime added in v2.7.0

type Playtime struct {
	Retention *int           `toml:"retention,omitempty"`
	Sync      *bool          `toml:"sync,omitempty"`
	BaseURL   string         `toml:"base_url,omitempty"`
	Limits    PlaytimeLimits `toml:"limits,omitempty"`
}

Playtime configures play time tracking and limits.

type PlaytimeLimits added in v2.7.0

type PlaytimeLimits struct {
	Enabled      *bool    `toml:"enabled,omitempty"`
	Daily        string   `toml:"daily,omitempty"`
	Session      string   `toml:"session,omitempty"`
	SessionReset *string  `toml:"session_reset,omitempty"`
	Warnings     []string `toml:"warnings,omitempty,multiline"`
}

PlaytimeLimits configures time limits and warnings for gameplay sessions.

type Profiles added in v2.16.0

type Profiles struct {
	RequireForLaunch *bool `toml:"require_for_launch,omitempty"`
	SwapData         *bool `toml:"swap_data,omitempty"`
}

Profiles configures device profile behavior.

type Publishers added in v2.7.0

type Publishers struct {
	MQTT      []MQTTPublisher      `toml:"mqtt,omitempty"`
	PixelCade []PixelCadePublisher `toml:"pixelcade,omitempty"`
}

type ReaderEnableContext added in v2.11.0

type ReaderEnableContext string

ReaderEnableContext selects the reader usage path being evaluated.

const (
	// ReaderEnableContextCandidate filters platform-supported reader instances.
	ReaderEnableContextCandidate ReaderEnableContext = "candidate"
	// ReaderEnableContextManualConnect evaluates a configured [[readers.connect]] entry.
	ReaderEnableContextManualConnect ReaderEnableContext = "manual_connect"
	// ReaderEnableContextAutoDetect evaluates whether a reader may probe for devices.
	ReaderEnableContextAutoDetect ReaderEnableContext = "auto_detect"
)

type Readers

type Readers struct {
	Drivers     map[string]DriverConfig `toml:"drivers,omitempty"`
	ScanHistory *int                    `toml:"scan_history,omitempty"`
	Connect     []ReadersConnect        `toml:"connect,omitempty"`
	Scan        ReadersScan             `toml:"scan,omitempty"`
	AutoDetect  bool                    `toml:"auto_detect"`
}

type ReadersConnect

type ReadersConnect struct {
	Enabled  *bool  `toml:"enabled,omitempty"`
	Driver   string `toml:"driver"`
	Path     string `toml:"path,omitempty"`
	IDSource string `toml:"id_source,omitempty"`
}

func (ReadersConnect) ConnectionString

func (r ReadersConnect) ConnectionString() string

func (ReadersConnect) IsEnabled added in v2.11.0

func (r ReadersConnect) IsEnabled() bool

IsEnabled returns whether this connection is enabled. nil (omitted) and true both mean enabled; only explicit false disables.

type ReadersScan

type ReadersScan struct {
	Mode            string          `toml:"mode"`
	OnScan          string          `toml:"on_scan,omitempty"`
	OnRemove        string          `toml:"on_remove,omitempty"`
	IgnoreSystem    []string        `toml:"ignore_system,omitempty"`
	ExitDelay       float32         `toml:"exit_delay,omitempty"`
	IgnoreOnConnect bool            `toml:"ignore_on_connect,omitempty"`
	LaunchGuard     ScanLaunchGuard `toml:"launch_guard,omitempty"`
}

type ScanLaunchGuard added in v2.11.0

type ScanLaunchGuard struct {
	Timeout        float32 `toml:"timeout,omitempty"`
	Delay          float32 `toml:"delay,omitempty"`
	Enabled        bool    `toml:"enabled,omitempty"`
	RequireConfirm bool    `toml:"require_confirm,omitempty"`
}

type Scraper added in v2.16.0

type Scraper struct {
	GamelistXML ScraperGamelistXML `toml:"gamelist_xml,omitempty"`
}

Scraper configures metadata scraper behavior.

type ScraperGamelistXML added in v2.16.0

type ScraperGamelistXML struct {
	CustomPath string `toml:"custom_path,omitempty"`
}

ScraperGamelistXML configures the EmulationStation gamelist.xml scraper.

type Service

type Service struct {
	APIPort   *int      `toml:"api_port,omitempty"`
	Discovery Discovery `toml:"discovery,omitempty"`
	DeviceID  string    `toml:"device_id"`
	APIListen string    `toml:"api_listen,omitempty"`
	OnBoot    string    `toml:"on_boot,omitempty"`
	OnReady   string    `toml:"on_ready,omitempty"`
	// AllowRun is the list of allowed run patterns.
	AllowRun []string `toml:"allow_run,omitempty,multiline"`

	AllowedOrigins []string   `toml:"allowed_origins,omitempty"`
	AllowedIPs     []string   `toml:"allowed_ips,omitempty"`
	Publishers     Publishers `toml:"publishers,omitempty"`
	// Encryption enables PAKE pairing + AES-256-GCM on the WebSocket
	// transport. False (the default) accepts plaintext and encrypted WebSocket
	// connections. True requires paired clients for remote
	// WebSocket connections; localhost is always exempt.
	Encryption bool `toml:"encryption,omitempty"`
	// contains filtered or unexported fields
}

type Systems

type Systems struct {
	Default []SystemsDefault `toml:"default,omitempty"`
}

type SystemsDefault

type SystemsDefault struct {
	PauseOnLaunch *bool  `toml:"pause_on_launch,omitempty"`
	System        string `toml:"system"`
	Launcher      string `toml:"launcher,omitempty"`
	BeforeExit    string `toml:"before_exit,omitempty"`
}

type TUIConfig added in v2.9.0

type TUIConfig struct {
	Theme                  string `toml:"theme"`
	WriteFormat            string `toml:"write_format"`
	Mouse                  bool   `toml:"mouse"`
	CRTMode                bool   `toml:"crt_mode"`
	OnScreenKeyboard       bool   `toml:"on_screen_keyboard"`
	ErrorReportingPrompted bool   `toml:"error_reporting_prompted"`
	EncryptionPrompted     bool   `toml:"encryption_prompted"`
}

TUIConfig holds TUI-specific configuration.

func DefaultTUIConfig added in v2.9.0

func DefaultTUIConfig() TUIConfig

DefaultTUIConfig returns the default TUI configuration.

func GetTUIConfig added in v2.9.0

func GetTUIConfig() TUIConfig

GetTUIConfig returns the current TUI configuration.

type Values

type Values struct {
	Groovy         Groovy    `toml:"groovy,omitempty"`
	Input          Input     `toml:"input,omitempty"`
	AutoUpdate     *bool     `toml:"auto_update,omitempty"`
	UpdateChannel  *string   `toml:"update_channel,omitempty"`
	Audio          Audio     `toml:"audio"`
	Backup         Backup    `toml:"backup,omitempty"`
	Service        Service   `toml:"service,omitempty"`
	Launchers      Launchers `toml:"launchers,omitempty"`
	Playtime       Playtime  `toml:"playtime,omitempty"`
	Profiles       Profiles  `toml:"profiles,omitempty"`
	Media          Media     `toml:"media,omitempty"`
	Scraper        Scraper   `toml:"scraper,omitempty"`
	ZapScript      ZapScript `toml:"zapscript,omitempty"`
	Mappings       Mappings  `toml:"mappings,omitempty"`
	Systems        Systems   `toml:"systems,omitempty"`
	Readers        Readers   `toml:"readers,omitempty"`
	ConfigSchema   int       `toml:"config_schema"`
	DebugLogging   bool      `toml:"debug_logging"`
	ErrorReporting bool      `toml:"error_reporting"`
}

type ZapScript

type ZapScript struct {
	AllowExecute []string `toml:"allow_execute,omitempty,multiline"`

	AllowHTTP []string `toml:"allow_http,omitempty,multiline"`

	BlockCommands []string `toml:"block_commands,omitempty,multiline"`

	Input InputConfig `toml:"input,omitempty"`
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL