Documentation ¶
Overview ¶
Package input processes button presses from a gamepad or keyboard.
Index ¶
- func PackButtons(buttons ...Button) uint64
- type Button
- type Context
- func (c *Context) Consume(btn Button) bool
- func (c *Context) ConsumeAllowRepeat(btn Button, defaultDelay, minDelay uint64) bool
- func (c *Context) ConsumeClick()
- func (c *Context) ConsumeKey() (key.Event, bool)
- func (c *Context) Held(btn Button) bool
- func (c *Context) IsMouseDrag(dist float32) bool
- func (c *Context) LastMouse() (x, y float32, click bool)
- func (c *Context) LoadState(s State)
- func (c *Context) Mouse() (x, y float32, click bool)
- func (c *Context) OnKey(e key.Event)
- func (c *Context) OnMouse(e mouse.Event)
- func (c *Context) OnSize(e size.Event)
- func (c *Context) OnTouch(e touch.Event)
- func (c *Context) SaveState() State
- func (c *Context) Tick()
- func (c *Context) Wheel() float32
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackButtons ¶ added in v0.2.81
PackButtons combines the specified buttons into a bitmask. Order is not preserved, and any repeated buttons are only stored once.
Types ¶
type Button ¶ added in v0.2.81
type Button uint8
Button represents a gamepad button.
const ( BtnUp Button = 0 BtnDown Button = 1 BtnLeft Button = 2 BtnRight Button = 3 BtnConfirm Button = 4 BtnCancel Button = 5 BtnSwitch Button = 6 BtnToggle Button = 7 BtnPause Button = 8 BtnHelp Button = 9 NumButtons = 10 )
Constants for Button.
func UnpackButtons ¶ added in v0.2.81
UnpackButtons extracts the buttons from a given bitmask.
type Context ¶
type Context struct { // OnMouseImmediate is called when a mouse event occurs, which may be // helpful for APIs that require being called from an event. OnMouseImmediate func() // contains filtered or unexported fields }
Context is an input context.
func GetContext ¶
GetContext returns the Context created using NewContext.
It panics if no context was created.
func NewContext ¶
NewContext creates a new input context.
func (*Context) Consume ¶
Consume returns true if a button is pressed, and consumes the button press indefinitely.
func (*Context) ConsumeAllowRepeat ¶
ConsumeAllowRepeat returns true if a button is pressed, and consumes the button press for a number of ticks.
func (*Context) ConsumeClick ¶ added in v0.2.81
func (c *Context) ConsumeClick()
ConsumeClick sets the mouse drag distance to infinity.
This API may change in the future.
func (*Context) ConsumeKey ¶ added in v0.2.81
ConsumeKey takes a key event from the queue.
This API may change in the future.
func (*Context) IsMouseDrag ¶ added in v0.2.81
IsMouseDrag returns true if the mouse has been dragged at least this many pixels.
This API may change in the future.
func (*Context) LastMouse ¶ added in v0.2.81
LastMouse returns the mouse state for the previous tick.
This API may change in the future.
func (*Context) Mouse ¶ added in v0.2.75
Mouse returns the mouse position and pressed state.
This API may change in the future.