vgamepad

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseGamepad

type BaseGamepad struct {
	// contains filtered or unexported fields
}

BaseGamepad contains common functionality for all gamepad types

func NewBaseGamepad

func NewBaseGamepad(targetAlloc func() (uintptr, error)) (*BaseGamepad, error)

NewBaseGamepad creates a new BaseGamepad

func (*BaseGamepad) Close

func (g *BaseGamepad) Close()

Close closes the gamepad and removes it from the bus

func (*BaseGamepad) GetIndex

func (g *BaseGamepad) GetIndex() uint32

GetIndex returns the internally used index of the target device

func (*BaseGamepad) GetPID

func (g *BaseGamepad) GetPID() uint16

GetPID returns the product ID of the virtual device

func (*BaseGamepad) GetType

func (g *BaseGamepad) GetType() commons.ViGEmTargetType

GetType returns the type of the object

func (*BaseGamepad) GetVID

func (g *BaseGamepad) GetVID() uint16

GetVID returns the vendor ID of the virtual device

func (*BaseGamepad) SetPID

func (g *BaseGamepad) SetPID(pid uint16)

SetPID sets the product ID of the virtual device

func (*BaseGamepad) SetVID

func (g *BaseGamepad) SetVID(vid uint16)

SetVID sets the vendor ID of the virtual device

type Gamepad

type Gamepad interface {
	// Update sends the current report to the virtual device
	Update() error

	// Reset resets the gamepad to default state
	Reset()

	// Close closes the gamepad and removes it from the bus
	Close()

	// GetVID returns the vendor ID of the virtual device
	GetVID() uint16

	// GetPID returns the product ID of the virtual device
	GetPID() uint16

	// SetVID sets the vendor ID of the virtual device
	SetVID(vid uint16)

	// SetPID sets the product ID of the virtual device
	SetPID(pid uint16)

	// GetIndex returns the internally used index of the target device
	GetIndex() uint32

	// GetType returns the type of the object
	GetType() commons.ViGEmTargetType

	// RegisterNotification registers a callback function for notifications
	RegisterNotification(callback NotificationCallback) error

	// UnregisterNotification unregisters a previously registered callback function
	UnregisterNotification()
}

Gamepad is the interface for all gamepad types

type NotificationCallback

type NotificationCallback func(client, target uintptr, largeMotor, smallMotor, ledNumber uint8, userData uintptr)

NotificationCallback is the function signature for notification callbacks client: vigem bus ID target: vigem device ID largeMotor: integer in [0, 255] representing the state of the large motor smallMotor: integer in [0, 255] representing the state of the small motor ledNumber: integer in [0, 255] representing the state of the LED ring userData: placeholder, do not use

type VBus

type VBus struct {
	// contains filtered or unexported fields
}

VBus represents a virtual USB bus (ViGEmBus)

func GetVBus

func GetVBus() (*VBus, error)

GetVBus returns the global VBus instance (singleton)

func (*VBus) Close

func (v *VBus) Close()

Close closes the VBus

type VDS4Gamepad

type VDS4Gamepad struct {
	*BaseGamepad
	// contains filtered or unexported fields
}

VDS4Gamepad represents a virtual DualShock 4 gamepad

func NewVDS4Gamepad

func NewVDS4Gamepad() (*VDS4Gamepad, error)

NewVDS4Gamepad creates a new virtual DualShock 4 gamepad

func (*VDS4Gamepad) DirectionalPad

func (g *VDS4Gamepad) DirectionalPad(direction commons.DS4DPadDirection)

DirectionalPad sets the direction of the directional pad (hat)

func (*VDS4Gamepad) LeftJoystick

func (g *VDS4Gamepad) LeftJoystick(xValue, yValue uint8)

LeftJoystick sets the values (0-255, 128 = neutral position) of the X and Y axis for the left joystick

func (*VDS4Gamepad) LeftJoystickFloat

func (g *VDS4Gamepad) LeftJoystickFloat(xValueFloat, yValueFloat float64)

LeftJoystickFloat sets the values (-1.0 to 1.0, 0 = neutral position) of the X and Y axis for the left joystick using floats

func (*VDS4Gamepad) LeftTrigger

func (g *VDS4Gamepad) LeftTrigger(value uint8)

LeftTrigger sets the value (0-255, 0 = trigger released) of the left trigger

func (*VDS4Gamepad) LeftTriggerFloat

func (g *VDS4Gamepad) LeftTriggerFloat(valueFloat float64)

LeftTriggerFloat sets the value (0.0-1.0, 0.0 = trigger released) of the left trigger using a float

func (*VDS4Gamepad) PressButton

func (g *VDS4Gamepad) PressButton(button commons.DS4Button)

PressButton presses a button (no effect if already pressed)

func (*VDS4Gamepad) PressSpecialButton

func (g *VDS4Gamepad) PressSpecialButton(specialButton commons.DS4SpecialButton)

PressSpecialButton presses a special button (no effect if already pressed)

func (*VDS4Gamepad) RegisterNotification

func (g *VDS4Gamepad) RegisterNotification(callback NotificationCallback) error

RegisterNotification registers a callback function for notifications

func (*VDS4Gamepad) ReleaseButton

func (g *VDS4Gamepad) ReleaseButton(button commons.DS4Button)

ReleaseButton releases a button (no effect if already released)

func (*VDS4Gamepad) ReleaseSpecialButton

func (g *VDS4Gamepad) ReleaseSpecialButton(specialButton commons.DS4SpecialButton)

ReleaseSpecialButton releases a special button (no effect if already released)

func (*VDS4Gamepad) Reset

func (g *VDS4Gamepad) Reset()

Reset resets the gamepad to default state

func (*VDS4Gamepad) RightJoystick

func (g *VDS4Gamepad) RightJoystick(xValue, yValue uint8)

RightJoystick sets the values (0-255, 128 = neutral position) of the X and Y axis for the right joystick

func (*VDS4Gamepad) RightJoystickFloat

func (g *VDS4Gamepad) RightJoystickFloat(xValueFloat, yValueFloat float64)

RightJoystickFloat sets the values (-1.0 to 1.0, 0 = neutral position) of the X and Y axis for the right joystick using floats

func (*VDS4Gamepad) RightTrigger

func (g *VDS4Gamepad) RightTrigger(value uint8)

RightTrigger sets the value (0-255, 0 = trigger released) of the right trigger

func (*VDS4Gamepad) RightTriggerFloat

func (g *VDS4Gamepad) RightTriggerFloat(valueFloat float64)

RightTriggerFloat sets the value (0.0-1.0, 0.0 = trigger released) of the right trigger using a float

func (*VDS4Gamepad) UnregisterNotification

func (g *VDS4Gamepad) UnregisterNotification()

UnregisterNotification unregisters a previously registered callback function

func (*VDS4Gamepad) Update

func (g *VDS4Gamepad) Update() error

Update sends the current report to the virtual device

func (*VDS4Gamepad) UpdateExtendedReport

func (g *VDS4Gamepad) UpdateExtendedReport(extendedReport *commons.DS4ReportEx) error

UpdateExtendedReport enables using DS4_REPORT_EX instead of DS4_REPORT (advanced users only)

type VX360Gamepad

type VX360Gamepad struct {
	*BaseGamepad
	// contains filtered or unexported fields
}

VX360Gamepad represents a virtual Xbox 360 gamepad

func NewVX360Gamepad

func NewVX360Gamepad() (*VX360Gamepad, error)

NewVX360Gamepad creates a new virtual Xbox 360 gamepad

func (*VX360Gamepad) LeftJoystick

func (g *VX360Gamepad) LeftJoystick(xValue, yValue int16)

LeftJoystick sets the values (-32768 to 32768, 0 = neutral position) of the X and Y axis for the left joystick

func (*VX360Gamepad) LeftJoystickFloat

func (g *VX360Gamepad) LeftJoystickFloat(xValueFloat, yValueFloat float64)

LeftJoystickFloat sets the values (-1.0 to 1.0, 0 = neutral position) of the X and Y axis for the left joystick using floats

func (*VX360Gamepad) LeftTrigger

func (g *VX360Gamepad) LeftTrigger(value uint8)

LeftTrigger sets the value (0-255, 0 = trigger released) of the left trigger

func (*VX360Gamepad) LeftTriggerFloat

func (g *VX360Gamepad) LeftTriggerFloat(valueFloat float64)

LeftTriggerFloat sets the value (0.0-1.0, 0.0 = trigger released) of the left trigger using a float

func (*VX360Gamepad) PressButton

func (g *VX360Gamepad) PressButton(button commons.XUSBButton)

PressButton presses a button (no effect if already pressed)

func (*VX360Gamepad) RegisterNotification

func (g *VX360Gamepad) RegisterNotification(callback NotificationCallback) error

RegisterNotification registers a callback function for notifications

func (*VX360Gamepad) ReleaseButton

func (g *VX360Gamepad) ReleaseButton(button commons.XUSBButton)

ReleaseButton releases a button (no effect if already released)

func (*VX360Gamepad) Reset

func (g *VX360Gamepad) Reset()

Reset resets the gamepad to default state

func (*VX360Gamepad) RightJoystick

func (g *VX360Gamepad) RightJoystick(xValue, yValue int16)

RightJoystick sets the values (-32768 to 32768, 0 = neutral position) of the X and Y axis for the right joystick

func (*VX360Gamepad) RightJoystickFloat

func (g *VX360Gamepad) RightJoystickFloat(xValueFloat, yValueFloat float64)

RightJoystickFloat sets the values (-1.0 to 1.0, 0 = neutral position) of the X and Y axis for the right joystick using floats

func (*VX360Gamepad) RightTrigger

func (g *VX360Gamepad) RightTrigger(value uint8)

RightTrigger sets the value (0-255, 0 = trigger released) of the right trigger

func (*VX360Gamepad) RightTriggerFloat

func (g *VX360Gamepad) RightTriggerFloat(valueFloat float64)

RightTriggerFloat sets the value (0.0-1.0, 0.0 = trigger released) of the right trigger using a float

func (*VX360Gamepad) UnregisterNotification

func (g *VX360Gamepad) UnregisterNotification()

UnregisterNotification unregisters a previously registered callback function

func (*VX360Gamepad) Update

func (g *VX360Gamepad) Update() error

Update sends the current report to the virtual device

Jump to

Keyboard shortcuts

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