input

package
v0.0.0-...-c243d71 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ButtonA ControllerButton = iota
	ButtonB
	ButtonX
	ButtonY
	ButtonBack
	ButtonGuide
	ButtonStart
	ButtonLeftStick
	ButtonRightStick
	ButtonLeftShoulder
	ButtonRightShoulder
	ButtonDirPadUp
	ButtonDirPadDown
	ButtonDirPadLeft
	ButtonDirPadRight
	AxisLeftX ControllerAxis = iota
	AxisLeftY
	AxisRightX
	AxisRightY
	AxisTriggerLeft
	AxisTriggerRight

	// MaxNumJoysticks max num of joysticks allowed by glfw
	MaxNumJoysticks = glfw.JoystickLast
)

Constants for all the buttons and axes

Variables

View Source
var (
	JoystickControllers map[int]*JoystickController
)

Functions

func ConnectMouse

func ConnectMouse()

ConnectMouse Registers the callbacks and starts receiving the mouse's events

func DisconnectMouse

func DisconnectMouse()

DisconnectMouse Unregisters the callbacks and stops receiving the mouse's events

func IsKeyboardFree

func IsKeyboardFree() bool

func MouseButton

func MouseButton(index int) bool

MouseButton Returns the state of the specified mouse button

func MouseDelta

func MouseDelta() (float64, float64)

MouseDelta Returns the latest movement of the cursor

func MousePosition

func MousePosition() (float64, float64)

MousePosition Returns the coordinates of the cursor's position

func MouseScroll

func MouseScroll() (float64, float64)

MouseScroll Returns the last wheel's scroll offsets

func RegisterKeyCallback

func RegisterKeyCallback(callback glfw.KeyCallback)

func UnregisterKeyCallback

func UnregisterKeyCallback()

func UpdateCameraWithMouse

func UpdateCameraWithMouse(camera *graphics.Camera2D)

Types

type ControllerAxis

type ControllerAxis int

ControllerAxis type representing an axis of the input device

type ControllerButton

type ControllerButton int

ControllerButton type representing a button of the input device

type GameController

type GameController interface {
	Connected() bool
	Open(deviceIndex int) bool
	Close()
	Update()
	NumButtons() int
	NumAxes() int
	ButtonPressed(button ControllerButton) bool
	ButtonReleased(button ControllerButton) bool
	ButtonDown(button ControllerButton) bool
	AxisValue(axis ControllerAxis) float64
	AxisDigitalValue(axis ControllerAxis) int
	SetMapping(mapping *GameControllerMapping)
	Description() string
}

GameController represents a physical input device

type GameControllerMapping

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

GameControllerMapping a axes/buttons mapping for a specific device

var (
	GameControllerMappings []*GameControllerMapping
	MappingXBox360         GameControllerMapping
	MappingPS4             GameControllerMapping
	MappingKeyboard        GameControllerMapping
)

A set of basic mappings

func (*GameControllerMapping) Set

func (g *GameControllerMapping) Set(nameRegEx string, buttons []int, axes []int)

type JoystickController

type JoystickController struct {
	GameController
	// contains filtered or unexported fields
}

func (*JoystickController) AxisDigitalValue

func (c *JoystickController) AxisDigitalValue(axis ControllerAxis) int

func (*JoystickController) AxisValue

func (c *JoystickController) AxisValue(axis ControllerAxis) float64

func (*JoystickController) ButtonDown

func (c *JoystickController) ButtonDown(button ControllerButton) bool

func (*JoystickController) ButtonPressed

func (c *JoystickController) ButtonPressed(button ControllerButton) bool

func (*JoystickController) ButtonReleased

func (c *JoystickController) ButtonReleased(button ControllerButton) bool

func (*JoystickController) Close

func (c *JoystickController) Close()

func (*JoystickController) Connected

func (c *JoystickController) Connected() bool

func (*JoystickController) Description

func (c *JoystickController) Description() string

func (*JoystickController) NumAxes

func (c *JoystickController) NumAxes() int

func (*JoystickController) NumButtons

func (c *JoystickController) NumButtons() int

func (*JoystickController) Open

func (c *JoystickController) Open(deviceIndex int) bool

func (*JoystickController) SetMapping

func (c *JoystickController) SetMapping(mapping *GameControllerMapping)

func (*JoystickController) Update

func (c *JoystickController) Update()

type KeyboardController

type KeyboardController struct {
	GameController
	// contains filtered or unexported fields
}

KeyboardController A GameController that uses the keyboard to simulate a joystick

func (*KeyboardController) AxisDigitalValue

func (c *KeyboardController) AxisDigitalValue(axis ControllerAxis) int

AxisDigitalValue returns a digital value for the axis

func (*KeyboardController) AxisValue

func (c *KeyboardController) AxisValue(axis ControllerAxis) float64

AxisValue returns the current value, from -1 to 1, of the axis

func (*KeyboardController) ButtonDown

func (c *KeyboardController) ButtonDown(button ControllerButton) bool

ButtonDown checks if a button is currently pressed

func (*KeyboardController) ButtonPressed

func (c *KeyboardController) ButtonPressed(button ControllerButton) bool

ButtonPressed checks if a button has been pressed since the last frame

func (*KeyboardController) ButtonReleased

func (c *KeyboardController) ButtonReleased(button ControllerButton) bool

ButtonReleased checks if a button has been released since the last frame

func (*KeyboardController) Close

func (c *KeyboardController) Close()

Close disables the keyboard callback and resets all the data

func (*KeyboardController) Connected

func (c *KeyboardController) Connected() bool

Connected returns if this controller is connected and initialized

func (*KeyboardController) Description

func (c *KeyboardController) Description() string

Description identification string of this controller

func (*KeyboardController) NumAxes

func (c *KeyboardController) NumAxes() int

NumAxes number of the axes this controller is simulating

func (*KeyboardController) NumButtons

func (c *KeyboardController) NumButtons() int

NumButtons number of the buttons this controller is simulating

func (*KeyboardController) Open

func (c *KeyboardController) Open(_ int) bool

Open initializes the keyboard. The parameter is ignored

func (*KeyboardController) SetMapping

func (c *KeyboardController) SetMapping(mapping *GameControllerMapping)

SetMapping maps the keys to the virtual controller inputs

func (*KeyboardController) Update

func (c *KeyboardController) Update()

Update gets the input from the keyboard and sets the game controller accordingly

Jump to

Keyboard shortcuts

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