Documentation ¶
Overview ¶
Package device contains abstractions to handle devices.
Index ¶
- type ButtplugConnection
- type Controller
- func (c *Controller) Battery() (float64, error)
- func (c *Controller) Linear(vectors map[int]Vector) error
- func (c *Controller) RSSILevel() (float64, error)
- func (c *Controller) Rotate(rotations map[int]Rotation) error
- func (c *Controller) Stop() error
- func (c *Controller) Vibrate(motorSpeeds map[int]float64) error
- func (c *Controller) VibrationMotors() int
- func (c *Controller) VibrationSteps() []int
- func (c *Controller) WithAsync() *Controller
- func (c *Controller) WithContext(ctx context.Context) *Controller
- type Device
- type DeviceMessages
- type Manager
- type Rotation
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ButtplugConnection ¶
type ButtplugConnection interface { Command(ctx context.Context, msg buttplug.Message) (buttplug.Message, error) Send(ctx context.Context, msgs ...buttplug.Message) }
ButtplugConnection describes a connection to the Buttplug (Intiface) controller. A *buttplug.Websocket will satisfy this.
type Controller ¶
type Controller struct { // Device is the device that this controller belongs to. Device // contains filtered or unexported fields }
Controller binds a device and a websocket together to provide abstraction methods for controlling it.
func NewController ¶
func NewController(conn ButtplugConnection, device Device) *Controller
NewController creates a new device controller.
func (*Controller) Battery ¶
func (c *Controller) Battery() (float64, error)
Battery queries for the battery level. The returned number is between 0 and 1.
func (*Controller) Linear ¶
func (c *Controller) Linear(vectors map[int]Vector) error
Linear asks the server to linearly move the device over a certain amount of time. Linear can be asynchronous.
func (*Controller) RSSILevel ¶
func (c *Controller) RSSILevel() (float64, error)
RSSILevel gets the received signal strength indication level, expressed as dB gain, typically like [-100:0], where -100 is the number returned.
func (*Controller) Rotate ¶
func (c *Controller) Rotate(rotations map[int]Rotation) error
Rotate asks the server to rotate some or all of the device's motors. Rotate can be asynchronous.
func (*Controller) Stop ¶
func (c *Controller) Stop() error
Stop asks the server to stop the device. Stop ca be asynchronous.
func (*Controller) Vibrate ¶
func (c *Controller) Vibrate(motorSpeeds map[int]float64) error
Vibrate asks the server to start vibrating. Vibrate can be asynchronous.
func (*Controller) VibrationMotors ¶
func (c *Controller) VibrationMotors() int
VibrationMotors returns the number of vibration motors for the device. 0 is returned if the device doesn't support vibration.
func (*Controller) VibrationSteps ¶
func (c *Controller) VibrationSteps() []int
VibrationSteps returns the number of vibration steps that the device can support. The returned list has the length of the number of motors, with each item being the step count of each motor. Nil is returned if the device doesn't support vibration or if the server doesn't have this information.
func (*Controller) WithAsync ¶
func (c *Controller) WithAsync() *Controller
WithAsync returns a new Controller that is fully asynchronous. When that's the case, Controller will send commands asynchronously whenever possible. The return types for command methods will always be a zero-value. Methods that behave differently when async will be explicitly documented.
func (*Controller) WithContext ¶
func (c *Controller) WithContext(ctx context.Context) *Controller
WithContext returns a new Controller that internally uses the given context.
type Device ¶
type Device struct { // Name is the device name. Name buttplug.DeviceName // Index identifies the device. Index buttplug.DeviceIndex // Messages holds the message types that the device will accept and the // features that it supports. Messages DeviceMessages }
Device describes a single device.
type DeviceMessages ¶
type DeviceMessages map[buttplug.MessageType]buttplug.GenericMessageAttributes
DeviceMessages is a type that holds the supported message types for a device.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds an internal state of devices and does its best to keep it updated.
func (*Manager) Controller ¶
func (m *Manager) Controller(conn ButtplugConnection, ix buttplug.DeviceIndex) *Controller
Controller returns a new device controller for the given device index. If the device is not found, then nil is returned.