From f0e04b1964d7f3ed519659ce26e302009f991f03 Mon Sep 17 00:00:00 2001 From: datalore Date: Tue, 5 Aug 2025 20:54:33 +0200 Subject: [PATCH] fix(config): Fixed config parsing --- config.go | 30 +++++++++++++++--------------- config.yaml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config.go b/config.go index fd185b3..e5b4ebd 100644 --- a/config.go +++ b/config.go @@ -9,25 +9,25 @@ import ( ) type Config struct { - Controller []ControllerConfig + Controller []ControllerConfig `yaml:"controller"` } type ControllerConfig struct { - PortName string - VendorID uint16 - ProductID uint16 - Mappings []MappingConfig + PortName string `yaml:"portName"` + VendorID uint16 `yaml:"vendorID"` + ProductID uint16 `yaml:"productID"` + Mappings []MappingConfig `yaml:"mappings"` } type MappingConfig struct { - Comment string - Type MappingType - MidiChannel uint8 - MidiKey uint8 - MidiController uint8 - Button ButtonName - Axis AxisName - IsSigned bool + Comment string `yaml:"comment"` + Type MappingType `yaml:"type"` + MidiChannel uint8 `yaml:"midiChannel"` + MidiKey uint8 `yaml:"midiKey"` + MidiController uint8 `yaml:"midiController"` + Button ButtonName `yaml:"button"` + Axis AxisName `yaml:"axis"` + IsSigned bool `yaml:"isSigned"` } type MappingType string @@ -128,7 +128,7 @@ func (bn ButtonName) Construct() (int, error) { case ButtonWest: return uinput.ButtonWest, nil default: - return -1, fmt.Errorf("Invalid button name") + return -1, fmt.Errorf("Invalid button name \"%s\"", bn) } } @@ -143,6 +143,6 @@ func (an AxisName) Construct() (ControllerAxis, error) { case AxisRightY: return RightY, nil default: - return -1, fmt.Errorf("Invalid axis name") + return -1, fmt.Errorf("Invalid axis name \"%s\"", an) } } diff --git a/config.yaml b/config.yaml index 6b9c6b6..f62e3a1 100644 --- a/config.yaml +++ b/config.yaml @@ -6,7 +6,7 @@ controller: - type: button midiChannel: 1 midiKey: 7 - key: south + button: south - type: control midiChannel: 1 midiController: 0