gamehandoff

package
v2.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gamehandoff tells when a launched game has been handed to the emulator or core that runs it. The process that loads a game opens its file, reads it and usually closes it, and Core can watch those events without any cooperation from the emulator: MiSTer's Main streams the game into the FPGA core, and RetroArch under Batocera reads it as it starts the content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wait

func Wait(ctx context.Context, clock clockwork.Clock, events <-chan Kind, opts Options) error

Wait returns once events show the game handed over and Settle has passed with no further activity on it. It returns nil without a handover when the game is never opened within OpenWindow, and ctx's error if the wait is cancelled first.

func Watch

func Watch(ctx context.Context, path string) (<-chan Kind, error)

Watch reports opens, reads and closes of the file at path until ctx ends, then closes the returned channel. A full channel drops no events: the watcher blocks, and the kernel queues events meanwhile.

Types

type Kind

type Kind int

Kind is what happened to the watched file.

const (
	// Open means a process opened the file.
	Open Kind = iota
	// Close means a process closed an open of the file.
	Close
	// Access means a process read from the file.
	Access
)

type LaunchLog

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

LaunchLog remembers the last game Core launched. A probe waits only for a game launched by Core: one already running when a tracker noticed it was opened before anything could watch, so waiting on it would stall until the open window ends.

func NewLaunchLog

func NewLaunchLog(clock clockwork.Clock) *LaunchLog

NewLaunchLog returns an empty log.

func (*LaunchLog) Forget added in v2.22.0

func (l *LaunchLog) Forget(path string)

Forget drops the launch of path, for a launch that failed. A later launch that has since replaced it is kept.

func (*LaunchLog) Note

func (l *LaunchLog) Note(path string)

Note records that Core is launching path.

func (*LaunchLog) Recent

func (l *LaunchLog) Recent(path string, within time.Duration) bool

Recent reports whether path is the game Core launched within the last within.

func (*LaunchLog) Since

func (l *LaunchLog) Since(path string, within time.Duration) (time.Time, bool)

Since returns when path was launched, if it is the game Core launched within the last within.

type Options

type Options struct {
	OpenWindowStart <-chan struct{}
	Settle          time.Duration
	OpenWindow      time.Duration
	IdleHandover    time.Duration
	UntilClose      bool
}

Options say what counts as the game being handed over.

Jump to

Keyboard shortcuts

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