v0.1.4 Latest Latest

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

Go to latest
Published: Apr 17, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0



Package protocol provides ways to playback movement.



This section is empty.


View Source
var ErrTimeout = errors.New("operation timed out")

ErrTimeout is the error returned when a requested operation could not be performed in time.


This section is empty.


type Action

type Action struct {
	Position int `json:"pos"`
	Speed    int `json:"spd"`

Action is a command that can be send to a device.

type Dumpable added in v0.0.4

type Dumpable interface {
	// Dump the full script as TimedActions.
	Dump() (TimedActions, error)

Dumpable is a interface thtat wraps the dump method.

type LatencyCalibrator

type LatencyCalibrator interface {
	Latency(t time.Duration)

LatencyCalibrator wraps the Latency method.

type Loader

type Loader interface {
	// Load a script from the provided reader.
	Load(r io.Reader) (p Player, err error)

Loader is the interface that wraps the Load method.

type LoaderFunc

type LoaderFunc func(io.Reader) (Player, error)

LoaderFunc type is an adapter to allow the use of ordinary functions as script loader.

func (LoaderFunc) Load

func (f LoaderFunc) Load(r io.Reader) (Player, error)

Load calls f(r)

type Mover

type Mover interface {
	Move(position, speed int)

Mover interface provides a device that can move to a position in percent with a specific speed.

type Pausable

type Pausable interface {
	// Pause playback.
	Pause() error
	// Resume playback from the current position.
	Resume() error

Pausable is a interface that defines the pause and resume actions.

type Player

type Player interface {
	// Start playback of the loaded script the reader channel should be
	// attached to a device.
	Play() <-chan Action

	// Stop stops playback and resets the player.
	Stop() error

Player is an interface that has the basic functions to play a script.

type PositionLimiter

type PositionLimiter interface {
	LimitPosition(lowest, highest int)

PositionLimiter wraps the limitposition method.

type Skippable

type Skippable interface {
	// Skip (jump) to the specified position/timecode.
	Skip(position time.Duration) error

Skippable is a interface that wraps the skip method.

type SpeedLimiter

type SpeedLimiter interface {
	LimitSpeed(slowest, fastest int)

SpeedLimiter wraps the limitposition method.

type TimedAction

type TimedAction struct {
	Time time.Duration

TimedAction wraps Action together with a timestamp.

func (TimedAction) MarshalJSON added in v0.0.4

func (ta TimedAction) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*TimedAction) UnmarshalJSON added in v0.0.4

func (ta *TimedAction) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type TimedActions added in v0.0.4

type TimedActions []TimedAction

TimedActions is an ordered list of TimeAction items.

type TimedActionsPlayer

type TimedActionsPlayer struct {
	// Script that the player will use.
	Script []TimedAction
	// contains filtered or unexported fields

TimedActionsPlayer can playback an array of TimeActions. It can be used by protocols that can pre-calculate TimeActions.

All of the SkippableScriptPlayer methods are implemented except for ScriptLoader. Protocols only need to implement ScriptLoader themselves and set the Script field with their result.

func NewTimedActionsPlayer

func NewTimedActionsPlayer() *TimedActionsPlayer

NewTimedActionsPlayer returns a new TimedActionsPlayer.

func (*TimedActionsPlayer) Dump added in v0.0.4

func (ta *TimedActionsPlayer) Dump() (TimedActions, error)

Dump will return the loaded script as TimedActions.

func (*TimedActionsPlayer) Latency

func (ta *TimedActionsPlayer) Latency(t time.Duration)

Latency implements the LatencyCalibrator interface to calibrate the latency.

func (*TimedActionsPlayer) LimitPosition

func (ta *TimedActionsPlayer) LimitPosition(low, high int)

LimitPosition implements the PositionLimiter interface. low is the lowest position in percent to move to. high is the highst position in percent to move to.

func (*TimedActionsPlayer) LimitSpeed

func (ta *TimedActionsPlayer) LimitSpeed(slow, fast int)

LimitSpeed implements the SpeedLimiter interface. slow is the slowest speed in percent to move with. fast is the highst speed in percent to move with.

func (*TimedActionsPlayer) Pause

func (ta *TimedActionsPlayer) Pause() error

Pause will halt playback at the current position.

func (*TimedActionsPlayer) Play

func (ta *TimedActionsPlayer) Play() <-chan Action

Play will start executing the loaded script from the start.

func (*TimedActionsPlayer) Resume

func (ta *TimedActionsPlayer) Resume() error

Resume will continue playback from the paused location.

func (*TimedActionsPlayer) Skip

func (ta *TimedActionsPlayer) Skip(p time.Duration) error

Skip will jump to a specific position.

func (*TimedActionsPlayer) Stop

func (ta *TimedActionsPlayer) Stop() error

Stop stops playback and resets player.


Path Synopsis
Package funscript manages the Funscript format.
Package funscript manages the Funscript format.
Package kiiroo manages the Kiiroo haptics protocol.
Package kiiroo manages the Kiiroo haptics protocol.
Package raw manages the raw launch protocol.
Package raw manages the raw launch protocol.

Jump to

Keyboard shortcuts

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