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 ¶
- func ClearKeyboardState()
- func ClearMouseState()
- func EventLoopStart(mouseGotCaptured, keyboardGotCaptured bool)
- func GetMouseMotion() (xDelta, yDelta int32)
- func GetMouseMotionCaptured() (xDelta, yDelta int32)
- func GetMouseMotionNorm() (xDelta, yDelta int32)
- func GetMouseMotionNormCaptured() (xDelta, yDelta int32)
- func GetMousePos() (x, y int32)
- func GetMouseWheelMotion() (xDelta, yDelta int32)
- func GetMouseWheelMotionCaptured() (xDelta, yDelta int32)
- func GetMouseWheelXNorm() int32
- func GetMouseWheelXNormCaptured() int32
- func GetMouseWheelYNorm() int32
- func GetMouseWheelYNormCaptured() int32
- func HandleKeyboardEvent(e *sdl.KeyboardEvent)
- func HandleMouseBtnEvent(e *sdl.MouseButtonEvent)
- func HandleMouseMotionEvent(e *sdl.MouseMotionEvent)
- func HandleMouseWheelEvent(e *sdl.MouseWheelEvent)
- func HandleQuitEvent(e *sdl.QuitEvent)
- func IsKeyboardCaptured() bool
- func IsMouseCaptured() bool
- func IsQuitClicked() bool
- func KeyClicked(kc sdl.Keycode) bool
- func KeyClickedCaptured(kc sdl.Keycode) bool
- func KeyDown(kc sdl.Keycode) bool
- func KeyDownCaptured(kc sdl.Keycode) bool
- func KeyReleased(kc sdl.Keycode) bool
- func KeyReleasedCaptured(kc sdl.Keycode) bool
- func KeyUp(kc sdl.Keycode) bool
- func KeyUpCaptured(kc sdl.Keycode) bool
- func MouseClicked(mb int) bool
- func MouseClickedCaptued(mb int) bool
- func MouseDoubleClicked(mb int) bool
- func MouseDoubleClickedCaptured(mb int) bool
- func MouseDown(mb int) bool
- func MouseDownCaptued(mb int) bool
- func MouseReleased(mb int) bool
- func MouseReleasedCaptured(mb int) bool
- func MouseUp(mb int) bool
- func MouseUpCaptured(mb int) bool
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 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 KeyClickedCaptured ¶ added in v0.23.1
func KeyDownCaptured ¶ added in v0.23.1
func KeyReleased ¶
func KeyReleasedCaptured ¶ added in v0.23.1
func KeyUpCaptured ¶ added in v0.23.1
func MouseClicked ¶
func MouseClickedCaptued ¶ added in v0.23.1
func MouseDoubleClicked ¶
func MouseDoubleClickedCaptured ¶ added in v0.23.1
func MouseDownCaptued ¶ added in v0.23.1
func MouseReleased ¶
func MouseReleasedCaptured ¶ added in v0.23.1
func MouseUpCaptured ¶ added in v0.23.1
Types ¶
This section is empty.