Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsJoystickPresent ¶
IsJoystickPresent returns true if the joystick is detected.
Types ¶
type JoystickAxisBinding ¶
type JoystickAxisBinding struct { // ID is the axis id to check for input ID int // Min is the minimum value on the axis to trigger the callback Min float32 // Max is the maximum value on the axis to trigger the callback Max float32 // NegativeMapping indicates whether or not the values from // the axis should be run through the Abs function before // getting passed to the callback. NegativeMapping bool // Callback is the function to call if the axis id has input // withing the [Min..Max] range. Delta will be scaled to match // the strength of input. Callback JoystickAxisCallback }
JoystickAxisBinding determines what values on an axis are mapped to what callback.
func NewJoystickAxisBinding ¶
func NewJoystickAxisBinding(id int, min, max float32, negativeMapping bool, cb JoystickAxisCallback) (jb JoystickAxisBinding)
NewJoystickAxisBinding creates a new joystick binding with the given settings.
type JoystickAxisCallback ¶
type JoystickAxisCallback func(axis float32)
JoystickAxisCallback is the type of the function that gets called for the joystick axis callback events.
type JoystickButtonCallback ¶
type JoystickButtonCallback func()
JoystickButtonCallback is the type of the function that gets called for the joystick button callback events.
type JoystickModel ¶
type JoystickModel struct { // ButtonBindings maps a button id to a callback function ButtonBindings map[int]JoystickButtonCallback // AxisBindings maps an axis id to an axis binding structure // that determines what input ranges trigger the callback. // // Note: this is a slice because there can be multiple bindings // for a given axis ID. AxisBindings []JoystickAxisBinding // contains filtered or unexported fields }
JoystickModel is the way to bind joystick buttons and axes to movement.
func NewJoystickModel ¶
func NewJoystickModel(w *glfw.Window, j glfw.Joystick) *JoystickModel
NewJoystickModel returns a newly created joystic model object
func (*JoystickModel) BindAxis ¶
func (jm *JoystickModel) BindAxis(binding JoystickAxisBinding)
BindAxis binds an axis mapping for an axis id over a range of values on a joystick.
func (*JoystickModel) BindButton ¶
func (jm *JoystickModel) BindButton(button int, f JoystickButtonCallback)
BindButton binds an event handler for a given button id on a joystick.
func (*JoystickModel) CheckInput ¶
func (jm *JoystickModel) CheckInput()
CheckInput checks the joystick input against the bindings and invokes any matched callbacks.
func (*JoystickModel) IsActive ¶
func (jm *JoystickModel) IsActive() bool
IsActive returns true if the bound joystick id is present.
type KeyCallback ¶
type KeyCallback func()
KeyCallback is the type of the function that gets called for the key callback events.
type KeyboardModel ¶
type KeyboardModel struct { // KeyTriggerBindings are the functions to call when the given key is pressed KeyTriggerBindings map[glfw.Key]KeyCallback // KeyBindings are the functions to call when the given key is considered // 'pressed' when the KeyboardModel runs CheckKeyPresses. KeyBindings map[glfw.Key]KeyCallback // keyCallback is the function that will get passed to GLFW as the // callback handler for key presses KeyCallback glfw.KeyCallback // contains filtered or unexported fields }
KeyboardModel is the way to bind keys to events.
func NewKeyboardModel ¶
func NewKeyboardModel(w *glfw.Window) *KeyboardModel
NewKeyboardModel returns a newly created keyboard model object
func (*KeyboardModel) Bind ¶
func (kb *KeyboardModel) Bind(key glfw.Key, f KeyCallback)
Bind binds a key press event with a callback that will get called when CheckKeyPresses finds the key to be pressed.
func (*KeyboardModel) BindTrigger ¶
func (kb *KeyboardModel) BindTrigger(key glfw.Key, f KeyCallback)
BindTrigger binds a key event that gets called when the key is pressed once.
func (*KeyboardModel) CheckKeyPresses ¶
func (kb *KeyboardModel) CheckKeyPresses()
CheckKeyPresses runs through all of the KeyBindings and checks to see if that key is held down -- if it is, then the callback is invoked.
func (*KeyboardModel) SetupCallbacks ¶
func (kb *KeyboardModel) SetupCallbacks()
SetupCallbacks sets the callback handlers for the window.