gamepad

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button int

Button identifies a logical gamepad button.

const (
	ButtonUp Button = iota + 1
	ButtonRight
	ButtonDown
	ButtonLeft

	ButtonNorth
	ButtonEast
	ButtonSouth
	ButtonWest

	ButtonL1
	ButtonR1

	ButtonL2
	ButtonR2

	ButtonL3
	ButtonR3

	ButtonSelect
	ButtonStart
	ButtonMode

	ButtonFiller1
	ButtonFiller2
	ButtonFiller3
	ButtonFiller4
)

type HatEvent

type HatEvent struct {
	Axis  linux.AbsoluteAxis
	Value int32
}

HatEvent represents a D-pad hat switch event with axis and direction.

type InputEvent

type InputEvent interface{}

InputEvent represents a gamepad input event (button, key, axis, or scan code).

type MSCScanCode

type MSCScanCode uint32

MSCScanCode is a scan code value sent as an MSC_SCAN event.

type MappingDigital

type MappingDigital map[Button]InputEvent // single or array

MappingDigital maps gamepad buttons to their input events.

type MappingStick

type MappingStick struct {
	X virtual_device.AbsAxis
	Y virtual_device.AbsAxis
}

MappingStick defines the X and Y axes for an analog stick.

type VirtualGamepad

type VirtualGamepad interface {
	Register() error
	Unregister() error

	Press(button Button)
	Release(button Button)

	MoveLeftStick(x, y float32)
	MoveLeftStickX(x float32)
	MoveLeftStickY(y float32)

	MoveRightStick(x, y float32)
	MoveRightStickX(x float32)
	MoveRightStickY(y float32)

	Send(evType, code uint16, value int32)

	EventPath() string
}

VirtualGamepad is a high-level virtual gamepad input device.

func NewJoyConL added in v1.1.0

func NewJoyConL() VirtualGamepad

func NewJoyConR added in v1.1.0

func NewJoyConR() VirtualGamepad

func NewSN30Pro

func NewSN30Pro() VirtualGamepad

func NewSaitekP2600 added in v1.2.0

func NewSaitekP2600() VirtualGamepad

func NewSonyPS4

func NewSonyPS4() VirtualGamepad

func NewSonyPS5

func NewSonyPS5() VirtualGamepad

func NewStadia

func NewStadia() VirtualGamepad

func NewSwitchPro

func NewSwitchPro() VirtualGamepad

func NewXBox360

func NewXBox360() VirtualGamepad

func NewXBoxOneElite2 added in v1.1.0

func NewXBoxOneElite2() VirtualGamepad

func NewXBoxOneS

func NewXBoxOneS() VirtualGamepad

type VirtualGamepadFactory

type VirtualGamepadFactory interface {
	WithDevice(device virtual_device.VirtualDevice) VirtualGamepadFactory
	WithDigital(mapping MappingDigital) VirtualGamepadFactory
	WithLeftStick(mapping MappingStick) VirtualGamepadFactory
	WithRightStick(mapping MappingStick) VirtualGamepadFactory
	Create() VirtualGamepad
}

VirtualGamepadFactory configures and creates VirtualGamepad instances.

func NewVirtualGamepadFactory

func NewVirtualGamepadFactory() VirtualGamepadFactory

NewVirtualGamepadFactory returns a new factory for building virtual gamepads.

Jump to

Keyboard shortcuts

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