Clean up custom unmarshaler.
This commit is contained in:
parent
ff582d864f
commit
c8d0e67a15
1 changed files with 14 additions and 14 deletions
|
@ -9,8 +9,6 @@
|
|||
|
||||
package config
|
||||
|
||||
import "git.annabunches.net/annabunches/joyful/internal/logger"
|
||||
|
||||
type Config struct {
|
||||
Devices []DeviceConfig `yaml:"devices"`
|
||||
Modes []string `yaml:"modes,omitempty"`
|
||||
|
@ -59,19 +57,21 @@ type RuleTargetConfig struct {
|
|||
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 {
|
||||
var raw struct {
|
||||
Name string `yaml:"name"`
|
||||
Type string `yaml:"type"`
|
||||
DeviceName string `yaml:"device_name,omitempty"`
|
||||
Uuid string `yaml:"uuid,omitempty"`
|
||||
Preset string `yaml:"preset,omitempty"`
|
||||
NumButtons int `yaml:"num_buttons,omitempty"`
|
||||
NumAxes int `yaml:"num_axes,omitempty"`
|
||||
NumRelativeAxes int `yaml:"num_rel_axes"`
|
||||
Buttons []string `yaml:"buttons,omitempty"`
|
||||
Axes []string `yaml:"axes,omitempty"`
|
||||
RelativeAxes []string `yaml:"rel_axes,omitempty"`
|
||||
Name string
|
||||
Type string
|
||||
DeviceName string `yaml:"device_name"`
|
||||
Uuid string
|
||||
Preset string
|
||||
NumButtons int `yaml:"num_buttons"`
|
||||
NumAxes int `yaml:"num_axes"`
|
||||
NumRelativeAxes int `yaml:"num_rel_axes"`
|
||||
Buttons []string
|
||||
Axes []string
|
||||
RelativeAxes []string `yaml:"relative_axes"`
|
||||
Lock bool `yaml:"lock,omitempty"`
|
||||
}
|
||||
raw.Lock = true
|
||||
|
@ -80,7 +80,7 @@ func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) er
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.LogDebugf("%v", raw)
|
||||
|
||||
*dc = DeviceConfig{
|
||||
Name: raw.Name,
|
||||
Type: raw.Type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue