joystick

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AxisValue

type AxisValue struct {
	Value int
	// contains filtered or unexported fields
}

type Constraint

type Constraint struct {
	MinIn  int
	MaxIn  int
	MinOut int16
	MaxOut int16
}

type Definitions

type Definitions struct {
	ReportID     byte
	ButtonCnt    int
	HatSwitchCnt int
	AxisDefs     []Constraint
	// contains filtered or unexported fields
}

func DefaultDefinitions

func DefaultDefinitions() Definitions

func (Definitions) Descriptor

func (c Definitions) Descriptor() []byte

func (Definitions) NewState

func (c Definitions) NewState() State

type HatDirection

type HatDirection uint8
const (
	HatUp HatDirection = iota
	HatRightUp
	HatRight
	HatRightDown
	HatDown
	HatLeftDown
	HatLeft
	HatLeftUp
	HatCenter
)

type Joystick

type Joystick struct {
	State
	// contains filtered or unexported fields
}

func Enable

func Enable(def Definitions, rxHandlerFunc func(b []byte),
	setupFunc func(setup usb.Setup) bool, hidDesc []byte) *Joystick

func Port

func Port() *Joystick

Port returns the USB Joystick port.

func (*Joystick) SendReport

func (m *Joystick) SendReport(reportID byte, b []byte)

to InterruptOut

func (*Joystick) SendState

func (m *Joystick) SendState()

type RingBuffer

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

RingBuffer is ring buffer implementation inspired by post at https://www.embeddedrelated.com/showthread/comp.arch.embedded/77084-1.php

func NewRingBuffer

func NewRingBuffer() *RingBuffer

NewRingBuffer returns a new ring buffer.

func (*RingBuffer) Clear

func (rb *RingBuffer) Clear()

Clear resets the head and tail pointer to zero.

func (*RingBuffer) Get

func (rb *RingBuffer) Get() ([]byte, bool)

Get returns a byte from the buffer. If the buffer is empty, the method will return a false as the second value.

func (*RingBuffer) Put

func (rb *RingBuffer) Put(val []byte) bool

Put stores a byte in the buffer. If the buffer is already full, the method will return false.

func (*RingBuffer) Used

func (rb *RingBuffer) Used() uint8

Used returns how many bytes in buffer have been used.

type State

type State struct {
	Buttons     []byte
	HatSwitches []HatDirection
	Axises      []*AxisValue
	// contains filtered or unexported fields
}

func (State) Axis

func (s State) Axis(index int) int

func (State) Button

func (s State) Button(index int) bool

func (State) Hat

func (s State) Hat(index int) HatDirection

func (State) MarshalBinary

func (s State) MarshalBinary() ([]byte, error)

func (State) SetAxis

func (s State) SetAxis(index int, v int)

func (State) SetButton

func (s State) SetButton(index int, push bool)

func (State) SetHat

func (s State) SetHat(index int, dir HatDirection)

Jump to

Keyboard shortcuts

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