Documentation ¶
Overview ¶
Package blusb implements protocol and data structures for configuring the various settings of the Blusb Universal BT-USB Model M Controller.
Index ¶
- Variables
- type Controller
- func (c *Controller) Close()
- func (c Controller) GetBrightness() (uint, uint, error)
- func (c Controller) GetDebounce() (time.Duration, error)
- func (c Controller) GetLayers() (ls Layers, err error)
- func (c Controller) GetMacros() (ms Macros, err error)
- func (c Controller) GetMatrix() (int, int, error)
- func (c Controller) GetVersion() (int, int, error)
- func (c Controller) SetBrightness(usb, bt uint) error
- func (c Controller) SetDebounce(dur time.Duration) error
- func (c Controller) SetLayers(ls Layers) error
- func (c Controller) SetMacros(ms Macros) error
- func (c Controller) String() string
- type Layer
- type Layers
- type Macro
- type Macros
Constants ¶
This section is empty.
Variables ¶
var ( VID gousb.ID = 0x04b3 PID gousb.ID = 0x301c )
Default Vendor and Product ID's.
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) 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.
type Layers ¶
type Layers []Layer
Layers represents all configured layers.
func (Layers) MarshalBinary ¶
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 ¶
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) UnmarshalBinary ¶
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 ¶
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 ¶
MarshalBinary encodes a 193-byte macro table data packet.
func (Macros) MarshalText ¶
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) UnmarshalBinary ¶
UnmarshalBinary decodes a 192-byte macro table data packet.
func (*Macros) UnmarshalText ¶
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.