gamepaddb

package
v2.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HatUp    = 1
	HatRight = 2
	HatDown  = 4
	HatLeft  = 8
)
View Source
const (
	SDLControllerButtonA             = 0
	SDLControllerButtonB             = 1
	SDLControllerButtonX             = 2
	SDLControllerButtonY             = 3
	SDLControllerButtonBack          = 4
	SDLControllerButtonGuide         = 5
	SDLControllerButtonStart         = 6
	SDLControllerButtonLeftStick     = 7
	SDLControllerButtonRightStick    = 8
	SDLControllerButtonLeftShoulder  = 9
	SDLControllerButtonRightShoulder = 10
	SDLControllerButtonDpadUp        = 11
	SDLControllerButtonDpadDown      = 12
	SDLControllerButtonDpadLeft      = 13
	SDLControllerButtonDpadRight     = 14
	SDLControllerButtonMisc1         = 15
	SDLControllerButtonPaddle1       = 16
	SDLControllerButtonPaddle2       = 17
	SDLControllerButtonPaddle3       = 18
	SDLControllerButtonPaddle4       = 19
	SDLControllerButtonTouchpad      = 20
	SDLControllerButtonMax           = SDLControllerButtonTouchpad // This is different from the original SDL_CONTROLLER_BUTTON_MAX.
)

See https://github.com/libsdl-org/SDL/blob/120c76c84bbce4c1bfed4e9eb74e10678bd83120/include/SDL_gamecontroller.h#L655-L680

View Source
const (
	SDLControllerAxisLeftX        = 0
	SDLControllerAxisLeftY        = 1
	SDLControllerAxisRightX       = 2
	SDLControllerAxisRightY       = 3
	SDLControllerAxisTriggerLeft  = 4
	SDLControllerAxisTriggerRight = 5
)

See https://github.com/libsdl-org/SDL/blob/120c76c84bbce4c1bfed4e9eb74e10678bd83120/include/SDL_gamecontroller.h#L550-L560

View Source
const ButtonPressedThreshold = 30.0 / 255.0

ButtonPressedThreshold represents the value up to which a button counts as not yet pressed. This has been set to match XInput's trigger dead zone. See https://source.chromium.org/chromium/chromium/src/+/main:device/gamepad/public/cpp/gamepad.h;l=22-23;drc=6997f8a177359bb99598988ed5e900841984d242 Note: should be used with >, not >=, comparisons.

Variables

This section is empty.

Functions

func HasStandardAxis added in v2.4.0

func HasStandardAxis(id string, axis StandardAxis) bool

func HasStandardButton added in v2.4.0

func HasStandardButton(id string, button StandardButton) bool

func HasStandardLayoutMapping

func HasStandardLayoutMapping(id string) bool

func IsStandardButtonPressed added in v2.7.0

func IsStandardButtonPressed(id string, button StandardButton, state GamepadState) bool

func Name added in v2.3.0

func Name(id string) string

func StandardAxisValue added in v2.7.0

func StandardAxisValue(id string, axis StandardAxis, state GamepadState) float64

func StandardButtonValue added in v2.7.0

func StandardButtonValue(id string, button StandardButton, state GamepadState) float64

func Update

func Update(mappingData []byte) error

Update adds new gamepad mappings. The string must be in the format of SDL_GameControllerDB.

Update works atomically. If an error happens, nothing is updated.

Types

type GamepadState

type GamepadState interface {
	IsAxisReady(index int) bool
	Axis(index int) float64
	Button(index int) bool
	Hat(index int) int
}

type StandardAxis added in v2.3.0

type StandardAxis int
const (
	StandardAxisLeftStickHorizontal StandardAxis = iota
	StandardAxisLeftStickVertical
	StandardAxisRightStickHorizontal
	StandardAxisRightStickVertical

	StandardAxisMax = StandardAxisRightStickVertical
)

https://www.w3.org/TR/gamepad/#remapping

type StandardButton added in v2.3.0

type StandardButton int
const (
	StandardButtonRightBottom StandardButton = iota
	StandardButtonRightRight
	StandardButtonRightLeft
	StandardButtonRightTop
	StandardButtonFrontTopLeft
	StandardButtonFrontTopRight
	StandardButtonFrontBottomLeft
	StandardButtonFrontBottomRight
	StandardButtonCenterLeft
	StandardButtonCenterRight
	StandardButtonLeftStick
	StandardButtonRightStick
	StandardButtonLeftTop
	StandardButtonLeftBottom
	StandardButtonLeftLeft
	StandardButtonLeftRight
	StandardButtonCenterCenter

	StandardButtonMax = StandardButtonCenterCenter
)

https://www.w3.org/TR/gamepad/#remapping

Jump to

Keyboard shortcuts

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