input

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 1 Imported by: 3

Documentation

Overview

The input package provides an interface to mouse and keyboard inputs like key clicks and releases, along with some higher level constructs like pressed/released this frames, double clicks, and normalized inputs.

The input package has two sets of functions for most cases, where one is in the form 'xy' and the other 'xyCaptured'. The captured form always returns normal events even if the mouse or keyboard are captured by the UI system. The 'xy' form however will return zero/false if the respective input device is currently captured (with the exception of mouse position, that is always correctly returned).

For most cases, you want to use the 'xy' form. For example, you only want to receive key down events for game character movement when the UI isn't capturing the keyboard, because otherwise the character will move while typing in a UI textbox.

The functions IsMouseCaptured and IsKeyboardCaptured are also available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearKeyboardState added in v0.19.9

func ClearKeyboardState()

func ClearMouseState added in v0.19.9

func ClearMouseState()

func EventLoopStart

func EventLoopStart(mouseGotCaptured, keyboardGotCaptured bool)

func GetMouseMotion

func GetMouseMotion() (xDelta, yDelta int32)

GetMouseMotion returns how many pixels were moved last frame

func GetMouseMotionCaptured added in v0.23.1

func GetMouseMotionCaptured() (xDelta, yDelta int32)

func GetMouseMotionNorm

func GetMouseMotionNorm() (xDelta, yDelta int32)

func GetMouseMotionNormCaptured added in v0.23.1

func GetMouseMotionNormCaptured() (xDelta, yDelta int32)

func GetMousePos

func GetMousePos() (x, y int32)

GetMousePos returns the window coordinates of the mouse regardless of whether the mouse is captured or not

func GetMouseWheelMotion

func GetMouseWheelMotion() (xDelta, yDelta int32)

func GetMouseWheelMotionCaptured added in v0.23.1

func GetMouseWheelMotionCaptured() (xDelta, yDelta int32)

func GetMouseWheelXNorm

func GetMouseWheelXNorm() int32

GetMouseWheelXNorm returns 1 if mouse wheel xDelta > 0, -1 if xDelta < 0, and 0 otherwise

func GetMouseWheelXNormCaptured added in v0.23.1

func GetMouseWheelXNormCaptured() int32

GetMouseWheelXNormCaptured returns 1 if mouse wheel xDelta > 0, -1 if xDelta < 0, and 0 otherwise

func GetMouseWheelYNorm

func GetMouseWheelYNorm() int32

GetMouseWheelYNorm returns 1 if mouse wheel yDelta > 0, -1 if yDelta < 0, and 0 otherwise

func GetMouseWheelYNormCaptured added in v0.23.1

func GetMouseWheelYNormCaptured() int32

GetMouseWheelYNormCaptured returns 1 if mouse wheel yDelta > 0, -1 if yDelta < 0, and 0 otherwise

func HandleKeyboardEvent

func HandleKeyboardEvent(e *sdl.KeyboardEvent)

func HandleMouseBtnEvent

func HandleMouseBtnEvent(e *sdl.MouseButtonEvent)

func HandleMouseMotionEvent

func HandleMouseMotionEvent(e *sdl.MouseMotionEvent)

func HandleMouseWheelEvent

func HandleMouseWheelEvent(e *sdl.MouseWheelEvent)

func HandleQuitEvent added in v0.0.6

func HandleQuitEvent(e *sdl.QuitEvent)

func IsKeyboardCaptured added in v0.23.1

func IsKeyboardCaptured() bool

func IsMouseCaptured added in v0.23.1

func IsMouseCaptured() bool

func IsQuitClicked added in v0.0.6

func IsQuitClicked() bool

func KeyClicked

func KeyClicked(kc sdl.Keycode) bool

func KeyClickedCaptured added in v0.23.1

func KeyClickedCaptured(kc sdl.Keycode) bool

func KeyDown

func KeyDown(kc sdl.Keycode) bool

func KeyDownCaptured added in v0.23.1

func KeyDownCaptured(kc sdl.Keycode) bool

func KeyReleased

func KeyReleased(kc sdl.Keycode) bool

func KeyReleasedCaptured added in v0.23.1

func KeyReleasedCaptured(kc sdl.Keycode) bool

func KeyUp

func KeyUp(kc sdl.Keycode) bool

func KeyUpCaptured added in v0.23.1

func KeyUpCaptured(kc sdl.Keycode) bool

func MouseClicked

func MouseClicked(mb int) bool

func MouseClickedCaptued added in v0.23.1

func MouseClickedCaptued(mb int) bool

func MouseDoubleClicked

func MouseDoubleClicked(mb int) bool

func MouseDoubleClickedCaptured added in v0.23.1

func MouseDoubleClickedCaptured(mb int) bool

func MouseDown

func MouseDown(mb int) bool

func MouseDownCaptued added in v0.23.1

func MouseDownCaptued(mb int) bool

func MouseReleased

func MouseReleased(mb int) bool

func MouseReleasedCaptured added in v0.23.1

func MouseReleasedCaptured(mb int) bool

func MouseUp

func MouseUp(mb int) bool

func MouseUpCaptured added in v0.23.1

func MouseUpCaptured(mb int) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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