Support keyboard buttons and add presets. #14
1 changed files with 14 additions and 14 deletions
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import "git.annabunches.net/annabunches/joyful/internal/logger"
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Devices []DeviceConfig `yaml:"devices"`
|
Devices []DeviceConfig `yaml:"devices"`
|
||||||
Modes []string `yaml:"modes,omitempty"`
|
Modes []string `yaml:"modes,omitempty"`
|
||||||
|
@ -59,19 +57,21 @@ type RuleTargetConfig struct {
|
||||||
Modes []string `yaml:"modes,omitempty"`
|
Modes []string `yaml:"modes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: custom yaml unmarshaling is obtuse; do we really need to do all of this work
|
||||||
|
// just to set a single default value?
|
||||||
func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) error {
|
func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) error {
|
||||||
var raw struct {
|
var raw struct {
|
||||||
Name string `yaml:"name"`
|
Name string
|
||||||
Type string `yaml:"type"`
|
Type string
|
||||||
DeviceName string `yaml:"device_name,omitempty"`
|
DeviceName string `yaml:"device_name"`
|
||||||
Uuid string `yaml:"uuid,omitempty"`
|
Uuid string
|
||||||
Preset string `yaml:"preset,omitempty"`
|
Preset string
|
||||||
NumButtons int `yaml:"num_buttons,omitempty"`
|
NumButtons int `yaml:"num_buttons"`
|
||||||
NumAxes int `yaml:"num_axes,omitempty"`
|
NumAxes int `yaml:"num_axes"`
|
||||||
NumRelativeAxes int `yaml:"num_rel_axes"`
|
NumRelativeAxes int `yaml:"num_rel_axes"`
|
||||||
Buttons []string `yaml:"buttons,omitempty"`
|
Buttons []string
|
||||||
Axes []string `yaml:"axes,omitempty"`
|
Axes []string
|
||||||
RelativeAxes []string `yaml:"rel_axes,omitempty"`
|
RelativeAxes []string `yaml:"relative_axes"`
|
||||||
Lock bool `yaml:"lock,omitempty"`
|
Lock bool `yaml:"lock,omitempty"`
|
||||||
}
|
}
|
||||||
raw.Lock = true
|
raw.Lock = true
|
||||||
|
@ -80,7 +80,7 @@ func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.LogDebugf("%v", raw)
|
|
||||||
*dc = DeviceConfig{
|
*dc = DeviceConfig{
|
||||||
Name: raw.Name,
|
Name: raw.Name,
|
||||||
Type: raw.Type,
|
Type: raw.Type,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue