device

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device provides access to a platform specific user input and display surface.

func New

func New(windowed bool, title string, x int32, y int32, w int32, h int32) *Device

New creates the platform for the current host.

func (*Device) CreateDisplay added in v0.20.0

func (d *Device) CreateDisplay() error

CreateDisplay initializes a window. Called once at initialization.

func (*Device) Dispose

func (d *Device) Dispose()

Dispose releases all platform specific resources.

func (*Device) GetInput added in v0.20.0

func (d *Device) GetInput() *Input

GetInput updates the user input. Expected to be called frequently, ie: once before each game update.

func (*Device) IsRunning added in v0.20.0

func (d *Device) IsRunning() bool

IsRunning returns true if the app is still running.

func (*Device) SetResizeHandler added in v0.20.0

func (d *Device) SetResizeHandler(callback func())

SetResizeHandler registers a callback to do stuff any time the window is resized.

func (*Device) SurfaceSize added in v0.20.0

func (d *Device) SurfaceSize() (w, h uint32)

Returns the size of the surface in pixels.

type Input added in v0.20.0

type Input struct {
	Mx, My int32 // Mouse location relative to top left.
	Scroll int   // Scroll amount: positive, negative, or Zero if no scrolling.
	Focus  bool  // True if window has focus.

	// Pressed are keys that were pressed since last request.
	Pressed map[int32]bool //

	// Down are keys that are currently being pressed.
	// This includes keys that were just pressed and which
	// are being held down. The value can be used to calculate
	// how long the key has been down.
	// Down keys are cleared when the key is
	// released or when the windows looses focus.
	Down map[int32]time.Time // time when key was pressed.

	// Released are keys that were just released since last request.
	// Keys are also released when the window loses focus.
	Released map[int32]time.Duration // total time down.
	// contains filtered or unexported fields
}

Input gathers user input and organizes it for mapping to game actions. Input data is shared with the app and the app should treat the data as read only.

Jump to

Keyboard shortcuts

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