Documentation ¶
Overview ¶
Package dkb4q implements the low-level protocol of "Das Keyboard 4Q".
This is a very early draft and very much work in progress. The goal is to support "Das Keyboard 4Q", because that's the one I happen to own.
Index ¶
Constants ¶
const ( // SetColor steadily lights the key in a single color. SetColor IdleEffect = 0x01 // Breathe cycles the key's light through continuous phases of high/low intensity. Breathe = 0x08 // Blink turns the key's light on/off at regular intervals. Blink = 0x1F // ColorCycle continuously cycles the key's light through the colors of the rainbow. ColorCycle = 0x14 )
const (
// MaxID is the maximum LED.
MaxID = 130
)
Variables ¶
var None = ActiveEffect{}
None disables an active effect, i.e. the key will not react to key presses.
Functions ¶
This section is empty.
Types ¶
type ActiveEffect ¶
type ActiveEffect struct {
// contains filtered or unexported fields
}
ActiveEffect describes the key's behavior when it is activated, i.e. pressed.
func BlinkActive ¶
func BlinkActive(opts ...ActiveEffectOption) ActiveEffect
BlinkActive lets keys blink when pressed. Number of on/off cycles and the cycle duration can be controlled with CycleCount and CycleDuration.
func BreatheActive ¶
func BreatheActive(opts ...ActiveEffectOption) ActiveEffect
BreatheActive lets keys "breathe" – smoothly cycle through high/low intensity – when pressed. Number of on/off cycles and the cycle duration can be controlled with CycleCount and CycleDuration.
func SetColorActive ¶
func SetColorActive(opts ...ActiveEffectOption) ActiveEffect
SetColorActive lights the key in a single color. After some time (default: 1.9 seconds) the key reverts to its idle state.
type ActiveEffectOption ¶
type ActiveEffectOption func(*ActiveEffect)
ActiveEffectOption is an option to an active effect. Not all active effects support all options – see the option's documentation for the effects they support.
func CycleCount ¶
func CycleCount(c uint8) ActiveEffectOption
CycleCount sets how often a key blinks with the "BlinkActive" effect or "breathes" with the "BreatheActive" effect.
func CycleDuration ¶
func CycleDuration(d time.Duration) ActiveEffectOption
CycleDuration sets how long each on/off cycle of the "BlinkActive" effect is. Defaults to 1.05 seconds.
func EffectDuration ¶
func EffectDuration(d time.Duration) ActiveEffectOption
EffectDuration sets how long the "SetColorActive" effect lasts before it reverts to the idle state.
type IdleEffect ¶
type IdleEffect uint8
IdleEffect describes the key's behavior when it is inactive.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard represents the connection to a keyboard.
func Open ¶
Open scans USB devices for a "Das Keyboard" by looking for the vendor ID 0x24F0. It returns a Keyboard talking to the first device successfully opened. If no device could be opened, an error is returned.
The connection to the keyboard should be closed with Close().
type State ¶
type State struct { ID uint8 IdleEffect IdleEffect IdleColor color.NRGBA ActiveEffect ActiveEffect ActiveColor color.NRGBA }
State represents the (desired) state of one key. "Idle" refers to the key's normal state, "active" to the keys state after is has been pressed.