Documentation
¶
Index ¶
- Constants
- Variables
- func ArtworkDownloadDisplayName(setting string) string
- func AspectRatioDisplayName(mode string) string
- func AtomicWriteFile(path string, data []byte) error
- func AtomicWriteJSON(path string, data interface{}) error
- func CleanGameKey(key string) string
- func CreateConfigIfMissing() error
- func CreateLibraryIfMissing() error
- func DeleteScreenshot(dir, path string) error
- func EnsureDirectories() error
- func GetArtworkDir() (string, error)
- func GetBaseDir() (string, error)
- func GetConfigPath() (string, error)
- func GetGameArtworkDir(gameID string) (string, error)
- func GetGameSaveDir(gameID string) (string, error)
- func GetGameScreenshotDir(gameID string) (string, error)
- func GetGameSettingsDir() (string, error)
- func GetGameSettingsPath(gameID string) (string, error)
- func GetLibraryPath() (string, error)
- func GetRemovedGamesPath() (string, error)
- func GetSavesDir() (string, error)
- func GetScreenshotDir() (string, error)
- func GetUpdateDir() (string, error)
- func Init(dataDirName string)
- func LoadUpdateManifest(maxManifest, maxSig int64) (manifest, sig []byte, err error)
- func ParseScreenshotName(name string) (ts time.Time, achievement string, ok bool)
- func ReadJSON(path string, data interface{}) error
- func SanitizeGameSettings(s *GameSettingsFile)
- func SanitizeRemovedGames(removed *RemovedGames)
- func SanitizeScreenshotTitle(s string) string
- func SaveGameSettings(gameID string, settings *GameSettingsFile) error
- func SaveRemovedGames(removed *RemovedGames) error
- func SaveUpdateManifest(manifest, sig []byte) error
- func SaveUpdateState(state *UpdateState) error
- func ScreenshotFilename(ts time.Time, n int, tag string) string
- func ValidCoreOption(opt coreif.CoreOption, v string) bool
- func ValidPadMapping(guid, line string) bool
- type AudioConfig
- type BIOSConfig
- type CheatSettings
- type Config
- func (c *Config) AddProfile(p ControllerProfile) string
- func (c *Config) ClearRetroAchievementsLogin()
- func (c *Config) ClearRetroAchievementsToken()
- func (c *Config) Correct(rules ConfigRules)
- func (c *Config) DeleteProfile(id string)
- func (c *Config) Flush()
- func (c *Config) Input() InputConfig
- func (c *Config) RemoveBIOSFile(key, label string)
- func (c *Config) ResetKeyboardBindings()
- func (c *Config) ResetProfileBindings(id string)
- func (c *Config) RetroAchievements() RetroAchievementsConfig
- func (c *Config) SetArtworkDownload(setting string)
- func (c *Config) SetAspectRatio(mode string)
- func (c *Config) SetBIOSActive(key, label string)
- func (c *Config) SetBIOSFile(key, label, path string)
- func (c *Config) SetBoxArtRegion(region string)
- func (c *Config) SetCoreOption(key, value string)
- func (c *Config) SetFullscreen(fullscreen bool)
- func (c *Config) SetKeyboardBinding(button, key string)
- func (c *Config) SetPadMapping(guid, line string)
- func (c *Config) SetPlayerProfile(player int, id string)
- func (c *Config) SetProfileBinding(id, button, padButton string)
- func (c *Config) SetProfileName(id, name string)
- func (c *Config) SetProfileRumbleScale(id string, scale float64)
- func (c *Config) SetRetroAchievementsLogin(username, token string)
- func (c *Config) SetRewindBufferSizeMB(mb int)
- func (c *Config) SetRewindFrameStep(step int)
- func (c *Config) SetSortBy(sortBy string)
- func (c *Config) SetTheme(name string)
- func (c *Config) SetViewMode(mode string)
- func (c *Config) SetVolume(volume float64)
- func (c *Config) SetWindow(w WindowConfig)
- func (c *Config) Shaders() ShaderConfig
- func (c *Config) ToggleAchievementNotification() bool
- func (c *Config) ToggleAchievementScreenshot() bool
- func (c *Config) ToggleAchievementSound() bool
- func (c *Config) ToggleAutoCheck() bool
- func (c *Config) ToggleEncoreMode() bool
- func (c *Config) ToggleFastForwardMute() bool
- func (c *Config) ToggleFavoritesFilter() bool
- func (c *Config) ToggleGameShader(id string) bool
- func (c *Config) ToggleMuted() bool
- func (c *Config) ToggleRetroAchievements() bool
- func (c *Config) ToggleRewind() bool
- func (c *Config) ToggleSpectatorMode() bool
- func (c *Config) ToggleUIShader(id string) bool
- func (c *Config) Validate(rules ConfigRules) []string
- func (c *Config) Values() ConfigData
- type ConfigData
- type ConfigRules
- type ControllerProfile
- type CustomCheat
- type FileStatus
- type GameDisc
- type GameEntry
- type GameInfo
- type GameKeys
- type GameSettingsFile
- type InputConfig
- type Library
- func (lib *Library) AddExcludedPath(path string)
- func (lib *Library) AddGame(entry GameEntry)
- func (lib *Library) AddPlayTime(gameID string, seconds int64)
- func (lib *Library) AddScanDirectory(path string, recursive bool)
- func (lib *Library) Correct()
- func (lib *Library) ExcludedPaths() []string
- func (lib *Library) Flush()
- func (lib *Library) Game(gameID string) (GameEntry, bool)
- func (lib *Library) GameCount() int
- func (lib *Library) Games() map[string]GameEntry
- func (lib *Library) GamesSorted(sortBy string, favoritesOnly bool, info GameInfo) []GameEntry
- func (lib *Library) GamesSortedFiltered(sortBy string, favoritesOnly bool, searchText string, info GameInfo) []GameEntry
- func (lib *Library) HasGame(gameID string) bool
- func (lib *Library) IsPathExcluded(path string) bool
- func (lib *Library) MergeScanned(found map[string]*GameEntry) int
- func (lib *Library) RemoveDisc(gameID string, idx int)
- func (lib *Library) RemoveExcludedPath(path string)
- func (lib *Library) RemoveGames(keys ...string) error
- func (lib *Library) RemoveMissing(files map[string]FileStatus) (int, error)
- func (lib *Library) RemoveScanDirectory(path string)
- func (lib *Library) ScanBase() map[string]*GameEntry
- func (lib *Library) ScanDirectories() []ScanDirectory
- func (lib *Library) SetLastPlayed(gameID string, unix int64)
- func (lib *Library) SetSelectedDisc(gameID string, idx int)
- func (lib *Library) ToggleFavorite(gameID string) bool
- func (lib *Library) Validate() []string
- type LibraryView
- type OverrideSettings
- func (o *OverrideSettings) ClearCoreOption(key string)
- func (o *OverrideSettings) ClearShader(id string)
- func (o *OverrideSettings) CoreOption(opt coreif.CoreOption) (string, bool)
- func (o *OverrideSettings) Reset()
- func (o *OverrideSettings) SetCoreOption(key, value string)
- func (o *OverrideSettings) SetShader(id string, on bool)
- func (o *OverrideSettings) Shader(id string) (on bool, ok bool)
- type PlayerConfig
- type RemovedGames
- type RetroAchievementsConfig
- type RewindConfig
- type SaveStateSettings
- type ScanDirectory
- type Screenshot
- type ShaderConfig
- type UpdateState
- type UpdatesConfig
- type VideoConfig
- type WindowConfig
Constants ¶
const ( MaxCustomCheats = 1000 MaxCustomCheatNameLen = 64 // runes MaxCustomCheatCodeLen = 1024 // runes, line breaks included MaxCustomCheatCodeRows = 128 // lines )
Limits on custom cheats. Entries over them are dropped on load.
const ( ArtworkDownloadAll = "all" // the covers, discs, flyers and posters ArtworkDownloadFront = "front" // the front cover ArtworkDownloadCovers = "covers" // the front and back covers ArtworkDownloadNone = "none" // nothing )
Artwork download settings: which images a library scan downloads. They only limit downloads; artwork already on disk is kept and shown.
const DefaultRumbleScale = 1.0
DefaultRumbleScale is the rumble intensity assigned to new profiles.
const MaxInputPlayers = 2
MaxInputPlayers is the maximum number of player slots stored in config.
const MaxScreenshotTitleBytes = 192
MaxScreenshotTitleBytes is the most UTF-8 bytes of an achievement title kept in a screenshot filename. It keeps the whole filename under the 255 byte component limit of common filesystems when the title is made of wide runes.
const MaxScreenshotTitleLen = 64
MaxScreenshotTitleLen is the most runes of an achievement title kept in a screenshot filename
const ScreenshotAchievementTag = "achievement_"
ScreenshotAchievementTag starts the filename tag of a screenshot taken on an achievement unlock. The achievement title follows it.
Variables ¶
var ValidArtworkDownloads = []string{ArtworkDownloadAll, ArtworkDownloadFront, ArtworkDownloadCovers, ArtworkDownloadNone}
ValidArtworkDownloads lists the artwork download settings in the order they are offered
var ValidAspectRatios = []string{"dar", "4:3", "1:1", "stretch"}
ValidAspectRatios lists the allowed aspect ratio mode values
Functions ¶
func ArtworkDownloadDisplayName ¶ added in v0.8.0
ArtworkDownloadDisplayName returns a user-facing label for an artwork download setting
func AspectRatioDisplayName ¶
AspectRatioDisplayName returns a user-facing label for the given mode.
func AtomicWriteFile ¶ added in v0.7.0
AtomicWriteFile writes data to a file atomically. It writes to a temporary file first, then renames to the target path. This ensures the file is never in a partially-written state.
func AtomicWriteJSON ¶
AtomicWriteJSON writes data to a JSON file atomically. It writes to a temporary file first, then renames to the target path. This ensures the file is never in a partially-written state.
func CleanGameKey ¶ added in v0.7.0
CleanGameKey removes path separators and control characters from a game key so it is safe to use as a file or directory name. Returns "" when nothing usable remains or the result is a traversal name.
func CreateConfigIfMissing ¶
func CreateConfigIfMissing() error
CreateConfigIfMissing creates a default config.json if it doesn't exist
func CreateLibraryIfMissing ¶
func CreateLibraryIfMissing() error
CreateLibraryIfMissing creates a default library.json if it doesn't exist
func DeleteScreenshot ¶ added in v0.7.0
DeleteScreenshot removes the screenshot file at path. path must name a screenshot directly inside dir, the game's screenshot directory, so a bad path cannot remove anything else.
func EnsureDirectories ¶
func EnsureDirectories() error
EnsureDirectories creates all necessary directories for the application
func GetArtworkDir ¶
GetArtworkDir returns the full path to the artwork directory
func GetBaseDir ¶
GetBaseDir returns the base directory for application data. The directory name is set by Init(). Example paths: - macOS: ~/Library/Application Support/<appName> - Linux: ~/.local/share/<appName> - Windows: %APPDATA%/<appName>
func GetConfigPath ¶
GetConfigPath returns the full path to config.json
func GetGameArtworkDir ¶ added in v0.8.0
GetGameArtworkDir returns the directory holding a game's artwork images. An empty or unclean game ID is an error.
func GetGameSaveDir ¶
GetGameSaveDir returns the save directory for a specific game (by game ID). An empty or unclean game ID is an error.
func GetGameScreenshotDir ¶ added in v0.7.0
GetGameScreenshotDir returns the screenshot directory for a specific game (by game ID). An empty or unclean game ID is an error.
func GetGameSettingsDir ¶ added in v0.7.0
GetGameSettingsDir returns the full path to the per-game settings directory
func GetGameSettingsPath ¶ added in v0.7.0
GetGameSettingsPath returns the path to a game's settings file. An empty or unclean game ID is an error.
func GetLibraryPath ¶
GetLibraryPath returns the full path to library.json
func GetRemovedGamesPath ¶ added in v0.7.0
GetRemovedGamesPath returns the full path to removed.json
func GetSavesDir ¶
GetSavesDir returns the full path to the saves directory
func GetScreenshotDir ¶
GetScreenshotDir returns the full path to the screenshots directory
func GetUpdateDir ¶ added in v0.7.0
GetUpdateDir returns the full path to the update state directory
func Init ¶
func Init(dataDirName string)
Init sets the application data directory name. Must be called before any storage operations.
func LoadUpdateManifest ¶ added in v0.7.0
LoadUpdateManifest reads the stored update manifest and its signature file byte for byte. It returns an error when either is missing, unreadable, or larger than its limit.
func ParseScreenshotName ¶ added in v0.7.0
ParseScreenshotName reads a screenshot file name written by ScreenshotFilename: the capture time and the achievement title, or "" for a manual capture. Names from before millisecond timestamps, with ten or fewer digits, are read as seconds. ok is false for any other name, including an achievement title that SanitizeScreenshotTitle would not produce, so a file planted with a crafted name is not a screenshot.
func SanitizeGameSettings ¶ added in v0.7.0
func SanitizeGameSettings(s *GameSettingsFile)
SanitizeGameSettings silently corrects invalid game settings fields. This runs on load so invalid values never reach the UI or emulator.
func SanitizeRemovedGames ¶ added in v0.7.0
func SanitizeRemovedGames(removed *RemovedGames)
SanitizeRemovedGames silently corrects invalid removed game entries the same way as library entries, and clears any files and added time so a restored entry only gets the files a scan finds and is added when found.
func SanitizeScreenshotTitle ¶ added in v0.7.0
SanitizeScreenshotTitle reduces an achievement title to text allowed in a screenshot filename: letters, digits, marks, spaces, and the punctuation in screenshotTitlePunctuation. Everything else is dropped, runs of whitespace become one space, and the result is trimmed and capped at MaxScreenshotTitleLen runes and MaxScreenshotTitleBytes bytes. The allow-list keeps every shell, path, and command line metacharacter out of the name, and ParseScreenshotName accepts only titles it would produce.
func SaveGameSettings ¶ added in v0.7.0
func SaveGameSettings(gameID string, settings *GameSettingsFile) error
SaveGameSettings writes a game's settings file.
func SaveRemovedGames ¶ added in v0.7.0
func SaveRemovedGames(removed *RemovedGames) error
SaveRemovedGames saves removed.json atomically
func SaveUpdateManifest ¶ added in v0.7.0
SaveUpdateManifest stores an update manifest and its signature file byte for byte. Each file is written atomically. If only one is replaced the pair no longer verifies and is treated as not stored.
func SaveUpdateState ¶ added in v0.7.0
func SaveUpdateState(state *UpdateState) error
SaveUpdateState saves update/update.json atomically
func ScreenshotFilename ¶ added in v0.7.0
ScreenshotFilename returns the name of a screenshot taken at ts: the millisecond Unix timestamp, "-n" when n is above zero, "_" and the tag when one is set, and the .png extension. ParseScreenshotName reads the name back.
func ValidCoreOption ¶ added in v0.8.0
func ValidCoreOption(opt coreif.CoreOption, v string) bool
ValidCoreOption reports whether v is a value the core option accepts: true or false for a Bool, one of its values for a Select. A value of another type is not checked. A stored value the option no longer accepts, such as a Select value the core dropped, is read as unset, so the declared default applies.
func ValidPadMapping ¶ added in v0.5.0
ValidPadMapping reports whether guid and line form a well-formed pad mapping entry: the GUID is 32 lowercase hex characters, the line starts with the GUID, and the line is a single line.
Types ¶
type AudioConfig ¶
type AudioConfig struct {
Volume float64 `json:"volume"`
Muted bool `json:"muted"`
FastForwardMute bool `json:"fastForwardMute"` // Mute audio during fast-forward (default: true)
}
AudioConfig contains audio-related settings
type BIOSConfig ¶
type BIOSConfig struct {
Active string `json:"active,omitempty"` // Active variant label, empty = none
Files map[string]string `json:"files,omitempty"` // variant label -> file path
}
BIOSConfig stores the user's BIOS configuration for one BIOSOption.
type CheatSettings ¶ added in v0.7.0
type CheatSettings struct {
Enabled []string `json:"enabled,omitempty"` // IDs of the cheats turned on
Custom []CustomCheat `json:"custom,omitempty"` // cheats added by the user
}
CheatSettings holds a game's cheat choices.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the application configuration, safe for use from any goroutine. Its contents are only reachable through its methods: Values returns a copy and every change is a single locked operation. A configuration loaded from or created in config.json saves itself in the background after each change; one from DefaultConfig is never written.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration, never written to disk. It is used where a configuration is needed but must not replace config.json, such as when config.json failed to load.
func LoadConfig ¶
LoadConfig loads the configuration from config.json. If the file doesn't exist, it returns the default configuration, saved on its first change. If the file is corrupted, it returns an error. Missing fields (absent from JSON) are silently defaulted.
func ResetConfig ¶ added in v0.8.0
ResetConfig replaces config.json with the defaults and returns a configuration saved to it.
func (*Config) AddProfile ¶ added in v0.8.0
func (c *Config) AddProfile(p ControllerProfile) string
AddProfile adds a controller profile with a new unique ID and returns the ID. The profile's ID field is ignored.
func (*Config) ClearRetroAchievementsLogin ¶ added in v0.8.0
func (c *Config) ClearRetroAchievementsLogin()
ClearRetroAchievementsLogin forgets the stored username and token.
func (*Config) ClearRetroAchievementsToken ¶ added in v0.8.0
func (c *Config) ClearRetroAchievementsToken()
ClearRetroAchievementsToken forgets the stored token, keeping the username.
func (*Config) Correct ¶ added in v0.8.0
func (c *Config) Correct(rules ConfigRules)
Correct resets any invalid fields to their defaults and removes invalid input entries, keeping valid ones.
func (*Config) DeleteProfile ¶ added in v0.8.0
DeleteProfile removes a controller profile and unassigns it from every player.
func (*Config) Flush ¶ added in v0.8.0
func (c *Config) Flush()
Flush waits until every change has been written. Call before exit.
func (*Config) Input ¶
func (c *Config) Input() InputConfig
Input returns a copy of the input settings. It copies only that section, for code that reads it every frame.
func (*Config) RemoveBIOSFile ¶ added in v0.8.0
RemoveBIOSFile forgets the file chosen for a BIOS option's variant and, when that variant was active, selects none.
func (*Config) ResetKeyboardBindings ¶ added in v0.8.0
func (c *Config) ResetKeyboardBindings()
ResetKeyboardBindings removes every player 1 keyboard override.
func (*Config) ResetProfileBindings ¶ added in v0.8.0
ResetProfileBindings removes every binding override from a profile.
func (*Config) RetroAchievements ¶
func (c *Config) RetroAchievements() RetroAchievementsConfig
RetroAchievements returns a copy of the RetroAchievements settings. It copies only that section, for code that reads it every frame.
func (*Config) SetArtworkDownload ¶ added in v0.8.0
SetArtworkDownload sets which artwork a scan downloads.
func (*Config) SetAspectRatio ¶ added in v0.8.0
SetAspectRatio sets the game aspect ratio mode.
func (*Config) SetBIOSActive ¶ added in v0.8.0
SetBIOSActive selects the BIOS variant used for a BIOS option; empty selects none.
func (*Config) SetBIOSFile ¶ added in v0.8.0
SetBIOSFile records the file chosen for a BIOS option's variant.
func (*Config) SetBoxArtRegion ¶ added in v0.8.0
SetBoxArtRegion sets the region whose artwork is shown first.
func (*Config) SetCoreOption ¶ added in v0.8.0
SetCoreOption sets a core option value.
func (*Config) SetFullscreen ¶ added in v0.8.0
SetFullscreen records whether the window is fullscreen.
func (*Config) SetKeyboardBinding ¶ added in v0.8.0
SetKeyboardBinding sets player 1's keyboard key for a button; an empty key removes the override.
func (*Config) SetPadMapping ¶ added in v0.8.0
SetPadMapping stores a generated controller mapping line for a SDL GUID.
func (*Config) SetPlayerProfile ¶ added in v0.8.0
SetPlayerProfile assigns a controller profile to a player; an empty ID unassigns it.
func (*Config) SetProfileBinding ¶ added in v0.8.0
SetProfileBinding sets a controller profile's pad button for a button; an empty pad button removes the override.
func (*Config) SetProfileName ¶ added in v0.8.0
SetProfileName renames a controller profile.
func (*Config) SetProfileRumbleScale ¶ added in v0.8.0
SetProfileRumbleScale sets a controller profile's rumble intensity.
func (*Config) SetRetroAchievementsLogin ¶ added in v0.8.0
SetRetroAchievementsLogin stores a successful login and turns RetroAchievements on.
func (*Config) SetRewindBufferSizeMB ¶ added in v0.8.0
SetRewindBufferSizeMB sets the rewind buffer size in MB.
func (*Config) SetRewindFrameStep ¶ added in v0.8.0
SetRewindFrameStep sets how many frames pass between rewind captures.
func (*Config) SetViewMode ¶ added in v0.8.0
SetViewMode sets the library view mode, "icon" or "list".
func (*Config) SetWindow ¶ added in v0.8.0
func (c *Config) SetWindow(w WindowConfig)
SetWindow records the window size, position and fullscreen state.
func (*Config) Shaders ¶
func (c *Config) Shaders() ShaderConfig
Shaders returns a copy of the shader lists. It copies only that section, for code that reads it every frame.
func (*Config) ToggleAchievementNotification ¶ added in v0.8.0
ToggleAchievementNotification flips the unlock popup and returns the new value.
func (*Config) ToggleAchievementScreenshot ¶ added in v0.8.0
ToggleAchievementScreenshot flips the unlock screenshot and returns the new value.
func (*Config) ToggleAchievementSound ¶ added in v0.8.0
ToggleAchievementSound flips the unlock sound and returns the new value.
func (*Config) ToggleAutoCheck ¶ added in v0.8.0
ToggleAutoCheck flips the automatic update check and returns the new value.
func (*Config) ToggleEncoreMode ¶ added in v0.8.0
ToggleEncoreMode flips encore mode and returns the new value.
func (*Config) ToggleFastForwardMute ¶ added in v0.8.0
ToggleFastForwardMute flips muting during fast-forward and returns the new value.
func (*Config) ToggleFavoritesFilter ¶ added in v0.8.0
ToggleFavoritesFilter flips showing only favorites and returns the new value.
func (*Config) ToggleGameShader ¶ added in v0.8.0
ToggleGameShader adds the shader to the game shader list, or removes it if present, and reports whether it is now enabled.
func (*Config) ToggleMuted ¶ added in v0.8.0
ToggleMuted flips audio muting and returns the new value.
func (*Config) ToggleRetroAchievements ¶ added in v0.8.0
ToggleRetroAchievements flips RetroAchievements and returns the new value.
func (*Config) ToggleRewind ¶ added in v0.8.0
ToggleRewind flips rewind and returns the new value.
func (*Config) ToggleSpectatorMode ¶ added in v0.8.0
ToggleSpectatorMode flips spectator mode and returns the new value.
func (*Config) ToggleUIShader ¶ added in v0.8.0
ToggleUIShader adds the shader to the UI shader list, or removes it if present, and reports whether it is now enabled.
func (*Config) Validate ¶ added in v0.8.0
func (c *Config) Validate(rules ConfigRules) []string
Validate checks all config fields, input included, against valid ranges and rules, and returns human-readable error descriptions. An empty slice means the config is valid.
func (*Config) Values ¶ added in v0.8.0
func (c *Config) Values() ConfigData
Values returns a copy of the configuration that shares nothing with it.
type ConfigData ¶ added in v0.8.0
type ConfigData struct {
Version int `json:"version"`
Theme string `json:"theme"` // Theme name: "Default", "Dark", "Light", "Retro"
Video VideoConfig `json:"video"`
Audio AudioConfig `json:"audio"`
Window WindowConfig `json:"window"`
Library LibraryView `json:"library"`
Shaders ShaderConfig `json:"shaders"`
Rewind RewindConfig `json:"rewind"`
Input InputConfig `json:"input"`
CoreOptions map[string]string `json:"coreOptions,omitempty"`
BIOS map[string]BIOSConfig `json:"bios,omitempty"`
RetroAchievements RetroAchievementsConfig `json:"retroAchievements"`
Updates UpdatesConfig `json:"updates"`
}
ConfigData is the application configuration stored in config.json. The live configuration is a Config; ConfigData values returned by Config.Values are copies.
type ConfigRules ¶ added in v0.8.0
type ConfigRules struct {
Themes []string // known theme names
ValidKey func(name string) bool // a key name usable in a keyboard binding
ValidPad func(name string) bool // a button name usable in a controller binding
}
ConfigRules are the values a configuration is checked against that only the application knows. All fields must be set.
type ControllerProfile ¶ added in v0.5.0
type ControllerProfile struct {
ID string `json:"id"`
SDLID string `json:"sdlId"`
Controller string `json:"controller"`
Name string `json:"name"`
RumbleScale float64 `json:"rumbleScale"` // intensity multiplier 0.0-3.0 in 0.05 steps, 0=off
Bindings map[string]string `json:"bindings,omitempty"` // button name -> pad button name override
}
ControllerProfile is a named controller button mapping for a controller model. The model is identified by SDLID+Controller; multiple profiles can exist for the same model (e.g. third-party pads reported as the same device). ID is immutable and referenced by PlayerConfig; Name is the user-editable display name, unique per model.
func (*ControllerProfile) MatchesPad ¶ added in v0.5.0
func (p *ControllerProfile) MatchesPad(sdlID, name string) bool
MatchesPad reports whether this profile's controller model matches the given pad identity (SDL ID and name).
func (*ControllerProfile) UnmarshalJSON ¶ added in v0.5.0
func (p *ControllerProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a profile with RumbleScale pre-set to the default, so a profile saved without the key loads at the default intensity instead of 0 (off). An explicit 0 in the file is preserved.
type CustomCheat ¶ added in v0.7.0
CustomCheat is a cheat added by the user: a name and a code string as entered.
type FileStatus ¶ added in v0.7.0
type FileStatus struct {
Missing bool // No file of the game is available
DiscMissing []bool // Per Discs row; nil for cartridge games
}
FileStatus reports which of a game's files are missing on disk
func (FileStatus) HasMissing ¶ added in v0.7.0
func (s FileStatus) HasMissing() bool
HasMissing reports whether any of the game's files is missing
func (FileStatus) MissingAt ¶ added in v0.7.0
func (s FileStatus) MissingAt(idx int) bool
MissingAt reports whether the disc at the given Discs index is missing. For a cartridge game it reports whether the game is missing.
type GameDisc ¶ added in v0.3.0
type GameDisc struct {
Index int `json:"index"` // 0-based disc index (DiscNumber-1)
File string `json:"file"` // Path to this disc's image on disk
Name string `json:"name"` // Per-disc display name
}
GameDisc is one disc of a multi-disc disc-based game.
type GameEntry ¶
type GameEntry struct {
GameID string `json:"gameId"` // Library key: CRC32 hex for cartridges, product number for discs
File string `json:"file,omitempty"` // Cartridge ROM/archive path; disc games leave this empty and use Discs
ConsoleID int `json:"consoleID,omitempty"` // RetroAchievements console ID; 0 = use system default
Favorite bool `json:"favorite"` // User marked as favorite
PlayTimeSeconds int64 `json:"playTimeSeconds"` // Total play time
LastPlayed int64 `json:"lastPlayed"` // Unix timestamp
Added int64 `json:"added"` // Unix timestamp when added to library
// Discs lists the discs of a disc-based game (one entry even for a
// single-disc game), ordered by Index. Empty for cartridge games,
// which use File.
Discs []GameDisc `json:"discs,omitempty"`
// SelectedDisc is the 0-based slice index into Discs to launch.
// Persisted so the chosen disc is remembered. Ignored when Discs is
// empty.
SelectedDisc int `json:"selectedDisc,omitempty"`
}
GameEntry represents a single game in the library. It holds the game's identity, file locations, and user data. Descriptive metadata such as the title comes from the core's metadata provider, not the library.
func (*GameEntry) CheckFiles ¶ added in v0.7.0
func (g *GameEntry) CheckFiles() FileStatus
CheckFiles stats the game's files. A file is missing when it does not exist; other stat errors count as present and are reported by launch.
func (*GameEntry) RemoveDisc ¶ added in v0.7.0
RemoveDisc removes the Discs row at idx. The selection stays on the same disc when another row is removed and moves to the first row when the selected row is removed.
func (*GameEntry) SelectedDiscIndex ¶ added in v0.7.0
SelectedDiscIndex returns the Discs index to launch: SelectedDisc, or the first disc when SelectedDisc is out of range. Returns 0 for a cartridge game.
type GameKeys ¶ added in v0.8.0
GameKeys is what a game is sorted and searched by: its title and its supported region codes in the order of its metadata regions.
type GameSettingsFile ¶ added in v0.7.0
type GameSettingsFile struct {
SaveStates SaveStateSettings `json:"saveStates"`
Cheats CheatSettings `json:"cheats"`
Overrides OverrideSettings `json:"overrides"`
}
GameSettingsFile holds a game's settings, stored per game in gamesettings/<key>.json. Each feature has its own section.
func LoadGameSettings ¶ added in v0.7.0
func LoadGameSettings(gameID string) (*GameSettingsFile, error)
LoadGameSettings loads a game's settings file. A missing file returns empty settings. Invalid entries are removed on load.
func (*GameSettingsFile) CheatEnabled ¶ added in v0.7.0
func (s *GameSettingsFile) CheatEnabled(id string) bool
CheatEnabled reports whether the cheat with the given ID is turned on.
func (*GameSettingsFile) SetCheatEnabled ¶ added in v0.7.0
func (s *GameSettingsFile) SetCheatEnabled(id string, on bool)
SetCheatEnabled turns the cheat with the given ID on or off.
type InputConfig ¶
type InputConfig struct {
P1Keyboard map[string]string `json:"p1Keyboard,omitempty"` // button name -> key name override
Profiles []ControllerProfile `json:"profiles,omitempty"` // named controller mappings, in creation order
Players []PlayerConfig `json:"players,omitempty"` // player slot -> profile assignment
PadMappings map[string]string `json:"padMappings,omitempty"` // SDL GUID -> generated standard-layout mapping line
}
InputConfig contains input binding overrides and controller configuration. Empty/nil maps mean "use adaptor defaults." Only user overrides are stored.
func (*InputConfig) NewProfileID ¶ added in v0.5.0
func (c *InputConfig) NewProfileID() string
NewProfileID returns a random 8-hex-char profile ID unique within this input config.
func (*InputConfig) PlayerProfile ¶ added in v0.5.0
func (c *InputConfig) PlayerProfile(player int) *ControllerProfile
PlayerProfile returns the profile assigned to the given player slot, or nil if the slot is unassigned or the reference is dangling.
func (*InputConfig) PlayerRumbleScale ¶ added in v0.5.0
func (c *InputConfig) PlayerRumbleScale(player int) float64
PlayerRumbleScale returns the rumble intensity for the given player slot from the assigned profile, or 0 (off) when the slot has no profile.
func (*InputConfig) ProfileByID ¶ added in v0.5.0
func (c *InputConfig) ProfileByID(id string) *ControllerProfile
ProfileByID returns the profile with the given ID, or nil if not found.
func (*InputConfig) RumbleEnabled ¶ added in v0.5.0
func (c *InputConfig) RumbleEnabled() bool
RumbleEnabled reports whether any player slot has a profile with a non-zero rumble intensity.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library is the game library, safe for use from any goroutine. Its contents are only reachable through its methods: reads return copies and every change is a single locked operation. A library loaded from or created in library.json saves itself in the background after each change; one from DefaultLibrary is never written.
func DefaultLibrary ¶
func DefaultLibrary() *Library
DefaultLibrary returns an empty library that is never written to disk. It is used where a library is needed but must not replace library.json, such as while the error screen is shown.
func LoadLibrary ¶
LoadLibrary loads the library from library.json. If the file doesn't exist, it returns an empty library that is saved on its first change. If the file is corrupted, it returns an error.
func ResetLibrary ¶ added in v0.8.0
ResetLibrary deletes library.json and returns a new empty library that is saved to it.
func (*Library) AddExcludedPath ¶
AddExcludedPath adds a path to the exclusion list
func (*Library) AddPlayTime ¶ added in v0.8.0
AddPlayTime adds seconds to the game's total play time.
func (*Library) AddScanDirectory ¶
AddScanDirectory adds a directory to scan for ROMs
func (*Library) Correct ¶ added in v0.8.0
func (lib *Library) Correct()
Correct resets any invalid library-level fields to their defaults.
func (*Library) ExcludedPaths ¶
ExcludedPaths returns a copy of the paths excluded from scans.
func (*Library) Flush ¶ added in v0.8.0
func (lib *Library) Flush()
Flush waits until every change has been written. Call before exit.
func (*Library) GamesSorted ¶ added in v0.8.0
GamesSorted returns copies of the games sorted by sortBy, using info for each game's title and region.
func (*Library) GamesSortedFiltered ¶ added in v0.8.0
func (lib *Library) GamesSortedFiltered(sortBy string, favoritesOnly bool, searchText string, info GameInfo) []GameEntry
GamesSortedFiltered returns copies of the games filtered by search text and sorted by sortBy, using info for each game's title and region. Search is case-insensitive and matches against the title. Empty searchText returns all games. info is called without the library locked.
func (*Library) HasGame ¶ added in v0.8.0
HasGame reports whether the library holds the game with the given ID.
func (*Library) IsPathExcluded ¶
IsPathExcluded checks if a path is in the exclusion list
func (*Library) MergeScanned ¶ added in v0.8.0
MergeScanned puts the games a scan found into the library, replacing the entries they update, and returns how many were not in the library before. Restored removed games count as new. Once the library holding them is on disk, restored games are dropped from removed.json in the background, so their user data is never only in memory.
func (*Library) RemoveDisc ¶ added in v0.8.0
RemoveDisc removes the game's Discs row at idx; see GameEntry.RemoveDisc.
func (*Library) RemoveExcludedPath ¶
RemoveExcludedPath removes a path from the exclusion list
func (*Library) RemoveGames ¶ added in v0.7.0
RemoveGames moves the games with the given keys from the library to removed.json. removed.json is written before the games leave the library, so a failed write never loses a game's user data. Keys not in the library are ignored.
func (*Library) RemoveMissing ¶ added in v0.7.0
func (lib *Library) RemoveMissing(files map[string]FileStatus) (int, error)
RemoveMissing removes the missing files found by CheckFiles, keyed by game key: disc rows whose file is gone are dropped, and games with no file left move to removed.json. A status whose disc count no longer matches its game is skipped. Returns the number of games changed or removed.
func (*Library) RemoveScanDirectory ¶
RemoveScanDirectory removes a directory from the scan list
func (*Library) ScanBase ¶ added in v0.8.0
ScanBase returns copies of the entries whose user data a scan keeps: the library's games, plus removed games not in the library so a scan that finds one again restores it.
func (*Library) ScanDirectories ¶
func (lib *Library) ScanDirectories() []ScanDirectory
ScanDirectories returns a copy of the directories scanned for games.
func (*Library) SetLastPlayed ¶ added in v0.8.0
SetLastPlayed records when the game was last played, as a Unix time.
func (*Library) SetSelectedDisc ¶ added in v0.8.0
SetSelectedDisc sets the disc the game launches with.
func (*Library) ToggleFavorite ¶ added in v0.8.0
ToggleFavorite flips the game's favorite mark and returns the new value.
type LibraryView ¶
type LibraryView struct {
ViewMode string `json:"viewMode"` // "icon" or "list"
SortBy string `json:"sortBy"` // "title", "lastPlayed", "playTime"
FavoritesFilter bool `json:"favoritesFilter"` // Show only favorites
ArtworkDownload string `json:"artworkDownload"` // which artwork a scan downloads: one of ValidArtworkDownloads
BoxArtRegion string `json:"boxArtRegion"` // region whose artwork is shown first for a game released in more than one region: one of region.All
}
LibraryView contains library display preferences
type OverrideSettings ¶ added in v0.7.0
type OverrideSettings struct {
CoreOptions map[string]string `json:"coreOptions,omitempty"` // core option key -> value
Shaders map[string]bool `json:"shaders,omitempty"` // shader ID -> on or off
}
OverrideSettings holds a game's overrides of global settings. A setting with no entry uses the global value.
func (*OverrideSettings) ClearCoreOption ¶ added in v0.7.0
func (o *OverrideSettings) ClearCoreOption(key string)
ClearCoreOption removes the core option's override
func (*OverrideSettings) ClearShader ¶ added in v0.7.0
func (o *OverrideSettings) ClearShader(id string)
ClearShader removes the shader's override
func (*OverrideSettings) CoreOption ¶ added in v0.7.0
func (o *OverrideSettings) CoreOption(opt coreif.CoreOption) (string, bool)
CoreOption returns the game's value for a core option and whether the game overrides it. Only per game Bool and Select options can be overridden, and only with a value the option accepts.
func (*OverrideSettings) Reset ¶ added in v0.7.0
func (o *OverrideSettings) Reset()
Reset removes every override
func (*OverrideSettings) SetCoreOption ¶ added in v0.7.0
func (o *OverrideSettings) SetCoreOption(key, value string)
SetCoreOption overrides a core option with value
func (*OverrideSettings) SetShader ¶ added in v0.7.0
func (o *OverrideSettings) SetShader(id string, on bool)
SetShader overrides the shader on or off
type PlayerConfig ¶ added in v0.5.0
type PlayerConfig struct {
Profile string `json:"profile,omitempty"` // ControllerProfile.ID
}
PlayerConfig holds the controller assignment for one player slot. An empty Profile means no controller is assigned to that player.
type RemovedGames ¶ added in v0.7.0
type RemovedGames struct {
Version int `json:"version"`
Games map[string]*GameEntry `json:"games"` // Library key -> entry without File, Discs, and Added
}
RemovedGames represents the games removed from the library, stored in removed.json. Each entry keeps its user data without its files so a scan that finds the game again restores it.
func LoadRemovedGames ¶ added in v0.7.0
func LoadRemovedGames() (*RemovedGames, error)
LoadRemovedGames loads removed.json. If the file doesn't exist or can't be read, it returns an empty set, and the next save overwrites the file; the removed games are not worth blocking removal over.
type RetroAchievementsConfig ¶
type RetroAchievementsConfig struct {
Enabled bool `json:"enabled"`
EncoreMode bool `json:"encoreMode"` // Allow re-triggering unlocked achievements
UnlockSound bool `json:"unlockSound"` // Play sound on achievement unlock
ShowNotification bool `json:"showNotification"` // Show popup notification on achievement unlock
AutoScreenshot bool `json:"autoScreenshot"` // Take screenshot on achievement unlock
SpectatorMode bool `json:"spectatorMode"` // Watch achievements without submitting unlocks
Username string `json:"username,omitempty"`
Token string `json:"token,omitempty"` // Auth token (password is never stored)
}
RetroAchievementsConfig contains RetroAchievements integration settings
type RewindConfig ¶
type RewindConfig struct {
Enabled bool `json:"enabled"` // Default: false (off due to RAM usage)
BufferSizeMB int `json:"bufferSizeMB"` // Default: 40
FrameStep int `json:"frameStep"` // Default: 1 (capture every frame)
}
RewindConfig contains rewind feature settings
type SaveStateSettings ¶ added in v0.7.0
type SaveStateSettings struct {
Slot int `json:"slot,omitempty"` // Last-used save state slot (0-9)
}
SaveStateSettings holds a game's save state choices.
type ScanDirectory ¶
ScanDirectory represents a directory to scan for ROMs
type Screenshot ¶ added in v0.7.0
type Screenshot struct {
Path string // full path of the PNG file
Time time.Time // capture time
Achievement string // achievement title the capture was taken for, or "" for a manual capture
}
Screenshot is one saved screenshot of a game
func ListScreenshots ¶ added in v0.7.0
func ListScreenshots(dir string) ([]Screenshot, error)
ListScreenshots returns the screenshots in dir, newest first. Entries that are not regular files named as screenshots are skipped, so a symlink or a planted file is never previewed, deleted, or shown in the file manager. A missing dir lists nothing.
type ShaderConfig ¶
type ShaderConfig struct {
UIShaders []string `json:"uiShaders"` // Ordered list of shader IDs for UI context
GameShaders []string `json:"gameShaders"` // Ordered list of shader IDs for Game context
}
ShaderConfig contains shader effect settings
type UpdateState ¶ added in v0.7.0
type UpdateState struct {
Version int `json:"version"`
LastCheck int64 `json:"lastCheck"` // Unix time of the last check, 0 = never
IgnoredVersion string `json:"ignoredVersion"` // Version the update bar is not shown for
}
UpdateState is the update check state stored in update/update.json.
func LoadUpdateState ¶ added in v0.7.0
func LoadUpdateState() (*UpdateState, error)
LoadUpdateState loads update/update.json. If the file doesn't exist or can't be read, it returns an empty state, and the next save overwrites the file. Losing it only costs an extra check.
type UpdatesConfig ¶ added in v0.7.0
type UpdatesConfig struct {
AutoCheck bool `json:"autoCheck"` // Check for updates at startup (default: true)
}
UpdatesConfig contains update check settings
type VideoConfig ¶
type VideoConfig struct {
AspectRatio string `json:"aspectRatio"`
}
VideoConfig contains video-related settings