input

package
v0.2.74 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package input processes button presses from a gamepad or keyboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context is an input context.

func GetContext

func GetContext(ctx context.Context) *Context

GetContext returns the Context created using NewContext.

It panics if no context was created.

func NewContext

func NewContext(ctx context.Context, fetch func() []arcade.Button) (context.Context, *Context)

NewContext creates a new input context.

func (*Context) Consume

func (c *Context) Consume(btn arcade.Button) bool

Consume returns true if a button is pressed, and consumes the button press indefinitely.

func (*Context) ConsumeAllowRepeat

func (c *Context) ConsumeAllowRepeat(btn arcade.Button, delayTicks uint64) bool

ConsumeAllowRepeat returns true if a button is pressed, and consumes the button press for delayTicks.

func (*Context) Held

func (c *Context) Held(btn arcade.Button) bool

Held returns true if a button is currently held.

func (*Context) LoadState

func (c *Context) LoadState(s State)

LoadState loads the input state from a snapshot.

func (*Context) SaveState

func (c *Context) SaveState() State

SaveState takes a snapshot of the input state.

func (*Context) Tick

func (c *Context) Tick()

Tick updates the input context.

type State

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

State is a snapshot of the input context state.

Jump to

Keyboard shortcuts

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