Documentation
¶
Overview ¶
Package wittyplay knows the consoles a game library can hold and how to tell which console a file belongs to. It has no dependencies, so the server's scanner can use it without pulling in anything that runs or streams a game.
The sub-packages do the rest: stream (sessions, on the server), host and libretro (the separate process that runs a game), cores (installing them).
Index ¶
- Constants
- Variables
- func BIOSHelp(coreID string, consoleName string) string
- func ByExtension(ext string) string
- func CheatsForCore(list []Cheat) []ipc.Cheat
- func CleanControl(consoleID, kind string, data json.RawMessage) (json.RawMessage, error)
- func CleanValue(s *Setting, v any) (any, error)
- func CollectBIOS(console *Console, coreID, gamePath, systemDir string) error
- func ControlFor(values map[string]any, lim Limits) ipc.Control
- func CoreOptions(id string) map[string]string
- func DefaultGamepad() map[int]Binding
- func DefaultGamepadFor(consoleID string) map[int]Binding
- func DefaultKeyboard() map[int]string
- func DefaultKeyboardFor(consoleID string) map[int]string
- func DefaultRemote() map[int]string
- func DefaultResolution(consoleID string) int
- func Detect(relPath string) string
- func EffectiveKeys(consoleID string, p *Profile) map[int]string
- func EffectiveMap(consoleID string, p *Profile) map[int]Binding
- func IsBIOSFile(consoleID, name string) bool
- func IsCustomConsole(id string) bool
- func IsLibdragon(path string) bool
- func IsNonCommercial(id string) bool
- func IsSatellaview(path string) bool
- func KnownExtension(ext string) bool
- func LibdragonOptions() map[string]string
- func MissingBIOS(coreID, systemDir string) string
- func NonCommercialLicense(text string) bool
- func NonCommercialName(name string) bool
- func ParseCustom(src []byte, in CustomInput) (*Layer, CustomReport)
- func Refusal(path, consoleID string) string
- func RefusalForCore(path, consoleID, coreID string) string
- func RunnerArgs(coreID string) []string
- func SetCustomConsoles(list []Console)
- func ShortText(s string) string
- func StartOptions(consoleID, coreID, resolution, systemDir string) map[string]string
- func ValidLibraryConsole(id string, testing bool) bool
- type BIOS
- type BIOSRule
- type Binding
- type Cheat
- type Choice
- type Console
- type Control
- type ControllerData
- type Core
- type CoreTraits
- type CustomConsole
- type CustomControl
- type CustomInput
- type CustomReport
- type Issue
- type KnownPad
- type Layer
- type Limits
- type NamedLayer
- type OptionInfo
- type PadButton
- type PadLayout
- type Placement
- type Preset
- type Profile
- type ProfileFile
- type ProfileOptions
- type RawLayout
- type Resolved
- type Setting
- type Target
- type ThreeDSFile
- type TouchLayout
Constants ¶
const ( MaxCheats = 500 MaxCheatCode = 2048 MaxCheatLabel = 120 MaxCheatFile = 2 << 20 )
Limits on cheats.
const ( RetroB = iota RetroY RetroSelect RetroStart RetroUp RetroDown RetroLeft RetroRight RetroA RetroX RetroL RetroR RetroL2 RetroR2 RetroL3 RetroR3 )
RetroPad buttons. libretro speaks one controller, so a console only needs its own names for these, and which of them it has. On the pad itself, bottom is B, right is A, left is Y and top is X.
const ( StickLeftL = iota + retroButtons // left stick, left StickRightL StickUpL StickDownL StickLeftR // right stick, left StickRightR StickUpR StickDownR )
Analog directions, numbered after the buttons so that a mapping can treat them alike: a stick can press a button, and a button can push a stick. Each is one half of one axis; up is negative, as libretro has it.
const ( DPadKey = "dpad" StickKey = "lstick" )
Keys in a touch layout: the D-pad, and an analog stick of its own.
const ( Landscape = "landscape" Portrait = "portrait" )
Orientations a touch layout can be for.
const ( KindGamepad = "gamepad" KindKeyboard = "keyboard" KindTouch = "touch" )
Control kinds a person can save.
const ( MaxCustomSize = 256 << 10 MaxCustomDepth = 8 MaxCustomNodes = 20000 MaxCustomText = 1024 )
Limits on a settings file.
const ( LibdragonCore = "parallel_n64" LibdragonNeedsCore = "" /* 145-byte string literal not displayed */ LibdragonNotice = "" /* 165-byte string literal not displayed */ )
Most new Nintendo 64 homebrew is built with libdragon, whose games boot from its own code and run their own programs on the console's graphics processor, where a commercial game runs Nintendo's. Mupen64Plus-Next can't run them: on its fast CPU setting, it ends the whole process with exit(1) while compiling their code, and on the slower ones it never makes a frame. ParaLLEl N64 can, but only with its software renderer and the real graphics processor emulated: a graphics plugin guessing at what's being drawn makes the game crash.
const ( ProfileGamepad = "gamepad" ProfileKeyboard = "keyboard" )
Kinds of profile.
const ( MaxProfiles = 200 MaxProfileSize = 16 << 10 MaxImportSize = 256 << 10 MaxImportEntries = 100 )
Limits on what a person can store and bring in.
const ( SatellaviewCore = "mesen-s" SatellaviewBIOS = "BS-X.bin" )
Satellaview games were broadcast to a receiver on the Super Famicom. Those dumped like cartridges run on any SNES core. A .bs file holds only what was broadcast, so it runs from the receiver's own cartridge, and only on this core.
const ( LevelBuiltin = "builtin" LevelServer = "server" LevelServerConsole = "serverConsole" LevelPerson = "person" LevelConsole = "console" LevelGame = "game" )
Levels a layer can sit at, least specific first.
const ( KindToggle = "toggle" KindChoice = "choice" KindSlider = "slider" KindColor = "color" KindBezel = "bezel" )
Kinds of setting.
const ( GroupDisplay = "display" GroupOSD = "osd" GroupEmulation = "emulation" GroupAudio = "audio" GroupStates = "states" GroupHotkeys = "hotkeys" )
Groups of settings, in the order menus show them.
const ( MaxCoreOptions = 512 MaxCustomControls = 64 MaxPresets = 32 MaxControlChoices = 256 MaxOptionKey = ipc.MaxOptionKey MaxOptionValue = ipc.MaxOptionValue MaxLabel = 80 )
Limits on what one layer may hold.
const ( NewThreeDSOption = "citra_is_new_3ds" NewThreeDSValue = "New 3DS" )
Azahar, like the 3DS, starts as the older model unless it's told otherwise. A game made for the New 3DS, whose header says so, won't run on that.
const Auto = "auto"
Auto is the Library console value for one folder of many consoles.
const BIOSFolderName = "BIOS"
BIOSFolderName is what the server looks for beside the games. Any capitalisation and any folders inside it are fine.
const ControllerKeyboard = "keyboard"
ControllerKeyboard is the Controller of every keyboard profile.
const CustomPrefix = "custom-"
CustomPrefix starts every custom console's ID, so one can never collide with a console added to the table in a later version.
const MaxControlSize = 16 << 10
MaxControlSize bounds one saved layout; the largest real one is under 2 KB.
const MaxCustomConsoleJSON = 64 << 10
MaxCustomConsoleJSON is the most JSON one console may be sent as.
const MaxCustomConsoles = 200
MaxCustomConsoles bounds what the scanner and every console list has to go through.
const MaxStateSlot = ipc.MaxStateSlot
MaxStateSlot is the highest numbered save slot a person can use.
const ProfileFormat = "wittyplay-controller-profiles"
ProfileFormat names the files profiles are exported to.
const TestConsole = "wittytest"
TestConsole is the console of the built-in test core, shown only when testing.
Variables ¶
var ( // ErrPlayLoneBin is why Play! won't play a lone PS2 .bin file. ErrPlayLoneBin = errors.New("Play! cannot open a PlayStation 2 game kept as a single .bin; use LRPS2 or a .cue sheet") // ErrPlayBinWithCue is why Play! won't open a .bin directly when a .cue exists. ErrPlayBinWithCue = errors.New("Play! cannot open a PlayStation 2 .bin directly; open its .cue sheet or use LRPS2") )
var BuiltinPresets = []Preset{ {Name: "Clean", Description: "Sharp pixels and nothing else.", Values: map[string]any{"display.scaling": "sharp", "display.scanlines": 0.0, "display.curve": 0.0, "display.mask": 0.0, "display.glow": 0.0, "display.vignette": 0.0, "display.lcdGrid": 0.0, "display.blend": 0.0, "display.flicker": 0.0}}, {Name: "Scanlines", Description: "The dark lines of a TV picture, on a flat screen.", Values: map[string]any{"display.scaling": "sharp", "display.scanlines": 0.45, "display.curve": 0.0, "display.mask": 0.0, "display.glow": 0.1, "display.vignette": 0.0, "display.lcdGrid": 0.0, "display.blend": 0.0}}, {Name: "CRT TV", Description: "Scanlines, a curved glass front and a phosphor pattern.", Values: map[string]any{"display.scaling": "sharp", "display.scanlines": 0.5, "display.curve": 0.35, "display.mask": 0.35, "display.glow": 0.25, "display.vignette": 0.3, "display.lcdGrid": 0.0, "display.blend": 0.0}}, {Name: "Arcade", Description: "Strong scanlines and glow on a flat tube.", Values: map[string]any{"display.scaling": "sharp", "display.scanlines": 0.7, "display.curve": 0.1, "display.mask": 0.5, "display.glow": 0.4, "display.vignette": 0.1, "display.lcdGrid": 0.0, "display.blend": 0.0}}, {Name: "Handheld LCD", Description: "A pixel grid and the slow fade of an old handheld's screen.", Values: map[string]any{"display.scaling": "sharp", "display.scanlines": 0.0, "display.curve": 0.0, "display.mask": 0.0, "display.glow": 0.0, "display.vignette": 0.0, "display.lcdGrid": 0.45, "display.blend": 0.4, "display.integer": true}}, }
BuiltinPresets are starting points for the picture.
var Consoles = []Console{ {ID: "nes", Name: "Nintendo Entertainment System", Short: "NES", Extensions: []string{".nes", ".fds", ".unf", ".unif"}, Aliases: []string{"nes", "famicom", "nintendoentertainmentsystem", "nintendonintendoentertainmentsystem", "fc", "famicomdisksystem", "fds"}, Cores: []Core{{"fceumm", "FCEUmm", "GPL-2.0"}, {"nestopia", "Nestopia UE", "GPL-2.0"}, {"mesen", "Mesen", "GPL-3.0"}}, BIOS: []BIOS{{"disksys.rom", "Famicom Disk System games", false}}}, {ID: "snes", Name: "Super Nintendo", Short: "SNES", Extensions: []string{".sfc", ".smc", ".fig", ".swc", ".bs", ".gd3", ".gd7", ".dx2", ".bsx"}, Aliases: []string{"snes", "sfc", "supernintendo", "superfamicom", "supernes", "nintendosupernintendoentertainmentsystem", "supernintendoentertainmentsystem"}, Cores: []Core{{"mednafen_supafaust", "Beetle Supafaust", "GPL-2.0-or-later"}, {"bsnes2014_performance", "bsnes 2014 Performance", "GPL-3.0"}, {"mesen-s", "Mesen-S", "GPL-3.0"}}, BIOS: []BIOS{{SatellaviewBIOS, "Satellaview games in .bs files, on Mesen-S; nothing else needs it", false}}}, {ID: "gb", Name: "Game Boy and Game Boy Color", Short: "Game Boy", Extensions: []string{".gb", ".gbc", ".dmg", ".cgb", ".sgb"}, Aliases: []string{"gb", "gbc", "gameboy", "gameboycolor", "gameboycolour", "nintendogameboy", "nintendogameboycolor"}, Cores: []Core{{"gambatte", "Gambatte", "GPL-2.0"}, {"sameboy", "SameBoy", "MIT"}, {"mgba", "mGBA", "MPL-2.0"}}}, {ID: "gba", Name: "Game Boy Advance", Short: "GBA", Extensions: []string{".gba"}, Aliases: []string{"gba", "gameboyadvance", "nintendogameboyadvance"}, Cores: []Core{{"mgba", "mGBA", "MPL-2.0"}, {"vba_next", "VBA Next", "GPL-2.0"}}, BIOS: []BIOS{{"gba_bios.bin", "better accuracy; games run without it", false}}}, {ID: "md", Name: "Sega Mega Drive / Genesis", Short: "Mega Drive", Extensions: []string{".md", ".gen", ".smd", ".68k", ".sgd"}, Shared: []string{".bin"}, Aliases: []string{"md", "genesis", "megadrive", "segagenesis", "segamegadrive", "segamegadrivegenesis"}, Cores: []Core{{"blastem", "BlastEm", "GPL-3.0"}, {"clownmdemu", "ClownMDEmu", "AGPL-3.0"}}}, {ID: "sms", Name: "Sega Master System", Short: "Master System", Extensions: []string{".sms"}, Aliases: []string{"sms", "mastersystem", "segamastersystem", "segamastersystemmarkiii", "markiii"}, Cores: []Core{{"gearsystem", "Gearsystem", "GPL-3.0"}, {"smsplus", "SMS Plus GX", "GPL-2.0"}}}, {ID: "gg", Name: "Sega Game Gear", Short: "Game Gear", Extensions: []string{".gg"}, Aliases: []string{"gg", "gamegear", "segagamegear"}, Cores: []Core{{"gearsystem", "Gearsystem", "GPL-3.0"}, {"smsplus", "SMS Plus GX", "GPL-2.0"}}}, {ID: "ps1", Name: "Sony PlayStation", Short: "PlayStation", Extensions: []string{".pbp"}, Shared: []string{".cue", ".chd", ".m3u", ".iso", ".img", ".toc", ".ccd", ".bin"}, Aliases: []string{"ps1", "psx", "psone", "playstation", "playstation1", "sonyplaystation"}, Cores: []Core{{"pcsx_rearmed", "PCSX ReARMed", "GPL-2.0"}, {"mednafen_psx", "Beetle PSX", "GPL-2.0"}, {"swanstation", "SwanStation (graphics card)", "GPL-3.0"}, {"mednafen_psx_hw", "Beetle PSX HW (graphics card)", "GPL-2.0"}}, BIOS: []BIOS{{"scph5501.bin", "US consoles; PCSX ReARMed runs most games without one", false}, {"scph5500.bin", "Japanese consoles", false}, {"scph5502.bin", "European consoles", false}}}, {ID: "pce", Name: "PC Engine / TurboGrafx-16", Short: "PC Engine", Extensions: []string{".pce"}, Shared: []string{".cue", ".chd", ".ccd", ".toc", ".m3u"}, Aliases: []string{"pce", "pcengine", "turbografx16", "turbografx", "tg16", "necpcenginetg16", "pcenginecd"}, Cores: []Core{{"mednafen_pce_fast", "Beetle PCE Fast", "GPL-2.0"}}, BIOS: []BIOS{{"syscard3.pce", "CD games", false}}}, {ID: "a2600", Name: "Atari 2600", Short: "Atari 2600", Extensions: []string{".a26"}, Shared: []string{".bin"}, Aliases: []string{"a2600", "atari2600", "2600", "atari"}, Cores: []Core{{"stella2014", "Stella 2014", "GPL-2.0"}, {"stella", "Stella", "GPL-2.0"}}}, {ID: "a7800", Name: "Atari 7800", Short: "Atari 7800", Extensions: []string{".a78"}, Shared: []string{".bin"}, Aliases: []string{"a7800", "atari7800", "7800"}, Cores: []Core{{"prosystem", "ProSystem", "GPL-2.0"}}, BIOS: []BIOS{{"7800 BIOS (U).rom", "the Atari start-up screen; optional", false}}}, {ID: "lynx", Name: "Atari Lynx", Short: "Lynx", Extensions: []string{".lnx", ".lyx"}, Aliases: []string{"lynx", "atarilynx"}, Cores: []Core{{"handy", "Handy", "Zlib"}}, BIOS: []BIOS{{"lynxboot.img", "most games need it", false}}}, {ID: "ws", Name: "WonderSwan and WonderSwan Color", Short: "WonderSwan", Extensions: []string{".ws", ".wsc", ".pc2"}, Aliases: []string{"ws", "wsc", "wonderswan", "wonderswancolor", "bandaiwonderswan"}, Cores: []Core{{"mednafen_wswan", "Beetle WonderSwan", "GPL-2.0"}}}, {ID: "ngp", Name: "Neo Geo Pocket and Color", Short: "Neo Geo Pocket", Extensions: []string{".ngp", ".ngc", ".ngpc", ".npc"}, Aliases: []string{"ngp", "ngpc", "neogeopocket", "neogeopocketcolor", "snkneogeopocket"}, Cores: []Core{{"mednafen_ngp", "Beetle NeoPop", "GPL-2.0"}}}, {ID: "vb", Name: "Virtual Boy", Short: "Virtual Boy", Extensions: []string{".vb", ".vboy"}, Aliases: []string{"vb", "virtualboy", "nintendovirtualboy"}, Cores: []Core{{"mednafen_vb", "Beetle VB", "GPL-2.0"}}}, {ID: "n64", Name: "Nintendo 64", Short: "N64", Extensions: []string{".n64", ".z64", ".v64"}, Aliases: []string{"n64", "nintendo64"}, Cores: []Core{{"mupen64plus_next", "Mupen64Plus-Next", "GPL-2.0"}, {"parallel_n64", "ParaLLEl N64", "GPL-2.0"}}}, {ID: "nds", Name: "Nintendo DS", Short: "DS", Extensions: []string{".nds"}, Aliases: []string{"nds", "ds", "nintendods"}, Cores: []Core{{"melonds", "melonDS", "GPL-3.0"}, {"desmume", "DeSmuME", "GPL-2.0"}}, BIOS: []BIOS{{"bios7.bin", "melonDS: better accuracy; games run without it", false}, {"bios9.bin", "melonDS: better accuracy; games run without it", false}, {"firmware.bin", "melonDS: the DS's own start-up menu", false}}}, {ID: "3ds", Name: "Nintendo 3DS", Short: "3DS", Extensions: []string{".3ds", ".3dsx", ".cci", ".cxi", ".cia", ".zcci", ".zcxi", ".z3dsx", ".bcci", ".bcxi"}, Shared: []string{".app", ".elf", ".axf"}, Aliases: []string{"3ds", "n3ds", "nintendo3ds"}, Cores: []Core{{"azahar", "Azahar", "GPL-2.0-or-later"}, {"panda3ds", "Panda3DS", "GPL-3.0"}}}, {ID: "ps2", Name: "Sony PlayStation 2", Short: "PS2", Shared: []string{".iso", ".bin", ".cue", ".chd", ".cso", ".zso", ".ciso", ".gz", ".img", ".mdf", ".nrg", ".m3u"}, Aliases: []string{"ps2", "playstation2", "sonyplaystation2", "pstwo"}, Cores: []Core{{"pcsx2", "LRPS2 (PCSX2)", "GPL-3.0"}, {"play", "Play!", "MIT"}}, BIOS: []BIOS{{"scph39001.bin", "LRPS2 needs one BIOS from a PlayStation 2 you own, and any region will do; Play! runs without one", true}}}, {ID: "psp", Name: "PlayStation Portable", Short: "PSP", Extensions: []string{".cso"}, Shared: []string{".iso", ".pbp", ".chd"}, Aliases: []string{"psp", "playstationportable", "sonyplaystationportable"}, Cores: []Core{{"ppsspp", "PPSSPP", "GPL-2.0"}}}, {ID: "dc", Name: "Sega Dreamcast", Short: "Dreamcast", Extensions: []string{".gdi", ".cdi"}, Shared: []string{".chd", ".cue", ".m3u"}, Aliases: []string{"dc", "dreamcast", "segadreamcast"}, Cores: []Core{{"flycast", "Flycast", "GPL-2.0"}}, BIOS: []BIOS{{"dc/dc_boot.bin", "better compatibility; most games run without it", false}, {"dc/dc_flash.bin", "the console's settings", false}}}, {ID: TestConsole, Name: "WittyPlay test console", Short: "Test", Extensions: []string{".wittytest"}, Aliases: []string{"wittytest"}, Hidden: true}, }
Consoles is every console, in the order the add-library flow lists them.
var ErrEncrypted3DS = errors.New("This 3DS game file is encrypted: its program is scrambled, as it came from the console or the store. It can't be played here, and this server won't decrypt it")
ErrEncrypted3DS is why an encrypted 3DS file won't play.
var ManifestJSON []byte
ManifestJSON is this module's manifest (docs/MODULES.md, "The manifest").
var Settings = []Setting{ {Key: "display.scaling", Group: GroupDisplay, Section: "Scaling", Label: "Scaling", Help: "Sharp keeps pixels crisp at any size. Pixel is exact squares, which can look uneven unless the size is a whole number. Smooth blurs them.", Kind: KindChoice, Default: "sharp", Choices: choices("sharp", "Sharp", "pixel", "Pixel", "smooth", "Smooth")}, {Key: "display.integer", Group: GroupDisplay, Section: "Scaling", Label: "Whole-number scale", Help: "Every game pixel is the same size. The picture may not fill the screen.", Kind: KindToggle, Default: false}, {Key: "display.aspect", Group: GroupDisplay, Section: "Scaling", Label: "Shape", Kind: KindChoice, Default: "original", Choices: choices("original", "As the game says", "4:3", "4:3", "16:9", "16:9", "square", "Square pixels", "stretch", "Fill the screen", "custom", "Custom")}, {Key: "display.aspectCustom", Group: GroupDisplay, Section: "Scaling", Label: "Custom shape", Help: "Width divided by height, used when Shape is Custom.", Kind: KindSlider, Default: 1.33, Min: 0.5, Max: 3, Step: 0.01}, {Key: "display.cropX", Group: GroupDisplay, Section: "Scaling", Label: "Crop the sides", Help: "Old consoles drew past the edge of a TV. This hides that part.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 20, Step: 0.5, Unit: "%"}, {Key: "display.cropY", Group: GroupDisplay, Section: "Scaling", Label: "Crop top and bottom", Kind: KindSlider, Default: 0.0, Min: 0, Max: 20, Step: 0.5, Unit: "%"}, {Key: "display.rotate", Group: GroupDisplay, Section: "Scaling", Label: "Rotate", Kind: KindChoice, Default: "0", Choices: choices("0", "None", "90", "90° clockwise", "180", "180°", "270", "90° anticlockwise")}, {Key: "display.scanlines", Group: GroupDisplay, Section: "Screen effects", Label: "Scanlines", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.curve", Group: GroupDisplay, Section: "Screen effects", Label: "CRT curve", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.mask", Group: GroupDisplay, Section: "Screen effects", Label: "CRT phosphor pattern", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.glow", Group: GroupDisplay, Section: "Screen effects", Label: "Glow", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.vignette", Group: GroupDisplay, Section: "Screen effects", Label: "Dark corners", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.lcdGrid", Group: GroupDisplay, Section: "Screen effects", Label: "LCD grid", Help: "The gaps between pixels on a handheld's screen.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true}, {Key: "display.blend", Group: GroupDisplay, Section: "Screen effects", Label: "Frame blend", Help: "Mixes each picture with the last, as a slow LCD did. Handheld games that flicker sprites on purpose look right with it.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 0.8, Step: 0.05, Shader: true}, {Key: "display.flicker", Group: GroupDisplay, Section: "Screen effects", Label: "Tube flicker", Caution: "This makes the picture flicker. Leave it off if flashing or flickering light affects you. It stays off when your device asks for reduced motion.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 1, Step: 0.05, Shader: true, Motion: true}, {Key: "display.brightness", Group: GroupDisplay, Section: "Colour", Label: "Brightness", Kind: KindSlider, Default: 1.0, Min: 0.5, Max: 1.5, Step: 0.01}, {Key: "display.contrast", Group: GroupDisplay, Section: "Colour", Label: "Contrast", Kind: KindSlider, Default: 1.0, Min: 0.5, Max: 1.5, Step: 0.01}, {Key: "display.saturation", Group: GroupDisplay, Section: "Colour", Label: "Colour strength", Kind: KindSlider, Default: 1.0, Min: 0, Max: 2, Step: 0.01}, {Key: "display.gamma", Group: GroupDisplay, Section: "Colour", Label: "Gamma", Kind: KindSlider, Default: 1.0, Min: 0.5, Max: 2, Step: 0.01, Shader: true}, {Key: "display.bezel", Group: GroupDisplay, Section: "Around the picture", Label: "Around the picture", Kind: KindChoice, Default: "none", Choices: choices("none", "Black", "color", "A colour", "image", "An image of yours")}, {Key: "display.bezelColor", Group: GroupDisplay, Section: "Around the picture", Label: "Colour", Kind: KindColor, Default: "#14161e"}, {Key: "display.bezelImage", Group: GroupDisplay, Section: "Around the picture", Label: "Image", Kind: KindBezel, Default: 0.0}, {Key: "display.bezelInset", Group: GroupDisplay, Section: "Around the picture", Label: "Picture size inside it", Help: "Makes room for what's around the picture.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 45, Step: 1, Unit: "%"}, {Key: "osd.on", Group: GroupOSD, Label: "Show numbers while playing", Kind: KindToggle, Default: false}, {Key: "osd.corner", Group: GroupOSD, Label: "Corner", Kind: KindChoice, Default: "tl", Choices: choices("tl", "Top left", "tr", "Top right", "bl", "Bottom left", "br", "Bottom right")}, {Key: "osd.size", Group: GroupOSD, Label: "Text size", Kind: KindChoice, Default: "normal", Choices: choices("small", "Small", "normal", "Normal", "large", "Large")}, {Key: "osd.fps", Group: GroupOSD, Section: "What to show", Label: "Frames shown here", Kind: KindToggle, Default: true}, {Key: "osd.gameFps", Group: GroupOSD, Section: "What to show", Label: "Frames the game ran", Kind: KindToggle, Default: true}, {Key: "osd.latency", Group: GroupOSD, Section: "What to show", Label: "Network delay", Kind: KindToggle, Default: true}, {Key: "osd.stages", Group: GroupOSD, Section: "What to show", Label: "Where the delay goes", Help: "From a press to the screen, and each stage on the way: the game, the encoder, the network, decoding and the display.", Kind: KindToggle, Default: true}, {Key: "osd.encode", Group: GroupOSD, Section: "What to show", Label: "Encode time", Kind: KindToggle, Default: false}, {Key: "osd.bitrate", Group: GroupOSD, Section: "What to show", Label: "Bitrate", Kind: KindToggle, Default: false}, {Key: "osd.dropped", Group: GroupOSD, Section: "What to show", Label: "Dropped frames", Kind: KindToggle, Default: false}, {Key: "osd.resolution", Group: GroupOSD, Section: "What to show", Label: "Resolution", Kind: KindToggle, Default: false}, {Key: "osd.core", Group: GroupOSD, Section: "What to show", Label: "Core and encoder", Kind: KindToggle, Default: false}, {Key: "emulation.frameSkip", Group: GroupEmulation, Section: "Speed", Label: "Frame skip", Help: "Runs every frame but sends fewer. Helps a slow server. Automatic skips only when it falls behind.", Kind: KindChoice, Default: "off", Choices: choices("off", "Off", "auto", "Automatic", "1", "Skip 1", "2", "Skip 2", "3", "Skip 3", "4", "Skip 4")}, {Key: "emulation.ffSpeed", Group: GroupEmulation, Section: "Speed", Label: "Fast-forward speed", Help: "This server may hold it lower.", Caution: "Fast-forward can make a game flash quickly.", Kind: KindSlider, Default: 4.0, Min: 1.5, Max: 16, Step: 0.5, Unit: "×"}, {Key: "emulation.ffMode", Group: GroupEmulation, Section: "Speed", Label: "Fast-forward button", Kind: KindChoice, Default: "hold", Choices: choices("hold", "Hold it", "toggle", "Press on, press off")}, {Key: "emulation.slowSpeed", Group: GroupEmulation, Section: "Speed", Label: "Slow-motion speed", Kind: KindSlider, Default: 0.5, Min: 0.1, Max: 0.9, Step: 0.05, Unit: "×"}, {Key: "emulation.rewind", Group: GroupEmulation, Section: "Rewind", Label: "Rewind", Help: "Keeps the last few seconds in memory on the server. Off by default, as it costs a little all the time.", Kind: KindToggle, Default: false}, {Key: "emulation.rewindSeconds", Group: GroupEmulation, Section: "Rewind", Label: "How far back", Help: "The server's memory limit can make it less.", Kind: KindSlider, Default: 20.0, Min: 5, Max: 120, Step: 5, Unit: "s"}, {Key: "emulation.latency", Group: GroupEmulation, Section: "Latency", Label: "Speed or steadiness", Help: "Fastest shows every frame the moment it arrives. Steadiest lets your browser hold frames back to smooth out a poor connection, which adds delay. Automatic is Fastest until the connection turns uneven, then Balanced until it settles.", Kind: KindChoice, Default: "auto", Choices: choices("auto", "Automatic", "fastest", "Fastest", "balanced", "Balanced", "steady", "Steadiest")}, {Key: "emulation.runAheadAuto", Group: GroupEmulation, Section: "Latency", Label: "Automatic run-ahead", Help: "Games take a frame or two to react to a button, as they did on the real console. For the older consoles, whose whole state saves in a moment, this shows the picture from a frame ahead, so that the game reacts a frame sooner. It's off for a game if the server can't keep up. A rare game may show a small glitch, and this is what to turn off if one does.", Kind: KindToggle, Default: true}, {Key: "emulation.runAhead", Group: GroupEmulation, Section: "Latency", Label: "Run-ahead", Help: "Takes frames off the delay by running the game ahead and going back, on any core that can. Costs the server more, and can glitch on some games. It turns itself off when it doesn't fit.", Kind: KindSlider, Default: 0.0, Min: 0, Max: 3, Step: 1, Unit: " frames"}, {Key: "emulation.pauseHidden", Group: GroupEmulation, Section: "When you step away", Label: "Pause when this tab is hidden", Kind: KindToggle, Default: true}, {Key: "audio.volume", Group: GroupAudio, Label: "Volume", Kind: KindSlider, Default: 1.0, Min: 0, Max: 1, Step: 0.05}, {Key: "audio.mute", Group: GroupAudio, Label: "Mute", Kind: KindToggle, Default: false}, {Key: "audio.latency", Group: GroupAudio, Label: "Sound buffer", Help: "A bigger buffer stops crackling on a poor connection, and puts the sound a little behind the picture.", Kind: KindChoice, Default: "lowest", Choices: choices("lowest", "Lowest delay", "balanced", "Balanced", "smooth", "Smoothest")}, {Key: "states.autoSave", Group: GroupStates, Label: "Save automatically on exit", Kind: KindToggle, Default: true}, {Key: "states.resume", Group: GroupStates, Label: "When a game is opened", Kind: KindChoice, Default: "ask", Choices: choices("ask", "Offer to resume", "always", "Always resume", "never", "Start from the beginning")}, {Key: "states.quickSlot", Group: GroupStates, Label: "Quick-save slot", Kind: KindSlider, Default: 1.0, Min: 1, Max: MaxStateSlot, Step: 1}, {Key: "states.confirm", Group: GroupStates, Label: "Ask before replacing a saved state", Kind: KindToggle, Default: true}, {Key: "hotkeys.padCombos", Group: GroupHotkeys, Section: "Controller", Label: "Controller shortcuts", Help: "Hold the shortcut button and press another. Start and Select together, or Guide, always opens the menu.", Kind: KindToggle, Default: true}, {Key: "hotkeys.padModifier", Group: GroupHotkeys, Section: "Controller", Label: "Shortcut button", Help: "Held for every shortcut. The game also sees it, unless it's a button the console doesn't have.", Kind: KindChoice, Default: "select", Choices: choices("select", "Select", "l3", "Left stick press", "r3", "Right stick press")}, {Key: "hotkeys.pad.fastForward", Group: GroupHotkeys, Section: "Controller", Label: "Fast-forward", Kind: KindChoice, Default: "r", Choices: padButtons}, {Key: "hotkeys.pad.rewind", Group: GroupHotkeys, Section: "Controller", Label: "Rewind", Kind: KindChoice, Default: "l", Choices: padButtons}, {Key: "hotkeys.pad.quickSave", Group: GroupHotkeys, Section: "Controller", Label: "Quick save", Kind: KindChoice, Default: "r2", Choices: padButtons}, {Key: "hotkeys.pad.quickLoad", Group: GroupHotkeys, Section: "Controller", Label: "Quick load", Kind: KindChoice, Default: "l2", Choices: padButtons}, {Key: "hotkeys.pad.slow", Group: GroupHotkeys, Section: "Controller", Label: "Slow motion", Kind: KindChoice, Default: "x", Choices: padButtons}, {Key: "hotkeys.pad.pause", Group: GroupHotkeys, Section: "Controller", Label: "Pause", Kind: KindChoice, Default: "y", Choices: padButtons}, {Key: "hotkeys.pad.advance", Group: GroupHotkeys, Section: "Controller", Label: "Next frame", Kind: KindChoice, Default: "right", Choices: padButtons}, {Key: "hotkeys.pad.screenshot", Group: GroupHotkeys, Section: "Controller", Label: "Screenshot", Kind: KindChoice, Default: "a", Choices: padButtons}, {Key: "hotkeys.pad.menu", Group: GroupHotkeys, Section: "Controller", Label: "Menu", Kind: KindChoice, Default: "b", Choices: padButtons}, {Key: "hotkeys.key.fastForward", Group: GroupHotkeys, Section: "Keyboard", Label: "Fast-forward", Kind: KindChoice, Default: "Space", Choices: hotkeyKeys}, {Key: "hotkeys.key.rewind", Group: GroupHotkeys, Section: "Keyboard", Label: "Rewind", Kind: KindChoice, Default: "Backspace", Choices: hotkeyKeys}, {Key: "hotkeys.key.quickSave", Group: GroupHotkeys, Section: "Keyboard", Label: "Quick save", Kind: KindChoice, Default: "F2", Choices: hotkeyKeys}, {Key: "hotkeys.key.quickLoad", Group: GroupHotkeys, Section: "Keyboard", Label: "Quick load", Kind: KindChoice, Default: "F4", Choices: hotkeyKeys}, {Key: "hotkeys.key.slow", Group: GroupHotkeys, Section: "Keyboard", Label: "Slow motion", Kind: KindChoice, Default: "KeyB", Choices: hotkeyKeys}, {Key: "hotkeys.key.pause", Group: GroupHotkeys, Section: "Keyboard", Label: "Pause", Kind: KindChoice, Default: "KeyP", Choices: hotkeyKeys}, {Key: "hotkeys.key.advance", Group: GroupHotkeys, Section: "Keyboard", Label: "Next frame", Kind: KindChoice, Default: "KeyN", Choices: hotkeyKeys}, {Key: "hotkeys.key.screenshot", Group: GroupHotkeys, Section: "Keyboard", Label: "Screenshot", Kind: KindChoice, Default: "F8", Choices: hotkeyKeys}, {Key: "hotkeys.key.mute", Group: GroupHotkeys, Section: "Keyboard", Label: "Mute", Kind: KindChoice, Default: "KeyM", Choices: hotkeyKeys}, {Key: "hotkeys.key.osd", Group: GroupHotkeys, Section: "Keyboard", Label: "Show numbers", Kind: KindChoice, Default: "KeyO", Choices: hotkeyKeys}, {Key: "hotkeys.touchBar", Group: GroupHotkeys, Section: "Touch", Label: "Shortcut buttons on screen", Help: "Fast-forward, rewind, quick save and quick load, beside the menu button.", Kind: KindToggle, Default: false}, }
Settings is every setting there is.
Functions ¶
func ByExtension ¶
ByExtension is the one console that uses an extension, or "" for none or several.
func CheatsForCore ¶ added in v0.3.3
CheatsForCore is what a runner is given.
func CleanControl ¶
func CleanControl(consoleID, kind string, data json.RawMessage) (json.RawMessage, error)
CleanControl checks a layout someone wants to save, and returns it in the one form the server stores. It comes from a client, so nothing about it is taken on trust.
func CleanValue ¶ added in v0.3.3
CleanValue checks a value against its setting and returns it in its one proper form.
func CollectBIOS ¶ added in v0.3.3
CollectBIOS copies BIOS files the core wants from BIOS folders near a game into the system folder, leaving the originals alone. A file already there stays. It looks in the game's own folder and the one above it.
func ControlFor ¶ added in v0.3.3
ControlFor turns settings into what a runner is told, held to the server's limits.
func CoreOptions ¶ added in v0.3.3
CoreOptions returns a copy of a core's starting settings, nil when it has none.
func DefaultGamepad ¶
DefaultGamepad maps by position, which is how libretro expects pads to be laid out.
func DefaultGamepadFor ¶ added in v0.3.3
DefaultGamepadFor is DefaultGamepad for one console: only what its controller has, and its sticks where it has them.
func DefaultKeyboard ¶
DefaultKeyboard uses KeyboardEvent.code names.
func DefaultKeyboardFor ¶ added in v0.3.3
DefaultKeyboardFor is DefaultKeyboard for one console. A stick gets I, J, K and L, and where the stick is how games steer it gets the arrows instead.
func DefaultRemote ¶
DefaultRemote is for a TV remote playing a game, using KeyboardEvent.key names. A remote has few buttons, so Back opens the game's menu, which can also press Start and Select, and a game needing more wants a gamepad.
func DefaultResolution ¶ added in v0.3.3
DefaultResolution is how many times native a console renders at with the setting on Automatic. Sharp enough to be worth the graphics card, small enough to stream well.
PlayStation 2 stays native. Its games draw full-screen effects in small tiles, and the fixes that hold those together when upscaled are worked out per game by the core's own database, which doesn't always succeed: Gran Turismo 4 at 2x comes out in bands of the wrong colour with a grid over them. At native size no such seams exist, and a frame has a quarter of the pixels to draw, encode and send.
func Detect ¶
Detect sorts a file into a console, for a library holding many. The folders between the library's root and the file come first, nearest first, since they are what the owner chose; after that, an extension only one console uses. It returns "" when nothing is sure.
func EffectiveKeys ¶ added in v0.3.3
EffectiveKeys is EffectiveMap for a keyboard. A key does one thing, so a key the profile uses leaves the default it would otherwise also press.
func EffectiveMap ¶ added in v0.3.3
EffectiveMap is what each of a console's targets is pressed by under a profile: the console's default, changed by what the profile says. p may be nil. A profile of a pad's own numbers starts from nothing, as the defaults use standard numbers.
func IsBIOSFile ¶ added in v0.3.3
IsBIOSFile says whether a file beside the games is firmware rather than a game, going by its name. A .bin of the right name in a game folder shouldn't be listed as something to play.
func IsCustomConsole ¶ added in v0.3.3
IsCustomConsole says whether an ID belongs to a custom console.
func IsLibdragon ¶ added in v0.3.3
IsLibdragon says whether a Nintendo 64 file boots from libdragon's own code, whichever of the three byte orders it was dumped in. Nothing here decides for a file it can't read.
func IsNonCommercial ¶
IsNonCommercial says whether a core's licence forbids commercial use, as far as this table knows.
func IsSatellaview ¶ added in v0.3.3
IsSatellaview says whether a SNES file needs the receiver.
func KnownExtension ¶ added in v0.3.3
KnownExtension says whether any console uses an extension.
func LibdragonOptions ¶ added in v0.3.3
LibdragonOptions are what ParaLLEl N64 takes to run such a game. Nothing here needs a graphics card. The cached interpreter takes about twice the CPU of the recompiler (12 seconds against 7 in 20 of a test suite's menus), and is what shows a game's own error where the recompiler shows a black screen for good. cxd4 is in every build of this core.
func MissingBIOS ¶ added in v0.3.3
MissingBIOS says what a core needs and doesn't have, "" when it has what it needs.
func NonCommercialLicense ¶ added in v0.3.3
NonCommercialLicense says whether licence text forbids commercial use.
func NonCommercialName ¶ added in v0.3.3
NonCommercialName says whether a core's own name for itself is one of the cores whose licence forbids commercial use. A file can be called anything, so what it reports gets looked at as well as what it's called.
func ParseCustom ¶ added in v0.3.3
func ParseCustom(src []byte, in CustomInput) (*Layer, CustomReport)
ParseCustom checks a settings file and returns what can be used from it.
func Refusal ¶ added in v0.3.3
Refusal says why a file for this console can't be played, in words for a person, or "" when nothing is known against it. A file that can't be read is a different problem, and whoever opens it next says so. Nothing here decrypts anything or tries to: it only reads what a file's headers say in the open (see threeds.go).
func RefusalForCore ¶ added in v0.3.5
RefusalForCore says why a file for this console can't be played by a specific core, in words for a person, or "" when nothing is known against it. When coreID is "", only console-wide refusals are checked.
func RunnerArgs ¶ added in v0.3.3
RunnerArgs are what a runner is told about the core it will load, before it loads it. A core nobody knows gets the same as a demanding one.
func SetCustomConsoles ¶ added in v0.3.3
func SetCustomConsoles(list []Console)
SetCustomConsoles replaces the custom consoles.
func ShortText ¶ added in v0.3.3
ShortText is a piece of an untrusted name, safe to say back in a message.
func StartOptions ¶ added in v0.3.3
StartOptions are the options to start a core with: what CoreOptions says for it, then what running on a graphics card takes. resolution is the setting: "" for the console's default, or "1" to "4". systemDir is where its BIOS files are.
func ValidLibraryConsole ¶
ValidLibraryConsole says whether a library may be set to this console.
Types ¶
type BIOS ¶
type BIOS struct {
File string `json:"file"`
For string `json:"for"`
Required bool `json:"required"`
}
BIOS is a file a core may want, named so people can supply their own. Nothing here ever downloads or links to one.
type BIOSRule ¶ added in v0.3.3
type BIOSRule struct {
Folder string // under the system folder
Example string // a file name to mention
For string // who it's from, for the message
Match *regexp.Regexp // file names, lower case
MinSize int64
MaxSize int64
// Option is the core option naming which BIOS to use, when it finds several.
Option string
}
BIOSRule says where a core looks for its BIOS and what one looks like, so the server can say exactly what is missing and find one left beside the games.
type Binding ¶
type Binding struct {
Button *int `json:"b,omitempty"`
Axis *int `json:"a,omitempty"`
Hat *int `json:"h,omitempty"`
// Dir: for an axis, 1 or -1. For a hat, 1 up, 2 right, 3 down, 4 left.
Dir int `json:"d,omitempty"`
// Rest: where a trigger reported as an axis sits when let go, -1 or 1. Its travel
// then counts from there rather than from the middle.
Rest int `json:"r,omitempty"`
}
Binding is what presses a RetroPad button on a gamepad: a button, one direction of an axis, or one direction of a hat (a D-pad reported as a single axis). Numbers are those of the W3C standard gamepad, which native clients translate to and from their platform's names (docs/GAMING-API.md).
type Cheat ¶ added in v0.3.3
type Cheat struct {
Label string `json:"label"`
Code string `json:"code"`
Enabled bool `json:"enabled"`
}
Cheat is one saved cheat code.
func CleanCheats ¶ added in v0.3.3
CleanCheats checks a list of cheats. It's all or nothing, with the first problem named.
func ParseCheatFile ¶ added in v0.3.3
ParseCheatFile reads a cheat list in the widely used "cheat0_desc = ..." text format. Only descriptions, codes and whether each is on are read. Anything else in the file, and any entry that isn't sound, is left out, and the count says how many.
type Console ¶
type Console struct {
ID string `json:"id"`
Name string `json:"name"`
Short string `json:"short"`
// Extensions only this console uses; a file with one can be sorted by
// extension alone.
Extensions []string `json:"extensions"`
// they need a console library or a folder name to be sure.
Shared []string `json:"shared,omitempty"`
// Aliases are folder names that mean this console, written without spaces or
// punctuation (see normalise).
Aliases []string `json:"-"`
Cores []Core `json:"cores"`
BIOS []BIOS `json:"bios,omitempty"`
// not played yet.
Unavailable string `json:"unavailable,omitempty"`
// Hidden consoles are for testing and never shown to people.
Hidden bool `json:"-"`
// PadLike, on a custom console, is a console whose controller to copy.
PadLike string `json:"padLike,omitempty"`
}
Console is one console a library can hold.
func All ¶ added in v0.3.3
func All() []Console
All is every console, the table's first. Don't change what it returns.
func CustomConsoles ¶ added in v0.3.3
func CustomConsoles() []Console
CustomConsoles is the custom consoles now in use.
type Control ¶
type Control struct {
Key string `json:"key"`
ID int `json:"id"` // the RetroPad button; -1 for the D-pad as a whole, -2 for the stick
Label string `json:"label"`
Kind string `json:"kind"` // dpad | stick | face | shoulder | meta
// Stick: on screen, this D-pad is an analog stick, and drives the left stick.
Stick bool `json:"stick,omitempty"`
}
Control is something on a controller. Key is what layouts are stored under.
type ControllerData ¶ added in v0.3.3
type ControllerData struct {
Layouts map[string]RawLayout `json:"layouts"`
Pads []KnownPad `json:"pads"`
}
ControllerData is everything a browser needs to read pads it can't assume anything about.
func KnownControllers ¶ added in v0.3.3
func KnownControllers() ControllerData
KnownControllers returns the table. It's small, and only sent when a client asks.
type Core ¶
type Core struct {
ID string `json:"id"` // the file name without _libretro and its extension
Name string `json:"name"`
License string `json:"license"`
}
Core is a libretro core we can point at. Licences are from the core-info files libretro publishes under the MIT licence. Non-commercial cores are never in this table, so they are never offered for download.
func CoreLicense ¶
CoreLicense looks up a core we know about, for showing beside one an administrator placed in the folder themselves.
type CoreTraits ¶ added in v0.3.3
type CoreTraits struct {
// GPU cores draw with a graphics card. They count against the GPU limit and
// their runner gets what a graphics driver needs. docs/GAMING.md has the list.
GPU bool
// Demanding cores can't play at low priority on a machine doing anything else.
// Everything drawn on a graphics card is, as well as these.
Demanding bool
// Assets is the name of the core's support files on the build server, for
// cores that won't run without them. They go in the system folder.
Assets string
// RequiredBIOS is set when the core can't start without a BIOS file.
RequiredBIOS *BIOSRule
// SavesIn is a folder under the system folder where the core keeps saves, such as
// memory cards. A running core can't write to the system folder, which everyone
// shares, so this core gets a system folder of its own in the player's save folder.
SavesIn string
// core that maps its recompiled code twice can't.
SharedMemory bool
// LargeAddressSpace is set when the core reserves far more address space than a game
// normally gets: reservations, not memory, which stays limited as for any other game.
LargeAddressSpace bool
// OwnHome is set when the core won't start without a home folder it can write to. It gets
// its save folder as one, which is where what it keeps there belongs.
OwnHome bool
// CacheIn is a folder under the system folder where the core keeps what it has worked out,
// such as compiled shaders, kept between games for a core with a system folder of its own.
CacheIn string
// Options are always passed. Each one makes the core use what this runner has.
Options map[string]string
// Threaded are options for a machine with threads to spare, of four or more.
Threaded map[string]string
// Resolution gives the options for an internal resolution, 1 to 4 times native.
Resolution func(times int) map[string]string
}
CoreTraits describes one core.
func Traits ¶ added in v0.3.3
func Traits(id string) CoreTraits
Traits says how to run a core. A core we don't know gets GPU room, as it may draw with a graphics card and nothing says otherwise.
type CustomConsole ¶ added in v0.3.3
type CustomConsole struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Short string `json:"short"`
Extensions []string `json:"extensions"`
Aliases []string `json:"aliases,omitempty"`
BIOS []BIOS `json:"bios,omitempty"`
PadLike string `json:"padLike,omitempty"` // a console whose controller to copy; a whole RetroPad if empty
Cores []string `json:"cores,omitempty"`
}
CustomConsole is one as a person or a JSON file describes it. Cores names cores from this server's own list to offer for it, besides custom cores assigned to it.
func CustomConsoleInput ¶ added in v0.3.3
func CustomConsoleInput(c *Console, cores []string) CustomConsole
CustomConsoleInput turns a console back into what describes it, to edit or export.
func ParseCustomConsole ¶ added in v0.3.3
func ParseCustomConsole(raw []byte) (*CustomConsole, error)
ParseCustomConsole reads one console from JSON. Unknown fields are mistakes worth saying so about, rather than something quietly dropped.
func (*CustomConsole) Validate ¶ added in v0.3.3
func (in *CustomConsole) Validate(id string, existing []Console) (*Console, error)
Validate checks a custom console against everything else and returns it ready to use. id is the console being edited, or "" for a new one. existing is the other custom consoles.
type CustomControl ¶ added in v0.3.3
type CustomControl struct {
Label string `json:"label"`
Help string `json:"help,omitempty"`
Type string `json:"type"` // toggle | choice | slider
Option string `json:"option"`
On string `json:"on,omitempty"` // toggle
Off string `json:"off,omitempty"` // toggle
Choices []Choice `json:"choices,omitempty"`
}
CustomControl is a control a person defined for a core option: the label they want and how it behaves. It sets one core option and can do nothing else.
type CustomInput ¶ added in v0.3.3
type CustomInput struct {
Offered []OptionInfo
}
CustomInput is what checking a file knows about the game it's for: the options its core offers. Nil means it isn't known, and those checks wait until a game runs.
type CustomReport ¶ added in v0.3.3
CustomReport is what came of reading a settings file. Errors stop it being saved. Ignored things are harmless, and are shown so that nothing vanishes silently.
func (*CustomReport) OK ¶ added in v0.3.3
func (r *CustomReport) OK() bool
OK says the file can be saved.
type Issue ¶ added in v0.3.3
type Issue struct {
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
Path string `json:"path,omitempty"`
Message string `json:"message"`
}
Issue is something about a settings file, with where it is when that's known.
func CheckOptions ¶ added in v0.3.3
func CheckOptions(core map[string]string, offered []OptionInfo) []Issue
CheckOptions goes through core options against what a core really offers: an unknown option or an unlisted value is reported, not silently dropped. The runner would ignore them anyway. This is for telling people.
type KnownPad ¶ added in v0.3.3
type KnownPad struct {
ID string `json:"id"` // vendor:product, four lowercase hexadecimal digits each
Name string `json:"name"`
Style string `json:"style"`
Layout string `json:"layout,omitempty"`
LinuxLayout string `json:"linuxLayout,omitempty"`
}
KnownPad is a model. Layout applies to a browser that doesn't put it in standard order; LinuxLayout, when set, replaces it on Linux, where the kernel's driver chooses the order. Style says what its face buttons are called: xbox, playstation, nintendo or generic. It only changes words on the screen, as buttons are mapped by where they are.
type Layer ¶ added in v0.3.3
type Layer struct {
Values map[string]any `json:"settings,omitempty"`
CoreOptions map[string]string `json:"coreOptions,omitempty"`
Controls []CustomControl `json:"controls,omitempty"`
Presets []Preset `json:"presets,omitempty"`
}
Layer is the settings held at one level. Everything in it has been checked.
func (*Layer) Document ¶ added in v0.3.3
Document turns a layer back into the text of a settings file.
type Limits ¶ added in v0.3.3
type Limits struct {
MaxSpeed float64 `json:"maxSpeed"` // fast-forward, times normal speed
RewindBytes int64 `json:"rewindBytes"` // memory rewind may hold in a game; 0 means it's off here
RunAhead bool `json:"runAhead"` // whether run-ahead may be used
}
Limits are what a server allows, whatever anyone's settings say. They exist so that one person's fast-forward or rewind can't starve a small server.
type NamedLayer ¶ added in v0.3.3
NamedLayer is a layer with the level it came from.
type OptionInfo ¶ added in v0.3.3
type OptionInfo struct {
Key string `json:"key"`
Label string `json:"label"`
Info string `json:"info,omitempty"`
Category string `json:"category,omitempty"`
Choices []string `json:"choices"`
Labels []string `json:"labels,omitempty"` // the name of each choice
Default string `json:"default"`
Hidden bool `json:"hidden,omitempty"` // the core says it doesn't apply just now
}
OptionInfo is one option a core offers, as told to clients. It's what a runner said, so it's cut to size before anyone stores or shows it.
type PadLayout ¶
type PadLayout struct {
Face []PadButton `json:"face"` // main buttons, left to right
Shoulder []PadButton `json:"shoulder,omitempty"`
Meta []PadButton `json:"meta"` // Select, Start and their relatives
Sticks bool `json:"sticks,omitempty"`
Pointer bool `json:"pointer,omitempty"` // has a touch screen: clients send pointer states
// Extra buttons a gamepad can reach but an on-screen controller leaves out, such
// as stick clicks.
Extra []PadButton `json:"extra,omitempty"`
// Right is what the right stick's four directions mean, when it has them.
Right []PadButton `json:"right,omitempty"`
// Art is the shape of picture to draw: one, two, four, six, handle or dual.
Art string `json:"art"`
// StickFirst: the stick, not the D-pad, is how this console's games steer, so an
// on-screen D-pad and the arrow keys drive the stick.
StickFirst bool `json:"stickFirst,omitempty"`
// PreferDevices names the libretro device type to plug in, by words in its name,
// best first. A core that offers none of them gets its plain pad.
PreferDevices []string `json:"-"`
}
PadLayout says what a console's controller has.
type Placement ¶
type Placement struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Size float64 `json:"size"`
Opacity float64 `json:"opacity"`
Hidden bool `json:"hidden,omitempty"`
}
Placement is where a touch control sits. Positions are fractions of the play area; size is a fraction of its shorter side, so a button stays thumb-sized on any screen.
type Preset ¶ added in v0.3.3
type Preset struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Values map[string]any `json:"settings,omitempty"`
CoreOptions map[string]string `json:"coreOptions,omitempty"`
}
Preset is a named set of values a person can apply in one go.
type Profile ¶ added in v0.3.3
type Profile struct {
ID int64 `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Controller string `json:"controller"` // "054c:0ce6", "id:<model name>", "keyboard", or "" for any
// ControllerName is for showing, as the browser described the model.
ControllerName string `json:"controllerName,omitempty"`
Console string `json:"console,omitempty"`
Game int64 `json:"game,omitempty"`
GameTitle string `json:"gameTitle,omitempty"` // filled in by the server
// Raw: the numbers in Map are what this model reports in this browser, because it
// isn't a pad whose buttons we can put in standard order. Such a profile applies only
// to a pad in the same state. Everything else uses W3C standard numbers.
Raw bool `json:"raw,omitempty"`
// Active: of the profiles with the same scope, the one in use.
Active bool `json:"active"`
Map map[int]*Binding `json:"map,omitempty"` // what it changes; null means nothing presses it
Keys map[int]string `json:"keys,omitempty"` // keyboard: KeyboardEvent.code names
Options ProfileOptions `json:"options"`
UpdatedAt int64 `json:"updatedAt"`
}
Profile is one mapping. Its scope is Controller, Console and Game: each may be left empty to mean any.
func CleanProfile ¶ added in v0.3.3
CleanProfile checks a profile from outside and returns the one form the server keeps: fields nobody knows are gone. consoleOK says which consoles exist for this account.
func ParseProfileFile ¶ added in v0.3.3
ParseProfileFile reads a file someone wants to import, entirely untrusted: limited in size and count, and with every profile still to go through CleanProfile.
func ResolveProfile ¶ added in v0.3.3
func ResolveProfile(list []Profile, kind, controller, console string, game int64, raw bool) *Profile
ResolveProfile picks the profile for a controller on a console and game. The most specific wins, and a game outranks a console, which outranks a controller:
- this game and this controller
- this game, any controller
- this console and this controller
- this console, any controller
- this controller, on anything
- any controller, on anything
With none of these the console's defaults apply. raw says the pad is one whose numbers can't be put in standard order: only a profile of its own numbers can apply.
type ProfileFile ¶ added in v0.3.3
type ProfileFile struct {
Format string `json:"format"`
Version int `json:"version"`
Profiles []Profile `json:"profiles"`
}
ProfileFile is an exported file.
type ProfileOptions ¶ added in v0.3.3
type ProfileOptions struct {
Deadzone float64 `json:"deadzone,omitempty"` // up to 0.6: how far a stick moves before it counts
Threshold float64 `json:"threshold,omitempty"` // 0.1 to 0.9: how far an axis moves to press a button
StickDpad *bool `json:"stickDpad,omitempty"` // the left stick also steers the D-pad
Turbo []int `json:"turbo,omitempty"` // buttons that repeat while held
TurboHz int `json:"turboHz,omitempty"` // 2 to 30 presses a second
NoRumble bool `json:"noRumble,omitempty"`
// Calibration is, per axis, where it reads at its lowest, at rest and at its highest.
Calibration map[int][3]float64 `json:"calibration,omitempty"`
}
ProfileOptions is how a controller behaves, apart from which button is which. Zero values mean the console's default.
func DefaultOptions ¶ added in v0.3.3
func DefaultOptions(consoleID string) ProfileOptions
DefaultOptions is how a console's controller behaves until someone changes it. A console with no stick lets the left stick steer its D-pad.
func EffectiveOptions ¶ added in v0.3.3
func EffectiveOptions(consoleID string, p *Profile) ProfileOptions
EffectiveOptions is how a controller behaves under a profile. p may be nil.
type RawLayout ¶ added in v0.3.3
RawLayout puts a pad in standard order. Buttons is indexed by W3C standard number and says where each is really found; null means the pad has none. Axes are the left stick's X and Y and the right stick's X and Y, -1 for none. With no D-pad buttons listed (12 to 15), the D-pad is found by looking: a hat in the last axis, or else the last two axes.
type Resolved ¶ added in v0.3.3
type Resolved struct {
Values map[string]any `json:"values"`
Sources map[string]string `json:"sources"`
CoreOptions map[string]string `json:"coreOptions"`
CoreSources map[string]string `json:"coreSources"`
Controls []CustomControl `json:"controls"`
Presets []Preset `json:"presets"`
}
Resolved is every setting's effective value and where it came from.
func Resolve ¶ added in v0.3.3
func Resolve(layers []NamedLayer) Resolved
Resolve works out the effective settings, with later layers winning. Values are checked again here: what's stored may be older than the settings it was checked against, and a stale value must never reach a game.
type Setting ¶ added in v0.3.3
type Setting struct {
Key string `json:"key"`
Group string `json:"group"`
Section string `json:"section,omitempty"` // a heading within the group
Label string `json:"label"`
Help string `json:"help,omitempty"`
Caution string `json:"caution,omitempty"` // something to know first, such as flashing
Kind string `json:"kind"`
Default any `json:"default"`
Min float64 `json:"min,omitempty"`
Max float64 `json:"max,omitempty"`
Step float64 `json:"step,omitempty"`
Unit string `json:"unit,omitempty"`
Choices []Choice `json:"choices,omitempty"`
// Shader settings need the drawing path that costs a little; the rest don't.
Shader bool `json:"shader,omitempty"`
// Motion: this setting animates, so it stays off for people who ask for less motion.
Motion bool `json:"motion,omitempty"`
}
Setting describes one setting.
func SettingFor ¶ added in v0.3.3
SettingFor finds a setting's description.
type Target ¶ added in v0.3.3
type Target struct {
ID int `json:"id"`
Label string `json:"label"`
Group string `json:"group"` // dpad | face | shoulder | meta | stick
}
Target is one thing a controller can be mapped to on a console: a button, or one direction of a stick.
type ThreeDSFile ¶ added in v0.3.3
type ThreeDSFile struct {
Encrypted bool
// Program is where the game's main program is, for a package that wraps it. A
// core can't open a package, but it can open that program as a file of its own.
Program int64
ProgramLen int64
Package bool
// NewOnly: this game only runs on a New 3DS, so a core has to be told to be one.
NewOnly bool
}
ThreeDSFile is what a 3DS file's headers say.
func Inspect3DS ¶ added in v0.3.3
func Inspect3DS(path string) (ThreeDSFile, error)
Inspect3DS reads a 3DS file's headers. Files it has nothing to say about, such as homebrew programs, are simply not encrypted as far as it knows.
func (ThreeDSFile) CopyProgram ¶ added in v0.3.3
func (t ThreeDSFile) CopyProgram(from, to string) error
CopyProgram writes the program out of an unencrypted package to a file of its own. It's a plain copy of bytes that are already readable.
type TouchLayout ¶
TouchLayout is a whole on-screen controller, by Control.Key.
func DefaultTouch ¶
func DefaultTouch(consoleID, orientation string) TouchLayout
DefaultTouch is a console's on-screen controller as it starts out.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
wittyplay-check
command
Command wittyplay-check plays real games headlessly and says what happened.
|
Command wittyplay-check plays real games headlessly and says what happened. |
|
wittyplay-game-runner
command
Command wittyplay-game-runner runs one game for WittyMediaServer: it loads a libretro core, or the built-in test core, and speaks the ipc protocol on stdin and stdout.
|
Command wittyplay-game-runner runs one game for WittyMediaServer: it loads a libretro core, or the built-in test core, and speaks the ipc protocol on stdin and stdout. |
|
wittyplay-module
command
Command wittyplay-module is WittyPlay's service: the only way a server reaches it.
|
Command wittyplay-module is WittyPlay's service: the only way a server reaches it. |
|
wittyplay-probe
command
Command wittyplay-probe measures and inspects game streaming.
|
Command wittyplay-probe measures and inspects game streaming. |
|
Package cores finds libretro cores on this machine and installs them on an administrator's request.
|
Package cores finds libretro cores on this machine and installs them on an administrator's request. |
|
Package engine is what the host needs from something that runs a game: a libretro core in production, a small built-in core in tests.
|
Package engine is what the host needs from something that runs a game: a libretro core in production, a small built-in core in tests. |
|
Package host is the program that runs one game: it reads commands on one stream, writes frames on another and paces the engine at its own frame rate.
|
Package host is the program that runs one game: it reads commands on one stream, writes frames on another and paces the engine at its own frame rate. |
|
Package hostsandbox is what the host does to itself before it loads a core.
|
Package hostsandbox is what the host does to itself before it loads a core. |
|
Package ipc is the protocol between the server and a game runner process: length-prefixed messages over the runner's stdin and stdout.
|
Package ipc is the protocol between the server and a game runner process: length-prefixed messages over the runner's stdin and stdout. |
|
Package libretro is a small libretro frontend: it loads a core (a shared library the user installed), runs it one frame at a time and hands back raw video and audio.
|
Package libretro is a small libretro frontend: it loads a core (a shared library the user installed), runs it one frame at a time and hands back raw video and audio. |
|
Package patch applies a person's own IPS and BPS patch files to a copy of a game.
|
Package patch applies a person's own IPS and BPS patch files to a copy of a game. |
|
Package rpc answers a server's calls to WittyPlay's service: gen.go is generated, by kit/facade in WittyModule, and this is what can't be.
|
Package rpc answers a server's calls to WittyPlay's service: gen.go is generated, by kit/facade in WittyModule, and this is what can't be. |
|
Package stream runs game sessions on the server: it starts a runner process, reads its raw frames, encodes them with FFmpeg and sends them to viewers over WebRTC or a WebSocket.
|
Package stream runs game sessions on the server: it starts a runner process, reads its raw frames, encodes them with FFmpeg and sends them to viewers over WebRTC or a WebSocket. |
|
Package testcore is a tiny game written in Go: a square you move around a coloured field, a tone while a button is held, and a counter kept in save memory.
|
Package testcore is a tiny game written in Go: a square you move around a coloured field, a tone while a button is held, and a counter kept in save memory. |
|
fakecore
Package fakecore builds real shared libraries for tests of what happens when a core is added: one that works, and several that misbehave in the ways a hostile or broken file can.
|
Package fakecore builds real shared libraries for tests of what happens when a core is added: one that works, and several that misbehave in the ways a hostile or broken file can. |
|
fakecore/cmd/fakecore
command
Command fakecore writes one of the test cores to a folder, for trying the custom core pages by hand without any third-party code:
|
Command fakecore writes one of the test cores to a folder, for trying the custom core pages by hand without any third-party code: |






