controllers

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Zero2 = Vector2{}

Functions

func ApplyDeadZone

func ApplyDeadZone(v float64, deadZone float64) float64

func IsDeadZone

func IsDeadZone(axes Vector2) bool

Types

type Analog

type Analog struct {
	Direction       Vector2
	Hold            bool
	Hold_PRESS      bool
	Bumper          bool
	Bumper_PRESS    bool
	Bumper_UNPRESS  bool
	Trigger         float64
	Trigger_PRESS   bool
	Trigger_UNPRESS bool
}

type DPad

type DPad struct {
	Up    bool
	Down  bool
	Left  bool
	Right bool

	Up_PRESS    bool
	Down_PRESS  bool
	Left_PRESS  bool
	Right_PRESS bool
}

func (DPad) Direction

func (dpad DPad) Direction() (r Vector2)

type Gamepad

type Gamepad struct {
	Id       glfw.Joystick
	DeadZone float64
}

type Input

type Input struct {
	DPad                                       DPad
	Start, Back                                bool
	Start_PRESS, Back_PRESS                    bool
	Start_UNPRESS, Back_UNPRESS                bool
	A, B, X, Y                                 bool
	A_PRESS, B_PRESS, X_PRESS, Y_PRESS         bool
	A_UNPRESS, B_UNPRESS, X_UNPRESS, Y_UNPRESS bool

	Left  Analog
	Right Analog
}

func Read

func Read(gamepad Gamepad, lastInput Input) (Input, error)

type Vector2

type Vector2 struct{ X, Y float64 }

func (Vector2) Add

func (a Vector2) Add(b Vector2) Vector2

Add adds two vectors and returns the result

func (Vector2) AddScale

func (a Vector2) AddScale(b Vector2, s float64) Vector2

func (Vector2) Angle

func (a Vector2) Angle() float64

func (Vector2) Cross

func (a Vector2) Cross(b Vector2) float64

Cross product of a and b

func (Vector2) Distance

func (a Vector2) Distance(b Vector2) float64

Distance returns the distance to vector b

func (Vector2) Distance2

func (a Vector2) Distance2(b Vector2) float64

Distance2 returns the squared distance to vector b

func (Vector2) Dot

func (a Vector2) Dot(b Vector2) float64

Dot calculates the dot product

func (Vector2) Length

func (a Vector2) Length() float64

Length returns the length of the vector

func (Vector2) Length2

func (a Vector2) Length2() float64

Length2 returns the squared length of the vector

func (Vector2) NearZero

func (a Vector2) NearZero() bool

func (Vector2) Negate

func (a Vector2) Negate() Vector2

func (Vector2) Normalize

func (a Vector2) Normalize() Vector2

func (Vector2) Rotate

func (a Vector2) Rotate(angle float64) Vector2

func (Vector2) Rotate180

func (a Vector2) Rotate180() Vector2

func (Vector2) Rotate90

func (a Vector2) Rotate90() Vector2

func (Vector2) Rotate90c

func (a Vector2) Rotate90c() Vector2

func (Vector2) Scale

func (a Vector2) Scale(s float64) Vector2

Scale scales each component and returns the result

func (Vector2) Sub

func (a Vector2) Sub(b Vector2) Vector2

Sub subtracts two vectors and returns the result

func (Vector2) XY

func (a Vector2) XY() (x, y float64)

XY returns both components

Jump to

Keyboard shortcuts

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