blusb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package blusb implements protocol and data structures for configuring the various settings of the Blusb Universal BT-USB Model M Controller.

Index

Constants

This section is empty.

Variables

View Source
var (
	VID gousb.ID = 0x04b3
	PID gousb.ID = 0x301c
)

Default Vendor and Product ID's.

View Source
var (
	ErrInvalidBrightness  = errors.New("brightness value must be between 0 and 255")
	ErrInvalidDebounceDur = errors.New("debounce duration must be between 1ms and 255ms")
	ErrControllerNotFound = errors.New("blusb controller not found")
)

Errors

Functions

This section is empty.

Types

type Controller

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

Controller holds the Blusb Universal BT-USB Model M Controller context.

func Open

func Open() (Controller, error)

Open opens the controller and claims the default interface.

func (*Controller) Close

func (c *Controller) Close()

Close releases the controller.

func (Controller) GetBrightness

func (c Controller) GetBrightness() (uint, uint, error)

GetBrightness returns the Num Lock, Caps Lock, and Scroll Lock LED brightness values stored in the controller for USB and Bluetooth modes. The value range is 0-255.

func (Controller) GetDebounce

func (c Controller) GetDebounce() (time.Duration, error)

GetDebounce returns the debounce duration stored in the controller.

func (Controller) GetLayers

func (c Controller) GetLayers() (ls Layers, err error)

GetLayers returns the layers stored in the controller.

func (Controller) GetMacros

func (c Controller) GetMacros() (ms Macros, err error)

GetMacros returns the macro table stored in the controller.

func (Controller) GetMatrix

func (c Controller) GetMatrix() (int, int, error)

GetMatrix is a gets the matrix row and column for the current key being pressed. This is non-blocking and if no key is being pressed it returns 0, 0.

func (Controller) GetVersion

func (c Controller) GetVersion() (int, int, error)

GetVersion returns the controller firmware version as major and minor integers. These are usually written as "major.minor".

func (Controller) SetBrightness

func (c Controller) SetBrightness(usb, bt uint) error

SetBrightness sets the controller Num Lock, Caps Lock, and Scroll Lock LED brightness values for USB and Bluetooth modes. The value range is 0-255.

func (Controller) SetDebounce

func (c Controller) SetDebounce(dur time.Duration) error

SetDebounce sets the controller debounce duration.

func (Controller) SetLayers

func (c Controller) SetLayers(ls Layers) error

SetLayers sets the controller layers.

func (Controller) SetMacros

func (c Controller) SetMacros(ms Macros) error

SetMacros sets the controller macro table.

func (Controller) String

func (c Controller) String() string

type Layer

type Layer struct {
	// Each layer has a matrixRows*matrixCols matrix, representing up to
	// 160 keys.
	//
	// Each key is 2-bytes with the higher byte representing any modifiers
	// and the lower byte being a key code.
	Matrix [matrixRows][matrixCols]uint16
}

Layer represents one layer.

func (Layer) String

func (l Layer) String() string

type Layers

type Layers []Layer

Layers represents all configured layers.

func (Layers) MarshalBinary

func (ls Layers) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a layers data packet. It consists of 1-byte to indicate the number of layers and 160-bytes for each layer.

func (Layers) MarshalText

func (ls Layers) MarshalText() ([]byte, error)

MarshalText composes CSV formatted layers consisting of one line for each layer with each layer consisting of 160 hexadecimal combined modifier and key codes separated by commas.

func (Layers) String

func (ls Layers) String() string

func (*Layers) UnmarshalBinary

func (ls *Layers) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a layers data packet. It consists of 1-byte to indicate the number of layers and 160-bytes for each layer.

func (*Layers) UnmarshalText

func (ls *Layers) UnmarshalText(text []byte) error

UnmarshalText parses CSV formatted layers consisting of one line for each layer with each layer consisting of 160 hexadecimal combined modifier and key codes separated by commas.

type Macro

type Macro struct {
	Mods     uint8    // Internal modifier key codes
	Reserved uint8    // Reserved for future use
	Key      [6]uint8 // Up to 6 key codes
}

Macro represents one macro.

type Macros

type Macros [numMacros]Macro

Macros represents the full macro table.

func (Macros) MarshalBinary

func (ms Macros) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a 193-byte macro table data packet.

func (Macros) MarshalText

func (ms Macros) MarshalText() ([]byte, error)

MarshalText composes a CSV formatted macro table consisting of one line for each macro with each macro consisting of it's parts encoded as hexadecimal codes and separated by commas.

func (Macros) String

func (ms Macros) String() string

func (*Macros) UnmarshalBinary

func (ms *Macros) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a 192-byte macro table data packet.

func (*Macros) UnmarshalText

func (ms *Macros) UnmarshalText(text []byte) error

UnmarshalText parses a CSV formatted macro table that consists of one line for each macro with each macro consisting of it's parts encoded as hexadecimal codes and separated by commas.

Jump to

Keyboard shortcuts

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