fix(config): Fixed config parsing

This commit is contained in:
2025-08-05 20:54:33 +02:00
parent 54a2ff2ba8
commit f0e04b1964
2 changed files with 16 additions and 16 deletions

View File

@@ -9,25 +9,25 @@ import (
) )
type Config struct { type Config struct {
Controller []ControllerConfig Controller []ControllerConfig `yaml:"controller"`
} }
type ControllerConfig struct { type ControllerConfig struct {
PortName string PortName string `yaml:"portName"`
VendorID uint16 VendorID uint16 `yaml:"vendorID"`
ProductID uint16 ProductID uint16 `yaml:"productID"`
Mappings []MappingConfig Mappings []MappingConfig `yaml:"mappings"`
} }
type MappingConfig struct { type MappingConfig struct {
Comment string Comment string `yaml:"comment"`
Type MappingType Type MappingType `yaml:"type"`
MidiChannel uint8 MidiChannel uint8 `yaml:"midiChannel"`
MidiKey uint8 MidiKey uint8 `yaml:"midiKey"`
MidiController uint8 MidiController uint8 `yaml:"midiController"`
Button ButtonName Button ButtonName `yaml:"button"`
Axis AxisName Axis AxisName `yaml:"axis"`
IsSigned bool IsSigned bool `yaml:"isSigned"`
} }
type MappingType string type MappingType string
@@ -128,7 +128,7 @@ func (bn ButtonName) Construct() (int, error) {
case ButtonWest: case ButtonWest:
return uinput.ButtonWest, nil return uinput.ButtonWest, nil
default: 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: case AxisRightY:
return RightY, nil return RightY, nil
default: default:
return -1, fmt.Errorf("Invalid axis name") return -1, fmt.Errorf("Invalid axis name \"%s\"", an)
} }
} }

View File

@@ -6,7 +6,7 @@ controller:
- type: button - type: button
midiChannel: 1 midiChannel: 1
midiKey: 7 midiKey: 7
key: south button: south
- type: control - type: control
midiChannel: 1 midiChannel: 1
midiController: 0 midiController: 0