vial

package
v0.0.0-...-d8812d5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MagicSerialPrefix is a value in the serial number of HID devices
	// that the	Vial desktop app uses to identify compatible devices.
	MagicSerialPrefix = "vial:f64c2b3c"

	ViaProtocolVersion = 0x09

	VialProtocolVersion = 0x00000006

	VialUnlockCounterMax   = 50
	VialUnlockHoldDuration = 2 * time.Second
)
View Source
const (
	ViaChannelCustom       ViaChannelID = 0x00
	ViaChannelBacklight                 = 0x01
	ViaChannelRGBLight                  = 0x02
	ViaChannelRGBMatrix                 = 0x03
	ViaChannelQMKAudio                  = 0x04
	ViaChannelQMKLEDMatrix              = 0x05
)
View Source
const (
	VialRGBProtocolVersion = 1
)

Variables

This section is empty.

Functions

func MagicSerialNumber

func MagicSerialNumber(sn string) string

MagicSerialNumber returns a string value that the Vial desktop app can recognize as a Vial-compatible device based on a "magic" value (see MagicSerialPrefix constant in this package). If the provided string `sn` is not the zero value, it is appended with a separator to the prefix and returned; otherwise just the prefix is returned.

Types

type Device

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

func NewDevice

func NewDevice(def DeviceDefinition, driver DeviceDriver) *Device

func (*Device) Handle

func (dev *Device) Handle(rx []byte, tx []byte) bool

func (*Device) UnlockStatus

func (dev *Device) UnlockStatus() UnlockStatus

func (*Device) UseVialRGB

func (dev *Device) UseVialRGB(drv VialRGBer)

type DeviceDefinition

type DeviceDefinition struct {
	Name          string       `json:"name"`
	VendorID      string       `json:"vendorId"`
	ProductID     string       `json:"productId"`
	Matrix        DeviceMatrix `json:"matrix"`
	Lighting      string       `json:"lighting"`
	UnlockKeys    []Pos        `json:"-"`
	LzmaDefLength uint16       `json:"-"`
	LzmaDefWriter LzmaDefPageWriter
	// contains filtered or unexported fields
}

func (*DeviceDefinition) UseVialRGB

func (def *DeviceDefinition) UseVialRGB(drv VialRGBer)

type DeviceDriver

type DeviceDriver interface {
	GetLayerCount() uint8
	GetMatrixRowState(rowIndex int) uint32
	MapKey(layer, row, col int) keycodes.Keycode
	SetKey(layer, row, col int, kc keycodes.Keycode) bool
}

type DeviceMatrix

type DeviceMatrix struct {
	Rows int `json:"rows"`
	Cols int `json:"cols"`
}

type EncoderMapper

type EncoderMapper interface {
	MapEncoder(idx int) (ccwRow, ccwCol int, cwRow, cwCol int, ok bool)
}

type EncoderSetter

type EncoderSetter interface {
	SetEncoder(layer, idx int, clockwise bool, kc keycodes.Keycode)
}

type Handler

type Handler interface {
	Handle(rx []byte, tx []byte) bool
}

type HandlerFunc

type HandlerFunc func(rx []byte, tx []byte) (sendTx bool)

func (HandlerFunc) Handle

func (fn HandlerFunc) Handle(rx []byte, tx []byte) (sendTx bool)

type KeyOverrideEntry

type KeyOverrideEntry struct {
	Trigger         uint16
	Replacement     uint16
	Layers          uint16
	TriggerMods     uint8
	NegativeModMask uint8
	SupressedMods   uint8
	Options         uint8
}

the key override structure as it is stored in eeprom and transferred to vial-gui; it is deserialized into key_override_t by vial_get_key_override

type LightingMode

type LightingMode string
const (
	LightingModeVialRGB      LightingMode = "vialrgb"
	LightingModeQMKRGBLight  LightingMode = "qmk_rgblight"
	LightingModeQMKBacklight LightingMode = "qmk_backlight"
)

type LzmaDefPageWriter

type LzmaDefPageWriter interface {
	WriteLzmaDefPage(buf []byte, page uint16) bool
}

type LzmaDefPageWriterFunc

type LzmaDefPageWriterFunc func(buf []byte, page uint16) bool

func (LzmaDefPageWriterFunc) WriteLzmaDefPage

func (fn LzmaDefPageWriterFunc) WriteLzmaDefPage(buf []byte, page uint16) bool

type MacroDriver

type MacroDriver interface {
	GetMacroCount() uint8
	GetMacroBuffer() []byte
}

type Pos

type Pos struct {
	Row uint8
	Col uint8
}

type UnlockStatus

type UnlockStatus uint8
const (
	Locked UnlockStatus = iota
	Unlocked
	UnlockInProgress
)

func (UnlockStatus) String

func (i UnlockStatus) String() string

type ViaChannelID

type ViaChannelID uint8

type ViaCommand

type ViaCommand uint8

ViaCommand represents a command from the VIA command set. VIA is a graphical configurator for QMK firmware. Vial is an open source alternative to VIA, and shares some of the same command set as its predecessor. Not all VIA commands are supported by this package, only the ones that are necessary for Vial.

const (
	ViaCmdGetProtocolVersion       ViaCommand = 0x01
	ViaCmdGetKeyboardValue         ViaCommand = 0x02
	ViaCmdSetKeyboardValue         ViaCommand = 0x03
	ViaCmdDynamicKeymapGetKeycode  ViaCommand = 0x04
	ViaCmdDynamicKeymapSetKeycode  ViaCommand = 0x05
	ViaCmdDynamicKeymapReset       ViaCommand = 0x06
	ViaCmdLightingSetValue         ViaCommand = 0x07
	ViaCmdLightingGetValue         ViaCommand = 0x08
	ViaCmdLightingSave             ViaCommand = 0x09
	ViaCmdEepromReset              ViaCommand = 0x0A
	ViaCmdBootloaderJump           ViaCommand = 0x0B
	ViaCmdKeymapMacroGetCount      ViaCommand = 0x0C
	ViaCmdKeymapMacroGetBufferSize ViaCommand = 0x0D
	ViaCmdKeymapMacroGetBuffer     ViaCommand = 0x0E
	ViaCmdKeymapMacroSetBuffer     ViaCommand = 0x0F
	ViaCmdKeymapMacroReset         ViaCommand = 0x10
	ViaCmdKeymapGetLayerCount      ViaCommand = 0x11
	ViaCmdKeymapGetBuffer          ViaCommand = 0x12
	ViaCmdKeymapSetBuffer          ViaCommand = 0x13
	ViaCmdVialPrefix               ViaCommand = 0xFE
	ViaCmdUnhandled                ViaCommand = 0xFF
)

func (ViaCommand) String

func (i ViaCommand) String() string

type ViaKeyboardValueID

type ViaKeyboardValueID uint8
const (
	ViaKbdUptime            ViaKeyboardValueID = 0x01
	ViaKbdLayoutOptions     ViaKeyboardValueID = 0x02
	ViaKbdSwitchMatrixState ViaKeyboardValueID = 0x03
	ViaKbdFirmwareVersion   ViaKeyboardValueID = 0x04
	ViaKbdDeviceIndication  ViaKeyboardValueID = 0x05
)

func (ViaKeyboardValueID) String

func (i ViaKeyboardValueID) String() string

type ViaQmkLEDMatrixValue

type ViaQmkLEDMatrixValue uint8
const (
	ViaQmkLEDMatrixBrightness ViaQmkLEDMatrixValue = iota + 1
	ViaQmkLEDMatrixEffect
	ViaQmkLEDMatrixEffectSpeed
)

func (ViaQmkLEDMatrixValue) String

func (i ViaQmkLEDMatrixValue) String() string

type ViaQmkRGBLightValue

type ViaQmkRGBLightValue uint8
const (
	ViaQmkRGBLightBrightness ViaQmkRGBLightValue = iota + 0x80
	ViaQmkRGBLightEffect
	ViaQmkRGBLightEffectSpeed
	ViaQmkRGBLightColor
)

func (ViaQmkRGBLightValue) String

func (i ViaQmkRGBLightValue) String() string

type ViaQmkRGBMatrixValue

type ViaQmkRGBMatrixValue uint8
const (
	ViaQmkRGBMatrixBrightness ViaQmkRGBMatrixValue = iota + 1
	ViaQmkRGBMatrixEffect
	ViaQmkRGBMatrixEffectSpeed
	ViaQmkRGBMatrixColor
)

func (ViaQmkRGBMatrixValue) String

func (i ViaQmkRGBMatrixValue) String() string

type VialCommand

type VialCommand uint8
const (
	VialCmdGetKeyboardID    VialCommand = 0x00
	VialCmdGetSize          VialCommand = 0x01
	VialCmdGetDef           VialCommand = 0x02
	VialCmdGetEncoder       VialCommand = 0x03
	VialCmdSetEncoder       VialCommand = 0x04
	VialCmdGetUnlockStatus  VialCommand = 0x05
	VialCmdUnlockStart      VialCommand = 0x06
	VialCmdUnlockPoll       VialCommand = 0x07
	VialCmdLock             VialCommand = 0x08
	VialCmdQmkSettingsQuery VialCommand = 0x09
	VialCmdQmkSettingsGet   VialCommand = 0x0A
	VialCmdQmkSettingsSet   VialCommand = 0x0B
	VialCmdQmkSettingsReset VialCommand = 0x0C
	VialCmdDynamicEntryOp   VialCommand = 0x0D
)

func (VialCommand) String

func (i VialCommand) String() string

type VialRGBGetCommand

type VialRGBGetCommand uint8
const (
	VialRGBCommandGetInfo VialRGBGetCommand = iota + 0x40
	VialRGBCommandGetMode
	VialRGBCommandGetSupported
	VialRGBCommandGetNumberLEDs
	VialRGBCommandGetLEDInfo
)

func (VialRGBGetCommand) String

func (i VialRGBGetCommand) String() string

type VialRGBSetCommand

type VialRGBSetCommand uint8
const (
	VialRGBCommandSetMode VialRGBSetCommand = iota + 0x41
	VialRGBCommandDirectFastset
)

func (VialRGBSetCommand) String

func (i VialRGBSetCommand) String() string

type VialRGBer

type VialRGBer interface {
	VialRGBMode() uint16
	VialRGBSpeed() uint8
	VialRGBColor() hsv.Color
	VialRGBUpdate(mode uint16, speed uint8, color hsv.Color)
	VialRGBSave()
}

Jump to

Keyboard shortcuts

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