Configure per-device locking with default set to true.
This commit is contained in:
parent
e4246dd62e
commit
ff582d864f
3 changed files with 49 additions and 9 deletions
|
@ -9,6 +9,8 @@
|
|||
|
||||
package config
|
||||
|
||||
import "git.annabunches.net/annabunches/joyful/internal/logger"
|
||||
|
||||
type Config struct {
|
||||
Devices []DeviceConfig `yaml:"devices"`
|
||||
Modes []string `yaml:"modes,omitempty"`
|
||||
|
@ -27,6 +29,7 @@ type DeviceConfig struct {
|
|||
Buttons []string `yaml:"buttons,omitempty"`
|
||||
Axes []string `yaml:"axes,omitempty"`
|
||||
RelativeAxes []string `yaml:"rel_axes,omitempty"`
|
||||
Lock bool `yaml:"lock,omitempty"`
|
||||
}
|
||||
|
||||
type RuleConfig struct {
|
||||
|
@ -55,3 +58,42 @@ type RuleTargetConfig struct {
|
|||
Inverted bool `yaml:"inverted,omitempty"`
|
||||
Modes []string `yaml:"modes,omitempty"`
|
||||
}
|
||||
|
||||
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"`
|
||||
Lock bool `yaml:"lock,omitempty"`
|
||||
}
|
||||
raw.Lock = true
|
||||
|
||||
err := unmarshal(&raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.LogDebugf("%v", raw)
|
||||
*dc = DeviceConfig{
|
||||
Name: raw.Name,
|
||||
Type: raw.Type,
|
||||
DeviceName: raw.DeviceName,
|
||||
Uuid: raw.Uuid,
|
||||
Preset: raw.Preset,
|
||||
NumButtons: raw.NumButtons,
|
||||
NumAxes: raw.NumAxes,
|
||||
NumRelativeAxes: raw.NumRelativeAxes,
|
||||
Buttons: raw.Buttons,
|
||||
Axes: raw.Axes,
|
||||
RelativeAxes: raw.RelativeAxes,
|
||||
Lock: raw.Lock,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue